فهرست منبع

Use `COMPARE_TESTVECTOR()` consistently

Signed-off-by: Steffen Jaeckel <[email protected]>
Steffen Jaeckel 3 ماه پیش
والد
کامیت
6155a33e5f
13فایلهای تغییر یافته به همراه71 افزوده شده و 71 حذف شده
  1. 3 3
      tests/base16_test.c
  2. 3 3
      tests/base32_test.c
  3. 13 13
      tests/base64_test.c
  4. 1 1
      tests/bcrypt_test.c
  5. 2 2
      tests/der_test.c
  6. 11 11
      tests/dh_test.c
  7. 3 3
      tests/dsa_test.c
  8. 1 1
      tests/ecc_test.c
  9. 6 6
      tests/ed25519_test.c
  10. 10 10
      tests/file_test.c
  11. 4 4
      tests/mpi_test.c
  12. 11 11
      tests/rsa_test.c
  13. 3 3
      tests/x25519_test.c

+ 3 - 3
tests/base16_test.c

@@ -25,17 +25,17 @@ int base16_test(void)
          DO(base16_encode(in, x, out, &l1, idx));
          l2 = sizeof(tmp);
          DO(base16_decode(out, l1, tmp, &l2));
-         DO(do_compare_testvector(tmp, l2, in, x, "random base16", idx * 100 + x));
+         COMPARE_TESTVECTOR(tmp, l2, in, x, "random base16", idx * 100 + x);
       }
    }
 
    for (idx = 0; idx < 2; idx++) {
       l1 = sizeof(out);
       DO(base16_encode(testin, sizeof(testin), out, &l1, idx));
-      DO(do_compare_testvector(out, XSTRLEN(out), testout[idx], XSTRLEN(testout[idx]), "testout base16", idx));
+      COMPARE_TESTVECTOR(out, XSTRLEN(out), testout[idx], XSTRLEN(testout[idx]), "testout base16", idx);
       l2 = sizeof(tmp);
       DO(base16_decode(out, l1, tmp, &l2));
-      DO(do_compare_testvector(tmp, l2, testin, sizeof(testin), "testin base16", idx));
+      COMPARE_TESTVECTOR(tmp, l2, testin, sizeof(testin), "testin base16", idx);
    }
 
    l1 = 4;

+ 3 - 3
tests/base32_test.c

@@ -32,17 +32,17 @@ int base32_test(void)
          DO(base32_encode(in, x, out, &l1, testid[idx]));
          l2 = sizeof(tmp);
          DO(base32_decode(out, l1, tmp, &l2, testid[idx]));
-         DO(do_compare_testvector(tmp, l2, in, x, "random base32", idx * 100 + x));
+         COMPARE_TESTVECTOR(tmp, l2, in, x, "random base32", idx * 100 + x);
       }
    }
 
    for (idx = 0; idx < 4; idx++) {
       l1 = sizeof(out);
       DO(base32_encode(testin, sizeof(testin), out, &l1, testid[idx]));
-      DO(do_compare_testvector(out, l1, testout[idx], XSTRLEN(testout[idx]), "testout base32", idx));
+      COMPARE_TESTVECTOR(out, l1, testout[idx], XSTRLEN(testout[idx]), "testout base32", idx);
       l2 = sizeof(tmp);
       DO(base32_decode(out, l1, tmp, &l2, testid[idx]));
-      DO(do_compare_testvector(tmp, l2, testin, sizeof(testin), "testin base32", idx));
+      COMPARE_TESTVECTOR(tmp, l2, testin, sizeof(testin), "testin base32", idx);
    }
 
    return CRYPT_OK;

+ 13 - 13
tests/base64_test.c

