comparison libtomcrypt/src/hashes/rmd256.c @ 1471:6dba84798cd5

Update to libtomcrypt 1.18.1, merged with Dropbear changes
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 21:44:05 +0800
parents f849a5ca2efc
children
comparison
equal deleted inserted replaced
1470:8bba51a55704 1471:6dba84798cd5
3 * LibTomCrypt is a library that provides various cryptographic 3 * LibTomCrypt is a library that provides various cryptographic
4 * algorithms in a highly modular and flexible manner. 4 * algorithms in a highly modular and flexible manner.
5 * 5 *
6 * The library is free for all purposes without any express 6 * The library is free for all purposes without any express
7 * guarantee it works. 7 * guarantee it works.
8 *
9 * Tom St Denis, [email protected], http://libtom.org
10 */ 8 */
11 #include "tomcrypt.h" 9 #include "tomcrypt.h"
12 10
13 /** 11 /**
14 @param rmd256.c 12 @param rmd256.c
18 #ifdef LTC_RIPEMD256 16 #ifdef LTC_RIPEMD256
19 17
20 const struct ltc_hash_descriptor rmd256_desc = 18 const struct ltc_hash_descriptor rmd256_desc =
21 { 19 {
22 "rmd256", 20 "rmd256",
23 8, 21 13,
24 32, 22 32,
25 64, 23 64,
26 24
27 /* OID */ 25 /* OID */
28 { 1, 3, 36, 3, 2, 3 }, 26 { 1, 3, 36, 3, 2, 3 },
366 { 364 {
367 #ifndef LTC_TEST 365 #ifndef LTC_TEST
368 return CRYPT_NOP; 366 return CRYPT_NOP;
369 #else 367 #else
370 static const struct { 368 static const struct {
371 char *msg; 369 const char *msg;
372 unsigned char md[32]; 370 unsigned char hash[32];
373 } tests[] = { 371 } tests[] = {
374 { "", 372 { "",
375 { 0x02, 0xba, 0x4c, 0x4e, 0x5f, 0x8e, 0xcd, 0x18, 373 { 0x02, 0xba, 0x4c, 0x4e, 0x5f, 0x8e, 0xcd, 0x18,
376 0x77, 0xfc, 0x52, 0xd6, 0x4d, 0x30, 0xe3, 0x7a, 374 0x77, 0xfc, 0x52, 0xd6, 0x4d, 0x30, 0xe3, 0x7a,
377 0x2d, 0x97, 0x74, 0xfb, 0x1e, 0x5d, 0x02, 0x63, 375 0x2d, 0x97, 0x74, 0xfb, 0x1e, 0x5d, 0x02, 0x63,
406 0xb8, 0x44, 0x24, 0xae, 0x93, 0x1c, 0xbb, 0x1f, 404 0xb8, 0x44, 0x24, 0xae, 0x93, 0x1c, 0xbb, 0x1f,
407 0xe3, 0x63, 0xd1, 0xd0, 0xbf, 0x40, 0x17, 0xf1, 405 0xe3, 0x63, 0xd1, 0xd0, 0xbf, 0x40, 0x17, 0xf1,
408 0xa8, 0x9f, 0x7e, 0xa6, 0xde, 0x77, 0xa0, 0xb8 } 406 0xa8, 0x9f, 0x7e, 0xa6, 0xde, 0x77, 0xa0, 0xb8 }
409 } 407 }
410 }; 408 };
411 int x; 409
412 unsigned char buf[32]; 410 int i;
411 unsigned char tmp[32];
413 hash_state md; 412 hash_state md;
414 413
415 for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) { 414 for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) {
416 rmd256_init(&md); 415 rmd256_init(&md);
417 rmd256_process(&md, (unsigned char *)tests[x].msg, strlen(tests[x].msg)); 416 rmd256_process(&md, (unsigned char *)tests[i].msg, strlen(tests[i].msg));
418 rmd256_done(&md, buf); 417 rmd256_done(&md, tmp);
419 if (XMEMCMP(buf, tests[x].md, 32) != 0) { 418 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD256", i)) {
420 #if 0
421 printf("Failed test %d\n", x);
422 #endif
423 return CRYPT_FAIL_TESTVECTOR; 419 return CRYPT_FAIL_TESTVECTOR;
424 } 420 }
425 } 421 }
426 return CRYPT_OK; 422 return CRYPT_OK;
427 #endif 423 #endif
428 } 424 }
429 425
430 #endif 426 #endif
431 427
428 /* ref: $Format:%D$ */
429 /* git commit: $Format:%H$ */
430 /* commit time: $Format:%ai$ */