Browse Source

Merge pull request #707 from libtom/improve-tests

Improve tests
Steffen Jaeckel 2 weeks ago
parent
commit
34b6ad9a2e
91 changed files with 321 additions and 321 deletions
  1. 2 2
      src/ciphers/aes/aes.c
  2. 2 2
      src/ciphers/aes/aes_desc.c
  3. 2 2
      src/ciphers/aes/aesni.c
  4. 3 3
      src/ciphers/anubis.c
  5. 2 2
      src/ciphers/blowfish.c
  6. 2 2
      src/ciphers/camellia.c
  7. 2 2
      src/ciphers/cast5.c
  8. 7 7
      src/ciphers/des.c
  9. 2 2
      src/ciphers/idea.c
  10. 2 2
      src/ciphers/kasumi.c
  11. 3 3
      src/ciphers/khazad.c
  12. 2 2
      src/ciphers/kseed.c
  13. 3 3
      src/ciphers/multi2.c
  14. 2 2
      src/ciphers/noekeon.c
  15. 2 2
      src/ciphers/rc2.c
  16. 2 2
      src/ciphers/rc5.c
  17. 2 2
      src/ciphers/rc6.c
  18. 6 6
      src/ciphers/safer/safer.c
  19. 2 2
      src/ciphers/safer/saferp.c
  20. 2 2
      src/ciphers/serpent.c
  21. 2 2
      src/ciphers/skipjack.c
  22. 4 4
      src/ciphers/sm4.c
  23. 2 2
      src/ciphers/tea.c
  24. 2 2
      src/ciphers/twofish/twofish.c
  25. 2 2
      src/ciphers/xtea.c
  26. 5 5
      src/encauth/ccm/ccm_test.c
  27. 14 14
      src/encauth/chachapoly/chacha20poly1305_test.c
  28. 3 3
      src/encauth/eax/eax_test.c
  29. 4 4
      src/encauth/gcm/gcm_test.c
  30. 3 3
      src/encauth/ocb/ocb_test.c
  31. 10 10
      src/encauth/ocb3/ocb3_test.c
  32. 8 8
      src/encauth/siv/siv.c
  33. 4 4
      src/hashes/blake2b.c
  34. 4 4
      src/hashes/blake2s.c
  35. 1 1
      src/hashes/chc/chc.c
  36. 1 1
      src/hashes/md2.c
  37. 1 1
      src/hashes/md4.c
  38. 1 1
      src/hashes/md5.c
  39. 1 1
      src/hashes/rmd128.c
  40. 1 1
      src/hashes/rmd160.c
  41. 1 1
      src/hashes/rmd256.c
  42. 1 1
      src/hashes/rmd320.c
  43. 1 1
      src/hashes/sha1.c
  44. 1 1
      src/hashes/sha2/sha224.c
  45. 1 1
      src/hashes/sha2/sha256.c
  46. 1 1
      src/hashes/sha2/sha384.c
  47. 1 1
      src/hashes/sha2/sha512.c
  48. 1 1
      src/hashes/sha2/sha512_224.c
  49. 1 1
      src/hashes/sha2/sha512_256.c
  50. 40 40
      src/hashes/sha3_test.c
  51. 1 1
      src/hashes/tiger.c
  52. 1 1
      src/hashes/whirl/whirl.c
  53. 1 0
      src/headers/tomcrypt_misc.h
  54. 11 0
      src/headers/tomcrypt_private.h
  55. 2 2
      src/mac/blake2/blake2bmac_test.c
  56. 2 2
      src/mac/blake2/blake2smac_test.c
  57. 1 1
      src/mac/f9/f9_test.c
  58. 1 1
      src/mac/hmac/hmac_test.c
  59. 1 1
      src/mac/omac/omac_test.c
  60. 1 1
      src/mac/pelican/pelican_test.c
  61. 1 1
      src/mac/pmac/pmac_test.c
  62. 2 2
      src/mac/poly1305/poly1305_test.c
  63. 1 1
      src/mac/xcbc/xcbc_test.c
  64. 1 1
      src/misc/adler32.c
  65. 10 1
      src/misc/compare_testvector.c
  66. 1 1
      src/misc/crc32.c
  67. 6 0
      src/misc/deprecated.c
  68. 1 1
      src/misc/hkdf/hkdf_test.c
  69. 3 3
      src/misc/pkcs5/pkcs_5_test.c
  70. 1 1
      src/modes/ctr/ctr_test.c
  71. 1 1
      src/modes/f8/f8_test_mode.c
  72. 3 3
      src/modes/lrw/lrw_test.c
  73. 2 2
      src/modes/xts/xts_test.c
  74. 3 3
      src/prngs/chacha20.c
  75. 3 3
      src/prngs/rc4.c
  76. 3 3
      src/prngs/sober128.c
  77. 5 5
      src/stream/chacha/chacha_test.c
  78. 6 6
      src/stream/rabbit/rabbit.c
  79. 2 2
      src/stream/rc4/rc4_test.c
  80. 4 4
      src/stream/salsa20/salsa20_test.c
  81. 4 4
      src/stream/salsa20/xsalsa20_test.c
  82. 2 2
      src/stream/sober128/sober128_test.c
  83. 4 4
      src/stream/sosemanuk/sosemanuk_test.c
  84. 7 7
      tests/base64_test.c
  85. 0 10
      tests/common.c
  86. 1 3
      tests/common.h
  87. 8 8
      tests/dsa_test.c
  88. 11 11
      tests/ecc_test.c
  89. 25 36
      tests/modes_test.c
  90. 1 3
      tests/prng_test.c
  91. 3 5
      tests/x25519_test.c

+ 2 - 2
src/ciphers/aes/aes.c

@@ -677,8 +677,8 @@ int ECB_TEST(void)
 
     rijndael_ecb_encrypt(tests[i].pt, tmp[0], &key);
     rijndael_ecb_decrypt(tmp[0], tmp[1], &key);
-    if (compare_testvector(tmp[0], 16, tests[i].ct, 16, "AES Encrypt", i) ||
-          compare_testvector(tmp[1], 16, tests[i].pt, 16, "AES Decrypt", i)) {
+    if (ltc_compare_testvector(tmp[0], 16, tests[i].ct, 16, "AES Encrypt", i) ||
+          ltc_compare_testvector(tmp[1], 16, tests[i].pt, 16, "AES Decrypt", i)) {
         return CRYPT_FAIL_TESTVECTOR;
     }
 

+ 2 - 2
src/ciphers/aes/aes_desc.c

@@ -209,12 +209,12 @@ int AES_TEST(void)
     }
 
     AES_ENC(tests[i].pt, tmp[0], &key);
