mirror of
https://github.com/cryb-to/cryb-to.git
synced 2024-11-25 07:07:11 +00:00
Take advantage of t_compare_mem().
This commit is contained in:
parent
891ac33286
commit
8c9c5f26e4
13 changed files with 13 additions and 130 deletions
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
|
11
t/t_md2.c
11
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));
|
||||
}
|
||||
|
||||
|
||||
|
|
11
t/t_md4.c
11
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));
|
||||
}
|
||||
|
||||
|
||||
|
|
11
t/t_md5.c
11
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));
|
||||
}
|
||||
|
||||
|
||||
|
|
11
t/t_sha1.c
11
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));
|
||||
}
|
||||
|
||||
|
||||
|
|
11
t/t_sha224.c
11
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));
|
||||
}
|
||||
|
||||
|
||||
|
|
11
t/t_sha256.c
11
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));
|
||||
}
|
||||
|
||||
|
||||
|
|
11
t/t_sha384.c
11
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));
|
||||
}
|
||||
|
||||
|
||||
|
|
11
t/t_sha512.c
11
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));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue