Take advantage of t_compare_mem().

This commit is contained in:
Dag-Erling Smørgrav 2014-07-11 22:26:23 +00:00 committed by des
parent 891ac33286
commit 8c9c5f26e4
13 changed files with 13 additions and 130 deletions

View file

@ -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));
}

View file

@ -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));
}

View file

@ -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));
}

View file

@ -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));
}

View file

@ -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));
}

View file

@ -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));
}

View file

@ -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));
}

View file

@ -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));
}

View file

@ -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));
}

View file

@ -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));
}

View file

@ -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));
}

View file

@ -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));
}

View file

@ -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));
}