[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 16/22: test_{md5,sha{256,512_256}}: re-use of the contex
From: |
gnunet |
Subject: |
[libmicrohttpd] 16/22: test_{md5,sha{256,512_256}}: re-use of the context structure |
Date: |
Sun, 25 Sep 2022 17:43:51 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit eef2d639f6f0a20b7768b3e521b0d0339957baeb
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Thu Sep 15 11:25:43 2022 +0300
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_md5.c | 12 ++++++------
src/microhttpd/test_sha256.c | 12 ++++++------
src/microhttpd/test_sha512_256.c | 12 ++++++------
3 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/microhttpd/test_md5.c b/src/microhttpd/test_md5.c
index cf7ccbd1..13f9d46e 100644
--- a/src/microhttpd/test_md5.c
+++ b/src/microhttpd/test_md5.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
@@ -312,10 +312,10 @@ test1_str (void)
{
unsigned int i;
int num_failed = 0;
+ struct Md5Ctx ctx;
for (i = 0; i < units1_num; i++)
{
- struct Md5Ctx ctx;
uint8_t digest[MD5_DIGEST_SIZE];
MHD_MD5_init (&ctx);
@@ -334,10 +334,10 @@ test1_bin (void)
{
unsigned int i;
int num_failed = 0;
+ struct Md5Ctx ctx;
for (i = 0; i < units2_num; i++)
{
- struct Md5Ctx ctx;
uint8_t digest[MD5_DIGEST_SIZE];
MHD_MD5_init (&ctx);
@@ -356,10 +356,10 @@ test2_str (void)
{
unsigned int i;
int num_failed = 0;
+ struct Md5Ctx ctx;
for (i = 0; i < units1_num; i++)
{
- struct Md5Ctx ctx;
uint8_t digest[MD5_DIGEST_SIZE];
size_t part_s = data_units1[i].str_l.len / 4;
@@ -383,10 +383,10 @@ test2_bin (void)
{
unsigned int i;
int num_failed = 0;
+ struct Md5Ctx ctx;
for (i = 0; i < units2_num; i++)
{
- struct Md5Ctx ctx;
uint8_t digest[MD5_DIGEST_SIZE];
size_t part_s = data_units2[i].bin_l.len * 2 / 3;
@@ -414,6 +414,7 @@ test_unaligned (void)
unsigned int offset;
uint8_t *buf;
uint8_t *digest_buf;
+ struct Md5Ctx ctx;
const struct data_unit2 *const tdata = data_units2 + DATA_POS;
@@ -424,7 +425,6 @@ test_unaligned (void)
for (offset = MAX_OFFSET; offset >= 1; --offset)
{
- struct Md5Ctx ctx;
uint8_t *unaligned_digest;
uint8_t *unaligned_buf;
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;
diff --git a/src/microhttpd/test_sha512_256.c b/src/microhttpd/test_sha512_256.c
index e23ad256..81a505c0 100644
--- a/src/microhttpd/test_sha512_256.c
+++ b/src/microhttpd/test_sha512_256.c
@@ -1,6 +1,6 @@
/*
This file is part of libmicrohttpd
- Copyright (C) 2019-2022 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
@@ -446,10 +446,10 @@ test1_str (void)
{
int num_failed = 0;
unsigned int i;
+ struct Sha512_256Ctx ctx;
for (i = 0; i < units1_num; i++)
{
- struct Sha512_256Ctx ctx;
uint8_t digest[SHA512_256_DIGEST_SIZE];
MHD_SHA512_256_init (&ctx);
@@ -468,10 +468,10 @@ test1_bin (void)
{
int num_failed = 0;
unsigned int i;
+ struct Sha512_256Ctx ctx;
for (i = 0; i < units2_num; i++)
{
- struct Sha512_256Ctx ctx;
uint8_t digest[SHA512_256_DIGEST_SIZE];
MHD_SHA512_256_init (&ctx);
@@ -491,10 +491,10 @@ test2_str (void)
{
int num_failed = 0;
unsigned int i;
+ struct Sha512_256Ctx ctx;
for (i = 0; i < units1_num; i++)
{
- struct Sha512_256Ctx ctx;
uint8_t digest[SHA512_256_DIGEST_SIZE];
size_t part_s = data_units1[i].str_l.len / 4;
@@ -520,10 +520,10 @@ test2_bin (void)
{
int num_failed = 0;
unsigned int i;
+ struct Sha512_256Ctx ctx;
for (i = 0; i < units2_num; i++)
{
- struct Sha512_256Ctx ctx;
uint8_t digest[SHA512_256_DIGEST_SIZE];
size_t part_s = data_units2[i].bin_l.len * 2 / 3;
@@ -551,6 +551,7 @@ test_unaligned (void)
unsigned int offset;
uint8_t *buf;
uint8_t *digest_buf;
+ struct Sha512_256Ctx ctx;
const struct data_unit2 *const tdata = data_units2 + DATA_POS;
@@ -561,7 +562,6 @@ test_unaligned (void)
for (offset = MAX_OFFSET; offset >= 1; --offset)
{
- struct Sha512_256Ctx ctx;
uint8_t *unaligned_digest;
uint8_t *unaligned_buf;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] 14/22: test_{md5,sha{256,512_256}}: added long test sequence, (continued)
- [libmicrohttpd] 14/22: test_{md5,sha{256,512_256}}: added long test sequence, gnunet, 2022/09/25
- [libmicrohttpd] 07/22: sha512_256: additional trick for compacter code; doxy and comment fixes, gnunet, 2022/09/25
- [libmicrohttpd] 09/22: md5: improved performance of the first round on LE arches, gnunet, 2022/09/25
- [libmicrohttpd] 17/22: digestauth: removed redundant check and report, gnunet, 2022/09/25
- [libmicrohttpd] 12/22: test_sha{256,512_256}: minor fixes, gnunet, 2022/09/25
- [libmicrohttpd] 08/22: md5: replaced public domain MD5 implementation with our own implementation, gnunet, 2022/09/25
- [libmicrohttpd] 20/22: digestauth: refactored hashing asserts, gnunet, 2022/09/25
- [libmicrohttpd] 15/22: sha{256, 512_256}: improved performance of the first steps on BE arches, gnunet, 2022/09/25
- [libmicrohttpd] 22/22: w32: sync projects with autotools, gnunet, 2022/09/25
- [libmicrohttpd] 11/22: test_{md5,sha256,sha512_256}: added more checks, gnunet, 2022/09/25
- [libmicrohttpd] 16/22: test_{md5,sha{256,512_256}}: re-use of the context structure,
gnunet <=
- [libmicrohttpd] 19/22: digestauth: used weak pseudo-random generators to avoid nonces clashes, gnunet, 2022/09/25
- [libmicrohttpd] 21/22: Implemented support for hash calculation by GnuTLS lib functions, gnunet, 2022/09/25
- [libmicrohttpd] 13/22: test_md5: added more test sequences, gnunet, 2022/09/25
- [libmicrohttpd] 18/22: digestauth: changed "slot used" detection logic, gnunet, 2022/09/25