[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] branch master updated (714c5735 -> 7676e698)
From: |
gnunet |
Subject: |
[libmicrohttpd] branch master updated (714c5735 -> 7676e698) |
Date: |
Sun, 16 May 2021 20:56:26 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a change to branch master
in repository libmicrohttpd.
from 714c5735 Implemented SHA-1 calculation
new cea71d6e test_sha1: minor fixes
new 9b9b413a Updated .gitignore
new 7676e698 Updated test_sha* and test_md5 with unaligned data
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/microhttpd/.gitignore | 1 +
src/microhttpd/test_md5.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
src/microhttpd/test_sha1.c | 5 +++--
src/microhttpd/test_sha256.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
src/testcurl/.gitignore | 1 +
5 files changed, 95 insertions(+), 2 deletions(-)
diff --git a/src/microhttpd/.gitignore b/src/microhttpd/.gitignore
index 6e8dbcdf..66b0ac54 100644
--- a/src/microhttpd/.gitignore
+++ b/src/microhttpd/.gitignore
@@ -57,6 +57,7 @@ test_shutdown_poll
test_shutdown_select
test_md5
test_sha256
+/test_sha1
test_upgrade_large
test_upgrade_large_tls
test_postprocessor_md
diff --git a/src/microhttpd/test_md5.c b/src/microhttpd/test_md5.c
index 9d3ff63f..5e04ead0 100644
--- a/src/microhttpd/test_md5.c
+++ b/src/microhttpd/test_md5.c
@@ -27,6 +27,7 @@
#include "md5.h"
#include "test_helpers.h"
#include <stdio.h>
+#include <stdlib.h>
static int verbose = 0; /* verbose level (0-1)*/
@@ -369,6 +370,48 @@ test2_bin (void)
}
+/* Use data set number 7 as it has the longest sequence */
+#define DATA_POS 6
+#define MAX_OFFSET 31
+
+static int
+test_unaligned (void)
+{
+ int num_failed = 0;
+ unsigned int offset;
+ uint8_t *buf;
+ uint8_t *digest_buf;
+
+ const struct data_unit2 *const tdata = data_units2 + DATA_POS;
+
+ buf = malloc (tdata->bin_l.len + MAX_OFFSET);
+ digest_buf = malloc (MD5_DIGEST_SIZE + MAX_OFFSET);
+ if ((NULL == buf) || (NULL == digest_buf))
+ exit (99);
+
+ for (offset = MAX_OFFSET; offset >= 1; --offset)
+ {
+ struct MD5Context ctx;
+ uint8_t *unaligned_digest;
+ uint8_t *unaligned_buf;
+
+ unaligned_buf = buf + offset;
+ memcpy (unaligned_buf, tdata->bin_l.bin, tdata->bin_l.len);
+ unaligned_digest = digest_buf + MAX_OFFSET - offset;
+ memset (unaligned_digest, 0, MD5_DIGEST_SIZE);
+
+ MHD_MD5Init (&ctx);
+ MHD_MD5Update (&ctx, unaligned_buf, tdata->bin_l.len);
+ MHD_MD5Final (&ctx, unaligned_digest);
+ num_failed += check_result (__FUNCTION__, MAX_OFFSET - offset,
+ unaligned_digest, tdata->digest);
+ }
+ free (digest_buf);
+ free (buf);
+ return num_failed;
+}
+
+
int
main (int argc, char *argv[])
{
@@ -383,5 +426,7 @@ main (int argc, char *argv[])
num_failed += test2_str ();
num_failed += test2_bin ();
+ num_failed += test_unaligned ();
+
return num_failed ? 1 : 0;
}
diff --git a/src/microhttpd/test_sha1.c b/src/microhttpd/test_sha1.c
index 276c7838..4426a3c7 100644
--- a/src/microhttpd/test_sha1.c
+++ b/src/microhttpd/test_sha1.c
@@ -356,7 +356,7 @@ test2_bin (void)
}
-/* Use data set number 7 as it is the longest sequence */
+/* Use data set number 7 as it has the longest sequence */
#define DATA_POS 6
#define MAX_OFFSET 31
@@ -373,7 +373,7 @@ test_unaligned (void)
buf = malloc (tdata->bin_l.len + MAX_OFFSET);
digest_buf = malloc (SHA1_DIGEST_SIZE + MAX_OFFSET);
if ((NULL == buf) || (NULL == digest_buf))
- _exit (99);
+ exit (99);
for (offset = MAX_OFFSET; offset >= 1; --offset)
{
@@ -392,6 +392,7 @@ test_unaligned (void)
num_failed += check_result (__FUNCTION__, MAX_OFFSET - offset,
unaligned_digest, tdata->digest);
}
+ free (digest_buf);
free (buf);
return num_failed;
}
diff --git a/src/microhttpd/test_sha256.c b/src/microhttpd/test_sha256.c
index 863859fa..91b28af2 100644
--- a/src/microhttpd/test_sha256.c
+++ b/src/microhttpd/test_sha256.c
@@ -27,6 +27,7 @@
#include "sha256.h"
#include "test_helpers.h"
#include <stdio.h>
+#include <stdlib.h>
static int verbose = 0; /* verbose level (0-1)*/
@@ -416,6 +417,48 @@ test2_bin (void)
}
+/* Use data set number 7 as it has the longest sequence */
+#define DATA_POS 6
+#define MAX_OFFSET 31
+
+static int
+test_unaligned (void)
+{
+ int num_failed = 0;
+ unsigned int offset;
+ uint8_t *buf;
+ uint8_t *digest_buf;
+
+ const struct data_unit2 *const tdata = data_units2 + DATA_POS;
+
+ buf = malloc (tdata->bin_l.len + MAX_OFFSET);
+ digest_buf = malloc (SHA256_DIGEST_SIZE + MAX_OFFSET);
+ if ((NULL == buf) || (NULL == digest_buf))
+ exit (99);
+
+ for (offset = MAX_OFFSET; offset >= 1; --offset)
+ {
+ struct sha256_ctx ctx;
+ uint8_t *unaligned_digest;
+ uint8_t *unaligned_buf;
+
+ unaligned_buf = buf + offset;
+ memcpy (unaligned_buf, tdata->bin_l.bin, tdata->bin_l.len);
+ unaligned_digest = digest_buf + MAX_OFFSET - offset;
+ memset (unaligned_digest, 0, SHA256_DIGEST_SIZE);
+
+ MHD_SHA256_init (&ctx);
+ MHD_SHA256_update (&ctx, unaligned_buf, tdata->bin_l.len);
+ MHD_SHA256_finish (&ctx, unaligned_digest);
+ num_failed += check_result (__FUNCTION__, MAX_OFFSET - offset,
+ unaligned_digest, tdata->digest);
+ }
+ free (digest_buf);
+ free (buf);
+ return num_failed;
+}
+
+
int
main (int argc, char *argv[])
{
@@ -430,5 +473,7 @@ main (int argc, char *argv[])
num_failed += test2_str ();
num_failed += test2_bin ();
+ num_failed += test_unaligned ();
+
return num_failed ? 1 : 0;
}
diff --git a/src/testcurl/.gitignore b/src/testcurl/.gitignore
index bbc1b2a9..ef28dad4 100644
--- a/src/testcurl/.gitignore
+++ b/src/testcurl/.gitignore
@@ -26,6 +26,7 @@
/test_get_sendfile
/test_get_response_cleanup
/test_get_chunked
+/test_get_chunked_close
/test_get11
/test_get
/test_digestauth_with_arguments
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (714c5735 -> 7676e698),
gnunet <=