@@ -76,24 +76,24 @@ int base64_test(void)
        l1 = sizeof(tmp);
        if(url_cases[x].flag == strict) {
           DO(base64url_strict_decode(url_cases[x].s, slen1, tmp, &l1));
-          DO(do_compare_testvector(tmp, l1, special_case, sizeof(special_case) - 1, "base64url_strict_decode", x));
+          COMPARE_TESTVECTOR(tmp, l1, special_case, sizeof(special_case) - 1, "base64url_strict_decode", x);
           DO(base64url_sane_decode(url_cases[x].s, slen1, tmp, &l1));
-          DO(do_compare_testvector(tmp, l1, special_case, sizeof(special_case) - 1, "base64url_sane_decode/strict", x));
+          COMPARE_TESTVECTOR(tmp, l1, special_case, sizeof(special_case) - 1, "base64url_sane_decode/strict", x);
           DO(base64url_decode(url_cases[x].s, slen1, tmp, &l1));
-          DO(do_compare_testvector(tmp, l1, special_case, sizeof(special_case) - 1, "base64url_decode/strict", x));
+          COMPARE_TESTVECTOR(tmp, l1, special_case, sizeof(special_case) - 1, "base64url_decode/strict", x);
        }
        else if(url_cases[x].flag == relaxed) {
           DO(base64url_strict_decode(url_cases[x].s, slen1, tmp, &l1) == CRYPT_INVALID_PACKET ? CRYPT_OK : CRYPT_FAIL_TESTVECTOR);
           DO(base64url_sane_decode(url_cases[x].s, slen1, tmp, &l1));
-          DO(do_compare_testvector(tmp, l1, special_case, sizeof(special_case) - 1, "base64url_sane_decode/relaxed", x));
+          COMPARE_TESTVECTOR(tmp, l1, special_case, sizeof(special_case) - 1, "base64url_sane_decode/relaxed", x);
           DO(base64url_decode(url_cases[x].s, slen1, tmp, &l1));
-          DO(do_compare_testvector(tmp, l1, special_case, sizeof(special_case) - 1, "base64url_decode/relaxed", x));
+          COMPARE_TESTVECTOR(tmp, l1, special_case, sizeof(special_case) - 1, "base64url_decode/relaxed", x);
        }
        else if(url_cases[x].flag == insane) {
           DO(base64url_strict_decode(url_cases[x].s, slen1, tmp, &l1) == CRYPT_INVALID_PACKET ? CRYPT_OK : CRYPT_FAIL_TESTVECTOR);
           DO(base64url_sane_decode(url_cases[x].s, slen1, tmp, &l1) == CRYPT_INVALID_PACKET ? CRYPT_OK : CRYPT_FAIL_TESTVECTOR);
           DO(base64url_decode(url_cases[x].s, slen1, tmp, &l1));
-          DO(do_compare_testvector(tmp, l1, special_case, sizeof(special_case) - 1, "base64url_decode/insane", x));
+          COMPARE_TESTVECTOR(tmp, l1, special_case, sizeof(special_case) - 1, "base64url_decode/insane", x);
        }
        else { /* invalid */
           DO(base64url_strict_decode(url_cases[x].s, slen1, tmp, &l1) == CRYPT_INVALID_PACKET ? CRYPT_OK : CRYPT_FAIL_TESTVECTOR);
@@ -103,11 +103,11 @@ int base64_test(void)
        l2 = sizeof(out);
        if(x == 0) {
           DO(base64url_encode(tmp, l1, out, &l2));
-          DO(do_compare_testvector(out, l2, url_cases[x].s, XSTRLEN(url_cases[x].s), "base64url_encode", x));
+          COMPARE_TESTVECTOR(out, l2, url_cases[x].s, XSTRLEN(url_cases[x].s), "base64url_encode", x);
        }
        if(x == 1) {
           DO(base64url_strict_encode(tmp, l1, out, &l2));
-          DO(do_compare_testvector(out, l2, url_cases[x].s, XSTRLEN(url_cases[x].s), "base64url_strict_encode", x));
+          COMPARE_TESTVECTOR(out, l2, url_cases[x].s, XSTRLEN(url_cases[x].s), "base64url_strict_encode", x);
        }
    }
 #endif
@@ -119,14 +119,14 @@ int base64_test(void)
        slen1 = XSTRLEN(cases[x].s);
        l1 = sizeof(out);
        DO(base64_encode((unsigned char*)cases[x].s, slen1, out, &l1));
-       DO(do_compare_testvector(out, l1, cases[x].b64, XSTRLEN(cases[x].b64), "base64_encode", x));
+       COMPARE_TESTVECTOR(out, l1, cases[x].b64, XSTRLEN(cases[x].b64), "base64_encode", x);
        l2 = sizeof(tmp);
        DO(base64_strict_decode(out, l1, tmp, &l2));
-       DO(do_compare_testvector(tmp, l2, cases[x].s, slen1, "base64_strict_decode", x));
+       COMPARE_TESTVECTOR(tmp, l2, cases[x].s, slen1, "base64_strict_decode", x);
        DO(base64_sane_decode(out, l1, tmp, &l2));
-       DO(do_compare_testvector(tmp, l2, cases[x].s, slen1, "base64_sane_decode", x));
+       COMPARE_TESTVECTOR(tmp, l2, cases[x].s, slen1, "base64_sane_decode", x);
        DO(base64_decode(out, l1, tmp, &l2));
-       DO(do_compare_testvector(tmp, l2, cases[x].s, slen1, "base64_decode", x));
+       COMPARE_TESTVECTOR(tmp, l2, cases[x].s, slen1, "base64_decode", x);
    }
 
    for  (x = 0; x < 64; x++) {
@@ -135,7 +135,7 @@ int base64_test(void)
        DO(base64_encode(in, x, out, &l1));
        l2 = sizeof(tmp);
        DO(base64_decode(out, l1, tmp, &l2));
-       DO(do_compare_testvector(tmp, x, in, x, "random base64", x));
+       COMPARE_TESTVECTOR(tmp, x, in, x, "random base64", x);
    }
 
    x--;

+ 1 - 1
tests/bcrypt_test.c

@@ -125,7 +125,7 @@ int bcrypt_test(void)
       l = t->keylen;
       XMEMSET(key, 0, sizeof(key));
       DO(bcrypt_pbkdf_openbsd(t->password, t->passlen, (unsigned char*)t->salt, t->saltlen, t->rounds, idx, key, &l));
-      DO(do_compare_testvector(key, l, t->key, t->keylen, "OpenBSD testvectors", i));
+      COMPARE_TESTVECTOR(key, l, t->key, t->keylen, "OpenBSD testvectors", i);
 
 #if defined(LTC_TEST_DBG) && LTC_TEST_DBG > 1
       printf("BCRYPT test #%d OK\n", i);

