52#if !defined(MBEDTLS_CONFIG_FILE)
55#include MBEDTLS_CONFIG_FILE
58#if defined(MBEDTLS_MD5_C)
65#if defined(MBEDTLS_SELF_TEST)
66#if defined(MBEDTLS_PLATFORM_C)
70#define mbedtls_printf printf
74#if !defined(MBEDTLS_MD5_ALT)
80#define GET_UINT32_LE(n,b,i) \
82 (n) = ( (uint32_t) (b)[(i) ] ) \
83 | ( (uint32_t) (b)[(i) + 1] << 8 ) \
84 | ( (uint32_t) (b)[(i) + 2] << 16 ) \
85 | ( (uint32_t) (b)[(i) + 3] << 24 ); \
90#define PUT_UINT32_LE(n,b,i) \
92 (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \
93 (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \
94 (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \
95 (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \
126 ctx->state[0] = 0x67452301;
127 ctx->state[1] = 0xEFCDAB89;
128 ctx->state[2] = 0x98BADCFE;
129 ctx->state[3] = 0x10325476;
134#if !defined(MBEDTLS_DEPRECATED_REMOVED)
141#if !defined(MBEDTLS_MD5_PROCESS_ALT)
143 const unsigned char data[64] )
168 ( ( (x) << (n) ) | ( ( (x) & 0xFFFFFFFF) >> ( 32 - (n) ) ) )
170#define P(a,b,c,d,k,s,t) \
173 (a) += F((b),(c),(d)) + local.X[(k)] + (t); \
174 (a) = S((a),(s)) + (b); \
182#define F(x,y,z) ((z) ^ ((x) & ((y) ^ (z))))
203#define F(x,y,z) ((y) ^ ((z) & ((x) ^ (y))))
224#define F(x,y,z) ((x) ^ (y) ^ (z))
245#define F(x,y,z) ((y) ^ ((x) | ~(z)))
277#if !defined(MBEDTLS_DEPRECATED_REMOVED)
279 const unsigned char data[64] )
290 const unsigned char *
input,
304 ctx->total[0] &= 0xFFFFFFFF;
337#if !defined(MBEDTLS_DEPRECATED_REMOVED)
339 const unsigned char *
input,
350 unsigned char output[16] )
382 high = (
ctx->total[0] >> 29 )
383 | (
ctx->total[1] << 3 );
384 low = (
ctx->total[0] << 3 );
386 PUT_UINT32_LE( low,
ctx->buffer, 56 );
387 PUT_UINT32_LE( high,
ctx->buffer, 60 );
395 PUT_UINT32_LE(
ctx->state[0], output, 0 );
396 PUT_UINT32_LE(
ctx->state[1], output, 4 );
397 PUT_UINT32_LE(
ctx->state[2], output, 8 );
398 PUT_UINT32_LE(
ctx->state[3], output, 12 );
403#if !defined(MBEDTLS_DEPRECATED_REMOVED)
405 unsigned char output[16] )
418 unsigned char output[16] )
440#if !defined(MBEDTLS_DEPRECATED_REMOVED)
443 unsigned char output[16] )
449#if defined(MBEDTLS_SELF_TEST)
453static const unsigned char md5_test_buf[7][81] =
458 {
"message digest" },
459 {
"abcdefghijklmnopqrstuvwxyz" },
460 {
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" },
461 {
"12345678901234567890123456789012345678901234567890123456789012"
462 "345678901234567890" }
465static const size_t md5_test_buflen[7] =
467 0, 1, 3, 14, 26, 62, 80
470static const unsigned char md5_test_sum[7][16] =
472 { 0xD4, 0x1D, 0x8C, 0xD9, 0x8F, 0x00, 0xB2, 0x04,
473 0xE9, 0x80, 0x09, 0x98, 0xEC, 0xF8, 0x42, 0x7E },
474 { 0x0C, 0xC1, 0x75, 0xB9, 0xC0, 0xF1, 0xB6, 0xA8,
475 0x31, 0xC3, 0x99, 0xE2, 0x69, 0x77, 0x26, 0x61 },
476 { 0x90, 0x01, 0x50, 0x98, 0x3C, 0xD2, 0x4F, 0xB0,
477 0xD6, 0x96, 0x3F, 0x7D, 0x28, 0xE1, 0x7F, 0x72 },
478 { 0xF9, 0x6B, 0x69, 0x7D, 0x7C, 0xB7, 0x93, 0x8D,
479 0x52, 0x5A, 0x2F, 0x31, 0xAA, 0xF1, 0x61, 0xD0 },
480 { 0xC3, 0xFC, 0xD3, 0xD7, 0x61, 0x92, 0xE4, 0x00,
481 0x7D, 0xFB, 0x49, 0x6C, 0xCA, 0x67, 0xE1, 0x3B },
482 { 0xD1, 0x74, 0xAB, 0x98, 0xD2, 0x77, 0xD9, 0xF5,
483 0xA5, 0x61, 0x1C, 0x2C, 0x9F, 0x41, 0x9D, 0x9F },
484 { 0x57, 0xED, 0xF4, 0xA2, 0x2B, 0xE3, 0xC9, 0x55,
485 0xAC, 0x49, 0xDA, 0x2E, 0x21, 0x07, 0xB6, 0x7A }
491int mbedtls_md5_self_test(
int verbose )
494 unsigned char md5sum[16];
496 for(
i = 0;
i < 7;
i++ )
505 if(
memcmp( md5sum, md5_test_sum[
i], 16 ) != 0 )
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLenum GLenum input
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define memcpy(s1, s2, n)
Configuration options (set of defines)
MD5 message digest algorithm (hash function)
void mbedtls_md5_clone(mbedtls_md5_context *dst, const mbedtls_md5_context *src)
Clone (the state of) an MD5 context.
int mbedtls_internal_md5_process(mbedtls_md5_context *ctx, const unsigned char data[64])
MD5 process data block (internal use only)
MBEDTLS_DEPRECATED void mbedtls_md5(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD5( input buffer )
void mbedtls_md5_free(mbedtls_md5_context *ctx)
Clear MD5 context.
MBEDTLS_DEPRECATED void mbedtls_md5_process(mbedtls_md5_context *ctx, const unsigned char data[64])
MD5 process data block (internal use only)
MBEDTLS_DEPRECATED void mbedtls_md5_starts(mbedtls_md5_context *ctx)
MD5 context setup.
int mbedtls_md5_ret(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD5( input buffer )
int mbedtls_md5_starts_ret(mbedtls_md5_context *ctx)
MD5 context setup.
MBEDTLS_DEPRECATED void mbedtls_md5_finish(mbedtls_md5_context *ctx, unsigned char output[16])
MD5 final digest.
void mbedtls_md5_init(mbedtls_md5_context *ctx)
Initialize MD5 context.
int mbedtls_md5_update_ret(mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen)
MD5 process buffer.
int mbedtls_md5_finish_ret(mbedtls_md5_context *ctx, unsigned char output[16])
MD5 final digest.
MBEDTLS_DEPRECATED void mbedtls_md5_update(mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen)
MD5 process buffer.