53#if !defined(MBEDTLS_CONFIG_FILE)
56#include MBEDTLS_CONFIG_FILE
59#if defined(MBEDTLS_MD4_C)
66#if defined(MBEDTLS_SELF_TEST)
67#if defined(MBEDTLS_PLATFORM_C)
71#define mbedtls_printf printf
75#if !defined(MBEDTLS_MD4_ALT)
81#define GET_UINT32_LE(n,b,i) \
83 (n) = ( (uint32_t) (b)[(i) ] ) \
84 | ( (uint32_t) (b)[(i) + 1] << 8 ) \
85 | ( (uint32_t) (b)[(i) + 2] << 16 ) \
86 | ( (uint32_t) (b)[(i) + 3] << 24 ); \
91#define PUT_UINT32_LE(n,b,i) \
93 (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \
94 (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \
95 (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \
96 (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \
127 ctx->state[0] = 0x67452301;
128 ctx->state[1] = 0xEFCDAB89;
129 ctx->state[2] = 0x98BADCFE;
130 ctx->state[3] = 0x10325476;
135#if !defined(MBEDTLS_DEPRECATED_REMOVED)
142#if !defined(MBEDTLS_MD4_PROCESS_ALT)
144 const unsigned char data[64] )
168#define S(x,n) (((x) << (n)) | (((x) & 0xFFFFFFFF) >> (32 - (n))))
175#define F(x, y, z) (((x) & (y)) | ((~(x)) & (z)))
176#define P(a,b,c,d,x,s) \
179 (a) += F((b),(c),(d)) + (x); \
204#define F(x,y,z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
205#define P(a,b,c,d,x,s) \
208 (a) += F((b),(c),(d)) + (x) + 0x5A827999; \
232#define F(x,y,z) ((x) ^ (y) ^ (z))
233#define P(a,b,c,d,x,s) \
236 (a) += F((b),(c),(d)) + (x) + 0x6ED9EBA1; \
271#if !defined(MBEDTLS_DEPRECATED_REMOVED)
273 const unsigned char data[64] )
284 const unsigned char *
input,
298 ctx->total[0] &= 0xFFFFFFFF;
328 (
void *)
input, ilen );
334#if !defined(MBEDTLS_DEPRECATED_REMOVED)
336 const unsigned char *
input,
343static const unsigned char md4_padding[64] =
345 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
346 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
347 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
348 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
355 unsigned char output[16] )
360 unsigned char msglen[8];
362 high = (
ctx->total[0] >> 29 )
363 | (
ctx->total[1] << 3 );
364 low = (
ctx->total[0] << 3 );
366 PUT_UINT32_LE( low, msglen, 0 );
367 PUT_UINT32_LE( high, msglen, 4 );
380 PUT_UINT32_LE(
ctx->state[0], output, 0 );
381 PUT_UINT32_LE(
ctx->state[1], output, 4 );
382 PUT_UINT32_LE(
ctx->state[2], output, 8 );
383 PUT_UINT32_LE(
ctx->state[3], output, 12 );
388#if !defined(MBEDTLS_DEPRECATED_REMOVED)
390 unsigned char output[16] )
403 unsigned char output[16] )
425#if !defined(MBEDTLS_DEPRECATED_REMOVED)
428 unsigned char output[16] )
434#if defined(MBEDTLS_SELF_TEST)
439static const unsigned char md4_test_str[7][81] =
444 {
"message digest" },
445 {
"abcdefghijklmnopqrstuvwxyz" },
446 {
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" },
447 {
"12345678901234567890123456789012345678901234567890123456789012"
448 "345678901234567890" }
451static const size_t md4_test_strlen[7] =
453 0, 1, 3, 14, 26, 62, 80
456static const unsigned char md4_test_sum[7][16] =
458 { 0x31, 0xD6, 0xCF, 0xE0, 0xD1, 0x6A, 0xE9, 0x31,
459 0xB7, 0x3C, 0x59, 0xD7, 0xE0, 0xC0, 0x89, 0xC0 },
460 { 0xBD, 0xE5, 0x2C, 0xB3, 0x1D, 0xE3, 0x3E, 0x46,
461 0x24, 0x5E, 0x05, 0xFB, 0xDB, 0xD6, 0xFB, 0x24 },
462 { 0xA4, 0x48, 0x01, 0x7A, 0xAF, 0x21, 0xD8, 0x52,
463 0x5F, 0xC1, 0x0A, 0xE8, 0x7A, 0xA6, 0x72, 0x9D },
464 { 0xD9, 0x13, 0x0A, 0x81, 0x64, 0x54, 0x9F, 0xE8,
465 0x18, 0x87, 0x48, 0x06, 0xE1, 0xC7, 0x01, 0x4B },
466 { 0xD7, 0x9E, 0x1C, 0x30, 0x8A, 0xA5, 0xBB, 0xCD,
467 0xEE, 0xA8, 0xED, 0x63, 0xDF, 0x41, 0x2D, 0xA9 },
468 { 0x04, 0x3F, 0x85, 0x82, 0xF2, 0x41, 0xDB, 0x35,
469 0x1C, 0xE6, 0x27, 0xE1, 0x53, 0xE7, 0xF0, 0xE4 },
470 { 0xE3, 0x3B, 0x4D, 0xDC, 0x9C, 0x38, 0xF2, 0x19,
471 0x9C, 0x3E, 0x7B, 0x16, 0x4F, 0xCC, 0x05, 0x36 }
477int mbedtls_md4_self_test(
int verbose )
480 unsigned char md4sum[16];
482 for(
i = 0;
i < 7;
i++ )
491 if(
memcmp( md4sum, md4_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
MD4 message digest algorithm (hash function)
int mbedtls_md4_ret(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD4( input buffer )
MBEDTLS_DEPRECATED void mbedtls_md4_process(mbedtls_md4_context *ctx, const unsigned char data[64])
MD4 process data block (internal use only)
int mbedtls_md4_starts_ret(mbedtls_md4_context *ctx)
MD4 context setup.
void mbedtls_md4_free(mbedtls_md4_context *ctx)
Clear MD4 context.
int mbedtls_md4_update_ret(mbedtls_md4_context *ctx, const unsigned char *input, size_t ilen)
MD4 process buffer.
int mbedtls_md4_finish_ret(mbedtls_md4_context *ctx, unsigned char output[16])
MD4 final digest.
MBEDTLS_DEPRECATED void mbedtls_md4_finish(mbedtls_md4_context *ctx, unsigned char output[16])
MD4 final digest.
void mbedtls_md4_init(mbedtls_md4_context *ctx)
Initialize MD4 context.
void mbedtls_md4_clone(mbedtls_md4_context *dst, const mbedtls_md4_context *src)
Clone (the state of) an MD4 context.
MBEDTLS_DEPRECATED void mbedtls_md4_update(mbedtls_md4_context *ctx, const unsigned char *input, size_t ilen)
MD4 process buffer.
int mbedtls_internal_md4_process(mbedtls_md4_context *ctx, const unsigned char data[64])
MD4 process data block (internal use only)
MBEDTLS_DEPRECATED void mbedtls_md4(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD4( input buffer )
MBEDTLS_DEPRECATED void mbedtls_md4_starts(mbedtls_md4_context *ctx)
MD4 context setup.
#define memcpy(s1, s2, n)
Configuration options (set of defines)