53#if !defined(MBEDTLS_CONFIG_FILE)
56#include MBEDTLS_CONFIG_FILE
59#if defined(MBEDTLS_RIPEMD160_C)
66#if defined(MBEDTLS_SELF_TEST)
67#if defined(MBEDTLS_PLATFORM_C)
71#define mbedtls_printf printf
75#if !defined(MBEDTLS_RIPEMD160_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;
131 ctx->state[4] = 0xC3D2E1F0;
136#if !defined(MBEDTLS_DEPRECATED_REMOVED)
143#if !defined(MBEDTLS_RIPEMD160_PROCESS_ALT)
148 const unsigned char data[64] )
152 uint32_t A,
B,
C,
D,
E,
Ap, Bp, Cp, Dp, Ep,
X[16];
178#define F1( x, y, z ) ( (x) ^ (y) ^ (z) )
179#define F2( x, y, z ) ( ( (x) & (y) ) | ( ~(x) & (z) ) )
180#define F3( x, y, z ) ( ( (x) | ~(y) ) ^ (z) )
181#define F4( x, y, z ) ( ( (x) & (z) ) | ( (y) & ~(z) ) )
182#define F5( x, y, z ) ( (x) ^ ( (y) | ~(z) ) )
184#define S( x, n ) ( ( (x) << (n) ) | ( (x) >> (32 - (n)) ) )
186#define P( a, b, c, d, e, r, s, f, k ) \
189 (a) += f( (b), (c), (d) ) + local.X[r] + (k); \
190 (a) = S( (a), (s) ) + (e); \
191 (c) = S( (c), 10 ); \
194#define P2( a, b, c, d, e, r, s, rp, sp ) \
197 P( (a), (b), (c), (d), (e), (r), (s), F, K ); \
198 P( a ## p, b ## p, c ## p, d ## p, e ## p, \
199 (rp), (sp), Fp, Kp ); \
340#if !defined(MBEDTLS_DEPRECATED_REMOVED)
342 const unsigned char data[64] )
353 const unsigned char *
input,
367 ctx->total[0] &= 0xFFFFFFFF;
401#if !defined(MBEDTLS_DEPRECATED_REMOVED)
403 const unsigned char *
input,
410static const unsigned char ripemd160_padding[64] =
412 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
413 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
414 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
415 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
422 unsigned char output[20] )
427 unsigned char msglen[8];
429 high = (
ctx->total[0] >> 29 )
430 | (
ctx->total[1] << 3 );
431 low = (
ctx->total[0] << 3 );
433 PUT_UINT32_LE( low, msglen, 0 );
434 PUT_UINT32_LE( high, msglen, 4 );
447 PUT_UINT32_LE(
ctx->state[0], output, 0 );
448 PUT_UINT32_LE(
ctx->state[1], output, 4 );
449 PUT_UINT32_LE(
ctx->state[2], output, 8 );
450 PUT_UINT32_LE(
ctx->state[3], output, 12 );
451 PUT_UINT32_LE(
ctx->state[4], output, 16 );
456#if !defined(MBEDTLS_DEPRECATED_REMOVED)
458 unsigned char output[20] )
471 unsigned char output[20] )
493#if !defined(MBEDTLS_DEPRECATED_REMOVED)
496 unsigned char output[20] )
502#if defined(MBEDTLS_SELF_TEST)
508static const unsigned char ripemd160_test_str[TESTS][81] =
513 {
"message digest" },
514 {
"abcdefghijklmnopqrstuvwxyz" },
515 {
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" },
516 {
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" },
517 {
"12345678901234567890123456789012345678901234567890123456789012"
518 "345678901234567890" },
521static const size_t ripemd160_test_strlen[TESTS] =
523 0, 1, 3, 14, 26, 56, 62, 80
526static const unsigned char ripemd160_test_md[TESTS][20] =
528 { 0x9c, 0x11, 0x85, 0xa5, 0xc5, 0xe9, 0xfc, 0x54, 0x61, 0x28,
529 0x08, 0x97, 0x7e, 0xe8, 0xf5, 0x48, 0xb2, 0x25, 0x8d, 0x31 },
530 { 0x0b, 0xdc, 0x9d, 0x2d, 0x25, 0x6b, 0x3e, 0xe9, 0xda, 0xae,
531 0x34, 0x7b, 0xe6, 0xf4, 0xdc, 0x83, 0x5a, 0x46, 0x7f, 0xfe },
532 { 0x8e, 0xb2, 0x08, 0xf7, 0xe0, 0x5d, 0x98, 0x7a, 0x9b, 0x04,
533 0x4a, 0x8e, 0x98, 0xc6, 0xb0, 0x87, 0xf1, 0x5a, 0x0b, 0xfc },
534 { 0x5d, 0x06, 0x89, 0xef, 0x49, 0xd2, 0xfa, 0xe5, 0x72, 0xb8,
535 0x81, 0xb1, 0x23, 0xa8, 0x5f, 0xfa, 0x21, 0x59, 0x5f, 0x36 },
536 { 0xf7, 0x1c, 0x27, 0x10, 0x9c, 0x69, 0x2c, 0x1b, 0x56, 0xbb,
537 0xdc, 0xeb, 0x5b, 0x9d, 0x28, 0x65, 0xb3, 0x70, 0x8d, 0xbc },
538 { 0x12, 0xa0, 0x53, 0x38, 0x4a, 0x9c, 0x0c, 0x88, 0xe4, 0x05,
539 0xa0, 0x6c, 0x27, 0xdc, 0xf4, 0x9a, 0xda, 0x62, 0xeb, 0x2b },
540 { 0xb0, 0xe2, 0x0b, 0x6e, 0x31, 0x16, 0x64, 0x02, 0x86, 0xed,
541 0x3a, 0x87, 0xa5, 0x71, 0x30, 0x79, 0xb2, 0x1f, 0x51, 0x89 },
542 { 0x9b, 0x75, 0x2e, 0x45, 0x57, 0x3d, 0x4b, 0x39, 0xf4, 0xdb,
543 0xd3, 0x32, 0x3c, 0xab, 0x82, 0xbf, 0x63, 0x32, 0x6b, 0xfb },
549int mbedtls_ripemd160_self_test(
int verbose )
552 unsigned char output[20];
554 memset( output, 0,
sizeof output );
556 for(
i = 0;
i < TESTS;
i++ )
562 ripemd160_test_strlen[
i], output );
566 if(
memcmp( output, ripemd160_test_md[
i], 20 ) != 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)
RIPE MD-160 message digest.
MBEDTLS_DEPRECATED void mbedtls_ripemd160(const unsigned char *input, size_t ilen, unsigned char output[20])
Output = RIPEMD-160( input buffer )
MBEDTLS_DEPRECATED void mbedtls_ripemd160_process(mbedtls_ripemd160_context *ctx, const unsigned char data[64])
RIPEMD-160 process data block (internal use only)
void mbedtls_ripemd160_clone(mbedtls_ripemd160_context *dst, const mbedtls_ripemd160_context *src)
Clone (the state of) an RIPEMD-160 context.
void mbedtls_ripemd160_init(mbedtls_ripemd160_context *ctx)
Initialize RIPEMD-160 context.
int mbedtls_internal_ripemd160_process(mbedtls_ripemd160_context *ctx, const unsigned char data[64])
RIPEMD-160 process data block (internal use only)
void mbedtls_ripemd160_free(mbedtls_ripemd160_context *ctx)
Clear RIPEMD-160 context.
MBEDTLS_DEPRECATED void mbedtls_ripemd160_starts(mbedtls_ripemd160_context *ctx)
RIPEMD-160 context setup.
int mbedtls_ripemd160_update_ret(mbedtls_ripemd160_context *ctx, const unsigned char *input, size_t ilen)
RIPEMD-160 process buffer.
int mbedtls_ripemd160_ret(const unsigned char *input, size_t ilen, unsigned char output[20])
Output = RIPEMD-160( input buffer )
int mbedtls_ripemd160_finish_ret(mbedtls_ripemd160_context *ctx, unsigned char output[20])
RIPEMD-160 final digest.
MBEDTLS_DEPRECATED void mbedtls_ripemd160_finish(mbedtls_ripemd160_context *ctx, unsigned char output[20])
RIPEMD-160 final digest.
MBEDTLS_DEPRECATED void mbedtls_ripemd160_update(mbedtls_ripemd160_context *ctx, const unsigned char *input, size_t ilen)
RIPEMD-160 process buffer.
int mbedtls_ripemd160_starts_ret(mbedtls_ripemd160_context *ctx)
RIPEMD-160 context setup.
Configuration options (set of defines)
RIPEMD-160 context structure.