+ 2 - 2
tests/der_test.c

@@ -733,7 +733,7 @@ static void s_der_oid_test(void)
    DO(der_encode_object_identifier(decoded_list->data, decoded_list->size, buf, &len));
    der_sequence_free(decoded_list);
 
-   DO(do_compare_testvector(buf, len, oid_x690_8_19_5_example, sizeof(oid_x690_8_19_5_example), "OID X6.90 Ch. 8.19.5 Example", 0));
+   COMPARE_TESTVECTOR(buf, len, oid_x690_8_19_5_example, sizeof(oid_x690_8_19_5_example), "OID X6.90 Ch. 8.19.5 Example", 0);
 
    oid[0] = 3;
    oid[1] = 4;
@@ -1295,7 +1295,7 @@ static void der_Xcode_run(const der_Xcode_t* x)
       d2 = XREALLOC(d2, l2 * x->type_sz);
    }
    DO(x->decode(d1, l1, d2, &l2));
-   DO(do_compare_testvector(d2, (l2/x->factor) * x->type_sz, x->in, x->in_sz, x->what, __LINE__));
+   COMPARE_TESTVECTOR(d2, (l2/x->factor) * x->type_sz, x->in, x->in_sz, x->what, __LINE__);
    XFREE(d2);
    XFREE(d1);
 }

+ 11 - 11
tests/dh_test.c

@@ -125,7 +125,7 @@ static int s_dhparam_test(void)
       return CRYPT_ERROR;
    }
    DO(ltc_mp_to_unsigned_bin(k.prime, buf));
-   DO(do_compare_testvector(buf, sizeof(prime), prime, sizeof(prime), "dhparam_test: prime mismatch", 1));
+   COMPARE_TESTVECTOR(buf, sizeof(prime), prime, sizeof(prime), "dhparam_test: prime mismatch", 1);
    if (ltc_mp_cmp_d(k.base, 2) != LTC_MP_EQ) {
       printf("dhparam_test: base mismatch\n");
       dh_free(&k);
@@ -259,16 +259,16 @@ static int s_set_test(void)
 
       len = sizeof(buf);
       DO(dh_export(buf, &len, PK_PRIVATE, &k1));
-      DO(do_compare_testvector(buf, len, export_private, sizeof(export_private), "radix_test: dh_export+PK_PRIVATE mismatch", i*10 + 0));
+      COMPARE_TESTVECTOR(buf, len, export_private, sizeof(export_private), "radix_test: dh_export+PK_PRIVATE mismatch", i*10 + 0);
       len = sizeof(buf);
       DO(dh_export(buf, &len, PK_PUBLIC, &k1));
-      DO(do_compare_testvector(buf, len, export_public, sizeof(export_public), "radix_test: dh_export+PK_PUBLIC mismatch", i*10 + 1));
+      COMPARE_TESTVECTOR(buf, len, export_public, sizeof(export_public), "radix_test: dh_export+PK_PUBLIC mismatch", i*10 + 1);
       len = sizeof(buf);
       DO(dh_export_key(buf, &len, PK_PRIVATE, &k1));
-      DO(do_compare_testvector(buf, len, xbin, sizeof(xbin), "radix_test: dh_export+PK_PRIVATE mismatch", i*10 + 2));
+      COMPARE_TESTVECTOR(buf, len, xbin, sizeof(xbin), "radix_test: dh_export+PK_PRIVATE mismatch", i*10 + 2);
       len = sizeof(buf);
       DO(dh_export_key(buf, &len, PK_PUBLIC, &k1));
-      DO(do_compare_testvector(buf, len, ybin, sizeof(ybin), "radix_test: dh_export+PK_PUBLIC mismatch", i*10 + 3));
+      COMPARE_TESTVECTOR(buf, len, ybin, sizeof(ybin), "radix_test: dh_export+PK_PUBLIC mismatch", i*10 + 3);
       dh_free(&k1);
 
       DO(dh_set_pg(test[i].p, test[i].plen, test[i].g, test[i].glen, &k1));
@@ -276,10 +276,10 @@ static int s_set_test(void)
 
       len = sizeof(buf);
       DO(dh_export(buf, &len, PK_PRIVATE, &k1));
-      DO(do_compare_testvector(buf, len, export_private, sizeof(export_private), "radix_test: dh_export+PK_PRIVATE mismatc", i*10 + 4));
+      COMPARE_TESTVECTOR(buf, len, export_private, sizeof(export_private), "radix_test: dh_export+PK_PRIVATE mismatc", i*10 + 4);
       len = sizeof(buf);
       DO(dh_export(buf, &len, PK_PUBLIC, &k1));
-      DO(do_compare_testvector(buf, len, export_public, sizeof(export_public), "radix_test: dh_export+PK_PUBLIC mismatch", i*10 + 5));
+      COMPARE_TESTVECTOR(buf, len, export_public, sizeof(export_public), "radix_test: dh_export+PK_PUBLIC mismatch", i*10 + 5);
       dh_free(&k1);
 
       DO(dh_set_pg(test[i].p, test[i].plen, test[i].g, test[i].glen, &k2));
@@ -287,10 +287,10 @@ static int s_set_test(void)
 
       len = sizeof(buf);
       DO(dh_export(buf, &len, PK_PUBLIC, &k2));
-      DO(do_compare_testvector(buf, len, export_public, sizeof(export_public), "radix_test: dh_export+PK_PUBLIC mismatch", i*10 + 6));
+      COMPARE_TESTVECTOR(buf, len, export_public, sizeof(export_public), "radix_test: dh_export+PK_PUBLIC mismatch", i*10 + 6);
       len = sizeof(buf);
       DO(dh_export_key(buf, &len, PK_PUBLIC, &k2));
-      DO(do_compare_testvector(buf, len, ybin, sizeof(ybin), "radix_test: dh_export+PK_PUBLIC mismatch", i*10 + 7));
+      COMPARE_TESTVECTOR(buf, len, ybin, sizeof(ybin), "radix_test: dh_export+PK_PUBLIC mismatch", i*10 + 7);
       dh_free(&k2);
 
       DO(dh_set_pg(test[i].p, test[i].plen, test[i].g, test[i].glen, &k3));
@@ -298,10 +298,10 @@ static int s_set_test(void)
 
       len = ltc_mp_unsigned_bin_size(k3.prime);
       DO(ltc_mp_to_unsigned_bin(k3.prime, buf));
-      DO(do_compare_testvector(buf, len, pbin, sizeof(pbin), "radix_test: dh_make_key_ex prime mismatch", i*10 + 8));
+      COMPARE_TESTVECTOR(buf, len, pbin, sizeof(pbin), "radix_test: dh_make_key_ex prime mismatch", i*10 + 8);
       len = ltc_mp_unsigned_bin_size(k3.base);
       DO(ltc_mp_to_unsigned_bin(k3.base, buf));
-      DO(do_compare_testvector(buf, len, gbin, sizeof(gbin), "radix_test: dh_make_key_ex base mismatch", i*10 + 9));
+      COMPARE_TESTVECTOR(buf, len, gbin, sizeof(gbin), "radix_test: dh_make_key_ex base mismatch", i*10 + 9);
       dh_free(&k3);
    }
 

