Exemplo n.º 1
0
MD5_word *MD5_std_get_binary(char *ciphertext)
{
    static union {
        MD5_binary w;
        char b[16];
    } out;
    char *pos;
    MD5_word value;

    pos = ciphertext + 3;
    if (!strncmp(ciphertext, "$apr1$", 6))
        pos = ciphertext + 6;

    while (*pos++ != '$');

    TO_BINARY(0, 6, 12);
    TO_BINARY(1, 7, 13);
    TO_BINARY(2, 8, 14);
    TO_BINARY(3, 9, 15);
    TO_BINARY(4, 10, 5);
    out.b[11] =
        (MD5_word)atoi64[ARCH_INDEX(pos[0])] |
        ((MD5_word)atoi64[ARCH_INDEX(pos[1])] << 6);

#undef OOFFOOFF
#define OOFFOOFF 0x00ff00ff
    MD5_swap(out.w, out.w, 4);
#undef OOFFOOFF

    return out.w;
}
static void *get_binary(char *ciphertext)
{
	static ARCH_WORD_32 outbuf[BINARY_SIZE/4];
	ARCH_WORD_32 value;
	char *pos;
	unsigned char *out = (unsigned char*)outbuf;

	pos = strrchr(ciphertext, '$') + 1;

	TO_BINARY(0, 10, 20);
	TO_BINARY(21, 1, 11);
	TO_BINARY(12, 22, 2);
	TO_BINARY(3, 13, 23);
	TO_BINARY(24, 4, 14);
	TO_BINARY(15, 25, 5);
	TO_BINARY(6, 16, 26);
	TO_BINARY(27, 7, 17);
	TO_BINARY(18, 28, 8);
	TO_BINARY(9, 19, 29);
	value = (ARCH_WORD_32)atoi64[ARCH_INDEX(pos[0])] |
		((ARCH_WORD_32)atoi64[ARCH_INDEX(pos[1])] << 6) |
		((ARCH_WORD_32)atoi64[ARCH_INDEX(pos[2])] << 12);
	out[31] = value >> 8; \
	out[30] = value; \
	return (void *)out;
}
Exemplo n.º 3
0
static void * get_binary(char * ciphertext) {
    static ARCH_WORD_32 outbuf[BINARY_SIZE / 4];
    ARCH_WORD_32 value;
    char *pos = strrchr(ciphertext, '$') + 1;
    unsigned char *out = (unsigned char*) outbuf;
    int i = 0;

    do {
        TO_BINARY(i, (i + 21) % 63, (i + 42) % 63);
        i = (i + 22) % 63;
    } while (i != 21);

    value = (ARCH_WORD_32) atoi64[ARCH_INDEX(pos[0])] |
            ((ARCH_WORD_32) atoi64[ARCH_INDEX(pos[1])] << 6) |
            ((ARCH_WORD_32) atoi64[ARCH_INDEX(pos[2])] << 12);
    out[63] = value;

    return (void *) out;
}
Exemplo n.º 4
0
// Don't copy this code without realising it mimics bugs in the original code!
// We are actually missing the last 16 bits with this implementation.
static void *get_binary(char *ciphertext)
{
	static ARCH_WORD_32 outbuf[BINARY_SIZE/4];
	ARCH_WORD_32 value;
	char *pos;
	unsigned char *out = (unsigned char*)outbuf;
	int i;

	pos = strrchr(ciphertext, '$') + 1;

	for (i = 0; i < 20; i++) {
		TO_BINARY(i, i + 21, i + 42);
	}
	value = (ARCH_WORD_32)atoi64[ARCH_INDEX(pos[0])] |
		((ARCH_WORD_32)atoi64[ARCH_INDEX(pos[1])] << 6) |
		((ARCH_WORD_32)atoi64[ARCH_INDEX(pos[2])] << 12) |
		((ARCH_WORD_32)atoi64[ARCH_INDEX(pos[3])] << 18);
	out[20] = value >> 16;
	out[41] = value >> 8;

	return (void *)out;
}
static void *get_binary(char *ciphertext)
{
	static ARCH_WORD_32 outbuf[BINARY_SIZE/4];
	ARCH_WORD_32 value;
	char *pos;
	unsigned char *out = (unsigned char*)outbuf;

	pos = strrchr(ciphertext, '$') + 1;

	TO_BINARY(0, 21, 42);
	TO_BINARY(22, 43, 1);
	TO_BINARY(44, 2, 23);
	TO_BINARY(3, 24, 45);
	TO_BINARY(25, 46, 4);
	TO_BINARY(47, 5, 26);
	TO_BINARY(6, 27, 48);
	TO_BINARY(28, 49, 7);
	TO_BINARY(50, 8, 29);
	TO_BINARY(9, 30, 51);
	TO_BINARY(31, 52, 10);
	TO_BINARY(53, 11, 32);
	TO_BINARY(12, 33, 54);
	TO_BINARY(34, 55, 13);
	TO_BINARY(56, 14, 35);
	TO_BINARY(15, 36, 57);
	TO_BINARY(37, 58, 16);
	TO_BINARY(59, 17, 38);
	TO_BINARY(18, 39, 60);
	TO_BINARY(40, 61, 19);
	TO_BINARY(62, 20, 41);
	value = (ARCH_WORD_32)atoi64[ARCH_INDEX(pos[0])] |
		((ARCH_WORD_32)atoi64[ARCH_INDEX(pos[1])] << 6) |
		((ARCH_WORD_32)atoi64[ARCH_INDEX(pos[2])] << 12);
	out[63] = value; \
	return (void *)out;
}