comparison libtomcrypt/src/hashes/rmd320.c @ 1478:3a933956437e coverity

update coverity
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 23:49:22 +0800
parents 6dba84798cd5
children
comparison
equal deleted inserted replaced
1439:8d24733026c5 1478:3a933956437e
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 @file rmd320.c 12 @file rmd320.c
18 #ifdef LTC_RIPEMD320 16 #ifdef LTC_RIPEMD320
19 17
20 const struct ltc_hash_descriptor rmd320_desc = 18 const struct ltc_hash_descriptor rmd320_desc =
21 { 19 {
22 "rmd320", 20 "rmd320",
23 9, 21 14,
24 40, 22 40,
25 64, 23 64,
26 24
27 /* OID */ 25 /* OID ... does not exist
26 * http://oid-info.com/get/1.3.36.3.2 */
28 { 0 }, 27 { 0 },
29 0, 28 0,
30 29
31 &rmd320_init, 30 &rmd320_init,
32 &rmd320_process, 31 &rmd320_process,
430 { 429 {
431 #ifndef LTC_TEST 430 #ifndef LTC_TEST
432 return CRYPT_NOP; 431 return CRYPT_NOP;
433 #else 432 #else
434 static const struct { 433 static const struct {
435 char *msg; 434 const char *msg;
436 unsigned char md[40]; 435 unsigned char hash[40];
437 } tests[] = { 436 } tests[] = {
438 { "", 437 { "",
439 { 0x22, 0xd6, 0x5d, 0x56, 0x61, 0x53, 0x6c, 0xdc, 0x75, 0xc1, 438 { 0x22, 0xd6, 0x5d, 0x56, 0x61, 0x53, 0x6c, 0xdc, 0x75, 0xc1,
440 0xfd, 0xf5, 0xc6, 0xde, 0x7b, 0x41, 0xb9, 0xf2, 0x73, 0x25, 439 0xfd, 0xf5, 0xc6, 0xde, 0x7b, 0x41, 0xb9, 0xf2, 0x73, 0x25,
441 0xeb, 0xc6, 0x1e, 0x85, 0x57, 0x17, 0x7d, 0x70, 0x5a, 0x0e, 440 0xeb, 0xc6, 0x1e, 0x85, 0x57, 0x17, 0x7d, 0x70, 0x5a, 0x0e,
470 0xb8, 0x4d, 0xf7, 0x69, 0xa5, 0xde, 0x20, 0x60, 0xe2, 0x59, 469 0xb8, 0x4d, 0xf7, 0x69, 0xa5, 0xde, 0x20, 0x60, 0xe2, 0x59,
471 0xdf, 0x4c, 0x9b, 0xb4, 0xa4, 0x26, 0x8c, 0x0e, 0x93, 0x5b, 470 0xdf, 0x4c, 0x9b, 0xb4, 0xa4, 0x26, 0x8c, 0x0e, 0x93, 0x5b,
472 0xbc, 0x74, 0x70, 0xa9, 0x69, 0xc9, 0xd0, 0x72, 0xa1, 0xac } 471 0xbc, 0x74, 0x70, 0xa9, 0x69, 0xc9, 0xd0, 0x72, 0xa1, 0xac }
473 } 472 }
474 }; 473 };
475 int x; 474
476 unsigned char buf[40]; 475 int i;
476 unsigned char tmp[40];
477 hash_state md; 477 hash_state md;
478 478
479 for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) { 479 for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) {
480 rmd320_init(&md); 480 rmd320_init(&md);
481 rmd320_process(&md, (unsigned char *)tests[x].msg, strlen(tests[x].msg)); 481 rmd320_process(&md, (unsigned char *)tests[i].msg, strlen(tests[i].msg));
482 rmd320_done(&md, buf); 482 rmd320_done(&md, tmp);
483 if (XMEMCMP(buf, tests[x].md, 40) != 0) { 483 if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD320", i)) {
484 #if 0
485 printf("Failed test %d\n", x);
486 #endif
487 return CRYPT_FAIL_TESTVECTOR; 484 return CRYPT_FAIL_TESTVECTOR;
488 } 485 }
489 } 486 }
490 return CRYPT_OK; 487 return CRYPT_OK;
491 #endif 488 #endif
492 } 489 }
493 490
494 #endif 491 #endif
495 492
493 /* ref: $Format:%D$ */
494 /* git commit: $Format:%H$ */
495 /* commit time: $Format:%ai$ */