+ 3 - 3
tests/dsa_test.c

@@ -151,12 +151,12 @@ static int s_dsa_compat_test(void)
 
   x = sizeof(tmp);
   DO(dsa_export(tmp, &x, PK_PRIVATE | PK_STD, &key));
-  DO(do_compare_testvector(tmp, x, ltc_dsa_private_test_key, sizeof(ltc_dsa_private_test_key),
+  COMPARE_TESTVECTOR(tmp, x, ltc_dsa_private_test_key, sizeof(ltc_dsa_private_test_key),
                          "DSA private export from dsa_import(priv_key)\n", __LINE__);
 
   x = sizeof(tmp);
   DO(dsa_export(tmp, &x, PK_PUBLIC | PK_STD, &key));
-  DO(do_compare_testvector(tmp, x, openssl_pub_dsa, sizeof(openssl_pub_dsa),
+  COMPARE_TESTVECTOR(tmp, x, openssl_pub_dsa, sizeof(openssl_pub_dsa),
                          "DSA public export from dsa_import(priv_key)\n", __LINE__);
   dsa_free(&key);
 
@@ -164,7 +164,7 @@ static int s_dsa_compat_test(void)
 
   x = sizeof(tmp);
   DO(dsa_export(tmp, &x, PK_PUBLIC | PK_STD, &key));
-  DO(do_compare_testvector(tmp, x, openssl_pub_dsa, sizeof(openssl_pub_dsa),
+  COMPARE_TESTVECTOR(tmp, x, openssl_pub_dsa, sizeof(openssl_pub_dsa),
                          "DSA public export from dsa_import(pub_key)\n", __LINE__);
   dsa_free(&key);
 

+ 1 - 1
tests/ecc_test.c

@@ -420,7 +420,7 @@ static int s_ecc_old_api(void)
       y = sizeof(buf[1]);
       DO(ecc_shared_secret (&userb, &usera, buf[1], &y));
 
-      DO(do_compare_testvector(buf[0], x, buf[1], y, "ecc Shared keys", s));
+      COMPARE_TESTVECTOR(buf[0], x, buf[1], y, "ecc Shared keys", s);
 
       /* now export userb */
       y = sizeof(buf[0]);

+ 6 - 6
tests/ed25519_test.c

@@ -92,7 +92,7 @@ static int s_rfc_8410_10_test(void)
          DO(ed25519_export(buf, &buflen, rfc_8410_10[n].type, &key));
          tmplen = sizeof(tmp);
          DO(base64_encode(buf, buflen, tmp, &tmplen));
-         DO(do_compare_testvector(tmp, tmplen, rfc_8410_10[n].b64, XSTRLEN(rfc_8410_10[n].b64), "Ed25519 export-import", n));
+         COMPARE_TESTVECTOR(tmp, tmplen, rfc_8410_10[n].b64, XSTRLEN(rfc_8410_10[n].b64), "Ed25519 export-import", n);
       }
    }
    return CRYPT_OK;
@@ -225,9 +225,9 @@ static int s_rfc_8032_7_1_test(void)
       DO(ed25519_import_raw(sec, slen, PK_PRIVATE, &key));
       buflen = sizeof(buf);
       DO(ed25519_sign(msg, mlen, buf, &buflen, &key));
-      DO(do_compare_testvector(buf, buflen, sig, siglen, "Ed25519 RFC8032 7.1 - sign", n));
+      COMPARE_TESTVECTOR(buf, buflen, sig, siglen, "Ed25519 RFC8032 7.1 - sign", n);
       DO(ed25519_verify(msg, mlen, sig, siglen, &ret, &key));
-      DO(do_compare_testvector(&ret, sizeof(ret), &should, sizeof(should), "Ed25519 RFC8032 7.1 - verify w/ privkey", n));
+      COMPARE_TESTVECTOR(&ret, sizeof(ret), &should, sizeof(should), "Ed25519 RFC8032 7.1 - verify w/ privkey", n);
 
       xor_shuffle(sig, siglen, 0x8u);
       DO( ed25519_verify(msg, mlen, sig, siglen, &ret, &key));
@@ -244,7 +244,7 @@ static int s_rfc_8032_7_1_test(void)
       DO(base16_decode(rfc_8032_7_1[n].signature, XSTRLEN(rfc_8032_7_1[n].signature), sig, &siglen));
       DO(ed25519_import_raw(pub, plen, PK_PUBLIC, &key2));
       DO(ed25519_verify(msg, mlen, sig, siglen, &ret, &key2));
-      DO(do_compare_testvector(&ret, sizeof(ret), &should, sizeof(should), "Ed25519 RFC8032 7.1 - verify w/ pubkey", n));
+      COMPARE_TESTVECTOR(&ret, sizeof(ret), &should, sizeof(should), "Ed25519 RFC8032 7.1 - verify w/ pubkey", n);
 
       zeromem(&key, sizeof(key));
       zeromem(&key2, sizeof(key2));
@@ -331,7 +331,7 @@ static int s_rfc_8032_7_2_test(void)
 
       DO(ed25519_import_raw(sec, slen, PK_PRIVATE, &key));
       DO(ed25519ctx_sign(msg, mlen, buf, &buflen, ctx, ctxlen, &key));
-      DO(do_compare_testvector(buf, buflen, sig, siglen, "Ed25519 RFC8032 7.2 - sign", n));
+      COMPARE_TESTVECTOR(buf, buflen, sig, siglen, "Ed25519 RFC8032 7.2 - sign", n);
       DO(ed25519ctx_verify(msg, mlen, buf, buflen, ctx, ctxlen, &ret, &key));
       ENSUREX(ret == should, "Ed25519 RFC8032 7.2 - verify w/ privkey");
 
@@ -389,7 +389,7 @@ static int s_rfc_8032_7_3_test(void)
 
    DO(ed25519_import_raw(sec, slen, PK_PRIVATE, &key));
    DO(ed25519ph_sign(msg, mlen, buf, &buflen, NULL, 0, &key));
-   DO(do_compare_testvector(buf, buflen, sig, siglen, "Ed25519 RFC8032 7.3 - sign", 0));
+   COMPARE_TESTVECTOR(buf, buflen, sig, siglen, "Ed25519 RFC8032 7.3 - sign", 0);
    DO(ed25519ph_verify(msg, mlen, buf, buflen, NULL, 0, &ret, &key));
    ENSUREX(ret == should, "Ed25519 RFC8032 7.3 - verify w/ privkey");
 

+ 10 - 10
tests/file_test.c

@@ -33,11 +33,11 @@ int file_test(void)
    err = hash_filehandle(isha256, in, buf, &len);
    fclose(in);
    DO(err);
-   DO(do_compare_testvector(buf, len, exp_sha256, 32, "hash_filehandle", 1));
+   COMPARE_TESTVECTOR(buf, len, exp_sha256, 32, "hash_filehandle", 1);
 
    len = sizeof(buf);
    DO(hash_file(isha256, fname, buf, &len));
-   DO(do_compare_testvector(buf, len, exp_sha256, 32, "hash_file", 1));
+   COMPARE_TESTVECTOR(buf, len, exp_sha256, 32, "hash_file", 1);
 
 #ifdef LTC_HMAC
    {
@@ -45,7 +45,7 @@ int file_test(void)
                                            0x8F, 0x68, 0xCF, 0xBA, 0x2E, 0xAD, 0xC4, 0x63, 0x9D, 0x7F, 0x02, 0x99, 0x8C, 0x08, 0xAC, 0xC0 };
       len = sizeof(buf);
       DO(hmac_file(isha256, fname, key, 32, buf, &len));
-      DO(do_compare_testvector(buf, len, exp_hmacsha256, 32, "hmac_file", 1));
+      COMPARE_TESTVECTOR(buf, len, exp_hmacsha256, 32, "hmac_file", 1);
    }
 #endif
 #ifdef LTC_OMAC
@@ -53,7 +53,7 @@ int file_test(void)
       unsigned char exp_omacaes[16]    = { 0x50, 0xB4, 0x6C, 0x62, 0xE9, 0xCA, 0x48, 0xFC, 0x38, 0x8D, 0xF4, 0xA2, 0x7D, 0x6A, 0x1E, 0xD8 };
       len = sizeof(buf);
       DO(omac_file(iaes, key, 32, fname, buf, &len));
-      DO(do_compare_testvector(buf, len, exp_omacaes, 16, "omac_file", 1));
+      COMPARE_TESTVECTOR(buf, len, exp_omacaes, 16, "omac_file", 1);
    }
 #endif
 #ifdef LTC_PMAC
@@ -61,7 +61,7 @@ int file_test(void)
       unsigned char exp_pmacaes[16]    = { 0x7D, 0x65, 0xF0, 0x75, 0x4F, 0x8D, 0xE2, 0xB0, 0xE4, 0xFA, 0x54, 0x4E, 0x45, 0x01, 0x36, 0x1B };
       len = sizeof(buf);
       DO(pmac_file(iaes, key, 32, fname, buf, &len));
-      DO(do_compare_testvector(buf, len, exp_pmacaes, 16, "pmac_file", 1));
+      COMPARE_TESTVECTOR(buf, len, exp_pmacaes, 16, "pmac_file", 1);
    }
 #endif
 #ifdef LTC_XCBC
@@ -69,7 +69,7 @@ int file_test(void)
       unsigned char exp_xcbcaes[16]    = { 0x9C, 0x73, 0xA2, 0xD7, 0x90, 0xA5, 0x86, 0x25, 0x4D, 0x3C, 0x8A, 0x6A, 0x24, 0x6D, 0xD1, 0xAB };
       len = sizeof(buf);
       DO(xcbc_file(iaes, key, 32, fname, buf, &len));
-      DO(do_compare_testvector(buf, len, exp_xcbcaes, 16, "xcbc_file", 1));
+      COMPARE_TESTVECTOR(buf, len, exp_xcbcaes, 16, "xcbc_file", 1);
    }
 #endif
 #ifdef LTC_F9_MODE
