diff libtomcrypt/src/hashes/rmd320.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
line wrap: on
line diff
--- a/libtomcrypt/src/hashes/rmd320.c	Thu Feb 08 23:11:40 2018 +0800
+++ b/libtomcrypt/src/hashes/rmd320.c	Fri Feb 09 21:44:05 2018 +0800
@@ -5,8 +5,6 @@
  *
  * The library is free for all purposes without any express
  * guarantee it works.
- *
- * Tom St Denis, [email protected], http://libtom.org
  */
 #include "tomcrypt.h"
 
@@ -20,11 +18,12 @@
 const struct ltc_hash_descriptor rmd320_desc =
 {
     "rmd320",
-    9,
+    14,
     40,
     64,
 
-    /* OID */
+    /* OID ... does not exist
+     * http://oid-info.com/get/1.3.36.3.2 */
    { 0 },
    0,
 
@@ -432,8 +431,8 @@
    return CRYPT_NOP;
 #else
    static const struct {
-        char *msg;
-        unsigned char md[40];
+        const char *msg;
+        unsigned char hash[40];
    } tests[] = {
    { "",
      { 0x22, 0xd6, 0x5d, 0x56, 0x61, 0x53, 0x6c, 0xdc, 0x75, 0xc1,
@@ -472,18 +471,16 @@
        0xbc, 0x74, 0x70, 0xa9, 0x69, 0xc9, 0xd0, 0x72, 0xa1, 0xac }
    }
    };
-   int x;
-   unsigned char buf[40];
+
+   int i;
+   unsigned char tmp[40];
    hash_state md;
 
-   for (x = 0; x < (int)(sizeof(tests)/sizeof(tests[0])); x++) {
+   for (i = 0; i < (int)(sizeof(tests)/sizeof(tests[0])); i++) {
        rmd320_init(&md);
-       rmd320_process(&md, (unsigned char *)tests[x].msg, strlen(tests[x].msg));
-       rmd320_done(&md, buf);
-       if (XMEMCMP(buf, tests[x].md, 40) != 0) {
-#if 0
-          printf("Failed test %d\n", x);
-#endif
+       rmd320_process(&md, (unsigned char *)tests[i].msg, strlen(tests[i].msg));
+       rmd320_done(&md, tmp);
+       if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD320", i)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
    }
@@ -493,3 +490,6 @@
 
 #endif
 
+/* ref:         $Format:%D$ */
+/* git commit:  $Format:%H$ */
+/* commit time: $Format:%ai$ */