diff --git a/t/t_hmac_sha1.c b/t/t_hmac_sha1.c index 84e36b3..3c0f81b 100644 --- a/t/t_hmac_sha1.c +++ b/t/t_hmac_sha1.c @@ -156,16 +156,7 @@ t_hmac_sha1_vector(char **desc CRYB_UNUSED, void *arg) t_hmac_sha1_complete(vector->key, vector->keylen, (const uint8_t *)vector->msg, strlen(vector->msg), mac); - if (memcmp(mac, vector->mac, HMAC_SHA1_MAC_LEN) != 0) { - t_verbose("expected "); - t_verbose_hex(vector->mac, HMAC_SHA1_MAC_LEN); - t_verbose("\n"); - t_verbose("got "); - t_verbose_hex(mac, HMAC_SHA1_MAC_LEN); - t_verbose("\n"); - return (0); - } - return (1); + return (t_compare_mem(vector->mac, mac, HMAC_SHA1_MAC_LEN)); } diff --git a/t/t_hmac_sha224.c b/t/t_hmac_sha224.c index a955fa5..92692cf 100644 --- a/t/t_hmac_sha224.c +++ b/t/t_hmac_sha224.c @@ -161,16 +161,7 @@ t_hmac_sha224_vector(char **desc CRYB_UNUSED, void *arg) t_hmac_sha224_complete(vector->key, vector->keylen, (const uint8_t *)vector->msg, strlen(vector->msg), mac); - if (memcmp(mac, vector->mac, HMAC_SHA224_MAC_LEN) != 0) { - t_verbose("expected "); - t_verbose_hex(vector->mac, HMAC_SHA224_MAC_LEN); - t_verbose("\n"); - t_verbose("got "); - t_verbose_hex(mac, HMAC_SHA224_MAC_LEN); - t_verbose("\n"); - return (0); - } - return (1); + return (t_compare_mem(vector->mac, mac, HMAC_SHA224_MAC_LEN)); } diff --git a/t/t_hmac_sha256.c b/t/t_hmac_sha256.c index 10d9e60..e8710ab 100644 --- a/t/t_hmac_sha256.c +++ b/t/t_hmac_sha256.c @@ -161,16 +161,7 @@ t_hmac_sha256_vector(char **desc CRYB_UNUSED, void *arg) t_hmac_sha256_complete(vector->key, vector->keylen, (const uint8_t *)vector->msg, strlen(vector->msg), mac); - if (memcmp(mac, vector->mac, HMAC_SHA256_MAC_LEN) != 0) { - t_verbose("expected "); - t_verbose_hex(vector->mac, HMAC_SHA256_MAC_LEN); - t_verbose("\n"); - t_verbose("got "); - t_verbose_hex(mac, HMAC_SHA256_MAC_LEN); - t_verbose("\n"); - return (0); - } - return (1); + return (t_compare_mem(vector->mac, mac, HMAC_SHA256_MAC_LEN)); } diff --git a/t/t_hmac_sha384.c b/t/t_hmac_sha384.c index 6ec6c22..086b825 100644 --- a/t/t_hmac_sha384.c +++ b/t/t_hmac_sha384.c @@ -171,16 +171,7 @@ t_hmac_sha384_vector(char **desc CRYB_UNUSED, void *arg) t_hmac_sha384_complete(vector->key, vector->keylen, (const uint8_t *)vector->msg, strlen(vector->msg), mac); - if (memcmp(mac, vector->mac, HMAC_SHA384_MAC_LEN) != 0) { - t_verbose("expected "); - t_verbose_hex(vector->mac, HMAC_SHA384_MAC_LEN); - t_verbose("\n"); - t_verbose("got "); - t_verbose_hex(mac, HMAC_SHA384_MAC_LEN); - t_verbose("\n"); - return (0); - } - return (1); + return (t_compare_mem(vector->mac, mac, HMAC_SHA384_MAC_LEN)); } diff --git a/t/t_hmac_sha512.c b/t/t_hmac_sha512.c index 3222dd7..e2666ad 100644 --- a/t/t_hmac_sha512.c +++ b/t/t_hmac_sha512.c @@ -181,16 +181,7 @@ t_hmac_sha512_vector(char **desc CRYB_UNUSED, void *arg) t_hmac_sha512_complete(vector->key, vector->keylen, (const uint8_t *)vector->msg, strlen(vector->msg), mac); - if (memcmp(mac, vector->mac, HMAC_SHA512_MAC_LEN) != 0) { - t_verbose("expected "); - t_verbose_hex(vector->mac, HMAC_SHA512_MAC_LEN); - t_verbose("\n"); - t_verbose("got "); - t_verbose_hex(mac, HMAC_SHA512_MAC_LEN); - t_verbose("\n"); - return (0); - } - return (1); + return (t_compare_mem(vector->mac, mac, HMAC_SHA512_MAC_LEN)); } diff --git a/t/t_md2.c b/t/t_md2.c index 609cfff..dad09be 100644 --- a/t/t_md2.c +++ b/t/t_md2.c @@ -141,16 +141,7 @@ t_md2_vector(char **desc CRYB_UNUSED, void *arg) uint8_t digest[MD2_DIGEST_LEN]; t_md2_complete(vector->msg, strlen(vector->msg), digest); - if (memcmp(digest, vector->digest, MD2_DIGEST_LEN) != 0) { - t_verbose("expected "); - t_verbose_hex(vector->digest, MD2_DIGEST_LEN); - t_verbose("\n"); - t_verbose("got "); - t_verbose_hex(digest, MD2_DIGEST_LEN); - t_verbose("\n"); - return (0); - } - return (1); + return (t_compare_mem(vector->digest, digest, MD2_DIGEST_LEN)); } diff --git a/t/t_md4.c b/t/t_md4.c index f163726..4640f2d 100644 --- a/t/t_md4.c +++ b/t/t_md4.c @@ -157,16 +157,7 @@ t_md4_vector(char **desc CRYB_UNUSED, void *arg) uint8_t digest[MD4_DIGEST_LEN]; t_md4_complete(vector->msg, strlen(vector->msg), digest); - if (memcmp(digest, vector->digest, MD4_DIGEST_LEN) != 0) { - t_verbose("expected "); - t_verbose_hex(vector->digest, MD4_DIGEST_LEN); - t_verbose("\n"); - t_verbose("got "); - t_verbose_hex(digest, MD4_DIGEST_LEN); - t_verbose("\n"); - return (0); - } - return (1); + return (t_compare_mem(vector->digest, digest, MD4_DIGEST_LEN)); } diff --git a/t/t_md5.c b/t/t_md5.c index 45cfc2f..212d285 100644 --- a/t/t_md5.c +++ b/t/t_md5.c @@ -157,16 +157,7 @@ t_md5_vector(char **desc CRYB_UNUSED, void *arg) uint8_t digest[MD5_DIGEST_LEN]; t_md5_complete(vector->msg, strlen(vector->msg), digest); - if (memcmp(digest, vector->digest, MD5_DIGEST_LEN) != 0) { - t_verbose("expected "); - t_verbose_hex(vector->digest, MD5_DIGEST_LEN); - t_verbose("\n"); - t_verbose("got "); - t_verbose_hex(digest, MD5_DIGEST_LEN); - t_verbose("\n"); - return (0); - } - return (1); + return (t_compare_mem(vector->digest, digest, MD5_DIGEST_LEN)); } diff --git a/t/t_sha1.c b/t/t_sha1.c index c79feb6..2a9ff33 100644 --- a/t/t_sha1.c +++ b/t/t_sha1.c @@ -154,16 +154,7 @@ t_sha1_vector(char **desc CRYB_UNUSED, void *arg) t_sha1_complete(msg, 1000000, digest); free(msg); } - if (memcmp(digest, vector->digest, SHA1_DIGEST_LEN) != 0) { - t_verbose("expected "); - t_verbose_hex(vector->digest, SHA1_DIGEST_LEN); - t_verbose("\n"); - t_verbose("got "); - t_verbose_hex(digest, SHA1_DIGEST_LEN); - t_verbose("\n"); - return (0); - } - return (1); + return (t_compare_mem(vector->digest, digest, SHA1_DIGEST_LEN)); } diff --git a/t/t_sha224.c b/t/t_sha224.c index 97d85aa..22300f8 100644 --- a/t/t_sha224.c +++ b/t/t_sha224.c @@ -163,16 +163,7 @@ t_sha224_vector(char **desc CRYB_UNUSED, void *arg) t_sha224_complete(msg, 1000000, digest); free(msg); } - if (memcmp(digest, vector->digest, SHA224_DIGEST_LEN) != 0) { - t_verbose("expected "); - t_verbose_hex(vector->digest, SHA224_DIGEST_LEN); - t_verbose("\n"); - t_verbose("got "); - t_verbose_hex(digest, SHA224_DIGEST_LEN); - t_verbose("\n"); - return (0); - } - return (1); + return (t_compare_mem(vector->digest, digest, SHA224_DIGEST_LEN)); } diff --git a/t/t_sha256.c b/t/t_sha256.c index abfecae..53aea45 100644 --- a/t/t_sha256.c +++ b/t/t_sha256.c @@ -159,16 +159,7 @@ t_sha256_vector(char **desc CRYB_UNUSED, void *arg) t_sha256_complete(msg, 1000000, digest); free(msg); } - if (memcmp(digest, vector->digest, SHA256_DIGEST_LEN) != 0) { - t_verbose("expected "); - t_verbose_hex(vector->digest, SHA256_DIGEST_LEN); - t_verbose("\n"); - t_verbose("got "); - t_verbose_hex(digest, SHA256_DIGEST_LEN); - t_verbose("\n"); - return (0); - } - return (1); + return (t_compare_mem(vector->digest, digest, SHA256_DIGEST_LEN)); } diff --git a/t/t_sha384.c b/t/t_sha384.c index b175cc9..be9efa9 100644 --- a/t/t_sha384.c +++ b/t/t_sha384.c @@ -170,16 +170,7 @@ t_sha384_vector(char **desc CRYB_UNUSED, void *arg) t_sha384_complete(msg, 1000000, digest); free(msg); } - if (memcmp(digest, vector->digest, SHA384_DIGEST_LEN) != 0) { - t_verbose("expected "); - t_verbose_hex(vector->digest, SHA384_DIGEST_LEN); - t_verbose("\n"); - t_verbose("got "); - t_verbose_hex(digest, SHA384_DIGEST_LEN); - t_verbose("\n"); - return (0); - } - return (1); + return (t_compare_mem(vector->digest, digest, SHA384_DIGEST_LEN)); } diff --git a/t/t_sha512.c b/t/t_sha512.c index cb01ceb..2407a34 100644 --- a/t/t_sha512.c +++ b/t/t_sha512.c @@ -180,16 +180,7 @@ t_sha512_vector(char **desc CRYB_UNUSED, void *arg) t_sha512_complete(msg, 1000000, digest); free(msg); } - if (memcmp(digest, vector->digest, SHA512_DIGEST_LEN) != 0) { - t_verbose("expected "); - t_verbose_hex(vector->digest, SHA512_DIGEST_LEN); - t_verbose("\n"); - t_verbose("got "); - t_verbose_hex(digest, SHA512_DIGEST_LEN); - t_verbose("\n"); - return (0); - } - return (1); + return (t_compare_mem(vector->digest, digest, SHA512_DIGEST_LEN)); }