-    if (compare_testvector(tmp[0], 16, tests[i].ct, 16, "AES Encrypt", i)) {
+    if (ltc_compare_testvector(tmp[0], 16, tests[i].ct, 16, "AES Encrypt", i)) {
         return CRYPT_FAIL_TESTVECTOR;
     }
 #ifndef ENCRYPT_ONLY
     AES_DEC(tmp[0], tmp[1], &key);
-    if (compare_testvector(tmp[1], 16, tests[i].pt, 16, "AES Decrypt", i)) {
+    if (ltc_compare_testvector(tmp[1], 16, tests[i].pt, 16, "AES Decrypt", i)) {
         return CRYPT_FAIL_TESTVECTOR;
     }
 

+ 2 - 2
src/ciphers/aes/aesni.c

@@ -320,8 +320,8 @@ int aesni_test(void)
 
     aesni_ecb_encrypt(tests[i].pt, tmp[0], &key);
     aesni_ecb_decrypt(tmp[0], tmp[1], &key);
-    if (compare_testvector(tmp[0], 16, tests[i].ct, 16, "AES-NI Encrypt", i) ||
-          compare_testvector(tmp[1], 16, tests[i].pt, 16, "AES-NI Decrypt", i)) {
+    if (ltc_compare_testvector(tmp[0], 16, tests[i].ct, 16, "AES-NI Encrypt", i) ||
+          ltc_compare_testvector(tmp[1], 16, tests[i].pt, 16, "AES-NI Decrypt", i)) {
         return CRYPT_FAIL_TESTVECTOR;
     }
 

+ 3 - 3
src/ciphers/anubis.c

@@ -1502,14 +1502,14 @@ int anubis_test(void)
        anubis_setup(tests[x].key, tests[x].keylen, 0, &skey);
        anubis_ecb_encrypt(tests[x].pt, buf[0], &skey);
        anubis_ecb_decrypt(buf[0], buf[1], &skey);
-       if (compare_testvector(buf[0], 16, tests[x].ct, 16, "Anubis Encrypt", x) ||
-             compare_testvector(buf[1], 16, tests[x].pt, 16, "Anubis Decrypt", x)) {
+       if (ltc_compare_testvector(buf[0], 16, tests[x].ct, 16, "Anubis Encrypt", x) ||
+             ltc_compare_testvector(buf[1], 16, tests[x].pt, 16, "Anubis Decrypt", x)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
 
        for (y = 0; y < 1000; y++) anubis_ecb_encrypt(buf[0], buf[0], &skey);
        for (y = 0; y < 1000; y++) anubis_ecb_decrypt(buf[0], buf[0], &skey);
-       if (compare_testvector(buf[0], 16, tests[x].ct, 16, "Anubis 1000", 1000)) {
+       if (ltc_compare_testvector(buf[0], 16, tests[x].ct, 16, "Anubis 1000", 1000)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
 

+ 2 - 2
src/ciphers/blowfish.c

@@ -611,8 +611,8 @@ int blowfish_test(void)
       blowfish_ecb_decrypt(tmp[0], tmp[1], &key);
 
       /* compare */
-      if ((compare_testvector(tmp[0], 8, tests[x].ct, 8, "Blowfish Encrypt", x) != 0) ||
-            (compare_testvector(tmp[1], 8, tests[x].pt, 8, "Blowfish Decrypt", x) != 0)) {
+      if ((ltc_compare_testvector(tmp[0], 8, tests[x].ct, 8, "Blowfish Encrypt", x) != 0) ||
+            (ltc_compare_testvector(tmp[1], 8, tests[x].pt, 8, "Blowfish Decrypt", x) != 0)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
 

+ 2 - 2
src/ciphers/camellia.c

@@ -694,8 +694,8 @@ int camellia_test(void)
          return err;
       }
       camellia_done(&skey);
-      if (compare_testvector(tests[x].ct, 16, buf[0], 16, "Camellia Encrypt", x) ||
-            compare_testvector(tests[x].pt, 16, buf[1], 16, "Camellia Decrypt", x)) {
+      if (ltc_compare_testvector(tests[x].ct, 16, buf[0], 16, "Camellia Encrypt", x) ||
+            ltc_compare_testvector(tests[x].pt, 16, buf[1], 16, "Camellia Decrypt", x)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
    }

+ 2 - 2
src/ciphers/cast5.c

@@ -663,8 +663,8 @@ int cast5_test(void)
        }
        cast5_ecb_encrypt(tests[i].pt, tmp[0], &key);
        cast5_ecb_decrypt(tmp[0], tmp[1], &key);
-       if ((compare_testvector(tmp[0], 8, tests[i].ct, 8, "CAST5 Encrypt", i) != 0) ||
-             (compare_testvector(tmp[1], 8, tests[i].pt, 8, "CAST5 Decrypt", i) != 0)) {
+       if ((ltc_compare_testvector(tmp[0], 8, tests[i].ct, 8, "CAST5 Encrypt", i) != 0) ||
+             (ltc_compare_testvector(tmp[1], 8, tests[i].pt, 8, "CAST5 Decrypt", i) != 0)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
       /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */

+ 7 - 7
src/ciphers/des.c

@@ -2026,13 +2026,13 @@ int des_test(void)
 
         des_ecb_encrypt(cases[i].txt, ct, &skey);
 
-        if (compare_testvector(ct, sizeof(ct), cases[i].out, 8, "DES Encrypt", i) != 0) {
+        if (ltc_compare_testvector(ct, sizeof(ct), cases[i].out, 8, "DES Encrypt", i) != 0) {
             return CRYPT_FAIL_TESTVECTOR;
         }
 
         des_ecb_decrypt(ct, pt, &skey);
 
-        if (compare_testvector(pt, sizeof(pt), cases[i].txt, 8, "DES Decrypt", i) != 0) {
+        if (ltc_compare_testvector(pt, sizeof(pt), cases[i].txt, 8, "DES Decrypt", i) != 0) {
             return CRYPT_FAIL_TESTVECTOR;
         }
     }
@@ -2049,7 +2049,7 @@ int des_test(void)
     for (i = 0; i < 1000; i++) des_ecb_encrypt(tmp, tmp, &skey);
     for (i = 0; i < 1000; i++) des_ecb_decrypt(tmp, tmp, &skey);
 
-    if (compare_testvector(tmp, 8, pt, 8, "DES", 0) != 0) {
+    if (ltc_compare_testvector(tmp, 8, pt, 8, "DES", 0) != 0) {
         return CRYPT_FAIL_TESTVECTOR;
     }
 
@@ -2082,7 +2082,7 @@ int desx_test(void)
     for (i = 0; i < 1000; i++) desx_ecb_encrypt(tmp, tmp, &skey);
     for (i = 0; i < 1000; i++) desx_ecb_decrypt(tmp, tmp, &skey);
 
-    if (compare_testvector(tmp, 8, pt, 8, "DES-X", 0) != 0) {
+    if (ltc_compare_testvector(tmp, 8, pt, 8, "DES-X", 0) != 0) {
         return CRYPT_FAIL_TESTVECTOR;
     }
 
@@ -2133,13 +2133,13 @@ int des3_test(void)
 
         des3_ecb_encrypt(cases[i].txt, ct, &skey);
 
-        if (compare_testvector(ct, sizeof(ct), cases[i].out, 8, "3DES Encrypt", i) != 0) {
+        if (ltc_compare_testvector(ct, sizeof(ct), cases[i].out, 8, "3DES Encrypt", i) != 0) {
             return CRYPT_FAIL_TESTVECTOR;
         }
 
         des3_ecb_decrypt(ct, pt, &skey);
 
-        if (compare_testvector(pt, sizeof(pt), cases[i].txt, 8, "3DES Decrypt", i) != 0) {
+        if (ltc_compare_testvector(pt, sizeof(pt), cases[i].txt, 8, "3DES Decrypt", i) != 0) {
             return CRYPT_FAIL_TESTVECTOR;
         }
     }
@@ -2156,7 +2156,7 @@ int des3_test(void)
     for (i = 0; i < 1000; i++) des3_ecb_encrypt(tmp, tmp, &skey);
     for (i = 0; i < 1000; i++) des3_ecb_decrypt(tmp, tmp, &skey);
 
-    if (compare_testvector(tmp, 8, pt, 8, "3DES", 0) != 0) {
+    if (ltc_compare_testvector(tmp, 8, pt, 8, "3DES", 0) != 0) {
         return CRYPT_FAIL_TESTVECTOR;
     }
 

+ 2 - 2
src/ciphers/idea.c

@@ -233,13 +233,13 @@ int idea_test(void)
       if ((err = idea_ecb_encrypt(tests[x].pt, buf[0], &key)) != CRYPT_OK) {
          return err;
       }
-      if (compare_testvector(buf[0], 8, tests[x].ct, 8, "IDEA Encrypt", x)) {
+      if (ltc_compare_testvector(buf[0], 8, tests[x].ct, 8, "IDEA Encrypt", x)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
       if ((err = idea_ecb_decrypt(tests[x].ct, buf[1], &key)) != CRYPT_OK) {
          return err;
       }
-      if (compare_testvector(buf[1], 8, tests[x].pt, 8, "IDEA Decrypt", x)) {
+      if (ltc_compare_testvector(buf[1], 8, tests[x].pt, 8, "IDEA Decrypt", x)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
    }

+ 2 - 2
src/ciphers/kasumi.c

@@ -296,8 +296,8 @@ int kasumi_test(void)
        if ((err = kasumi_ecb_decrypt(tests[x].ct, buf[1], &key)) != CRYPT_OK) {
           return err;
        }
-       if (compare_testvector(buf[1], 8, tests[x].pt, 8, "Kasumi Decrypt", x) ||
-             compare_testvector(buf[0], 8, tests[x].ct, 8, "Kasumi Encrypt", x)) {
+       if (ltc_compare_testvector(buf[1], 8, tests[x].pt, 8, "Kasumi Decrypt", x) ||
+             ltc_compare_testvector(buf[0], 8, tests[x].ct, 8, "Kasumi Encrypt", x)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
    }

+ 3 - 3
src/ciphers/khazad.c

@@ -798,14 +798,14 @@ int khazad_test(void)
        khazad_setup(tests[x].key, 16, 0, &skey);
        khazad_ecb_encrypt(tests[x].pt, buf[0], &skey);
        khazad_ecb_decrypt(buf[0], buf[1], &skey);
-       if (compare_testvector(buf[0], 8, tests[x].ct, 8, "Khazad Encrypt", x) ||
-             compare_testvector(buf[1], 8, tests[x].pt, 8, "Khazad Decrypt", x)) {
+       if (ltc_compare_testvector(buf[0], 8, tests[x].ct, 8, "Khazad Encrypt", x) ||
+             ltc_compare_testvector(buf[1], 8, tests[x].pt, 8, "Khazad Decrypt", x)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
 
        for (y = 0; y < 1000; y++) khazad_ecb_encrypt(buf[0], buf[0], &skey);
        for (y = 0; y < 1000; y++) khazad_ecb_decrypt(buf[0], buf[0], &skey);
-       if (compare_testvector(buf[0], 8, tests[x].ct, 8, "Khazad 1000", 1000)) {
+       if (ltc_compare_testvector(buf[0], 8, tests[x].ct, 8, "Khazad 1000", 1000)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
 

+ 2 - 2
src/ciphers/kseed.c

@@ -338,8 +338,8 @@ int kseed_test(void)
        kseed_setup(tests[x].key, 16, 0, &skey);
        kseed_ecb_encrypt(tests[x].pt, buf[0], &skey);
        kseed_ecb_decrypt(buf[0], buf[1], &skey);
-       if (compare_testvector(buf[0], 16, tests[x].ct, 16, "KSEED Encrypt", x) ||
-             compare_testvector(buf[1], 16, tests[x].pt, 16, "KSEED Decrypt", x)) {
+       if (ltc_compare_testvector(buf[0], 16, tests[x].ct, 16, "KSEED Encrypt", x) ||
+             ltc_compare_testvector(buf[1], 16, tests[x].pt, 16, "KSEED Decrypt", x)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
    }

+ 3 - 3
src/ciphers/multi2.c

@@ -250,14 +250,14 @@ int multi2_test(void)
          return err;
       }
 
-      if (compare_testvector(buf, 8, tests[x].ct, 8, "Multi2 Encrypt", x)) {
+      if (ltc_compare_testvector(buf, 8, tests[x].ct, 8, "Multi2 Encrypt", x)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
 
       if ((err = multi2_ecb_decrypt(buf, buf, &skey)) != CRYPT_OK) {
          return err;
       }
-      if (compare_testvector(buf, 8, tests[x].pt, 8, "Multi2 Decrypt", x)) {
+      if (ltc_compare_testvector(buf, 8, tests[x].pt, 8, "Multi2 Decrypt", x)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
    }
@@ -274,7 +274,7 @@ int multi2_test(void)
         if ((err = multi2_ecb_decrypt(ct, buf, &skey)) != CRYPT_OK) {
                 return err;
         }
-        if (compare_testvector(buf, 8, tests[0].pt, 8, "Multi2 Rounds", x)) {
+        if (ltc_compare_testvector(buf, 8, tests[0].pt, 8, "Multi2 Rounds", x)) {
                 return CRYPT_FAIL_TESTVECTOR;
         }
    }

+ 2 - 2
src/ciphers/noekeon.c

@@ -275,8 +275,8 @@ int noekeon_test(void)
 
     noekeon_ecb_encrypt(tests[i].pt, tmp[0], &key);
     noekeon_ecb_decrypt(tmp[0], tmp[1], &key);
-    if (compare_testvector(tmp[0], 16, tests[i].ct, 16, "Noekeon Encrypt", i) ||
-          compare_testvector(tmp[1], 16, tests[i].pt, 16, "Noekeon Decrypt", i)) {
+    if (ltc_compare_testvector(tmp[0], 16, tests[i].ct, 16, "Noekeon Encrypt", i) ||
+          ltc_compare_testvector(tmp[1], 16, tests[i].pt, 16, "Noekeon Decrypt", i)) {
         return CRYPT_FAIL_TESTVECTOR;
     }
 

+ 2 - 2
src/ciphers/rc2.c

@@ -362,8 +362,8 @@ int rc2_test(void)
         rc2_ecb_encrypt(tests[x].pt, tmp[0], &skey);
         rc2_ecb_decrypt(tmp[0], tmp[1], &skey);
 
-        if (compare_testvector(tmp[0], 8, tests[x].ct, 8, "RC2 CT", x) ||
-              compare_testvector(tmp[1], 8, tests[x].pt, 8, "RC2 PT", x)) {
+        if (ltc_compare_testvector(tmp[0], 8, tests[x].ct, 8, "RC2 CT", x) ||
+              ltc_compare_testvector(tmp[1], 8, tests[x].pt, 8, "RC2 PT", x)) {
            return CRYPT_FAIL_TESTVECTOR;
         }
 

+ 2 - 2
src/ciphers/rc5.c

@@ -278,8 +278,8 @@ int rc5_test(void)
       rc5_ecb_decrypt(tmp[0], tmp[1], &key);
 
       /* compare */
-      if (compare_testvector(tmp[0], 8, tests[x].ct, 8, "RC5 Encrypt", x) != 0 ||
-            compare_testvector(tmp[1], 8, tests[x].pt, 8, "RC5 Decrypt", x) != 0) {
+      if (ltc_compare_testvector(tmp[0], 8, tests[x].ct, 8, "RC5 Encrypt", x) != 0 ||
+            ltc_compare_testvector(tmp[1], 8, tests[x].pt, 8, "RC5 Decrypt", x) != 0) {
          return CRYPT_FAIL_TESTVECTOR;
       }
 

+ 2 - 2
src/ciphers/rc6.c

@@ -280,8 +280,8 @@ int rc6_test(void)
       rc6_ecb_decrypt(tmp[0], tmp[1], &key);
 
       /* compare */
-      if (compare_testvector(tmp[0], 16, tests[x].ct, 16, "RC6 Encrypt", x) ||
-            compare_testvector(tmp[1], 16, tests[x].pt, 16, "RC6 Decrypt", x)) {
+      if (ltc_compare_testvector(tmp[0], 16, tests[x].ct, 16, "RC6 Encrypt", x) ||
+            ltc_compare_testvector(tmp[1], 16, tests[x].pt, 16, "RC6 Decrypt", x)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
 

+ 6 - 6
src/ciphers/safer/safer.c

@@ -390,8 +390,8 @@ int safer_k64_test(void)
    safer_ecb_encrypt(k64_pt, buf[0], &skey);
    safer_ecb_decrypt(buf[0], buf[1], &skey);
 
-   if (compare_testvector(buf[0], 8, k64_ct, 8, "Safer K64 Encrypt", 0) != 0 ||
-         compare_testvector(buf[1], 8, k64_pt, 8, "Safer K64 Decrypt", 0) != 0) {
+   if (ltc_compare_testvector(buf[0], 8, k64_ct, 8, "Safer K64 Encrypt", 0) != 0 ||
+         ltc_compare_testvector(buf[1], 8, k64_pt, 8, "Safer K64 Decrypt", 0) != 0) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -421,8 +421,8 @@ int safer_sk64_test(void)
    safer_ecb_encrypt(sk64_pt, buf[0], &skey);
    safer_ecb_decrypt(buf[0], buf[1], &skey);
 
-   if (compare_testvector(buf[0], 8, sk64_ct, 8, "Safer SK64 Encrypt", 0) != 0 ||
-         compare_testvector(buf[1], 8, sk64_pt, 8, "Safer SK64 Decrypt", 0) != 0) {
+   if (ltc_compare_testvector(buf[0], 8, sk64_ct, 8, "Safer SK64 Encrypt", 0) != 0 ||
+         ltc_compare_testvector(buf[1], 8, sk64_pt, 8, "Safer SK64 Decrypt", 0) != 0) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -465,8 +465,8 @@ int safer_sk128_test(void)
    safer_ecb_encrypt(sk128_pt, buf[0], &skey);
    safer_ecb_decrypt(buf[0], buf[1], &skey);
 
-   if (compare_testvector(buf[0], 8, sk128_ct, 8, "Safer SK128 Encrypt", 0) != 0 ||
-         compare_testvector(buf[1], 8, sk128_pt, 8, "Safer SK128 Decrypt", 0) != 0) {
+   if (ltc_compare_testvector(buf[0], 8, sk128_ct, 8, "Safer SK128 Encrypt", 0) != 0 ||
+         ltc_compare_testvector(buf[1], 8, sk128_pt, 8, "Safer SK128 Decrypt", 0) != 0) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 

+ 2 - 2
src/ciphers/safer/saferp.c

@@ -518,8 +518,8 @@ int saferp_test(void)
       saferp_ecb_decrypt(tmp[0], tmp[1], &skey);
 
       /* compare */
-      if (compare_testvector(tmp[0], 16, tests[i].ct, 16, "Safer+ Encrypt", i) ||
-            compare_testvector(tmp[1], 16, tests[i].pt, 16, "Safer+ Decrypt", i)) {
+      if (ltc_compare_testvector(tmp[0], 16, tests[i].ct, 16, "Safer+ Encrypt", i) ||
+            ltc_compare_testvector(tmp[1], 16, tests[i].pt, 16, "Safer+ Decrypt", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
 

+ 2 - 2
src/ciphers/serpent.c

@@ -700,13 +700,13 @@ int serpent_test(void)
       if ((err = serpent_ecb_encrypt(tests[x].pt, buf[0], &key)) != CRYPT_OK) {
         return err;
       }
-      if (compare_testvector(buf[0], 16, tests[x].ct, 16, "SERPENT Encrypt", x)) {
+      if (ltc_compare_testvector(buf[0], 16, tests[x].ct, 16, "SERPENT Encrypt", x)) {
         return CRYPT_FAIL_TESTVECTOR;
       }
       if ((err = serpent_ecb_decrypt(tests[x].ct, buf[1], &key)) != CRYPT_OK) {
         return err;
       }
-      if (compare_testvector(buf[1], 16, tests[x].pt, 16, "SERPENT Decrypt", x)) {
+      if (ltc_compare_testvector(buf[1], 16, tests[x].pt, 16, "SERPENT Decrypt", x)) {
         return CRYPT_FAIL_TESTVECTOR;
       }
    }

+ 2 - 2
src/ciphers/skipjack.c

@@ -290,8 +290,8 @@ int skipjack_test(void)
       skipjack_ecb_decrypt(buf[0], buf[1], &key);
 
       /* compare */
-      if (compare_testvector(buf[0], 8, tests[x].ct, 8, "Skipjack Encrypt", x) != 0 ||
-            compare_testvector(buf[1], 8, tests[x].pt, 8, "Skipjack Decrypt", x) != 0) {
+      if (ltc_compare_testvector(buf[0], 8, tests[x].ct, 8, "Skipjack Encrypt", x) != 0 ||
+            ltc_compare_testvector(buf[1], 8, tests[x].pt, 8, "Skipjack Decrypt", x) != 0) {
          return CRYPT_FAIL_TESTVECTOR;
       }
 

+ 4 - 4
src/ciphers/sm4.c

@@ -316,24 +316,24 @@ static int sm4_self_test_ltc(void)
 
     /*A.1 example 1*/
     sm4_ecb_encrypt(plaintext, output, &skey);
-    if (compare_testvector(output, 16, ciphertext, 16, "SM4 single encryption", 0) != 0)
+    if (ltc_compare_testvector(output, 16, ciphertext, 16, "SM4 single encryption", 0) != 0)
         result = CRYPT_ERROR;
 
     sm4_ecb_decrypt(ciphertext, output, &skey);
-    if (compare_testvector(output, 16, plaintext, 16, "SM4 single decryption", 0) != 0)
+    if (ltc_compare_testvector(output, 16, plaintext, 16, "SM4 single decryption", 0) != 0)
         result = CRYPT_ERROR;
 
     /*A.2 example 2*/
     XMEMCPY(output, plaintext, 16);
     for (i = 0; i < 1000000; ++i)
         sm4_ecb_encrypt(output, output, &skey);
-    if (compare_testvector(output, 16, ciphertext_1000000t, 16, "SM4 1000000 times encryption", 0) != 0)
+    if (ltc_compare_testvector(output, 16, ciphertext_1000000t, 16, "SM4 1000000 times encryption", 0) != 0)
         result = CRYPT_ERROR;
 
     XMEMCPY(output, ciphertext_1000000t, 16);
     for (i = 0; i < 1000000; ++i)
         sm4_ecb_decrypt(output, output, &skey);
-    if (compare_testvector(output, 16, plaintext, 16, "SM4 1000000 times encryption", 0) != 0)
+    if (ltc_compare_testvector(output, 16, plaintext, 16, "SM4 1000000 times encryption", 0) != 0)
         result = CRYPT_ERROR;
 
     keysize = 128;

+ 2 - 2
src/ciphers/tea.c

@@ -166,8 +166,8 @@ int tea_test(void)
        tea_ecb_encrypt(ptct[0], tmp[0], &skey);
        tea_ecb_decrypt(tmp[0], tmp[1], &skey);
 
-       if (compare_testvector(tmp[0], 8, ptct[1], 8, "TEA Encrypt", i) != 0 ||
-             compare_testvector(tmp[1], 8, ptct[0], 8, "TEA Decrypt", i) != 0) {
+       if (ltc_compare_testvector(tmp[0], 8, ptct[1], 8, "TEA Encrypt", i) != 0 ||
+             ltc_compare_testvector(tmp[1], 8, ptct[0], 8, "TEA Decrypt", i) != 0) {
           return CRYPT_FAIL_TESTVECTOR;
        }
 

+ 2 - 2
src/ciphers/twofish/twofish.c

@@ -657,8 +657,8 @@ int twofish_test(void)
     }
     twofish_ecb_encrypt(tests[i].pt, tmp[0], &key);
     twofish_ecb_decrypt(tmp[0], tmp[1], &key);
-    if (compare_testvector(tmp[0], 16, tests[i].ct, 16, "Twofish Encrypt", i) != 0 ||
-          compare_testvector(tmp[1], 16, tests[i].pt, 16, "Twofish Decrypt", i) != 0) {
+    if (ltc_compare_testvector(tmp[0], 16, tests[i].ct, 16, "Twofish Encrypt", i) != 0 ||
+          ltc_compare_testvector(tmp[1], 16, tests[i].pt, 16, "Twofish Decrypt", i) != 0) {
        return CRYPT_FAIL_TESTVECTOR;
     }
     /* now see if we can encrypt all zero bytes 1000 times, decrypt and come back where we started */

+ 2 - 2
src/ciphers/xtea.c

@@ -205,8 +205,8 @@ int xtea_test(void)
        xtea_ecb_encrypt(tests[i].pt, tmp[0], &skey);
        xtea_ecb_decrypt(tmp[0], tmp[1], &skey);
 
-       if (compare_testvector(tmp[0], 8, tests[i].ct, 8, "XTEA Encrypt", i) != 0 ||
-             compare_testvector(tmp[1], 8, tests[i].pt, 8, "XTEA Decrypt", i) != 0) {
+       if (ltc_compare_testvector(tmp[0], 8, tests[i].ct, 8, "XTEA Encrypt", i) != 0 ||
+             ltc_compare_testvector(tmp[1], 8, tests[i].pt, 8, "XTEA Decrypt", i) != 0) {
           return CRYPT_FAIL_TESTVECTOR;
        }
 

+ 5 - 5
src/encauth/ccm/ccm_test.c

@@ -168,10 +168,10 @@ int ccm_test(void)
             }
          }
 
-         if (compare_testvector(buf, tests[x].ptlen, tests[x].ct, tests[x].ptlen, "CCM encrypt data", x)) {
+         if (ltc_compare_testvector(buf, tests[x].ptlen, tests[x].ct, tests[x].ptlen, "CCM encrypt data", x)) {
             return CRYPT_FAIL_TESTVECTOR;
          }
-         if (compare_testvector(tag, taglen, tests[x].tag, tests[x].taglen, "CCM encrypt tag", x)) {
+         if (ltc_compare_testvector(tag, taglen, tests[x].tag, tests[x].taglen, "CCM encrypt tag", x)) {
             return CRYPT_FAIL_TESTVECTOR;
          }
 
@@ -207,7 +207,7 @@ int ccm_test(void)
          }
 
 
-         if (compare_testvector(buf2, tests[x].ptlen, tests[x].pt, tests[x].ptlen, "CCM decrypt data", x)) {
+         if (ltc_compare_testvector(buf2, tests[x].ptlen, tests[x].pt, tests[x].ptlen, "CCM decrypt data", x)) {
             return CRYPT_FAIL_TESTVECTOR;
          }
          if (y == 0) {
@@ -225,11 +225,11 @@ int ccm_test(void)
                            tag3, &taglen, 1   ) != CRYPT_ERROR) {
                return CRYPT_FAIL_TESTVECTOR;
             }
-            if (compare_testvector(buf2, tests[x].ptlen, zero, tests[x].ptlen, "CCM decrypt wrong tag", x)) {
+            if (ltc_compare_testvector(buf2, tests[x].ptlen, zero, tests[x].ptlen, "CCM decrypt wrong tag", x)) {
                return CRYPT_FAIL_TESTVECTOR;
             }
          } else {
-            if (compare_testvector(tag2, taglen, tests[x].tag, tests[x].taglen, "CCM decrypt tag", x)) {
+            if (ltc_compare_testvector(tag2, taglen, tests[x].tag, tests[x].taglen, "CCM decrypt tag", x)) {
                return CRYPT_FAIL_TESTVECTOR;
             }
          }

+ 14 - 14
src/encauth/chachapoly/chacha20poly1305_test.c

@@ -47,8 +47,8 @@ int chacha20poly1305_test(void)
    len = sizeof(emac);
    if ((err = chacha20poly1305_done(&st1, emac, &len)) != CRYPT_OK) return err;
 
-   if (compare_testvector(ct, mlen, enc, sizeof(enc), "ENC-CT", 1) != 0) return CRYPT_FAIL_TESTVECTOR;
-   if (compare_testvector(emac, len, tag, sizeof(tag), "ENC-TAG", 2) != 0) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(ct, mlen, enc, sizeof(enc), "ENC-CT", 1) != 0) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(emac, len, tag, sizeof(tag), "ENC-TAG", 2) != 0) return CRYPT_FAIL_TESTVECTOR;
 
    /* decrypt IV 96bit */
    if ((err = chacha20poly1305_init(&st2, k, sizeof(k))) != CRYPT_OK) return err;
@@ -59,22 +59,22 @@ int chacha20poly1305_test(void)
    len = sizeof(dmac);
    if ((err = chacha20poly1305_done(&st2, dmac, &len)) != CRYPT_OK) return err;
 
-   if (compare_testvector(pt, mlen, m, mlen, "DEC-PT", 3) != 0) return CRYPT_FAIL_TESTVECTOR;
-   if (compare_testvector(dmac, len, tag, sizeof(tag), "DEC-TAG", 4) != 0) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(pt, mlen, m, mlen, "DEC-PT", 3) != 0) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(dmac, len, tag, sizeof(tag), "DEC-TAG", 4) != 0) return CRYPT_FAIL_TESTVECTOR;
 
    /* chacha20poly1305_memory - encrypt */
    len = sizeof(emac);
    if ((err = chacha20poly1305_memory(k, sizeof(k), i12, sizeof(i12), aad, sizeof(aad), (unsigned char *)m,
                                       mlen, ct, emac, &len, CHACHA20POLY1305_ENCRYPT)) != CRYPT_OK) return err;
-   if (compare_testvector(ct, mlen, enc, sizeof(enc), "ENC-CT2", 1) != 0) return CRYPT_FAIL_TESTVECTOR;
-   if (compare_testvector(emac, len, tag, sizeof(tag), "ENC-TAG2", 2) != 0) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(ct, mlen, enc, sizeof(enc), "ENC-CT2", 1) != 0) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(emac, len, tag, sizeof(tag), "ENC-TAG2", 2) != 0) return CRYPT_FAIL_TESTVECTOR;
 
    /* chacha20poly1305_memory - decrypt */
    len = sizeof(dmac);
    XMEMCPY(dmac, tag, sizeof(tag));
    if ((err = chacha20poly1305_memory(k, sizeof(k), i12, sizeof(i12), aad, sizeof(aad),
                                       ct, mlen, pt, dmac, &len, CHACHA20POLY1305_DECRYPT)) != CRYPT_OK) return err;
-   if (compare_testvector(pt, mlen, m, mlen, "DEC-PT2", 3) != 0) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(pt, mlen, m, mlen, "DEC-PT2", 3) != 0) return CRYPT_FAIL_TESTVECTOR;
 
    /* encrypt - rfc7905 */
    if ((err = chacha20poly1305_init(&st1, k, sizeof(k))) != CRYPT_OK) return err;
@@ -84,8 +84,8 @@ int chacha20poly1305_test(void)
    len = sizeof(emac);
    if ((err = chacha20poly1305_done(&st1, emac, &len)) != CRYPT_OK) return err;
 
-   if (compare_testvector(ct, 16, rfc7905_enc, 16, "ENC-CT3", 1) != 0) return CRYPT_FAIL_TESTVECTOR;
-   if (compare_testvector(emac, len, rfc7905_tag, 16, "ENC-TAG3", 2) != 0) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(ct, 16, rfc7905_enc, 16, "ENC-CT3", 1) != 0) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(emac, len, rfc7905_tag, 16, "ENC-TAG3", 2) != 0) return CRYPT_FAIL_TESTVECTOR;
 
    /* decrypt - rfc7905 */
    if ((err = chacha20poly1305_init(&st1, k, sizeof(k))) != CRYPT_OK) return err;
@@ -95,8 +95,8 @@ int chacha20poly1305_test(void)
    len = sizeof(dmac);
    if ((err = chacha20poly1305_done(&st1, dmac, &len)) != CRYPT_OK) return err;
 
-   if (compare_testvector(pt, 16, rfc7905_pt, 16, "DEC-CT3", 1) != 0) return CRYPT_FAIL_TESTVECTOR;
-   if (compare_testvector(dmac, len, rfc7905_tag, 16, "DEC-TAG3", 2) != 0) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(pt, 16, rfc7905_pt, 16, "DEC-CT3", 1) != 0) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(dmac, len, rfc7905_tag, 16, "DEC-TAG3", 2) != 0) return CRYPT_FAIL_TESTVECTOR;
 
    /* encrypt IV 64bit */
    if ((err = chacha20poly1305_init(&st1, k, sizeof(k))) != CRYPT_OK) return err;
@@ -114,8 +114,8 @@ int chacha20poly1305_test(void)
    len = sizeof(dmac);
    if ((err = chacha20poly1305_done(&st2, dmac, &len)) != CRYPT_OK) return err;
 
-   if (compare_testvector(pt, mlen, m, mlen, "DEC-PT4", 1) != 0) return CRYPT_FAIL_TESTVECTOR;
-   if (compare_testvector(dmac, len, emac, len, "DEC-TAG4", 2) != 0) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(pt, mlen, m, mlen, "DEC-PT4", 1) != 0) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(dmac, len, emac, len, "DEC-TAG4", 2) != 0) return CRYPT_FAIL_TESTVECTOR;
 
    /* wycheproof failing test - https://github.com/libtom/libtomcrypt/pull/451 */
    {
@@ -135,7 +135,7 @@ int chacha20poly1305_test(void)
       err = chacha20poly1305_memory(key, sizeof(key), iv, sizeof(iv), waad, sizeof(waad),
                                     wpt, 0, wct, wtag, &taglen, CHACHA20POLY1305_ENCRYPT);
       if (err != CRYPT_OK) return CRYPT_FAIL_TESTVECTOR;
-      if (compare_testvector(wtag, taglen, valid_tag, sizeof(valid_tag), "WYCH", 1) != 0) return CRYPT_FAIL_TESTVECTOR;
+      if (ltc_compare_testvector(wtag, taglen, valid_tag, sizeof(valid_tag), "WYCH", 1) != 0) return CRYPT_FAIL_TESTVECTOR;
 
       /* VALID tag */
       taglen = sizeof(valid_tag);

+ 3 - 3
src/encauth/eax/eax_test.c

@@ -223,8 +223,8 @@ int eax_test(void)
             tests[x].plaintext, tests[x].msglen, outct, outtag, &len)) != CRYPT_OK) {
            return err;
         }
-        if (compare_testvector(outtag, len, tests[x].tag, len, "EAX Tag", x) ||
-              compare_testvector(outct, tests[x].msglen, tests[x].ciphertext, tests[x].msglen, "EAX CT", x)) {
+        if (ltc_compare_testvector(outtag, len, tests[x].tag, len, "EAX Tag", x) ||
+              ltc_compare_testvector(outct, tests[x].msglen, tests[x].ciphertext, tests[x].msglen, "EAX CT", x)) {
            return CRYPT_FAIL_TESTVECTOR;
         }
 
@@ -234,7 +234,7 @@ int eax_test(void)
              outct, tests[x].msglen, outct, outtag, len, &res)) != CRYPT_OK) {
             return err;
         }
-        if ((res != 1) || compare_testvector(outct, tests[x].msglen, tests[x].plaintext, tests[x].msglen, "EAX", x)) {
+        if ((res != 1) || ltc_compare_testvector(outct, tests[x].msglen, tests[x].plaintext, tests[x].msglen, "EAX", x)) {
 #ifdef LTC_TEST_DBG
            printf("\n\nEAX: Failure-decrypt - res = %d\n", res);
 #endif

+ 4 - 4
src/encauth/gcm/gcm_test.c

@@ -336,7 +336,7 @@ int gcm_test(void)
    if ((err = gcm_add_iv(&gcm, tests[0].IV, tests[0].IVlen)) != CRYPT_OK)    return err;
    /* intentionally skip gcm_add_aad + gcm_process */
    if ((err = gcm_done(&gcm, T[0], &y)) != CRYPT_OK)                         return err;
-   if (compare_testvector(T[0], y, tests[0].T, 16, "GCM Encrypt Tag-special", 0))      return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(T[0], y, tests[0].T, 16, "GCM Encrypt Tag-special", 0))      return CRYPT_FAIL_TESTVECTOR;
 
    for (x = 0; x < (int)LTC_ARRAY_SIZE(tests); x++) {
        y = sizeof(T[0]);
@@ -348,11 +348,11 @@ int gcm_test(void)
           return err;
        }
 
-       if (compare_testvector(out[0], tests[x].ptlen, tests[x].C, tests[x].ptlen, "GCM CT", x)) {
+       if (ltc_compare_testvector(out[0], tests[x].ptlen, tests[x].C, tests[x].ptlen, "GCM CT", x)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
 
-       if (compare_testvector(T[0], y, tests[x].T, 16, "GCM Encrypt Tag", x)) {
+       if (ltc_compare_testvector(T[0], y, tests[x].T, 16, "GCM Encrypt Tag", x)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
 
@@ -366,7 +366,7 @@ int gcm_test(void)
           return err;
        }
 
-       if (compare_testvector(out[1], tests[x].ptlen, tests[x].P, tests[x].ptlen, "GCM PT", x)) {
+       if (ltc_compare_testvector(out[1], tests[x].ptlen, tests[x].P, tests[x].ptlen, "GCM PT", x)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
    }

+ 3 - 3
src/encauth/ocb/ocb_test.c

@@ -174,8 +174,8 @@ int ocb_test(void)
            return err;
         }
 
-        if (compare_testvector(outtag, len, tests[x].tag, sizeof(tests[x].tag), "OCB Tag", x) ||
-              compare_testvector(outct, tests[x].ptlen, tests[x].ct, tests[x].ptlen, "OCB CT", x)) {
+        if (ltc_compare_testvector(outtag, len, tests[x].tag, sizeof(tests[x].tag), "OCB Tag", x) ||
+              ltc_compare_testvector(outct, tests[x].ptlen, tests[x].ct, tests[x].ptlen, "OCB CT", x)) {
            return CRYPT_FAIL_TESTVECTOR;
         }
 
@@ -183,7 +183,7 @@ int ocb_test(void)
              outct, tests[x].tag, len, &res)) != CRYPT_OK) {
            return err;
         }
-        if ((res != 1) || compare_testvector(outct, tests[x].ptlen, tests[x].pt, tests[x].ptlen, "OCB", x)) {
+        if ((res != 1) || ltc_compare_testvector(outct, tests[x].ptlen, tests[x].pt, tests[x].ptlen, "OCB", x)) {
 #ifdef LTC_TEST_DBG
            printf("\n\nOCB: Failure-decrypt - res = %d\n", res);
 #endif

+ 10 - 10
src/encauth/ocb3/ocb3_test.c

@@ -220,8 +220,8 @@ int ocb3_test(void)
            return err;
         }
 
-        if (compare_testvector(outtag, len, tests[x].tag, sizeof(tests[x].tag), "OCB3 Tag", x) ||
-              compare_testvector(outct, tests[x].ptlen, tests[x].ct, tests[x].ptlen, "OCB3 CT", x)) {
+        if (ltc_compare_testvector(outtag, len, tests[x].tag, sizeof(tests[x].tag), "OCB3 Tag", x) ||
+              ltc_compare_testvector(outct, tests[x].ptlen, tests[x].ct, tests[x].ptlen, "OCB3 CT", x)) {
            return CRYPT_FAIL_TESTVECTOR;
         }
 
@@ -233,7 +233,7 @@ int ocb3_test(void)
                                              tests[x].ptlen != 0 ? outct : NULL, tests[x].tag, len, &res)) != CRYPT_OK) {
            return err;
         }
-        if ((res != 1) || compare_testvector(outct, tests[x].ptlen, tests[x].pt, tests[x].ptlen, "OCB3", x)) {
+        if ((res != 1) || ltc_compare_testvector(outct, tests[x].ptlen, tests[x].pt, tests[x].ptlen, "OCB3", x)) {
 #ifdef LTC_TEST_DBG
            printf("\n\nOCB3: Failure-decrypt - res = %d\n", res);
 #endif
@@ -253,8 +253,8 @@ int ocb3_test(void)
        return err;
     }
 
-    if (compare_testvector(outtag, len, T, sizeof(T), "OCB3 Tag", x) ||
-          compare_testvector(outct, sizeof(P), C, sizeof(C), "OCB3 CT", x)) {
+    if (ltc_compare_testvector(outtag, len, T, sizeof(T), "OCB3 Tag", x) ||
+          ltc_compare_testvector(outct, sizeof(P), C, sizeof(C), "OCB3 CT", x)) {
        return CRYPT_FAIL_TESTVECTOR;
     }
 
@@ -266,7 +266,7 @@ int ocb3_test(void)
                                           outct, T, sizeof(T), &res)) != CRYPT_OK) {
        return err;
     }
-    if ((res != 1) || compare_testvector(outct, sizeof(C), P, sizeof(P), "OCB3", x)) {
+    if ((res != 1) || ltc_compare_testvector(outct, sizeof(C), P, sizeof(P), "OCB3", x)) {
 #ifdef LTC_TEST_DBG
        printf("\n\nOCB3: Failure-decrypt - res = %d\n", res);
 #endif
@@ -281,16 +281,16 @@ int ocb3_test(void)
     if ((err = ocb3_encrypt_last(&ocb, P+32, sizeof(P)-32, outct+32)) != CRYPT_OK) return err;
     len = sizeof(outtag); /* intentionally more than 12 */
     if ((err = ocb3_done(&ocb, outtag, &len)) != CRYPT_OK)                         return err;
-    if (compare_testvector(outct, sizeof(P), C, sizeof(C), "OCB3 CT", x))          return CRYPT_FAIL_TESTVECTOR;
-    if (compare_testvector(outtag, len, T, sizeof(T), "OCB3 Tag.enc", x))          return CRYPT_FAIL_TESTVECTOR;
+    if (ltc_compare_testvector(outct, sizeof(P), C, sizeof(C), "OCB3 CT", x))          return CRYPT_FAIL_TESTVECTOR;
+    if (ltc_compare_testvector(outtag, len, T, sizeof(T), "OCB3 Tag.enc", x))          return CRYPT_FAIL_TESTVECTOR;
     if ((err = ocb3_init(&ocb, idx, K, sizeof(K), N, sizeof(N), 12)) != CRYPT_OK)  return err;
     if ((err = ocb3_add_aad(&ocb, A, sizeof(A))) != CRYPT_OK)                      return err;
     if ((err = ocb3_decrypt(&ocb, C, 32, outct)) != CRYPT_OK)                      return err;
     if ((err = ocb3_decrypt_last(&ocb, C+32, sizeof(C)-32, outct+32)) != CRYPT_OK) return err;
     len = sizeof(outtag); /* intentionally more than 12 */
     if ((err = ocb3_done(&ocb, outtag, &len)) != CRYPT_OK)                         return err;
-    if (compare_testvector(outct, sizeof(C), P, sizeof(P), "OCB3 PT", x))          return CRYPT_FAIL_TESTVECTOR;
-    if (compare_testvector(outtag, len, T, sizeof(T), "OCB3 Tag.dec", x))          return CRYPT_FAIL_TESTVECTOR;
+    if (ltc_compare_testvector(outct, sizeof(C), P, sizeof(P), "OCB3 PT", x))          return CRYPT_FAIL_TESTVECTOR;
+    if (ltc_compare_testvector(outtag, len, T, sizeof(T), "OCB3 Tag.dec", x))          return CRYPT_FAIL_TESTVECTOR;
 
     return CRYPT_OK;
 #endif /* LTC_TEST */

+ 8 - 8
src/encauth/siv/siv.c

@@ -617,7 +617,7 @@ int siv_test(void)
                              buf, &buflen)) != CRYPT_OK) {
          return err;
       }
-      if (compare_testvector(buf, buflen, siv_tests[n].output, siv_tests[n].outputlen, siv_tests[n].name, n) != 0) {
+      if (ltc_compare_testvector(buf, buflen, siv_tests[n].output, siv_tests[n].outputlen, siv_tests[n].name, n) != 0) {
          return CRYPT_FAIL_TESTVECTOR;
       }
       buflen = sizeof(buf);
@@ -628,7 +628,7 @@ int siv_test(void)
                              buf, &buflen)) != CRYPT_OK) {
          return err;
       }
-      if (compare_testvector(buf, buflen, siv_tests[n].Plaintext, siv_tests[n].Plaintextlen, siv_tests[n].name, n + 0x1000) != 0) {
+      if (ltc_compare_testvector(buf, buflen, siv_tests[n].Plaintext, siv_tests[n].Plaintextlen, siv_tests[n].name, n + 0x1000) != 0) {
          return CRYPT_FAIL_TESTVECTOR;
       }
    }
@@ -643,7 +643,7 @@ int siv_test(void)
                          NULL)) != CRYPT_OK) {
       return err;
    }
-   if (compare_testvector(buf, buflen, siv_tests[0].output, siv_tests[0].outputlen, siv_tests[0].name, n) != 0) {
+   if (ltc_compare_testvector(buf, buflen, siv_tests[0].output, siv_tests[0].outputlen, siv_tests[0].name, n) != 0) {
       return CRYPT_FAIL_TESTVECTOR;
    }
    /* Testcase 0x1002 */
@@ -656,7 +656,7 @@ int siv_test(void)
                          NULL)) != CRYPT_OK) {
       return err;
    }
-   if (compare_testvector(buf, buflen, siv_tests[0].Plaintext, siv_tests[0].Plaintextlen, siv_tests[0].name, n + 0x1000) != 0) {
+   if (ltc_compare_testvector(buf, buflen, siv_tests[0].Plaintext, siv_tests[0].Plaintextlen, siv_tests[0].name, n + 0x1000) != 0) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -674,7 +674,7 @@ int siv_test(void)
                          NULL)) != CRYPT_OK) {
       return err;
    }
-   if (compare_testvector(buf, buflen, siv_tests[1].output, siv_tests[1].outputlen, siv_tests[1].name, n) != 0) {
+   if (ltc_compare_testvector(buf, buflen, siv_tests[1].output, siv_tests[1].outputlen, siv_tests[1].name, n) != 0) {
       return CRYPT_FAIL_TESTVECTOR;
    }
    /* Testcase 0x1003 */
@@ -689,7 +689,7 @@ int siv_test(void)
                          NULL)) != CRYPT_OK) {
       return err;
    }
-   if (compare_testvector(buf, buflen, siv_tests[1].Plaintext, siv_tests[1].Plaintextlen, siv_tests[1].name, n + 0x1000) != 0) {
+   if (ltc_compare_testvector(buf, buflen, siv_tests[1].Plaintext, siv_tests[1].Plaintextlen, siv_tests[1].name, n + 0x1000) != 0) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -714,7 +714,7 @@ int siv_test(void)
       }
       tmplen = buflen;
    }
-   if (compare_testvector(&buflen, sizeof(buflen), &tmpmax, sizeof(tmpmax), "Multiple encrypt length", -(int)niter)) {
+   if (ltc_compare_testvector(&buflen, sizeof(buflen), &tmpmax, sizeof(tmpmax), "Multiple encrypt length", -(int)niter)) {
       err = CRYPT_FAIL_TESTVECTOR;
       goto out;
    }
@@ -730,7 +730,7 @@ int siv_test(void)
       }
       tmplen = buflen;
    }
-   if (compare_testvector(tmpd, tmplen, tmpe, tmplen, "Multi decrypt", niter + 0x2000)) {
+   if (ltc_compare_testvector(tmpd, tmplen, tmpe, tmplen, "Multi decrypt", niter + 0x2000)) {
       err = CRYPT_FAIL_TESTVECTOR;
    }
 

+ 4 - 4
src/hashes/blake2b.c

@@ -476,7 +476,7 @@ int blake2b_512_test(void)
       blake2b_512_init(&md);
       blake2b_process(&md, (unsigned char *)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       blake2b_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_512", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_512", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
    }
@@ -523,7 +523,7 @@ int blake2b_384_test(void)
       blake2b_384_init(&md);
       blake2b_process(&md, (unsigned char *)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       blake2b_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_384", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_384", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
    }
@@ -576,7 +576,7 @@ int blake2b_256_test(void)
       blake2b_256_init(&md);
       blake2b_process(&md, (unsigned char *)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       blake2b_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_256", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_256", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
    }
@@ -617,7 +617,7 @@ int blake2b_160_test(void)
       blake2b_160_init(&md);
       blake2b_process(&md, (unsigned char *)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       blake2b_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_160", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2B_160", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
    }

+ 4 - 4
src/hashes/blake2s.c

@@ -466,7 +466,7 @@ int blake2s_256_test(void)
       blake2s_256_init(&md);
       blake2s_process(&md, (unsigned char *)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       blake2s_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_256", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_256", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
 
@@ -510,7 +510,7 @@ int blake2s_224_test(void)
       blake2s_224_init(&md);
       blake2s_process(&md, (unsigned char *)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       blake2s_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_224", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_224", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
 
@@ -552,7 +552,7 @@ int blake2s_160_test(void)
       blake2s_160_init(&md);
       blake2s_process(&md, (unsigned char *)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       blake2s_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_160", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_160", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
 
@@ -592,7 +592,7 @@ int blake2s_128_test(void)
       blake2s_128_init(&md);
       blake2s_process(&md, (unsigned char *)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       blake2s_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_128", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "BLAKE2S_128", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
    }

+ 1 - 1
src/hashes/chc/chc.c

@@ -287,7 +287,7 @@ int chc_test(void)
        if ((err = chc_done(&md, tmp)) != CRYPT_OK) {
           return err;
        }
-       if (compare_testvector(tmp, tests[i].len, tests[i].hash, tests[i].len, "CHC", i)) {
+       if (ltc_compare_testvector(tmp, tests[i].len, tests[i].hash, tests[i].len, "CHC", i)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
    }

+ 1 - 1
src/hashes/md2.c

@@ -228,7 +228,7 @@ int md2_test(void)
        md2_init(&md);
        md2_process(&md, (unsigned char*)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
        md2_done(&md, tmp);
-       if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "MD2", i)) {
+       if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "MD2", i)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
    }

+ 1 - 1
src/hashes/md4.c

@@ -282,7 +282,7 @@ int md4_test(void)
         md4_init(&md);
         md4_process(&md, (unsigned char *)tests[i].input, (unsigned long)XSTRLEN(tests[i].input));
         md4_done(&md, tmp);
-        if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "MD4", i)) {
+        if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "MD4", i)) {
            return CRYPT_FAIL_TESTVECTOR;
         }
 

+ 1 - 1
src/hashes/md5.c

@@ -343,7 +343,7 @@ int  md5_test(void)
       md5_init(&md);
       md5_process(&md, (unsigned char *)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       md5_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "MD5", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "MD5", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
   }

+ 1 - 1
src/hashes/rmd128.c

@@ -384,7 +384,7 @@ int rmd128_test(void)
        rmd128_init(&md);
        rmd128_process(&md, (unsigned char *)tests[i].msg, XSTRLEN(tests[i].msg));
        rmd128_done(&md, tmp);
-       if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD128", i)) {
+       if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD128", i)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
    }

+ 1 - 1
src/hashes/rmd160.c

@@ -443,7 +443,7 @@ int rmd160_test(void)
        rmd160_init(&md);
        rmd160_process(&md, (unsigned char *)tests[i].msg, XSTRLEN(tests[i].msg));
        rmd160_done(&md, tmp);
-       if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD160", i)) {
+       if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD160", i)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
    }

+ 1 - 1
src/hashes/rmd256.c

@@ -409,7 +409,7 @@ int rmd256_test(void)
        rmd256_init(&md);
        rmd256_process(&md, (unsigned char *)tests[i].msg, XSTRLEN(tests[i].msg));
        rmd256_done(&md, tmp);
-       if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD256", i)) {
+       if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD256", i)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
    }

+ 1 - 1
src/hashes/rmd320.c

@@ -474,7 +474,7 @@ int rmd320_test(void)
        rmd320_init(&md);
        rmd320_process(&md, (unsigned char *)tests[i].msg, XSTRLEN(tests[i].msg));
        rmd320_done(&md, tmp);
-       if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD320", i)) {
+       if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "RIPEMD320", i)) {
           return CRYPT_FAIL_TESTVECTOR;
        }
    }

+ 1 - 1
src/hashes/sha1.c

@@ -263,7 +263,7 @@ int  sha1_test(void)
       sha1_init(&md);
       sha1_process(&md, (unsigned char*)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       sha1_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA1", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA1", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
   }

+ 1 - 1
src/hashes/sha2/sha224.c

@@ -107,7 +107,7 @@ int  sha224_test(void)
       sha224_init(&md);
       sha224_process(&md, (unsigned char*)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       sha224_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA224", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA224", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
   }

+ 1 - 1
src/hashes/sha2/sha256.c

@@ -309,7 +309,7 @@ int  sha256_test(void)
       sha256_init(&md);
       sha256_process(&md, (unsigned char*)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       sha256_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA256", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA256", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
   }

+ 1 - 1
src/hashes/sha2/sha384.c

@@ -113,7 +113,7 @@ int  sha384_test(void)
       sha384_init(&md);
       sha384_process(&md, (unsigned char*)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       sha384_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA384", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA384", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
   }

+ 1 - 1
src/hashes/sha2/sha512.c

@@ -289,7 +289,7 @@ int  sha512_test(void)
       sha512_init(&md);
       sha512_process(&md, (unsigned char *)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       sha512_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA512", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA512", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
   }

+ 1 - 1
src/hashes/sha2/sha512_224.c

@@ -109,7 +109,7 @@ int  sha512_224_test(void)
       sha512_224_init(&md);
       sha512_224_process(&md, (unsigned char*)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       sha512_224_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA512-224", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA512-224", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
   }

+ 1 - 1
src/hashes/sha2/sha512_256.c

@@ -109,7 +109,7 @@ int  sha512_256_test(void)
       sha512_256_init(&md);
       sha512_256_process(&md, (unsigned char*)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       sha512_256_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA512-265", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA512-265", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
   }

+ 40 - 40
src/hashes/sha3_test.c

@@ -36,7 +36,7 @@ int sha3_224_test(void)
    /* SHA3-224 on an empty buffer */
    sha3_224_init(&c);
    sha3_done(&c, hash);
-   if (compare_testvector(hash, sizeof(hash), sha3_224_empty, sizeof(sha3_224_empty), "SHA3-224", 0)) {
+   if (ltc_compare_testvector(hash, sizeof(hash), sha3_224_empty, sizeof(sha3_224_empty), "SHA3-224", 0)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -45,7 +45,7 @@ int sha3_224_test(void)
    sha3_process(&c, buf, sizeof(buf) / 2);
    sha3_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
    sha3_done(&c, hash);
-   if (compare_testvector(hash, sizeof(hash), sha3_224_0xa3_200_times, sizeof(sha3_224_0xa3_200_times), "SHA3-224", 1)) {
+   if (ltc_compare_testvector(hash, sizeof(hash), sha3_224_0xa3_200_times, sizeof(sha3_224_0xa3_200_times), "SHA3-224", 1)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -56,7 +56,7 @@ int sha3_224_test(void)
        sha3_process(&c, &c1, 1);
    }
    sha3_done(&c, hash);
-   if (compare_testvector(hash, sizeof(hash), sha3_224_0xa3_200_times, sizeof(sha3_224_0xa3_200_times), "SHA3-224", 2)) {
+   if (ltc_compare_testvector(hash, sizeof(hash), sha3_224_0xa3_200_times, sizeof(sha3_224_0xa3_200_times), "SHA3-224", 2)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -92,7 +92,7 @@ int sha3_256_test(void)
    /* SHA3-256 on an empty buffer */
    sha3_256_init(&c);
    sha3_done(&c, hash);
-   if (compare_testvector(hash, sizeof(hash), sha3_256_empty, sizeof(sha3_256_empty), "SHA3-256", 0)) {
+   if (ltc_compare_testvector(hash, sizeof(hash), sha3_256_empty, sizeof(sha3_256_empty), "SHA3-256", 0)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -100,7 +100,7 @@ int sha3_256_test(void)
    sha3_256_init(&c);
    sha3_process(&c, buf, sizeof(buf));
    sha3_done(&c, hash);
-   if (compare_testvector(hash, sizeof(hash), sha3_256_0xa3_200_times, sizeof(sha3_256_0xa3_200_times), "SHA3-256", 1)) {
+   if (ltc_compare_testvector(hash, sizeof(hash), sha3_256_0xa3_200_times, sizeof(sha3_256_0xa3_200_times), "SHA3-256", 1)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -109,7 +109,7 @@ int sha3_256_test(void)
    sha3_process(&c, buf, sizeof(buf) / 2);
    sha3_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
    sha3_done(&c, hash);
-   if (compare_testvector(hash, sizeof(hash), sha3_256_0xa3_200_times, sizeof(sha3_256_0xa3_200_times), "SHA3-256", 2)) {
+   if (ltc_compare_testvector(hash, sizeof(hash), sha3_256_0xa3_200_times, sizeof(sha3_256_0xa3_200_times), "SHA3-256", 2)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -120,7 +120,7 @@ int sha3_256_test(void)
        sha3_process(&c, &c1, 1);
    }
    sha3_done(&c, hash);
-   if (compare_testvector(hash, sizeof(hash), sha3_256_0xa3_200_times, sizeof(sha3_256_0xa3_200_times), "SHA3-256", 3)) {
+   if (ltc_compare_testvector(hash, sizeof(hash), sha3_256_0xa3_200_times, sizeof(sha3_256_0xa3_200_times), "SHA3-256", 3)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -146,7 +146,7 @@ int sha3_256_test(void)
            "\x76\x3d\x52\xdb\x98\xd9\x49\xd3"
            "\xb0\xfe\xd6\xa8\x05\x2f\xbb", 1080 / 8);
    sha3_done(&c, hash);
-   if(compare_testvector(hash, sizeof(hash),
+   if(ltc_compare_testvector(hash, sizeof(hash),
            "\xa1\x9e\xee\x92\xbb\x20\x97\xb6"
            "\x4e\x82\x3d\x59\x77\x98\xaa\x18"
            "\xbe\x9b\x7c\x73\x6b\x80\x59\xab"
@@ -183,7 +183,7 @@ int sha3_384_test(void)
    sha3_384_init(&c);
    sha3_process(&c, buf, sizeof(buf));
    sha3_done(&c, hash);
-   if (compare_testvector(hash, sizeof(hash), sha3_384_0xa3_200_times, sizeof(sha3_384_0xa3_200_times), "SHA3-384", 0)) {
+   if (ltc_compare_testvector(hash, sizeof(hash), sha3_384_0xa3_200_times, sizeof(sha3_384_0xa3_200_times), "SHA3-384", 0)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -192,7 +192,7 @@ int sha3_384_test(void)
    sha3_process(&c, buf, sizeof(buf) / 2);
    sha3_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
    sha3_done(&c, hash);
-   if (compare_testvector(hash, sizeof(hash), sha3_384_0xa3_200_times, sizeof(sha3_384_0xa3_200_times), "SHA3-384", 1)) {
+   if (ltc_compare_testvector(hash, sizeof(hash), sha3_384_0xa3_200_times, sizeof(sha3_384_0xa3_200_times), "SHA3-384", 1)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -203,7 +203,7 @@ int sha3_384_test(void)
        sha3_process(&c, &c1, 1);
    }
    sha3_done(&c, hash);
-   if (compare_testvector(hash, sizeof(hash), sha3_384_0xa3_200_times, sizeof(sha3_384_0xa3_200_times), "SHA3-384", 2)) {
+   if (ltc_compare_testvector(hash, sizeof(hash), sha3_384_0xa3_200_times, sizeof(sha3_384_0xa3_200_times), "SHA3-384", 2)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -238,7 +238,7 @@ int sha3_512_test(void)
    sha3_512_init(&c);
    sha3_process(&c, buf, sizeof(buf));
    sha3_done(&c, hash);
-   if (compare_testvector(hash, sizeof(hash), sha3_512_0xa3_200_times, sizeof(sha3_512_0xa3_200_times), "SHA3-512", 0)) {
+   if (ltc_compare_testvector(hash, sizeof(hash), sha3_512_0xa3_200_times, sizeof(sha3_512_0xa3_200_times), "SHA3-512", 0)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -247,7 +247,7 @@ int sha3_512_test(void)
    sha3_process(&c, buf, sizeof(buf) / 2);
    sha3_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
    sha3_done(&c, hash);
-   if (compare_testvector(hash, sizeof(hash), sha3_512_0xa3_200_times, sizeof(sha3_512_0xa3_200_times), "SHA3-512", 1)) {
+   if (ltc_compare_testvector(hash, sizeof(hash), sha3_512_0xa3_200_times, sizeof(sha3_512_0xa3_200_times), "SHA3-512", 1)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -258,7 +258,7 @@ int sha3_512_test(void)
        sha3_process(&c, &c1, 1);
    }
    sha3_done(&c, hash);
-   if (compare_testvector(hash, sizeof(hash), sha3_512_0xa3_200_times, sizeof(sha3_512_0xa3_200_times), "SHA3-512", 2)) {
+   if (ltc_compare_testvector(hash, sizeof(hash), sha3_512_0xa3_200_times, sizeof(sha3_512_0xa3_200_times), "SHA3-512", 2)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -307,14 +307,14 @@ int sha3_shake_test(void)
    /* SHAKE256 on an empty buffer */
    sha3_shake_init(&c, 256);
    for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
-   if (compare_testvector(hash, sizeof(shake256_empty), shake256_empty, sizeof(shake256_empty), "SHAKE256", 0)) {
+   if (ltc_compare_testvector(hash, sizeof(shake256_empty), shake256_empty, sizeof(shake256_empty), "SHAKE256", 0)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
    /* SHAKE256 via sha3_shake_memory [FIPS 202] */
    len = 512;
    sha3_shake_memory(256, buf, sizeof(buf), hash, &len);
-   if (compare_testvector(hash + 480, sizeof(shake256_0xa3_200_times), shake256_0xa3_200_times, sizeof(shake256_0xa3_200_times), "SHAKE256", 1)) {
+   if (ltc_compare_testvector(hash + 480, sizeof(shake256_0xa3_200_times), shake256_0xa3_200_times, sizeof(shake256_0xa3_200_times), "SHAKE256", 1)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -322,7 +322,7 @@ int sha3_shake_test(void)
    sha3_shake_init(&c, 256);
    sha3_shake_process(&c, buf, sizeof(buf));
    for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
-   if (compare_testvector(hash, sizeof(shake256_0xa3_200_times), shake256_0xa3_200_times, sizeof(shake256_0xa3_200_times), "SHAKE256", 2)) {
+   if (ltc_compare_testvector(hash, sizeof(shake256_0xa3_200_times), shake256_0xa3_200_times, sizeof(shake256_0xa3_200_times), "SHAKE256", 2)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -331,7 +331,7 @@ int sha3_shake_test(void)
    sha3_shake_process(&c, buf, sizeof(buf) / 2);
    sha3_shake_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
    for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
-   if (compare_testvector(hash, sizeof(shake256_0xa3_200_times), shake256_0xa3_200_times, sizeof(shake256_0xa3_200_times), "SHAKE256", 3)) {
+   if (ltc_compare_testvector(hash, sizeof(shake256_0xa3_200_times), shake256_0xa3_200_times, sizeof(shake256_0xa3_200_times), "SHAKE256", 3)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -340,21 +340,21 @@ int sha3_shake_test(void)
    sha3_shake_init(&c, 256);
    while (i--) sha3_shake_process(&c, &c1, 1);
    for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
-   if (compare_testvector(hash, sizeof(shake256_0xa3_200_times), shake256_0xa3_200_times, sizeof(shake256_0xa3_200_times), "SHAKE256", 4)) {
+   if (ltc_compare_testvector(hash, sizeof(shake256_0xa3_200_times), shake256_0xa3_200_times, sizeof(shake256_0xa3_200_times), "SHAKE256", 4)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
    /* SHAKE128 on an empty buffer */
    sha3_shake_init(&c, 128);
    for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
-   if (compare_testvector(hash, sizeof(shake128_empty), shake128_empty, sizeof(shake128_empty), "SHAKE128", 0)) {
+   if (ltc_compare_testvector(hash, sizeof(shake128_empty), shake128_empty, sizeof(shake128_empty), "SHAKE128", 0)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
    /* SHAKE128 via sha3_shake_memory [FIPS 202] */
    len = 512;
    sha3_shake_memory(128, buf, sizeof(buf), hash, &len);
-   if (compare_testvector(hash + 480, sizeof(shake128_0xa3_200_times), shake128_0xa3_200_times, sizeof(shake128_0xa3_200_times), "SHAKE128", 1)) {
+   if (ltc_compare_testvector(hash + 480, sizeof(shake128_0xa3_200_times), shake128_0xa3_200_times, sizeof(shake128_0xa3_200_times), "SHAKE128", 1)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -362,7 +362,7 @@ int sha3_shake_test(void)
    sha3_shake_init(&c, 128);
    sha3_shake_process(&c, buf, sizeof(buf));
    for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
-   if (compare_testvector(hash, sizeof(shake128_0xa3_200_times), shake128_0xa3_200_times, sizeof(shake128_0xa3_200_times), "SHAKE128", 2)) {
+   if (ltc_compare_testvector(hash, sizeof(shake128_0xa3_200_times), shake128_0xa3_200_times, sizeof(shake128_0xa3_200_times), "SHAKE128", 2)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -371,7 +371,7 @@ int sha3_shake_test(void)
    sha3_shake_process(&c, buf, sizeof(buf) / 2);
    sha3_shake_process(&c, buf + sizeof(buf) / 2, sizeof(buf) / 2);
    for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
-   if (compare_testvector(hash, sizeof(shake128_0xa3_200_times), shake128_0xa3_200_times, sizeof(shake128_0xa3_200_times), "SHAKE128", 3)) {
+   if (ltc_compare_testvector(hash, sizeof(shake128_0xa3_200_times), shake128_0xa3_200_times, sizeof(shake128_0xa3_200_times), "SHAKE128", 3)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -380,7 +380,7 @@ int sha3_shake_test(void)
    sha3_shake_init(&c, 128);
    while (i--) sha3_shake_process(&c, &c1, 1);
    for (i = 0; i < 16; i++) sha3_shake_done(&c, hash, 32); /* get 512 bytes, keep in hash the last 32 */
-   if (compare_testvector(hash, sizeof(shake128_0xa3_200_times), shake128_0xa3_200_times, sizeof(shake128_0xa3_200_times), "SHAKE128", 4)) {
+   if (ltc_compare_testvector(hash, sizeof(shake128_0xa3_200_times), shake128_0xa3_200_times, sizeof(shake128_0xa3_200_times), "SHAKE128", 4)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
@@ -403,7 +403,7 @@ int keccak_224_test(void)
    keccak_224_init(&c);
    keccak_process(&c, (unsigned char*) "\xcc", 1);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 28,
+   if(ltc_compare_testvector(hash, 28,
                          "\xa9\xca\xb5\x9e\xb4\x0a\x10\xb2"
                          "\x46\x29\x0f\x2d\x60\x86\xe3\x2e"
                          "\x36\x89\xfa\xf1\xd2\x6b\x47\x0c"
@@ -415,7 +415,7 @@ int keccak_224_test(void)
    keccak_224_init(&c);
    keccak_process(&c, (unsigned char*)"\x41\xfb", 2);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 28,
+   if(ltc_compare_testvector(hash, 28,
                          "\x61\x5b\xa3\x67\xaf\xdc\x35\xaa"
                          "\xc3\x97\xbc\x7e\xb5\xd5\x8d\x10"
                          "\x6a\x73\x4b\x24\x98\x6d\x5d\x97"
@@ -429,7 +429,7 @@ int keccak_224_test(void)
                     "\x52\xa6\x08\xab\x21\xcc\xdd\x8a"
                     "\x44\x57\xa5\x7e\xde\x78\x21\x76", 16);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 28,
+   if(ltc_compare_testvector(hash, 28,
                          "\x56\x79\xcd\x50\x9c\x51\x20\xaf"
                          "\x54\x79\x5c\xf4\x77\x14\x96\x41"
                          "\xcf\x27\xb2\xeb\xb6\xa5\xf9\x03"
@@ -454,7 +454,7 @@ int keccak_224_test(void)
                     "\x4a\x3f\x9d\x9e\x53\xe7\xe0\x84"
                     "\x6d\xcb\xb4\xce", 100);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 28,
+   if(ltc_compare_testvector(hash, 28,
                          "\x62\xb1\x0f\x1b\x62\x36\xeb\xc2"
                          "\xda\x72\x95\x77\x42\xa8\xd4\xe4"
                          "\x8e\x21\x3b\x5f\x89\x34\x60\x4b"
@@ -478,7 +478,7 @@ int keccak_256_test(void)
    keccak_256_init(&c);
    keccak_process(&c, (unsigned char*) "\xcc", 1);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 32,
+   if(ltc_compare_testvector(hash, 32,
                          "\xee\xad\x6d\xbf\xc7\x34\x0a\x56"
                          "\xca\xed\xc0\x44\x69\x6a\x16\x88"
                          "\x70\x54\x9a\x6a\x7f\x6f\x56\x96"
@@ -490,7 +490,7 @@ int keccak_256_test(void)
    keccak_256_init(&c);
    keccak_process(&c, (unsigned char*)"\x41\xfb", 2);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 32,
+   if(ltc_compare_testvector(hash, 32,
                          "\xa8\xea\xce\xda\x4d\x47\xb3\x28"
                          "\x1a\x79\x5a\xd9\xe1\xea\x21\x22"
                          "\xb4\x07\xba\xf9\xaa\xbc\xb9\xe1"
@@ -504,7 +504,7 @@ int keccak_256_test(void)
                     "\x52\xa6\x08\xab\x21\xcc\xdd\x8a"
                     "\x44\x57\xa5\x7e\xde\x78\x21\x76", 16);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 32,
+   if(ltc_compare_testvector(hash, 32,
                          "\x0e\x32\xde\xfa\x20\x71\xf0\xb5"
                          "\xac\x0e\x6a\x10\x8b\x84\x2e\xd0"
                          "\xf1\xd3\x24\x97\x12\xf5\x8e\xe0"
@@ -529,7 +529,7 @@ int keccak_256_test(void)
                     "\x4a\x3f\x9d\x9e\x53\xe7\xe0\x84"
                     "\x6d\xcb\xb4\xce", 100);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 32,
+   if(ltc_compare_testvector(hash, 32,
                          "\xce\x87\xa5\x17\x3b\xff\xd9\x23"
                          "\x99\x22\x16\x58\xf8\x01\xd4\x5c"
                          "\x29\x4d\x90\x06\xee\x9f\x3f\x9d"
@@ -553,7 +553,7 @@ int keccak_384_test(void)
    keccak_384_init(&c);
    keccak_process(&c, (unsigned char*) "\xcc", 1);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 48,
+   if(ltc_compare_testvector(hash, 48,
                          "\x1b\x84\xe6\x2a\x46\xe5\xa2\x01"
                          "\x86\x17\x54\xaf\x5d\xc9\x5c\x4a"
                          "\x1a\x69\xca\xf4\xa7\x96\xae\x40"
@@ -567,7 +567,7 @@ int keccak_384_test(void)
    keccak_384_init(&c);
    keccak_process(&c, (unsigned char*)"\x41\xfb", 2);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 48,
+   if(ltc_compare_testvector(hash, 48,
                          "\x49\x5c\xce\x27\x14\xcd\x72\xc8"
                          "\xc5\x3c\x33\x63\xd2\x2c\x58\xb5"
                          "\x59\x60\xfe\x26\xbe\x0b\xf3\xbb"
@@ -583,7 +583,7 @@ int keccak_384_test(void)
                     "\x52\xa6\x08\xab\x21\xcc\xdd\x8a"
                     "\x44\x57\xa5\x7e\xde\x78\x21\x76", 16);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 48,
+   if(ltc_compare_testvector(hash, 48,
                          "\x18\x42\x2a\xc1\xd3\xa1\xe5\x4b"
                          "\xad\x87\x68\x83\xd2\xd6\xdd\x65"
                          "\xf6\x5c\x1d\x5f\x33\xa7\x12\x5c"
@@ -610,7 +610,7 @@ int keccak_384_test(void)
                     "\x4a\x3f\x9d\x9e\x53\xe7\xe0\x84"
                     "\x6d\xcb\xb4\xce", 100);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 48,
+   if(ltc_compare_testvector(hash, 48,
                          "\x13\x51\x14\x50\x8d\xd6\x3e\x27"
                          "\x9e\x70\x9c\x26\xf7\x81\x7c\x04"
                          "\x82\x76\x6c\xde\x49\x13\x2e\x3e"
@@ -636,7 +636,7 @@ int keccak_512_test(void)
    keccak_512_init(&c);
    keccak_process(&c, (unsigned char*) "\xcc", 1);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 64,
+   if(ltc_compare_testvector(hash, 64,
                          "\x86\x30\xc1\x3c\xbd\x06\x6e\xa7"
                          "\x4b\xbe\x7f\xe4\x68\xfe\xc1\xde"
                          "\xe1\x0e\xdc\x12\x54\xfb\x4c\x1b"
@@ -652,7 +652,7 @@ int keccak_512_test(void)
    keccak_512_init(&c);
    keccak_process(&c, (unsigned char*)"\x41\xfb", 2);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 64,
+   if(ltc_compare_testvector(hash, 64,
                          "\x55\x1d\xa6\x23\x6f\x8b\x96\xfc"
                          "\xe9\xf9\x7f\x11\x90\xe9\x01\x32"
                          "\x4f\x0b\x45\xe0\x6d\xbb\xb5\xcd"
@@ -670,7 +670,7 @@ int keccak_512_test(void)
                     "\x52\xa6\x08\xab\x21\xcc\xdd\x8a"
                     "\x44\x57\xa5\x7e\xde\x78\x21\x76", 16);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 64,
+   if(ltc_compare_testvector(hash, 64,
                          "\x4b\x39\xd3\xda\x5b\xcd\xf4\xd9"
                          "\xb7\x69\x01\x59\x95\x64\x43\x11"
                          "\xc1\x4c\x43\x5b\xf7\x2b\x10\x09"
@@ -699,7 +699,7 @@ int keccak_512_test(void)
                     "\x4a\x3f\x9d\x9e\x53\xe7\xe0\x84"
                     "\x6d\xcb\xb4\xce", 100);
    keccak_done(&c, hash);
-   if(compare_testvector(hash, 64,
+   if(ltc_compare_testvector(hash, 64,
                          "\x52\x7d\x28\xe3\x41\xe6\xb1\x4f"
                          "\x46\x84\xad\xb4\xb8\x24\xc4\x96"
                          "\xc6\x48\x2e\x51\x14\x95\x65\xd3"

+ 1 - 1
src/hashes/tiger.c

@@ -862,7 +862,7 @@ static int s_tiger_test(unsigned int idx)
       init[idx](&md);
       tiger_process(&md, (unsigned char *)tests[i].msg, (unsigned long)XSTRLEN(tests[i].msg));
       tiger_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash[idx], sizeof(tests[i].hash[idx]), !idx ? "TIGER": "TIGER2", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash[idx], sizeof(tests[i].hash[idx]), !idx ? "TIGER": "TIGER2", i)) {
           return CRYPT_FAIL_TESTVECTOR;
       }
   }

+ 1 - 1
src/hashes/whirl/whirl.c

@@ -285,7 +285,7 @@ int  whirlpool_test(void)
       whirlpool_init(&md);
       whirlpool_process(&md, (unsigned char *)tests[i].msg, tests[i].len);
       whirlpool_done(&md, tmp);
-      if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "WHIRLPOOL", i)) {
+      if (ltc_compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "WHIRLPOOL", i)) {
          return CRYPT_FAIL_TESTVECTOR;
       }
   }

+ 1 - 0
src/headers/tomcrypt_misc.h

@@ -201,4 +201,5 @@ int ssh_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...) LT
 int ssh_decode_sequence_multi(const unsigned char *in, unsigned long *inlen, ...) LTC_NULL_TERMINATED;
 #endif /* LTC_SSH */
 
+LTC_DEPRECATED(nothing. API will be internal)
 int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which);

+ 11 - 0
src/headers/tomcrypt_private.h

@@ -393,6 +393,17 @@ struct get_char {
 void copy_or_zeromem(const unsigned char* src, unsigned char* dest, unsigned long len, int coz);
 void password_free(struct password *pw, const struct password_ctx *ctx);
 
+int ltc_compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which);
+int ltc_do_compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which);
+
+#define LTC_COMPARE_TESTVECTOR(i, il, s, sl, wa, wi)                                   \
+   do {                                                                                \
+      int LTC_TMPVAR(ret) = do_compare_testvector((i), (il), (s), (sl), (wa), (wi));   \
+      if (LTC_TMPVAR(ret) != CRYPT_OK) {                                               \
+         return LTC_TMPVAR(ret);                                                       \
+      }                                                                                \
+   } while(0)
+
 #if defined(LTC_PBES)
 int pbes_decrypt(const pbes_arg  *arg, unsigned char *dec_data, unsigned long *dec_size);
 

+ 2 - 2
src/mac/blake2/blake2bmac_test.c

@@ -289,13 +289,13 @@ int blake2bmac_test(void)
         blake2bmac_process(&st, (unsigned char*)inp + 14, 1);
         blake2bmac_process(&st, (unsigned char*)inp + 15, ilen - 15);
         blake2bmac_done(&st, out, &olen);
-        if (compare_testvector(out, olen, mac, mlen, "BLAKE2B MAC multi", ilen) != 0) return CRYPT_FAIL_TESTVECTOR;
+        if (ltc_compare_testvector(out, olen, mac, mlen, "BLAKE2B MAC multi", ilen) != 0) return CRYPT_FAIL_TESTVECTOR;
       }
       /* process in one go */
       blake2bmac_init(&st, olen, key, klen);
       blake2bmac_process(&st, (unsigned char*)inp, ilen);
       blake2bmac_done(&st, out, &olen);
-      if (compare_testvector(out, olen, mac, mlen, "BLAKE2B MAC single", ilen) != 0) return CRYPT_FAIL_TESTVECTOR;
+      if (ltc_compare_testvector(out, olen, mac, mlen, "BLAKE2B MAC single", ilen) != 0) return CRYPT_FAIL_TESTVECTOR;
    }
    return CRYPT_OK;
 #endif

+ 2 - 2
src/mac/blake2/blake2smac_test.c

@@ -289,13 +289,13 @@ int blake2smac_test(void)
         blake2smac_process(&st, (unsigned char*)inp + 14, 1);
         blake2smac_process(&st, (unsigned char*)inp + 15, ilen - 15);
         blake2smac_done(&st, out, &olen);
-        if (compare_testvector(out, olen, mac, mlen, "BLAKE2S MAC multi", ilen) != 0) return CRYPT_FAIL_TESTVECTOR;
+        if (ltc_compare_testvector(out, olen, mac, mlen, "BLAKE2S MAC multi", ilen) != 0) return CRYPT_FAIL_TESTVECTOR;
       }
       /* process in one go */
       blake2smac_init(&st, olen, key, klen);
       blake2smac_process(&st, (unsigned char*)inp, ilen);
       blake2smac_done(&st, out, &olen);
-      if (compare_testvector(out, olen, mac, mlen, "BLAKE2S MAC single", ilen) != 0) return CRYPT_FAIL_TESTVECTOR;
+      if (ltc_compare_testvector(out, olen, mac, mlen, "BLAKE2S MAC single", ilen) != 0) return CRYPT_FAIL_TESTVECTOR;
    }
    return CRYPT_OK;
 #endif

+ 1 - 1
src/mac/f9/f9_test.c

@@ -53,7 +53,7 @@ int f9_test(void)
      if ((err = f9_memory(idx, tests[x].K, 16, tests[x].M, tests[x].msglen, T, &taglen)) != CRYPT_OK) {
         return err;
      }
-     if (compare_testvector(T, taglen, tests[x].T, 4, "F9", x)) {
+     if (ltc_compare_testvector(T, taglen, tests[x].T, 4, "F9", x)) {
         return CRYPT_FAIL_TESTVECTOR;
      }
   }

+ 1 - 1
src/mac/hmac/hmac_test.c

@@ -599,7 +599,7 @@ int hmac_test(void)
             return err;
         }
 
-        if(compare_testvector(digest, outlen, cases[i].digest, (size_t)hash_descriptor[hash].hashsize, cases[i].num, i)) {
+        if(ltc_compare_testvector(digest, outlen, cases[i].digest, (size_t)hash_descriptor[hash].hashsize, cases[i].num, i)) {
             failed++;
         }
     }

+ 1 - 1
src/mac/omac/omac_test.c

@@ -82,7 +82,7 @@ int omac_test(void)
           return err;
        }
 
-       if (compare_testvector(out, len, tests[x].tag, sizeof(tests[x].tag), "OMAC", x) != 0) {
+       if (ltc_compare_testvector(out, len, tests[x].tag, sizeof(tests[x].tag), "OMAC", x) != 0) {
           return CRYPT_FAIL_TESTVECTOR;
        }
     }

+ 1 - 1
src/mac/pelican/pelican_test.c

@@ -91,7 +91,7 @@ int pelican_test(void)
           return err;
        }
 
-       if (compare_testvector(out, 16, tests[x].T, 16, "PELICAN", x)) {
+       if (ltc_compare_testvector(out, 16, tests[x].T, 16, "PELICAN", x)) {
            return CRYPT_FAIL_TESTVECTOR;
        }
    }

+ 1 - 1
src/mac/pmac/pmac_test.c

@@ -130,7 +130,7 @@ int pmac_test(void)
            return err;
         }
 
-        if (compare_testvector(outtag, len, tests[x].tag, sizeof(tests[x].tag), "PMAC", x)) {
+        if (ltc_compare_testvector(outtag, len, tests[x].tag, sizeof(tests[x].tag), "PMAC", x)) {
            return CRYPT_FAIL_TESTVECTOR;
         }
     }

+ 2 - 2
src/mac/poly1305/poly1305_test.c

@@ -33,12 +33,12 @@ int poly1305_test(void)
    if ((err = poly1305_process(&st, (unsigned char*)m + 14, 1)) != CRYPT_OK)         return err;
    if ((err = poly1305_process(&st, (unsigned char*)m + 15, mlen - 15)) != CRYPT_OK) return err;
    if ((err = poly1305_done(&st, out, &len)) != CRYPT_OK)                            return err;
-   if (compare_testvector(out, len, tag, sizeof(tag), "POLY1305-TV1", 1) != 0)       return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, len, tag, sizeof(tag), "POLY1305-TV1", 1) != 0)       return CRYPT_FAIL_TESTVECTOR;
    /* process in one go */
    if ((err = poly1305_init(&st, k, 32)) != CRYPT_OK)                                return err;
    if ((err = poly1305_process(&st, (unsigned char*)m, mlen)) != CRYPT_OK)           return err;
    if ((err = poly1305_done(&st, out, &len)) != CRYPT_OK)                            return err;
-   if (compare_testvector(out, len, tag, sizeof(tag), "POLY1305-TV2", 1) != 0)       return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, len, tag, sizeof(tag), "POLY1305-TV2", 1) != 0)       return CRYPT_FAIL_TESTVECTOR;
    return CRYPT_OK;
 #endif
 }

+ 1 - 1
src/mac/xcbc/xcbc_test.c

@@ -103,7 +103,7 @@ int xcbc_test(void)
      if ((err = xcbc_memory(idx, tests[x].K, 16, tests[x].M, tests[x].msglen, T, &taglen)) != CRYPT_OK) {
         return err;
      }
-     if (compare_testvector(T, taglen, tests[x].T, 16, "XCBC", x)) {
+     if (ltc_compare_testvector(T, taglen, tests[x].T, 16, "XCBC", x)) {
         return CRYPT_FAIL_TESTVECTOR;
      }
   }

+ 1 - 1
src/misc/adler32.c

@@ -114,7 +114,7 @@ int adler32_test(void)
    adler32_init(&ctx);
    adler32_update(&ctx, in, XSTRLEN(in));
    adler32_finish(&ctx, out, 4);
-   if (compare_testvector(adler32, 4, out, 4, "adler32", 0)) {
+   if (ltc_compare_testvector(adler32, 4, out, 4, "adler32", 0)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
    return CRYPT_OK;

+ 10 - 1
src/misc/compare_testvector.c

@@ -54,7 +54,7 @@ static void s_print_hex(const char* what, const void* v, const unsigned long l)
   @param which          The iteration count
   @return 0 on equality, -1 or 1 on difference
 */
-int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which)
+int ltc_compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which)
 {
    int res = 0;
    if(is_len != should_len) {
@@ -79,3 +79,12 @@ int compare_testvector(const void* is, const unsigned long is_len, const void* s
 
    return res;
 }
+
+int ltc_do_compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which)
+{
+   if (ltc_compare_testvector(is, is_len, should, should_len, what, which) == 0) {
+      return CRYPT_OK;
+   } else {
+      return CRYPT_FAIL_TESTVECTOR;
+   }
+}

+ 1 - 1
src/misc/crc32.c

@@ -184,7 +184,7 @@ int crc32_test(void)
    crc32_init(&ctx);
    crc32_update(&ctx, in, XSTRLEN(in));
    crc32_finish(&ctx, out, 4);
-   if (compare_testvector(crc32, 4, out, 4, "CRC32", 0)) {
+   if (ltc_compare_testvector(crc32, 4, out, 4, "CRC32", 0)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
    return CRYPT_OK;

+ 6 - 0
src/misc/deprecated.c

@@ -79,4 +79,10 @@ int ecc_verify_hash_rfc7518(const unsigned char *sig,  unsigned long siglen,
 }
 #endif /* LTC_MECC */
 
+int compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which)
+{
+   return ltc_compare_testvector(is, is_len, should, should_len, what, which);
+}
+
+
 #endif /* LTC_NO_DEPRECATED_APIS */

+ 1 - 1
src/misc/hkdf/hkdf_test.c

@@ -265,7 +265,7 @@ int hkdf_test(void)
             return err;
         }
 
-        if(compare_testvector(OKM, cases[i].OKM_l, cases[i].OKM, (size_t)cases[i].OKM_l, "HKDF", cases[i].num)) {
+        if(ltc_compare_testvector(OKM, cases[i].OKM_l, cases[i].OKM, (size_t)cases[i].OKM_l, "HKDF", cases[i].num)) {
             failed++;
         }
     }

+ 3 - 3
src/misc/pkcs5/pkcs_5_test.c

@@ -175,7 +175,7 @@ int pkcs_5_test (void)
 #endif
             ++failed;
         }
-        else if (compare_testvector(DK, dkLen, cases_5_2[i].DK, cases_5_2[i].dkLen, "PKCS#5_2", i)) {
+        else if (ltc_compare_testvector(DK, dkLen, cases_5_2[i].DK, cases_5_2[i].dkLen, "PKCS#5_2", i)) {
             ++failed;
         }
     }
@@ -193,7 +193,7 @@ int pkcs_5_test (void)
 #endif
             ++failed;
         }
-        else if (compare_testvector(DK, dkLen, cases_5_1[i].DK, cases_5_1[i].dkLen, "PKCS#5_1", i)) {
+        else if (ltc_compare_testvector(DK, dkLen, cases_5_1[i].DK, cases_5_1[i].dkLen, "PKCS#5_1", i)) {
             ++failed;
         }
     }
@@ -211,7 +211,7 @@ int pkcs_5_test (void)
 #endif
             ++failed;
         }
-        else if (compare_testvector(DK, dkLen, cases_5_1o[i].DK, cases_5_1o[i].dkLen, "PKCS#5_1o", i)) {
+        else if (ltc_compare_testvector(DK, dkLen, cases_5_1o[i].DK, cases_5_1o[i].dkLen, "PKCS#5_1o", i)) {
             ++failed;
         }
     }

+ 1 - 1
src/modes/ctr/ctr_test.c

@@ -59,7 +59,7 @@ int ctr_test(void)
         return err;
      }
      ctr_done(&ctr);
-     if (compare_testvector(buf, tests[x].msglen, tests[x].ct, tests[x].msglen, "CTR", x)) {
+     if (ltc_compare_testvector(buf, tests[x].msglen, tests[x].ct, tests[x].msglen, "CTR", x)) {
         return CRYPT_FAIL_TESTVECTOR;
      }
   }

+ 1 - 1
src/modes/f8/f8_test_mode.c

@@ -53,7 +53,7 @@ int f8_test_mode(void)
    f8_done(&f8);
 
    /* compare */
-   if (compare_testvector(buf, sizeof(ct), ct, sizeof(ct), "f8", 0)) {
+   if (ltc_compare_testvector(buf, sizeof(ct), ct, sizeof(ct), "f8", 0)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 

+ 3 - 3
src/modes/lrw/lrw_test.c

@@ -80,7 +80,7 @@ int lrw_test(void)
      }
 
      /* check pad against expected tweak */
-     if (compare_testvector(tests[x].expected_tweak, 16, lrw.pad, 16, "LRW Tweak", x)) {
+     if (ltc_compare_testvector(tests[x].expected_tweak, 16, lrw.pad, 16, "LRW Tweak", x)) {
         lrw_done(&lrw);
         return CRYPT_FAIL_TESTVECTOR;
      }
@@ -91,7 +91,7 @@ int lrw_test(void)
         return err;
      }
 
-     if (compare_testvector(buf[0], 16, tests[x].C, 16, "LRW Encrypt", x)) {
+     if (ltc_compare_testvector(buf[0], 16, tests[x].C, 16, "LRW Encrypt", x)) {
         lrw_done(&lrw);
         return CRYPT_FAIL_TESTVECTOR;
      }
@@ -107,7 +107,7 @@ int lrw_test(void)
         return err;
      }
 
-     if (compare_testvector(buf[1], 16, tests[x].P, 16, "LRW Decrypt", x)) {
+     if (ltc_compare_testvector(buf[1], 16, tests[x].P, 16, "LRW Decrypt", x)) {
         lrw_done(&lrw);
         return CRYPT_FAIL_TESTVECTOR;
      }

+ 2 - 2
src/modes/xts/xts_test.c

@@ -260,7 +260,7 @@ int xts_test(void)
                }
             }
 
-            if (compare_testvector(OUT, tests[i].PTLEN, tests[i].CTX, tests[i].PTLEN, "XTS encrypt", i)) {
+            if (ltc_compare_testvector(OUT, tests[i].PTLEN, tests[i].CTX, tests[i].PTLEN, "XTS encrypt", i)) {
                xts_done(&xts);
                return CRYPT_FAIL_TESTVECTOR;
             }
@@ -285,7 +285,7 @@ int xts_test(void)
                }
             }
 
-            if (compare_testvector(OUT, tests[i].PTLEN, tests[i].PTX, tests[i].PTLEN, "XTS decrypt", i)) {
+            if (ltc_compare_testvector(OUT, tests[i].PTLEN, tests[i].PTX, tests[i].PTLEN, "XTS decrypt", i)) {
                xts_done(&xts);
                return CRYPT_FAIL_TESTVECTOR;
             }

+ 3 - 3
src/prngs/chacha20.c

@@ -194,7 +194,7 @@ int chacha20_prng_test(void)
    if ((err = chacha20_prng_add_entropy(en, sizeof(en), &st)) != CRYPT_OK) return err;
    if ((err = chacha20_prng_ready(&st)) != CRYPT_OK)                       return err;
    if (chacha20_prng_read(out, 10, &st) != 10)                             return CRYPT_ERROR_READPRNG; /* 10 bytes for testing */
-   if (compare_testvector(out, 10, t1, sizeof(t1), "CHACHA-PRNG", 1))      return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, 10, t1, sizeof(t1), "CHACHA-PRNG", 1))      return CRYPT_FAIL_TESTVECTOR;
    if (chacha20_prng_read(out, 500, &st) != 500)                           return CRYPT_ERROR_READPRNG; /* skip 500 bytes */
    /* add entropy to already initialized prng */
    if ((err = chacha20_prng_add_entropy(en, sizeof(en), &st)) != CRYPT_OK) return err;
@@ -202,13 +202,13 @@ int chacha20_prng_test(void)
    if ((err = chacha20_prng_export(dmp, &dmplen, &st)) != CRYPT_OK)        return err;
    if (chacha20_prng_read(out, 500, &st) != 500)                           return CRYPT_ERROR_READPRNG; /* skip 500 bytes */
    if (chacha20_prng_read(out, 10, &st) != 10)                             return CRYPT_ERROR_READPRNG; /* 10 bytes for testing */
-   if (compare_testvector(out, 10, t2, sizeof(t2), "CHACHA-PRNG", 2))      return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, 10, t2, sizeof(t2), "CHACHA-PRNG", 2))      return CRYPT_FAIL_TESTVECTOR;
    if ((err = chacha20_prng_done(&st)) != CRYPT_OK)                        return err;
    if ((err = chacha20_prng_import(dmp, dmplen, &st)) != CRYPT_OK)         return err;
    if ((err = chacha20_prng_ready(&st)) != CRYPT_OK)                       return err;
    if (chacha20_prng_read(out, 500, &st) != 500)                           return CRYPT_ERROR_READPRNG; /* skip 500 bytes */
    if (chacha20_prng_read(out, 10, &st) != 10)                             return CRYPT_ERROR_READPRNG; /* 10 bytes for testing */
-   if (compare_testvector(out, 10, t3, sizeof(t3), "CHACHA-PRNG", 3))      return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, 10, t3, sizeof(t3), "CHACHA-PRNG", 3))      return CRYPT_FAIL_TESTVECTOR;
    if ((err = chacha20_prng_done(&st)) != CRYPT_OK)                        return err;
 
    return CRYPT_OK;

+ 3 - 3
src/prngs/rc4.c

@@ -197,7 +197,7 @@ int rc4_test(void)
    if ((err = rc4_add_entropy(en, sizeof(en), &st)) != CRYPT_OK)   return err;
    if ((err = rc4_ready(&st)) != CRYPT_OK)                         return err;
    if (rc4_read(out, 10, &st) != 10)                               return CRYPT_ERROR_READPRNG; /* 10 bytes for testing */
-   if (compare_testvector(out, 10, t1, sizeof(t1), "RC4-PRNG", 1)) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, 10, t1, sizeof(t1), "RC4-PRNG", 1)) return CRYPT_FAIL_TESTVECTOR;
    if (rc4_read(out, 500, &st) != 500)                             return CRYPT_ERROR_READPRNG; /* skip 500 bytes */
    /* add entropy to already initialized prng */
    if ((err = rc4_add_entropy(en, sizeof(en), &st)) != CRYPT_OK)   return err;
@@ -205,13 +205,13 @@ int rc4_test(void)
    if ((err = rc4_export(dmp, &dmplen, &st)) != CRYPT_OK)          return err;
    if (rc4_read(out, 500, &st) != 500)                             return CRYPT_ERROR_READPRNG; /* skip 500 bytes */
    if (rc4_read(out, 10, &st) != 10)                               return CRYPT_ERROR_READPRNG; /* 10 bytes for testing */
-   if (compare_testvector(out, 10, t2, sizeof(t2), "RC4-PRNG", 2)) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, 10, t2, sizeof(t2), "RC4-PRNG", 2)) return CRYPT_FAIL_TESTVECTOR;
    if ((err = rc4_done(&st)) != CRYPT_OK)                          return err;
    if ((err = rc4_import(dmp, dmplen, &st)) != CRYPT_OK)           return err;
    if ((err = rc4_ready(&st)) != CRYPT_OK)                         return err;
    if (rc4_read(out, 500, &st) != 500)                             return CRYPT_ERROR_READPRNG; /* skip 500 bytes */
    if (rc4_read(out, 10, &st) != 10)                               return CRYPT_ERROR_READPRNG; /* 10 bytes for testing */
-   if (compare_testvector(out, 10, t3, sizeof(t3), "RC4-PRNG", 3)) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, 10, t3, sizeof(t3), "RC4-PRNG", 3)) return CRYPT_FAIL_TESTVECTOR;
    if ((err = rc4_done(&st)) != CRYPT_OK)                          return err;
 
    return CRYPT_OK;

+ 3 - 3
src/prngs/sober128.c

@@ -196,7 +196,7 @@ int sober128_test(void)
    if ((err = sober128_add_entropy(en, sizeof(en), &st)) != CRYPT_OK)   return err;
    if ((err = sober128_ready(&st)) != CRYPT_OK)                         return err;
    if (sober128_read(out, 10, &st) != 10)                               return CRYPT_ERROR_READPRNG; /* 10 bytes for testing */
-   if (compare_testvector(out, 10, t1, sizeof(t1), "SOBER128-PRNG", 1)) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, 10, t1, sizeof(t1), "SOBER128-PRNG", 1)) return CRYPT_FAIL_TESTVECTOR;
    if (sober128_read(out, 500, &st) != 500)                             return CRYPT_ERROR_READPRNG; /* skip 500 bytes */
    /* add entropy to already initialized prng */
    if ((err = sober128_add_entropy(en, sizeof(en), &st)) != CRYPT_OK)   return err;
@@ -204,13 +204,13 @@ int sober128_test(void)
    if ((err = sober128_export(dmp, &dmplen, &st)) != CRYPT_OK)          return err;
    if (sober128_read(out, 500, &st) != 500)                             return CRYPT_ERROR_READPRNG; /* skip 500 bytes */
    if (sober128_read(out, 10, &st) != 10)                               return CRYPT_ERROR_READPRNG; /* 10 bytes for testing */
-   if (compare_testvector(out, 10, t2, sizeof(t2), "SOBER128-PRNG", 2)) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, 10, t2, sizeof(t2), "SOBER128-PRNG", 2)) return CRYPT_FAIL_TESTVECTOR;
    if ((err = sober128_done(&st)) != CRYPT_OK)                          return err;
    if ((err = sober128_import(dmp, dmplen, &st)) != CRYPT_OK)           return err;
    if ((err = sober128_ready(&st)) != CRYPT_OK)                         return err;
    if (sober128_read(out, 500, &st) != 500)                             return CRYPT_ERROR_READPRNG; /* skip 500 bytes */
    if (sober128_read(out, 10, &st) != 10)                               return CRYPT_ERROR_READPRNG; /* 10 bytes for testing */
-   if (compare_testvector(out, 10, t3, sizeof(t3), "SOBER128-PRNG", 3)) return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, 10, t3, sizeof(t3), "SOBER128-PRNG", 3)) return CRYPT_FAIL_TESTVECTOR;
    if ((err = sober128_done(&st)) != CRYPT_OK)                          return err;
 
    return CRYPT_OK;

+ 5 - 5
src/stream/chacha/chacha_test.c

@@ -43,29 +43,29 @@ int chacha_test(void)
    if ((err = chacha_crypt(&st, (unsigned char*)pt + 70,  5,       out + 70)) != CRYPT_OK) return err;
    if ((err = chacha_crypt(&st, (unsigned char*)pt + 75,  5,       out + 75)) != CRYPT_OK) return err;
    if ((err = chacha_crypt(&st, (unsigned char*)pt + 80, len - 80, out + 80)) != CRYPT_OK) return err;
-   if (compare_testvector(out, len, ct, sizeof(ct), "CHACHA-TV1", 1))                      return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, len, ct, sizeof(ct), "CHACHA-TV1", 1))                      return CRYPT_FAIL_TESTVECTOR;
 
    /* crypt in one go - using chacha_ivctr32() */
    if ((err = chacha_setup(&st, k, sizeof(k), 20)) != CRYPT_OK)                            return err;
    if ((err = chacha_ivctr32(&st, n, sizeof(n), 1)) != CRYPT_OK)                           return err;
    if ((err = chacha_crypt(&st, (unsigned char*)pt, len, out)) != CRYPT_OK)                return err;
-   if (compare_testvector(out, len, ct, sizeof(ct), "CHACHA-TV2", 1))                      return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, len, ct, sizeof(ct), "CHACHA-TV2", 1))                      return CRYPT_FAIL_TESTVECTOR;
 
    /* crypt in one go - using chacha_ivctr64() */
    if ((err = chacha_setup(&st, k, sizeof(k), 20)) != CRYPT_OK)                            return err;
    if ((err = chacha_ivctr64(&st, n + 4, sizeof(n) - 4, 1)) != CRYPT_OK)                   return err;
    if ((err = chacha_crypt(&st, (unsigned char*)pt, len, out)) != CRYPT_OK)                return err;
-   if (compare_testvector(out, len, ct, sizeof(ct), "CHACHA-TV3", 1))                      return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, len, ct, sizeof(ct), "CHACHA-TV3", 1))                      return CRYPT_FAIL_TESTVECTOR;
 
    /* crypt in a single call using 32-bit counter with a value of 1 */
    if ((err = chacha_memory(k, sizeof(k), 20,
                             n, sizeof(n), 1, (unsigned char*)pt, len, out)) != CRYPT_OK)   return err;
-   if (compare_testvector(out, len, ct, sizeof(ct), "CHACHA-TV4", 1))                      return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, len, ct, sizeof(ct), "CHACHA-TV4", 1))                      return CRYPT_FAIL_TESTVECTOR;
 
    /* crypt in a single call using 64-bit counter with a value of 1 */
    if ((err = chacha_memory(k, sizeof(k), 20,
                             n + 4, sizeof(n) - 4, 1, (unsigned char*)pt, len, out)) != CRYPT_OK)  return err;
-   if (compare_testvector(out, len, ct, sizeof(ct), "CHACHA-TV5", 1))                      return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, len, ct, sizeof(ct), "CHACHA-TV5", 1))                      return CRYPT_FAIL_TESTVECTOR;
 
    return CRYPT_OK;
 #endif

+ 6 - 6
src/stream/rabbit/rabbit.c

@@ -364,7 +364,7 @@ int rabbit_test(void)
          if ((err = rabbit_setup(&st, k, sizeof(k)))                   != CRYPT_OK) return err;
          if ((err = rabbit_setiv(&st, iv, sizeof(iv)))                 != CRYPT_OK) return err;
          if ((err = rabbit_crypt(&st, (unsigned char*)pt, ptlen, out)) != CRYPT_OK) return err;
-         if (compare_testvector(out, ptlen, ct, ptlen, "RABBIT-TV1", 1))   return CRYPT_FAIL_TESTVECTOR;
+         if (ltc_compare_testvector(out, ptlen, ct, ptlen, "RABBIT-TV1", 1))   return CRYPT_FAIL_TESTVECTOR;
       }
 
       /* --- Test 2 (generate unusual number of bytes each time) ------------ */
@@ -389,7 +389,7 @@ int rabbit_test(void)
          if ((err = rabbit_crypt(&st, (unsigned char*)pt + 16, 14, out + 16)) != CRYPT_OK) return err;
          if ((err = rabbit_crypt(&st, (unsigned char*)pt + 30,  2, out + 30)) != CRYPT_OK) return err;
          if ((err = rabbit_crypt(&st, (unsigned char*)pt + 32,  7, out + 32)) != CRYPT_OK) return err;
-         if (compare_testvector(out, ptlen, ct, ptlen, "RABBIT-TV2", 1))   return CRYPT_FAIL_TESTVECTOR;
+         if (ltc_compare_testvector(out, ptlen, ct, ptlen, "RABBIT-TV2", 1))   return CRYPT_FAIL_TESTVECTOR;
       }
 
       /* --- Test 3 (use non-null data) ------------------------------------- */
@@ -414,13 +414,13 @@ int rabbit_test(void)
          if ((err = rabbit_crypt(&st, (unsigned char*)pt,       5, out))      != CRYPT_OK) return err;
          if ((err = rabbit_crypt(&st, (unsigned char*)pt +  5, 29, out +  5)) != CRYPT_OK) return err;
          if ((err = rabbit_crypt(&st, (unsigned char*)pt + 34,  5, out + 34)) != CRYPT_OK) return err;
-         if (compare_testvector(out, ptlen, ct, ptlen, "RABBIT-TV3", 1))   return CRYPT_FAIL_TESTVECTOR;
+         if (ltc_compare_testvector(out, ptlen, ct, ptlen, "RABBIT-TV3", 1))   return CRYPT_FAIL_TESTVECTOR;
 
       /* --- Test 4 (crypt in a single call) ------------------------------------ */
 
          if ((err = rabbit_memory(k, sizeof(k), iv, sizeof(iv),
                                    (unsigned char*)pt, sizeof(pt), out))      != CRYPT_OK) return err;
-         if (compare_testvector(out, ptlen, ct, ptlen, "RABBIT-TV4", 1))   return CRYPT_FAIL_TESTVECTOR;
+         if (ltc_compare_testvector(out, ptlen, ct, ptlen, "RABBIT-TV4", 1))   return CRYPT_FAIL_TESTVECTOR;
          /* use 'out' (ciphertext) in the next decryption test */
 
       /* --- Test 5 (decrypt ciphertext) ------------------------------------ */
@@ -428,12 +428,12 @@ int rabbit_test(void)
          /* decrypt ct (out) and compare with pt (start with only setiv() to reset) */
          if ((err = rabbit_setiv(&st, iv, sizeof(iv)))                        != CRYPT_OK) return err;
          if ((err = rabbit_crypt(&st, out, ptlen, out2))                      != CRYPT_OK) return err;
-         if (compare_testvector(out2, ptlen, pt, ptlen, "RABBIT-TV5", 1))  return CRYPT_FAIL_TESTVECTOR;
+         if (ltc_compare_testvector(out2, ptlen, pt, ptlen, "RABBIT-TV5", 1))  return CRYPT_FAIL_TESTVECTOR;
 
       /* --- Test 6 (wipe state, incl key) ---------------------------------- */
 
          if ((err = rabbit_done(&st))                      != CRYPT_OK) return err;
-         if (compare_testvector(&st, sizeof(st), nulls, sizeof(st), "RABBIT-TV6", 1))  return CRYPT_FAIL_TESTVECTOR;
+         if (ltc_compare_testvector(&st, sizeof(st), nulls, sizeof(st), "RABBIT-TV6", 1))  return CRYPT_FAIL_TESTVECTOR;
 
       }
 

+ 2 - 2
src/stream/rc4/rc4_test.c

@@ -19,12 +19,12 @@ int rc4_stream_test(void)
 
    if ((err = rc4_stream_setup(&st, key, sizeof(key))) != CRYPT_OK)    return err;
    if ((err = rc4_stream_crypt(&st, pt, sizeof(pt), buf)) != CRYPT_OK) return err;
-   if (compare_testvector(buf, sizeof(ct), ct, sizeof(ct), "RC4-TV1", 0))  return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(buf, sizeof(ct), ct, sizeof(ct), "RC4-TV1", 0))  return CRYPT_FAIL_TESTVECTOR;
    if ((err = rc4_stream_done(&st)) != CRYPT_OK)                       return err;
 
    /* crypt in a single call */
    if ((err = rc4_stream_memory(key, sizeof(key), pt, sizeof(pt), buf)) != CRYPT_OK) return err;
-   if (compare_testvector(buf, sizeof(ct), ct, sizeof(ct), "RC4-TV2", 0))  return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(buf, sizeof(ct), ct, sizeof(ct), "RC4-TV2", 0))  return CRYPT_FAIL_TESTVECTOR;
 
    return CRYPT_OK;
 #endif

+ 4 - 4
src/stream/salsa20/salsa20_test.c

@@ -43,7 +43,7 @@ int salsa20_test(void)
    if ((err = salsa20_crypt(&st, (unsigned char*)pt +  5, 25,       out +  5)) != CRYPT_OK) return err;
    if ((err = salsa20_crypt(&st, (unsigned char*)pt + 30, 10,       out + 30)) != CRYPT_OK) return err;
    if ((err = salsa20_crypt(&st, (unsigned char*)pt + 40, len - 40, out + 40)) != CRYPT_OK) return err;
-   if (compare_testvector(out, len, ct, sizeof(ct), "SALSA20-TV1", 1))        return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, len, ct, sizeof(ct), "SALSA20-TV1", 1))        return CRYPT_FAIL_TESTVECTOR;
 
    /* crypt in one go - using salsa20_ivctr64() */
    counter = 0;
@@ -51,12 +51,12 @@ int salsa20_test(void)
    if ((err = salsa20_setup(&st, k, sizeof(k), rounds))         != CRYPT_OK)  return err;
    if ((err = salsa20_ivctr64(&st, n, sizeof(n), counter))      != CRYPT_OK)  return err;
    if ((err = salsa20_crypt(&st, (unsigned char*)pt, len, out)) != CRYPT_OK)  return err;
-   if (compare_testvector(out, len, ct2, sizeof(ct2), "SALSA20-TV2", 1))      return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, len, ct2, sizeof(ct2), "SALSA20-TV2", 1))      return CRYPT_FAIL_TESTVECTOR;
 
    /* crypt in a single call */
    if ((err = salsa20_memory(k, sizeof(k), rounds, n, sizeof(n), counter,
                                  (unsigned char*)pt, len, out)) != CRYPT_OK)  return err;
-   if (compare_testvector(out, len, ct2, sizeof(ct2), "SALSA20-TV3", 1))      return CRYPT_FAIL_TESTVECTOR;
+   if (ltc_compare_testvector(out, len, ct2, sizeof(ct2), "SALSA20-TV3", 1))      return CRYPT_FAIL_TESTVECTOR;
 
    {
        /* keystream
@@ -76,7 +76,7 @@ int salsa20_test(void)
        if ((err = salsa20_ivctr64(&st, n3, sizeof(n3), counter3)) != CRYPT_OK)     return err;
        if ((err = salsa20_keystream(&st, out, 64))                != CRYPT_OK)     return err;
        if ((err = salsa20_done(&st))                              != CRYPT_OK)     return err;
-       if (compare_testvector(out, 64, ct3, sizeof(ct3), "SALSA20-TV4", 1))        return CRYPT_FAIL_TESTVECTOR;
+       if (ltc_compare_testvector(out, 64, ct3, sizeof(ct3), "SALSA20-TV4", 1))        return CRYPT_FAIL_TESTVECTOR;
    }
 
    return CRYPT_OK;

+ 4 - 4
src/stream/salsa20/xsalsa20_test.c

@@ -8,7 +8,7 @@
  * Public domain from D. J. Bernstein
  */
 
-#include "tomcrypt.h"
+#include "tomcrypt_private.h"
 
 #ifdef LTC_XSALSA20
 
@@ -50,13 +50,13 @@ int xsalsa20_test(void)
         if ((err = salsa20_crypt(&st, ciphertext, msglen, msg2))    != CRYPT_OK)  return err;
         if ((err = salsa20_done(&st))                               != CRYPT_OK)  return err;
 
-        if (compare_testvector(msg, msglen, msg2, msglen, "XSALSA20-TV1", 1))  return CRYPT_FAIL_TESTVECTOR;
+        if (ltc_compare_testvector(msg, msglen, msg2, msglen, "XSALSA20-TV1", 1))  return CRYPT_FAIL_TESTVECTOR;
 
 
         /* round trip with two single function calls */
         if ((err = xsalsa20_memory(key, sizeof(key), 20, nonce, sizeof(nonce), msg, msglen, ciphertext))  != CRYPT_OK)                return err;
         if ((err = xsalsa20_memory(key, sizeof(key), 20, nonce, sizeof(nonce), ciphertext, msglen, msg2)) != CRYPT_OK)                return err;
-        if (compare_testvector(msg, msglen, msg2, msglen, "XSALSA20-TV2", 1))  return CRYPT_FAIL_TESTVECTOR;
+        if (ltc_compare_testvector(msg, msglen, msg2, msglen, "XSALSA20-TV2", 1))  return CRYPT_FAIL_TESTVECTOR;
     }
 
 #ifdef LTC_SHA256
@@ -78,7 +78,7 @@ int xsalsa20_test(void)
        if ((err = salsa20_keystream(&st, keystream, keystreamlen))   != CRYPT_OK)  return err;
        if ((err = salsa20_done(&st))                                 != CRYPT_OK)  return err;
        if ((err = s_sha256(hash, keystream, keystreamlen))            != CRYPT_OK)  return err;
-       if (compare_testvector(hash, sizeof(hash), expecthash, sizeof(expecthash),   "XSALSA20-TV3", 1))  return CRYPT_FAIL_TESTVECTOR;
+       if (ltc_compare_testvector(hash, sizeof(hash), expecthash, sizeof(expecthash),   "XSALSA20-TV3", 1))  return CRYPT_FAIL_TESTVECTOR;
    }
 #endif
 

+ 2 - 2
src/stream/sober128/sober128_test.c

@@ -25,14 +25,14 @@ int sober128_stream_test(void)
    if ((err = sober128_stream_setiv(&st, iv, sizeof(iv))) != CRYPT_OK)   return err;
    if ((err = sober128_stream_crypt(&st, src, len, dst)) != CRYPT_OK)    return err;
    if ((err = sober128_stream_done(&st)) != CRYPT_OK)                    return err;
-   if (compare_testvector(dst, len, out, len, "SOBER-128-TV1", 0)) {
+   if (ltc_compare_testvector(dst, len, out, len, "SOBER-128-TV1", 0)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 
    /* crypt in a single call */
    if ((err = sober128_stream_memory(key, sizeof(key), iv, sizeof(iv),
                                             src, len, dst)) != CRYPT_OK) return err;
-   if (compare_testvector(dst, len, out, len, "SOBER-128-TV2", 0)) {
+   if (ltc_compare_testvector(dst, len, out, len, "SOBER-128-TV2", 0)) {
       return CRYPT_FAIL_TESTVECTOR;
    }
 

+ 4 - 4
src/stream/sosemanuk/sosemanuk_test.c

@@ -30,18 +30,18 @@ int sosemanuk_test(void)
        if ((err = sosemanuk_crypt(&st, (unsigned char*)pt +  5, 25,       out +  5)) != CRYPT_OK) return err;
        if ((err = sosemanuk_crypt(&st, (unsigned char*)pt + 30, 10,       out + 30)) != CRYPT_OK) return err;
        if ((err = sosemanuk_crypt(&st, (unsigned char*)pt + 40, len - 40, out + 40)) != CRYPT_OK) return err;
-       if (compare_testvector(out, len, ct, sizeof(ct), "SOSEMANUK-TV1", 1))                      return CRYPT_FAIL_TESTVECTOR;
+       if (ltc_compare_testvector(out, len, ct, sizeof(ct), "SOSEMANUK-TV1", 1))                      return CRYPT_FAIL_TESTVECTOR;
 
        /* crypt in one go - using sosemanuk_ivctr64() */
        if ((err = sosemanuk_setup(&st, k, sizeof(k)))                 != CRYPT_OK) return err;
        if ((err = sosemanuk_setiv(&st, n, sizeof(n)))                 != CRYPT_OK) return err;
        if ((err = sosemanuk_crypt(&st, (unsigned char*)pt, len, out)) != CRYPT_OK) return err;
-       if (compare_testvector(out, len, ct, sizeof(ct), "SOSEMANUK-TV2", 1))       return CRYPT_FAIL_TESTVECTOR;
+       if (ltc_compare_testvector(out, len, ct, sizeof(ct), "SOSEMANUK-TV2", 1))       return CRYPT_FAIL_TESTVECTOR;
 
        /* crypt in a single call */
        if ((err = sosemanuk_memory(k, sizeof(k), n, sizeof(n),
                                        (unsigned char*)pt, len, out)) != CRYPT_OK) return err;
-       if (compare_testvector(out, len, ct, sizeof(ct), "SOSEMANUK-TV3", 1))       return CRYPT_FAIL_TESTVECTOR;
+       if (ltc_compare_testvector(out, len, ct, sizeof(ct), "SOSEMANUK-TV3", 1))       return CRYPT_FAIL_TESTVECTOR;
 
    }
    {
@@ -69,7 +69,7 @@ int sosemanuk_test(void)
        if ((err = sosemanuk_setiv(&st, n3, sizeof(n3)))      != CRYPT_OK)     return err;
        if ((err = sosemanuk_keystream(&st, out, 64))         != CRYPT_OK)     return err;
        if ((err = sosemanuk_done(&st))                       != CRYPT_OK)     return err;
-       if (compare_testvector(out, 64, ct3, sizeof(ct3), "SOSEMANUK-TV4", 1)) return CRYPT_FAIL_TESTVECTOR;
+       if (ltc_compare_testvector(out, 64, ct3, sizeof(ct3), "SOSEMANUK-TV4", 1)) return CRYPT_FAIL_TESTVECTOR;
    }
 
    return CRYPT_OK;

+ 7 - 7
tests/base64_test.c

@@ -145,15 +145,15 @@ int base64_test(void)
 
    out[10] = 0;
    DO(base64_decode(out, l1, tmp, &l2));
-   DO(compare_testvector(tmp, l2, in, l2, "insane base64 decoding (NUL)", 0));
+   COMPARE_TESTVECTOR(tmp, l2, in, l2, "insane base64 decoding (NUL)", 0);
    DO(base64_sane_decode(out, l1, tmp, &l2) == CRYPT_INVALID_PACKET ? CRYPT_OK : CRYPT_INVALID_PACKET);
    DO(base64_strict_decode(out, l1, tmp, &l2) == CRYPT_INVALID_PACKET ? CRYPT_OK : CRYPT_INVALID_PACKET);
 
    out[10] = 9; /* tab */
    DO(base64_decode(out, l1, tmp, &l2));
-   DO(compare_testvector(tmp, l2, in, l2, "insane base64 decoding (TAB)", 0));
+   COMPARE_TESTVECTOR(tmp, l2, in, l2, "insane base64 decoding (TAB)", 0);
    DO(base64_sane_decode(out, l1, tmp, &l2));
-   DO(compare_testvector(tmp, l2, in, l2, "relaxed base64 decoding (TAB)", 0));
+   COMPARE_TESTVECTOR(tmp, l2, in, l2, "relaxed base64 decoding (TAB)", 0);
    DO(base64_strict_decode(out, l1, tmp, &l2) == CRYPT_INVALID_PACKET ? CRYPT_OK : CRYPT_INVALID_PACKET);
 
    memset(in, 'A', sizeof(in));
@@ -161,16 +161,16 @@ int base64_test(void)
    SHOULD_FAIL(base64_encode_pem(in, 51, out, &l1, 0));
    l1++;
    DO(base64_encode_pem(in, 51, out, &l1, 0));
-   DO(compare_testvector(out, l1, As_lf, strlen(As_lf), "PEM output with \\n", 0));
+   COMPARE_TESTVECTOR(out, l1, As_lf, strlen(As_lf), "PEM output with \\n", 0);
    l1 = strlen(As_crlf) + 1;
    DO(base64_encode_pem(in, 51, out, &l1, BASE64_PEM_CRLF));
-   DO(compare_testvector(out, l1, As_crlf, strlen(As_crlf), "PEM output with \\r\\n", 0));
+   COMPARE_TESTVECTOR(out, l1, As_crlf, strlen(As_crlf), "PEM output with \\r\\n", 0);
    l1 = strlen(As_ssh_lf) + 1;
    DO(base64_encode_pem(in, 57, out, &l1, BASE64_PEM_SSH));
-   DO(compare_testvector(out, l1, As_ssh_lf, strlen(As_ssh_lf), "PEM SSH-style output with \\n", 0));
+   COMPARE_TESTVECTOR(out, l1, As_ssh_lf, strlen(As_ssh_lf), "PEM SSH-style output with \\n", 0);
    l1 = strlen(As_ssh_crlf) + 1;
    DO(base64_encode_pem(in, 57, out, &l1, BASE64_PEM_SSH | BASE64_PEM_CRLF));
-   DO(compare_testvector(out, l1, As_ssh_crlf, strlen(As_ssh_crlf), "PEM SSH-style output with \\r\\n", 0));
+   COMPARE_TESTVECTOR(out, l1, As_ssh_crlf, strlen(As_ssh_crlf), "PEM SSH-style output with \\r\\n", 0);
 #endif
 
    return 0;

+ 0 - 10
tests/common.c

@@ -55,16 +55,6 @@ void print_hex(const char* what, const void* v, const unsigned long l)
   }
 }
 
-int do_compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which)
-{
-   if (compare_testvector(is, is_len, should, should_len, what, which) == 0) {
-      return CRYPT_OK;
-   } else {
-      return CRYPT_FAIL_TESTVECTOR;
-   }
-}
-
-
 #ifdef LTC_TEST_READDIR
 
 #include <sys/stat.h>

+ 1 - 3
tests/common.h

@@ -38,7 +38,7 @@ int ecc_key_cmp(const int should_type, const ecc_key *should, const ecc_key *is)
 #define ENSUREX(x, str) do { run_cmd(((x)) ? CRYPT_OK : CRYPT_FAIL_TESTVECTOR, __LINE__, __FILE__, #x, (str)); } while (0)
 #endif
 
-#define COMPARE_TESTVECTOR(i, il, s, sl, wa, wi) do { DO(do_compare_testvector((i), (il), (s), (sl), (wa), (wi))); } while(0)
+#define COMPARE_TESTVECTOR(i, il, s, sl, wa, wi) do { DO(ltc_do_compare_testvector((i), (il), (s), (sl), (wa), (wi))); } while(0)
 
 #if !((defined(_WIN32) || defined(_WIN32_WCE)) && !defined(__GNUC__)) && !defined(LTC_NO_FILE)
 #define LTC_TEST_READDIR
@@ -54,6 +54,4 @@ void run_cmd(int res, int line, const char *file, const char *cmd, const char *a
 
 void print_hex(const char* what, const void* v, const unsigned long l);
 
-int do_compare_testvector(const void* is, const unsigned long is_len, const void* should, const unsigned long should_len, const char* what, int which);
-
 #endif /* DEMOS_COMMON_H_ */

+ 8 - 8
tests/dsa_test.c

@@ -187,8 +187,8 @@ static int s_dsa_compat_test(void)
                  &key));
   len = sizeof(buf);
   DO(dsa_export(buf, &len, PK_PRIVATE | PK_STD, &key));
-  DO(do_compare_testvector(buf, len, ltc_dsa_private_test_key, sizeof(ltc_dsa_private_test_key),
-                         "DSA private export from dsa_set_pqg() & dsa_set_key()\n", __LINE__));
+  COMPARE_TESTVECTOR(buf, len, ltc_dsa_private_test_key, sizeof(ltc_dsa_private_test_key),
+                         "DSA private export from dsa_set_pqg() & dsa_set_key()\n", __LINE__);
   dsa_free(&key);
 
   /* try import public key from raw hexadecimal numbers */
@@ -201,8 +201,8 @@ static int s_dsa_compat_test(void)
                  &key));
   len = sizeof(buf);
   DO(dsa_export(buf, &len, PK_PUBLIC | PK_STD, &key));
-  DO(do_compare_testvector(buf, len, openssl_pub_dsa, sizeof(openssl_pub_dsa),
-                         "DSA public export from dsa_set_pqg() & dsa_set_key()\n", __LINE__));
+  COMPARE_TESTVECTOR(buf, len, openssl_pub_dsa, sizeof(openssl_pub_dsa),
+                         "DSA public export from dsa_set_pqg() & dsa_set_key()\n", __LINE__);
   dsa_free(&key);
 
   /* try import dsaparam */
@@ -223,8 +223,8 @@ static int s_dsa_compat_test(void)
                  &key));
   len = sizeof(buf);
   DO(dsa_export(buf, &len, PK_PUBLIC | PK_STD, &key));
-  DO(do_compare_testvector(buf, len, openssl_pub_dsa, sizeof(openssl_pub_dsa),
-                         "DSA public export from dsa_set_pqg_dsaparam()\n", __LINE__));
+  COMPARE_TESTVECTOR(buf, len, openssl_pub_dsa, sizeof(openssl_pub_dsa),
+                         "DSA public export from dsa_set_pqg_dsaparam()\n", __LINE__);
   dsa_free(&key);
 
   /* try import dsaparam - our private key */
@@ -234,8 +234,8 @@ static int s_dsa_compat_test(void)
                  &key));
   len = sizeof(buf);
   DO(dsa_export(buf, &len, PK_PRIVATE | PK_STD, &key));
-  DO(do_compare_testvector(buf, len, ltc_dsa_private_test_key, sizeof(ltc_dsa_private_test_key),
-                         "DSA private export from dsa_set_pqg_dsaparam()\n", __LINE__));
+  COMPARE_TESTVECTOR(buf, len, ltc_dsa_private_test_key, sizeof(ltc_dsa_private_test_key),
+                         "DSA private export from dsa_set_pqg_dsaparam()\n", __LINE__);
   dsa_free(&key);
 
   return CRYPT_OK;

+ 11 - 11
tests/ecc_test.c

@@ -1886,39 +1886,39 @@ static int s_ecc_import_export(void) {
    /* export - openssl compatible DER format */
    outlen = sizeof(out);
    DO(ecc_export_openssl(out, &outlen, PK_PRIVATE, &pri));
-   if (compare_testvector(out, outlen, ltc_ecc_long_pri_test_key, sizeof(ltc_ecc_long_pri_test_key),   "e-ltc_ecc_long_pri_test_key",   0)) return CRYPT_ERROR;
+   COMPARE_TESTVECTOR(out, outlen, ltc_ecc_long_pri_test_key, sizeof(ltc_ecc_long_pri_test_key),   "e-ltc_ecc_long_pri_test_key",   0);
    outlen = sizeof(out);
    DO(ecc_export_openssl(out, &outlen, PK_PRIVATE|PK_COMPRESSED, &pri));
-   if (compare_testvector(out, outlen, long_pric, sizeof(long_pric),  "e-long_pric",  0)) return CRYPT_ERROR;
+   COMPARE_TESTVECTOR(out, outlen, long_pric, sizeof(long_pric),  "e-long_pric",  0);
    outlen = sizeof(out);
    DO(ecc_export_openssl(out, &outlen, PK_PUBLIC, &pub));
-   if (compare_testvector(out, outlen, long_pub, sizeof(long_pub),   "e-long_pub",   0)) return CRYPT_ERROR;
+   COMPARE_TESTVECTOR(out, outlen, long_pub, sizeof(long_pub),   "e-long_pub",   0);
    outlen = sizeof(out);
    DO(ecc_export_openssl(out, &outlen, PK_PUBLIC|PK_COMPRESSED, &pub));
-   if (compare_testvector(out, outlen, long_pubc, sizeof(long_pubc),  "e-long_pubc",  0)) return CRYPT_ERROR;
+   COMPARE_TESTVECTOR(out, outlen, long_pubc, sizeof(long_pubc),  "e-long_pubc",  0);
    outlen = sizeof(out);
    DO(ecc_export_openssl(out, &outlen, PK_PRIVATE|PK_CURVEOID, &pri));
-   if (compare_testvector(out, outlen, short_pri, sizeof(short_pri),  "e-short_pri",  0)) return CRYPT_ERROR;
+   COMPARE_TESTVECTOR(out, outlen, short_pri, sizeof(short_pri),  "e-short_pri",  0);
    outlen = sizeof(out);
    DO(ecc_export_openssl(out, &outlen, PK_PRIVATE|PK_CURVEOID|PK_COMPRESSED, &pri));
-   if (compare_testvector(out, outlen, short_pric, sizeof(short_pric), "e-short_pric", 0)) return CRYPT_ERROR;
+   COMPARE_TESTVECTOR(out, outlen, short_pric, sizeof(short_pric), "e-short_pric", 0);
    outlen = sizeof(out);
    DO(ecc_export_openssl(out, &outlen, PK_PUBLIC|PK_CURVEOID,  &pub));
-   if (compare_testvector(out, outlen, short_pub, sizeof(short_pub),  "e-short_pub",  0)) return CRYPT_ERROR;
+   COMPARE_TESTVECTOR(out, outlen, short_pub, sizeof(short_pub),  "e-short_pub",  0);
    outlen = sizeof(out);
    DO(ecc_export_openssl(out, &outlen, PK_PUBLIC|PK_CURVEOID|PK_COMPRESSED, &pub));
-   if (compare_testvector(out, outlen, short_pubc, sizeof(short_pubc), "e-short_pubc", 0)) return CRYPT_ERROR;
+   COMPARE_TESTVECTOR(out, outlen, short_pubc, sizeof(short_pubc), "e-short_pubc", 0);
 
    /* export - raw keys */
    outlen = sizeof(out);
    DO(ecc_get_key(out, &outlen, PK_PRIVATE, &pri));
-   if (compare_testvector(out, outlen, raw_pri, sizeof(raw_pri),    "e-raw_pri",    0)) return CRYPT_ERROR;
+   COMPARE_TESTVECTOR(out, outlen, raw_pri, sizeof(raw_pri),    "e-raw_pri",    0);
    outlen = sizeof(out);
    DO(ecc_get_key(out, &outlen, PK_PUBLIC, &pub));
-   if (compare_testvector(out, outlen, raw_pub, sizeof(raw_pub),    "e-raw_pub",    0)) return CRYPT_ERROR;
+   COMPARE_TESTVECTOR(out, outlen, raw_pub, sizeof(raw_pub),    "e-raw_pub",    0);
    outlen = sizeof(out);
    DO(ecc_get_key(out, &outlen, PK_PUBLIC|PK_COMPRESSED, &pub));
-   if (compare_testvector(out, outlen, raw_pubc, sizeof(raw_pubc),   "e-raw_pubc",   0)) return CRYPT_ERROR;
+   COMPARE_TESTVECTOR(out, outlen, raw_pubc, sizeof(raw_pubc),   "e-raw_pubc",   0);
 
    ecc_free(&pri);
    ecc_free(&pub);

+ 25 - 36
tests/modes_test.c

@@ -27,7 +27,6 @@ static const struct {
 
 int modes_test(void)
 {
-   int ret = CRYPT_NOP;
 #ifdef LTC_CBC_MODE
    symmetric_CBC cbc;
 #endif
@@ -50,57 +49,47 @@ int modes_test(void)
    ENSURE(yarrow_read(iv,  16, &yarrow_prng) == 16);
 
    /* get idx of AES handy */
-   cipher_idx = find_cipher("aes");
-   if (cipher_idx == -1) {
-      fprintf(stderr, "test requires AES");
-      return 1;
-   }
+   ENSURE((cipher_idx = find_cipher("aes")) != -1);
 #endif
 
 #ifdef LTC_F8_MODE
-   DO(ret = f8_test_mode());
+   DO(f8_test_mode());
 #endif
 
 #ifdef LTC_LRW_MODE
-   DO(ret = lrw_test());
+   DO(lrw_test());
 #endif
 
 #ifdef LTC_CBC_MODE
    /* test CBC mode */
    /* encode the block */
-   DO(ret = cbc_start(cipher_idx, iv, key, 16, 0, &cbc));
+   DO(cbc_start(cipher_idx, iv, key, 16, 0, &cbc));
    l = sizeof(iv2);
-   DO(ret = cbc_getiv(iv2, &l, &cbc));
-   if (l != 16 || memcmp(iv2, iv, 16)) {
-      fprintf(stderr, "cbc_getiv failed");
-      return 1;
-   }
-   DO(ret = cbc_encrypt(pt, ct, 64, &cbc));
+   DO(cbc_getiv(iv2, &l, &cbc));
+   COMPARE_TESTVECTOR(iv2, l, iv, 16, "cbc_getiv", 0);
+   DO(cbc_encrypt(pt, ct, 64, &cbc));
 
    /* decode the block */
-   DO(ret = cbc_setiv(iv2, l, &cbc));
+   DO(cbc_setiv(iv2, l, &cbc));
    zeromem(tmp, sizeof(tmp));
-   DO(ret = cbc_decrypt(ct, tmp, 64, &cbc));
-   if (memcmp(tmp, pt, 64) != 0) {
-      fprintf(stderr, "CBC failed");
-      return 1;
-   }
+   DO(cbc_decrypt(ct, tmp, 64, &cbc));
+   COMPARE_TESTVECTOR(pt, 64, tmp, 64, "CBC", 0);
 #endif
 
 #ifdef LTC_CFB_MODE
    /* test CFB mode */
    /* encode the block */
-   DO(ret = cfb_start(cipher_idx, iv, key, 16, 0, &cfb));
+   DO(cfb_start(cipher_idx, iv, key, 16, 0, &cfb));
    l = sizeof(iv2);
-   DO(ret = cfb_getiv(iv2, &l, &cfb));
+   DO(cfb_getiv(iv2, &l, &cfb));
    /* note we don't memcmp iv2/iv since cfb_start processes the IV for the first block */
    ENSURE(l == 16);
-   DO(ret = cfb_encrypt(pt, ct, 64, &cfb));
+   DO(cfb_encrypt(pt, ct, 64, &cfb));
 
    /* decode the block */
-   DO(ret = cfb_setiv(iv, l, &cfb));
+   DO(cfb_setiv(iv, l, &cfb));
    zeromem(tmp, sizeof(tmp));
-   DO(ret = cfb_decrypt(ct, tmp, 64, &cfb));
+   DO(cfb_decrypt(ct, tmp, 64, &cfb));
    COMPARE_TESTVECTOR(tmp, 64, pt, 64, "cfb128-enc-dec", 0);
    cfb_done(&cfb);
    XMEMSET(&cfb, 0, sizeof(cfb));
@@ -118,10 +107,10 @@ int modes_test(void)
       l = sizeof(iv2);
       DO(cfb_getiv(iv2, &l, &cfb));
       ENSURE(l == 16);
-      DO(ret = cfb_encrypt(pt, tmp, 2, &cfb));
+      DO(cfb_encrypt(pt, tmp, 2, &cfb));
       COMPARE_TESTVECTOR(tmp, 2, ct, 2, "cfb-enc", n);
       DO(cfb_setiv(iv2, l, &cfb));
-      DO(ret = cfb_decrypt(tmp, tmp2, 2, &cfb));
+      DO(cfb_decrypt(tmp, tmp2, 2, &cfb));
       COMPARE_TESTVECTOR(tmp2, 2, pt, 2, "cfb-dec", n);
    }
 #endif
@@ -129,25 +118,25 @@ int modes_test(void)
 #ifdef LTC_OFB_MODE
    /* test OFB mode */
    /* encode the block */
-   DO(ret = ofb_start(cipher_idx, iv, key, 16, 0, &ofb));
+   DO(ofb_start(cipher_idx, iv, key, 16, 0, &ofb));
    l = sizeof(iv2);
    DO(ofb_getiv(iv2, &l, &ofb));
-   DO(do_compare_testvector(iv2, l, iv, 16, "ofb_getiv", 0));
-   DO(ret = ofb_encrypt(pt, ct, 64, &ofb));
+   COMPARE_TESTVECTOR(iv2, l, iv, 16, "ofb_getiv", 0);
+   DO(ofb_encrypt(pt, ct, 64, &ofb));
 
    /* decode the block */
-   DO(ret = ofb_setiv(iv2, l, &ofb));
+   DO(ofb_setiv(iv2, l, &ofb));
    zeromem(tmp, sizeof(tmp));
-   DO(ret = ofb_decrypt(ct, tmp, 64, &ofb));
-   DO(do_compare_testvector(tmp, 64, pt, 64, "OFB", 0));
+   DO(ofb_decrypt(ct, tmp, 64, &ofb));
+   COMPARE_TESTVECTOR(tmp, 64, pt, 64, "OFB", 0);
 #endif
 
 #if defined(LTC_CTR_MODE) && defined(LTC_RIJNDAEL)
-   DO(ret = ctr_test());
+   DO(ctr_test());
 #endif
 
 #ifdef LTC_XTS_MODE
-   DO(ret = xts_test());
+   DO(xts_test());
 #endif
 
    return 0;

+ 1 - 3
tests/prng_test.c

@@ -101,9 +101,7 @@ int prng_test(void)
    }
    DO(fortuna_done(&nprng));
 
-   if (compare_testvector(buf + 64, 32, buf + 32, 32, "fortuna_add_entropy() vs. fortuna_add_random_event()", 0) != 0) {
-      err = CRYPT_FAIL_TESTVECTOR;
-   }
+   COMPARE_TESTVECTOR(buf + 64, 32, buf + 32, 32, "fortuna_add_entropy() vs. fortuna_add_random_event()", 0);
 #endif
    return err;
 }

+ 3 - 5
tests/x25519_test.c

@@ -51,9 +51,7 @@ static int s_rfc_7748_5_2_test(void)
 
    for (n = 0; n < LTC_ARRAY_SIZE(rfc_7748_5_2); ++n) {
       tweetnacl_crypto_scalarmult(out, rfc_7748_5_2[n].scalar, rfc_7748_5_2[n].u_in);
-      if (compare_testvector(out, sizeof(out), rfc_7748_5_2[n].u_out, sizeof(rfc_7748_5_2[n].u_out), "x25519 RFC 7748 Ch. 5.2", n) != 0) {
-         return CRYPT_FAIL_TESTVECTOR;
-      }
+      COMPARE_TESTVECTOR(out, sizeof(out), rfc_7748_5_2[n].u_out, sizeof(rfc_7748_5_2[n].u_out), "x25519 RFC 7748 Ch. 5.2", n);
    }
    return CRYPT_OK;
 }
@@ -101,12 +99,12 @@ static int s_rfc_7748_6_test(void)
    DO(x25519_import_raw(bob_public, sizeof(bob_public), PK_PUBLIC, &bob_pub));
 
    DO(x25519_shared_secret(&alice_priv, &bob_pub, buf, &buflen));
-   DO(compare_testvector(buf, buflen, shared_secret, sizeof(shared_secret), "x25519 - RFC 7748 Ch. 6", 0));
+   COMPARE_TESTVECTOR(buf, buflen, shared_secret, sizeof(shared_secret), "x25519 - RFC 7748 Ch. 6", 0);
 
    XMEMSET(buf, 0, sizeof(buf));
 
    DO(x25519_shared_secret(&bob_priv, &alice_pub, buf, &buflen));
-   DO(compare_testvector(buf, buflen, shared_secret, sizeof(shared_secret), "x25519 - RFC 7748 Ch. 6", 1));
+   COMPARE_TESTVECTOR(buf, buflen, shared_secret, sizeof(shared_secret), "x25519 - RFC 7748 Ch. 6", 1);
 
    return CRYPT_OK;
 }