32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
40 #if (MD5_CRYPT_SUPPORT == ENABLED)
43 static const char_t base64EncTable[64] =
45 '.',
'/',
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
46 'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
47 'U',
'V',
'W',
'X',
'Y',
'Z',
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
48 'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z'
71 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
78 if(password == NULL || salt == NULL || output == NULL)
95 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
99 if(md5Context == NULL)
106 md5Update(&md5Context[0], password, passwordLen);
110 md5Update(&md5Context[0], salt, saltLen);
115 md5Update(&md5Context[1], password, passwordLen);
117 md5Update(&md5Context[1], salt, saltLen);
119 md5Update(&md5Context[1], password, passwordLen);
126 for(j = 0; j < passwordLen; j +=
n)
135 for(
n = passwordLen;
n > 0;
n >>= 1)
163 md5Update(&md5Context[0], password, passwordLen);
175 md5Update(&md5Context[0], salt, saltLen);
182 md5Update(&md5Context[0], password, passwordLen);
194 md5Update(&md5Context[0], password, passwordLen);
218 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
224 if(outputLen != NULL)
248 for(i = 0, j = 0; i < 5; i++)
251 value = input[i] << 16;
252 value |= input[i + 6] << 8;
253 value |= (i < 4) ? input[i + 12] : input[5];
256 output[j++] = base64EncTable[
value & 0x3F];
257 output[j++] = base64EncTable[(
value >> 6) & 0x3F];
258 output[j++] = base64EncTable[(
value >> 12) & 0x3F];
259 output[j++] = base64EncTable[(
value >> 18) & 0x3F];
267 output[j++] = base64EncTable[
value & 0x3F];
268 output[j++] = base64EncTable[(
value >> 6) & 0x3F];