diff --git a/t/t_hmac_sha1.c b/t/t_hmac_sha1.c index dae8c97..154a3ad 100644 --- a/t/t_hmac_sha1.c +++ b/t/t_hmac_sha1.c @@ -30,7 +30,6 @@ #include "cryb/impl.h" -#include #include #include #include diff --git a/t/t_hmac_sha224.c b/t/t_hmac_sha224.c index 7a9d13f..e1c1e07 100644 --- a/t/t_hmac_sha224.c +++ b/t/t_hmac_sha224.c @@ -30,7 +30,6 @@ #include "cryb/impl.h" -#include #include #include #include diff --git a/t/t_hmac_sha256.c b/t/t_hmac_sha256.c index 26d7ef7..c26ed60 100644 --- a/t/t_hmac_sha256.c +++ b/t/t_hmac_sha256.c @@ -30,7 +30,6 @@ #include "cryb/impl.h" -#include #include #include #include diff --git a/t/t_hmac_sha384.c b/t/t_hmac_sha384.c index a86e798..804105f 100644 --- a/t/t_hmac_sha384.c +++ b/t/t_hmac_sha384.c @@ -30,7 +30,6 @@ #include "cryb/impl.h" -#include #include #include #include diff --git a/t/t_hmac_sha512.c b/t/t_hmac_sha512.c index 421b16a..159d770 100644 --- a/t/t_hmac_sha512.c +++ b/t/t_hmac_sha512.c @@ -30,7 +30,6 @@ #include "cryb/impl.h" -#include #include #include #include diff --git a/t/t_md2.c b/t/t_md2.c index 1c8b3dd..f1f5d9b 100644 --- a/t/t_md2.c +++ b/t/t_md2.c @@ -30,7 +30,6 @@ #include "cryb/impl.h" -#include #include #include #include @@ -174,23 +173,17 @@ t_md2_perf(char **desc, void *arg) struct timespec ts, te; unsigned long ns; uint8_t digest[MD2_DIGEST_LEN]; - char *msg, *comment; size_t msglen = *(size_t *)arg; + char msg[msglen]; - if ((msg = calloc(1, msglen)) == NULL) - err(1, "calloc()"); clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_md2_complete(msg, msglen, digest); clock_gettime(CLOCK_MONOTONIC, &te); - free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(&comment, "%zu bytes: %d iterations in %'lu ns", + asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); - if (comment == NULL) - err(1, "asprintf()"); - *desc = comment; return (1); } diff --git a/t/t_md4.c b/t/t_md4.c index f6a4e47..c58776c 100644 --- a/t/t_md4.c +++ b/t/t_md4.c @@ -30,7 +30,6 @@ #include "cryb/impl.h" -#include #include #include #include @@ -190,23 +189,17 @@ t_md4_perf(char **desc, void *arg) struct timespec ts, te; unsigned long ns; uint8_t digest[MD4_DIGEST_LEN]; - char *msg, *comment; size_t msglen = *(size_t *)arg; + char msg[msglen]; - if ((msg = calloc(1, msglen)) == NULL) - err(1, "calloc()"); clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_md4_complete(msg, msglen, digest); clock_gettime(CLOCK_MONOTONIC, &te); - free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(&comment, "%zu bytes: %d iterations in %'lu ns", + asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); - if (comment == NULL) - err(1, "asprintf()"); - *desc = comment; return (1); } diff --git a/t/t_md5.c b/t/t_md5.c index e6b3520..1c7462d 100644 --- a/t/t_md5.c +++ b/t/t_md5.c @@ -30,7 +30,6 @@ #include "cryb/impl.h" -#include #include #include #include @@ -190,23 +189,17 @@ t_md5_perf(char **desc, void *arg) struct timespec ts, te; unsigned long ns; uint8_t digest[MD5_DIGEST_LEN]; - char *msg, *comment; size_t msglen = *(size_t *)arg; + char msg[msglen]; - if ((msg = calloc(1, msglen)) == NULL) - err(1, "calloc()"); clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_md5_complete(msg, msglen, digest); clock_gettime(CLOCK_MONOTONIC, &te); - free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(&comment, "%zu bytes: %d iterations in %'lu ns", + asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); - if (comment == NULL) - err(1, "asprintf()"); - *desc = comment; return (1); } diff --git a/t/t_sha1.c b/t/t_sha1.c index 9b47f54..dfaad88 100644 --- a/t/t_sha1.c +++ b/t/t_sha1.c @@ -30,7 +30,6 @@ #include "cryb/impl.h" -#include #include #include #include @@ -137,17 +136,14 @@ t_sha1_vector(char **desc CRYB_UNUSED, void *arg) { struct t_vector *vector = (struct t_vector *)arg; uint8_t digest[SHA1_DIGEST_LEN]; - char *msg; + char msg[1000000]; if (vector->msg) { t_sha1_complete(vector->msg, strlen(vector->msg), digest); } else { /* special case for FIPS test vector 3 */ - if ((msg = malloc(1000000)) == NULL) - err(1, "malloc()"); memset(msg, 'a', 1000000); t_sha1_complete(msg, 1000000, digest); - free(msg); } return (t_compare_mem(vector->digest, digest, SHA1_DIGEST_LEN)); } @@ -186,23 +182,17 @@ t_sha1_perf(char **desc, void *arg) struct timespec ts, te; unsigned long ns; uint8_t digest[SHA1_DIGEST_LEN]; - char *msg, *comment; size_t msglen = *(size_t *)arg; + char msg[msglen]; - if ((msg = calloc(1, msglen)) == NULL) - err(1, "calloc()"); clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_sha1_complete(msg, msglen, digest); clock_gettime(CLOCK_MONOTONIC, &te); - free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(&comment, "%zu bytes: %d iterations in %'lu ns", + asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); - if (comment == NULL) - err(1, "asprintf()"); - *desc = comment; return (1); } diff --git a/t/t_sha224.c b/t/t_sha224.c index c496624..746d050 100644 --- a/t/t_sha224.c +++ b/t/t_sha224.c @@ -30,7 +30,6 @@ #include "cryb/impl.h" -#include #include #include #include @@ -146,17 +145,14 @@ t_sha224_vector(char **desc CRYB_UNUSED, void *arg) { struct t_vector *vector = (struct t_vector *)arg; uint8_t digest[SHA224_DIGEST_LEN]; - char *msg; + char msg[1000000]; if (vector->msg) { t_sha224_complete(vector->msg, strlen(vector->msg), digest); } else { /* special case for FIPS test vector 3 */ - if ((msg = malloc(1000000)) == NULL) - err(1, "malloc()"); memset(msg, 'a', 1000000); t_sha224_complete(msg, 1000000, digest); - free(msg); } return (t_compare_mem(vector->digest, digest, SHA224_DIGEST_LEN)); } @@ -195,23 +191,17 @@ t_sha224_perf(char **desc, void *arg) struct timespec ts, te; unsigned long ns; uint8_t digest[SHA224_DIGEST_LEN]; - char *msg, *comment; size_t msglen = *(size_t *)arg; + char msg[msglen]; - if ((msg = calloc(1, msglen)) == NULL) - err(1, "calloc()"); clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_sha224_complete(msg, msglen, digest); clock_gettime(CLOCK_MONOTONIC, &te); - free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(&comment, "%zu bytes: %d iterations in %'lu ns", + asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); - if (comment == NULL) - err(1, "asprintf()"); - *desc = comment; return (1); } diff --git a/t/t_sha256.c b/t/t_sha256.c index 69c85c2..92b0995 100644 --- a/t/t_sha256.c +++ b/t/t_sha256.c @@ -30,7 +30,6 @@ #include "cryb/impl.h" -#include #include #include #include @@ -142,17 +141,14 @@ t_sha256_vector(char **desc CRYB_UNUSED, void *arg) { struct t_vector *vector = (struct t_vector *)arg; uint8_t digest[SHA256_DIGEST_LEN]; - char *msg; + char msg[1000000]; if (vector->msg) { t_sha256_complete(vector->msg, strlen(vector->msg), digest); } else { /* special case for FIPS test vector 3 */ - if ((msg = malloc(1000000)) == NULL) - err(1, "malloc()"); memset(msg, 'a', 1000000); t_sha256_complete(msg, 1000000, digest); - free(msg); } return (t_compare_mem(vector->digest, digest, SHA256_DIGEST_LEN)); } @@ -191,23 +187,17 @@ t_sha256_perf(char **desc, void *arg) struct timespec ts, te; unsigned long ns; uint8_t digest[SHA256_DIGEST_LEN]; - char *msg, *comment; size_t msglen = *(size_t *)arg; + char msg[msglen]; - if ((msg = calloc(1, msglen)) == NULL) - err(1, "calloc()"); clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_sha256_complete(msg, msglen, digest); clock_gettime(CLOCK_MONOTONIC, &te); - free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(&comment, "%zu bytes: %d iterations in %'lu ns", + asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); - if (comment == NULL) - err(1, "asprintf()"); - *desc = comment; return (1); } diff --git a/t/t_sha384.c b/t/t_sha384.c index f3842e3..146c33e 100644 --- a/t/t_sha384.c +++ b/t/t_sha384.c @@ -30,7 +30,6 @@ #include "cryb/impl.h" -#include #include #include #include @@ -157,17 +156,14 @@ t_sha384_vector(char **desc CRYB_UNUSED, void *arg) { struct t_vector *vector = (struct t_vector *)arg; uint8_t digest[SHA384_DIGEST_LEN]; - char *msg; + char msg[1000000]; if (vector->msg) { t_sha384_complete(vector->msg, strlen(vector->msg), digest); } else { /* special case for FIPS test vector 3 */ - if ((msg = malloc(1000000)) == NULL) - err(1, "malloc()"); memset(msg, 'a', 1000000); t_sha384_complete(msg, 1000000, digest); - free(msg); } return (t_compare_mem(vector->digest, digest, SHA384_DIGEST_LEN)); } @@ -207,23 +203,17 @@ t_sha384_perf(char **desc, void *arg) struct timespec ts, te; unsigned long ns; uint8_t digest[SHA384_DIGEST_LEN]; - char *msg, *comment; size_t msglen = *(size_t *)arg; + char msg[msglen]; - if ((msg = calloc(1, msglen)) == NULL) - err(1, "calloc()"); clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_sha384_complete(msg, msglen, digest); clock_gettime(CLOCK_MONOTONIC, &te); - free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(&comment, "%zu bytes: %d iterations in %'lu ns", + asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); - if (comment == NULL) - err(1, "asprintf()"); - *desc = comment; return (1); } diff --git a/t/t_sha512.c b/t/t_sha512.c index 70cf02d..26d63a2 100644 --- a/t/t_sha512.c +++ b/t/t_sha512.c @@ -30,7 +30,6 @@ #include "cryb/impl.h" -#include #include #include #include @@ -167,17 +166,14 @@ t_sha512_vector(char **desc CRYB_UNUSED, void *arg) { struct t_vector *vector = (struct t_vector *)arg; uint8_t digest[SHA512_DIGEST_LEN]; - char *msg; + char msg[1000000]; if (vector->msg) { t_sha512_complete(vector->msg, strlen(vector->msg), digest); } else { /* special case for FIPS test vector 3 */ - if ((msg = malloc(1000000)) == NULL) - err(1, "malloc()"); memset(msg, 'a', 1000000); t_sha512_complete(msg, 1000000, digest); - free(msg); } return (t_compare_mem(vector->digest, digest, SHA512_DIGEST_LEN)); } @@ -217,23 +213,17 @@ t_sha512_perf(char **desc, void *arg) struct timespec ts, te; unsigned long ns; uint8_t digest[SHA512_DIGEST_LEN]; - char *msg, *comment; size_t msglen = *(size_t *)arg; + char msg[msglen]; - if ((msg = calloc(1, msglen)) == NULL) - err(1, "calloc()"); clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_sha512_complete(msg, msglen, digest); clock_gettime(CLOCK_MONOTONIC, &te); - free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; - asprintf(&comment, "%zu bytes: %d iterations in %'lu ns", + asprintf(desc, "%zu bytes: %d iterations in %'lu ns", msglen, T_PERF_ITERATIONS, ns); - if (comment == NULL) - err(1, "asprintf()"); - *desc = comment; return (1); } diff --git a/t/t_util.c b/t/t_util.c index 8c82774..264b781 100644 --- a/t/t_util.c +++ b/t/t_util.c @@ -29,7 +29,6 @@ #include "cryb/impl.h" -#include #include #include #include