@@ -77,7 +77,7 @@ int file_test(void)
       unsigned char exp_f9aes[16]      = { 0x6B, 0x6A, 0x18, 0x34, 0x13, 0x8E, 0x01, 0xEF, 0x33, 0x8E, 0x7A, 0x3F, 0x5B, 0x9A, 0xA6, 0x7A };
       len = sizeof(buf);
       DO(f9_file(iaes, key, 32, fname, buf, &len));
-      DO(do_compare_testvector(buf, len, exp_f9aes, 16, "f9_file", 1));
+      COMPARE_TESTVECTOR(buf, len, exp_f9aes, 16, "f9_file", 1);
    }
 #endif
 #ifdef LTC_POLY1305
@@ -85,7 +85,7 @@ int file_test(void)
       unsigned char exp_poly1305[16]   = { 0xD0, 0xC7, 0xFB, 0x13, 0xA8, 0x87, 0x84, 0x23, 0x21, 0xCC, 0xA9, 0x43, 0x81, 0x18, 0x75, 0xBE };
       len = sizeof(buf);
       DO(poly1305_file(fname, key, 32, buf, &len));
-      DO(do_compare_testvector(buf, len, exp_poly1305, 16, "poly1305_file", 1));
+      COMPARE_TESTVECTOR(buf, len, exp_poly1305, 16, "poly1305_file", 1);
    }
 #endif
 #ifdef LTC_BLAKE2SMAC
