From eef2d639f6f0a20b7768b3e521b0d0339957baeb Mon Sep 17 00:00:00 2001 From: "Evgeny Grin (Karlson2k)" Date: Thu, 15 Sep 2022 11:25:43 +0300 Subject: test_{md5,sha{256,512_256}}: re-use of the context structure The context structure declaration was moved outside the loops, it should help to re-use the same memory area which may trigger more potential bugs. --- src/microhttpd/test_sha256.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/microhttpd/test_sha256.c') diff --git a/src/microhttpd/test_sha256.c b/src/microhttpd/test_sha256.c index a44ceedc..f287afd6 100644 --- a/src/microhttpd/test_sha256.c +++ b/src/microhttpd/test_sha256.c @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - Copyright (C) 2019 Karlson2k (Evgeny Grin) + Copyright (C) 2019-2022 Evgeny Grin (Karlson2k) This test tool is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -339,10 +339,10 @@ test1_str (void) { int num_failed = 0; unsigned int i; + struct Sha256Ctx ctx; for (i = 0; i < units1_num; i++) { - struct Sha256Ctx ctx; uint8_t digest[SHA256_DIGEST_SIZE]; MHD_SHA256_init (&ctx); @@ -361,10 +361,10 @@ test1_bin (void) { int num_failed = 0; unsigned int i; + struct Sha256Ctx ctx; for (i = 0; i < units2_num; i++) { - struct Sha256Ctx ctx; uint8_t digest[SHA256_DIGEST_SIZE]; MHD_SHA256_init (&ctx); @@ -384,10 +384,10 @@ test2_str (void) { int num_failed = 0; unsigned int i; + struct Sha256Ctx ctx; for (i = 0; i < units1_num; i++) { - struct Sha256Ctx ctx; uint8_t digest[SHA256_DIGEST_SIZE]; size_t part_s = data_units1[i].str_l.len / 4; @@ -413,10 +413,10 @@ test2_bin (void) { int num_failed = 0; unsigned int i; + struct Sha256Ctx ctx; for (i = 0; i < units2_num; i++) { - struct Sha256Ctx ctx; uint8_t digest[SHA256_DIGEST_SIZE]; size_t part_s = data_units2[i].bin_l.len * 2 / 3; @@ -444,6 +444,7 @@ test_unaligned (void) unsigned int offset; uint8_t *buf; uint8_t *digest_buf; + struct Sha256Ctx ctx; const struct data_unit2 *const tdata = data_units2 + DATA_POS; @@ -454,7 +455,6 @@ test_unaligned (void) for (offset = MAX_OFFSET; offset >= 1; --offset) { - struct Sha256Ctx ctx; uint8_t *unaligned_digest; uint8_t *unaligned_buf; -- cgit v1.2.3