@@ -93,7 +93,7 @@ int file_test(void)
       unsigned char exp_blake2smac[16]   = { 0x4f, 0x94, 0x45, 0x15, 0xcd, 0xd1, 0xca, 0x02, 0x1a, 0x0c, 0x7a, 0xe4, 0x6d, 0x2f, 0xe8, 0xb3 };
       len = 16;
       DO(blake2smac_file(fname, key, 32, buf, &len));
-      DO(do_compare_testvector(buf, len, exp_blake2smac, 16, "exp_blake2smac_file", 1));
+      COMPARE_TESTVECTOR(buf, len, exp_blake2smac, 16, "exp_blake2smac_file", 1);
    }
 #endif
 #ifdef LTC_BLAKE2BMAC
@@ -101,7 +101,7 @@ int file_test(void)
       unsigned char exp_blake2bmac[16]   = { 0xdf, 0x0e, 0x7a, 0xab, 0x96, 0x6b, 0x75, 0x4e, 0x52, 0x6a, 0x43, 0x96, 0xbd, 0xef, 0xab, 0x44 };
       len = 16;
       DO(blake2bmac_file(fname, key, 32, buf, &len));
-      DO(do_compare_testvector(buf, len, exp_blake2bmac, 16, "exp_blake2bmac_file", 1));
+      COMPARE_TESTVECTOR(buf, len, exp_blake2bmac, 16, "exp_blake2bmac_file", 1);
    }
 #endif
 

+ 4 - 4
tests/mpi_test.c

@@ -123,10 +123,10 @@ static int s_radix_to_bin_test(void)
       DO(radix_to_bin(test[i].p, test[i].radix, key_parts[2], &key_lens[2]));
       DO(radix_to_bin(test[i].g, test[i].radix, key_parts[3], &key_lens[3]));
 
-      DO(do_compare_testvector(key_parts[0], key_lens[0], test[0].x, test[0].xlen, "radix_to_bin(x)", i));
-      DO(do_compare_testvector(key_parts[1], key_lens[1], test[0].y, test[0].ylen, "radix_to_bin(y)", i));
-      DO(do_compare_testvector(key_parts[2], key_lens[2], test[0].p, test[0].plen, "radix_to_bin(p)", i));
-      DO(do_compare_testvector(key_parts[3], key_lens[3], test[0].g, test[0].glen, "radix_to_bin(g)", i));
+      COMPARE_TESTVECTOR(key_parts[0], key_lens[0], test[0].x, test[0].xlen, "radix_to_bin(x)", i);
+      COMPARE_TESTVECTOR(key_parts[1], key_lens[1], test[0].y, test[0].ylen, "radix_to_bin(y)", i);
+      COMPARE_TESTVECTOR(key_parts[2], key_lens[2], test[0].p, test[0].plen, "radix_to_bin(p)", i);
+      COMPARE_TESTVECTOR(key_parts[3], key_lens[3], test[0].g, test[0].glen, "radix_to_bin(g)", i);
    }
    return CRYPT_OK;
 }

+ 11 - 11
tests/rsa_test.c

@@ -207,32 +207,32 @@ static int rsa_compat_test(void)
    /* now try to export private/public and compare */
    len = sizeof(buf);
    DO(rsa_export(buf, &len, PK_PRIVATE, &key));
-   DO(do_compare_testvector(buf, len, ltc_rsa_private_test_key, sizeof(ltc_rsa_private_test_key), "RSA private export (from OpenSSL)", 0));
+   COMPARE_TESTVECTOR(buf, len, ltc_rsa_private_test_key, sizeof(ltc_rsa_private_test_key), "RSA private export (from OpenSSL)", 0);
 
    len = sizeof(buf);
    DO(rsa_export(buf, &len, PK_PUBLIC, &key));
-   DO(do_compare_testvector(buf, len, openssl_public_rsa_stripped, sizeof(openssl_public_rsa_stripped), "RSA public export (from OpenSSL private key)", 0));
+   COMPARE_TESTVECTOR(buf, len, openssl_public_rsa_stripped, sizeof(openssl_public_rsa_stripped), "RSA public export (from OpenSSL private key)", 0);
    rsa_free(&key);
 
    /* try reading the public key */
    DO(rsa_import(openssl_public_rsa_stripped, sizeof(openssl_public_rsa_stripped), &key));
    len = sizeof(buf);
    DO(rsa_export(buf, &len, PK_PUBLIC, &key));
-   DO(do_compare_testvector(buf, len, openssl_public_rsa_stripped, sizeof(openssl_public_rsa_stripped), "RSA public export (from stripped OpenSSL)", 0));
+   COMPARE_TESTVECTOR(buf, len, openssl_public_rsa_stripped, sizeof(openssl_public_rsa_stripped), "RSA public export (from stripped OpenSSL)", 0);
    rsa_free(&key);
 
    /* try reading the public key */
    DO(rsa_import(openssl_public_rsa, sizeof(openssl_public_rsa), &key));
    len = sizeof(buf);
    DO(rsa_export(buf, &len, PK_PUBLIC, &key));
-   DO(do_compare_testvector(buf, len, openssl_public_rsa_stripped, sizeof(openssl_public_rsa_stripped), "RSA public export (from OpenSSL)", 0));
+   COMPARE_TESTVECTOR(buf, len, openssl_public_rsa_stripped, sizeof(openssl_public_rsa_stripped), "RSA public export (from OpenSSL)", 0);
    rsa_free(&key);
 
    /* try import private key in pkcs8 format */
    DO(rsa_import_pkcs8(pkcs8_private_rsa, sizeof(pkcs8_private_rsa), NULL, &key));
    len = sizeof(buf);
    DO(rsa_export(buf, &len, PK_PRIVATE, &key));
-   DO(do_compare_testvector(buf, len, ltc_rsa_private_test_key, sizeof(ltc_rsa_private_test_key), "RSA private export (from PKCS#8)", 0));
+   COMPARE_TESTVECTOR(buf, len, ltc_rsa_private_test_key, sizeof(ltc_rsa_private_test_key), "RSA private export (from PKCS#8)", 0);
    rsa_free(&key);
 
    /* convert raw hexadecimal numbers to binary */
@@ -246,21 +246,21 @@ static int rsa_compat_test(void)
    DO(rsa_set_crt_params(key_parts[pk_dP], key_lens[pk_dP], key_parts[pk_dQ], key_lens[pk_dQ], key_parts[pk_qP], key_lens[pk_qP], &key));
    len = sizeof(buf);
    DO(rsa_export(buf, &len, PK_PRIVATE, &key));
-   DO(do_compare_testvector(buf, len, ltc_rsa_private_test_key, sizeof(ltc_rsa_private_test_key), "RSA private export (from hex)", 0));
+   COMPARE_TESTVECTOR(buf, len, ltc_rsa_private_test_key, sizeof(ltc_rsa_private_test_key), "RSA private export (from hex)", 0);
    rsa_free(&key);
 
    /* try import public key from converted raw hexadecimal numbers */
    DO(rsa_set_key(key_parts[pk_N], key_lens[pk_N], key_parts[pk_e], key_lens[pk_e], NULL, 0, &key));
    len = sizeof(buf);
    DO(rsa_export(buf, &len, PK_PUBLIC, &key));
-   DO(do_compare_testvector(buf, len, openssl_public_rsa_stripped, sizeof(openssl_public_rsa_stripped), "RSA public export (from hex)", 0));
+   COMPARE_TESTVECTOR(buf, len, openssl_public_rsa_stripped, sizeof(openssl_public_rsa_stripped), "RSA public export (from hex)", 0);
    rsa_free(&key);
 
    /* try export in SubjectPublicKeyInfo format of the public key */
    DO(rsa_import(openssl_public_rsa, sizeof(openssl_public_rsa), &key));
    len = sizeof(buf);
    DO(rsa_export(buf, &len, PK_PUBLIC | PK_STD, &key));
-   DO(do_compare_testvector(buf, len, openssl_public_rsa, sizeof(openssl_public_rsa),  "RSA public export (X.509)", 0));
+   COMPARE_TESTVECTOR(buf, len, openssl_public_rsa, sizeof(openssl_public_rsa),  "RSA public export (X.509)", 0);
    rsa_free(&key);
 
    return 0;
@@ -546,7 +546,7 @@ print_hex("q", tmp, len);
             len2 = rsa_msgsize;
             DO(rsa_decrypt_key_ex(out, len, tmp, &len2, NULL, 0, mgf_hash, label_hash, LTC_PKCS_1_OAEP, &stat, &key));
             ENSUREX(stat == 1 && stat2 == 0, "rsa_decrypt_key (without lparam)");
-            DO(do_compare_testvector(tmp, len2, in, rsa_msgsize,  "rsa_decrypt_key (without lparam)", cnt << 8 | rsa_msgsize));
+            COMPARE_TESTVECTOR(tmp, len2, in, rsa_msgsize,  "rsa_decrypt_key (without lparam)", cnt << 8 | rsa_msgsize);
          }
 
          /* encrypt the key (with lparam) */
@@ -565,7 +565,7 @@ print_hex("q", tmp, len);
             len2 = rsa_msgsize;
             DO(rsa_decrypt_key_ex(out, len, tmp, &len2, lparam, sizeof(lparam), mgf_hash, label_hash, LTC_PKCS_1_OAEP, &stat, &key));
             ENSURE(stat == 1 && stat2 == 0);
-            DO(do_compare_testvector(tmp, len2, in, rsa_msgsize,  "rsa_decrypt_key (with lparam)", rsa_msgsize));
+            COMPARE_TESTVECTOR(tmp, len2, in, rsa_msgsize,  "rsa_decrypt_key (with lparam)", rsa_msgsize);
          }
 
       }
@@ -582,7 +582,7 @@ print_hex("q", tmp, len);
       len2 = rsa_msgsize;
       DO(rsa_decrypt_key_ex(out, len, tmp, &len2, NULL, 0, 0, -1, LTC_PKCS_1_V1_5, &stat, &key));
       ENSURE(stat == 1);
-      DO(do_compare_testvector(tmp, len2, in, rsa_msgsize,  "rsa_decrypt_key_ex", rsa_msgsize));
+      COMPARE_TESTVECTOR(tmp, len2, in, rsa_msgsize,  "rsa_decrypt_key_ex", rsa_msgsize);
    }
 
    /* sign a message (unsalted, lower cholestorol and Atkins approved) now */

+ 3 - 3
tests/x25519_test.c

@@ -197,7 +197,7 @@ static int s_x25519_compat_test(void)
 
    DO(x25519_export(buf, &buflen, PK_PRIVATE | PK_STD, &priv));
    DO(x25519_import_pkcs8(buf, buflen, NULL, &imported));
-   DO(do_compare_testvector(&priv, sizeof(priv), &imported, sizeof(imported), "priv after ex-&import", __LINE__));
+   COMPARE_TESTVECTOR(&priv, sizeof(priv), &imported, sizeof(imported), "priv after ex-&import", __LINE__);
    XMEMSET(&imported, 0, sizeof(imported));
 
    buflen = sizeof(buf);
@@ -208,14 +208,14 @@ static int s_x25519_compat_test(void)
    DO(x25519_export(buf, &buflen, PK_PUBLIC | PK_STD, &priv));
    DO(x25519_import(buf, buflen, &imported));
 
-   DO(do_compare_testvector(&pub, sizeof(pub), &imported, sizeof(imported), "pub after private ex-&import", __LINE__));
+   COMPARE_TESTVECTOR(&pub, sizeof(pub), &imported, sizeof(imported), "pub after private ex-&import", __LINE__);
    XMEMSET(&imported, 0, sizeof(imported));
 
    buflen = sizeof(buf);
    DO(x25519_export(buf, &buflen, PK_PUBLIC | PK_STD, &pub));
    DO(x25519_import(buf, buflen, &imported));
 
-   DO(do_compare_testvector(&pub, sizeof(pub), &imported, sizeof(imported), "pub after public ex-&import", __LINE__));
+   COMPARE_TESTVECTOR(&pub, sizeof(pub), &imported, sizeof(imported), "pub after public ex-&import", __LINE__);
 
    return CRYPT_OK;
 }