diff options
author | Steve Holme <steve_holme@hotmail.com> | 2020-02-22 05:37:01 +0000 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2020-02-23 07:50:33 +0000 |
commit | 37dc4df270b0080442a9e36f9ea13855db9253e6 (patch) | |
tree | 7799e625b9b2ff19c83d5b06bb40a62579abe5ab /tests | |
parent | 4959be810be3340aaa7a1efca4aba7e670d5e8b7 (diff) | |
download | curl-37dc4df270b0080442a9e36f9ea13855db9253e6.tar.gz |
md5/sha256: Updated the functions to allow non-string data to be hashed
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/unit1601.c | 20 | ||||
-rw-r--r-- | tests/unit/unit1610.c | 4 |
2 files changed, 13 insertions, 11 deletions
diff --git a/tests/unit/unit1601.c b/tests/unit/unit1601.c index a6120e1c2..bf00bc7e9 100644 --- a/tests/unit/unit1601.c +++ b/tests/unit/unit1601.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -36,18 +36,20 @@ static void unit_stop(void) UNITTEST_START #ifndef CURL_DISABLE_CRYPTO_AUTH - unsigned char output[16]; + const char string1[] = "1"; + const char string2[] = "hello-you-fool"; + unsigned char output[MD5_DIGEST_LEN]; unsigned char *testp = output; - Curl_md5it(output, (const unsigned char *)"1"); -/* !checksrc! disable LONGLINE 2 */ - verify_memory(testp, - "\xc4\xca\x42\x38\xa0\xb9\x23\x82\x0d\xcc\x50\x9a\x6f\x75\x84\x9b", 16); + Curl_md5it(output, (const unsigned char *) string1, strlen(string1)); - Curl_md5it(output, (const unsigned char *)"hello-you-fool"); + verify_memory(testp, "\xc4\xca\x42\x38\xa0\xb9\x23\x82\x0d\xcc\x50\x9a\x6f" + "\x75\x84\x9b", MD5_DIGEST_LEN); - verify_memory(testp, - "\x88\x67\x0b\x6d\x5d\x74\x2f\xad\xa5\xcd\xf9\xb6\x82\x87\x5f\x22", 16); + Curl_md5it(output, (const unsigned char *) string2, strlen(string2)); + + verify_memory(testp, "\x88\x67\x0b\x6d\x5d\x74\x2f\xad\xa5\xcd\xf9\xb6\x82" + "\x87\x5f\x22", MD5_DIGEST_LEN); #endif diff --git a/tests/unit/unit1610.c b/tests/unit/unit1610.c index 06c97198b..bb9c937c9 100644 --- a/tests/unit/unit1610.c +++ b/tests/unit/unit1610.c @@ -41,14 +41,14 @@ UNITTEST_START unsigned char output[SHA256_DIGEST_LENGTH]; unsigned char *testp = output; - Curl_sha256it(output, (const unsigned char *) string1); + Curl_sha256it(output, (const unsigned char *) string1, strlen(string1)); verify_memory(testp, "\x6b\x86\xb2\x73\xff\x34\xfc\xe1\x9d\x6b\x80\x4e\xff\x5a\x3f" "\x57\x47\xad\xa4\xea\xa2\x2f\x1d\x49\xc0\x1e\x52\xdd\xb7\x87" "\x5b\x4b", SHA256_DIGEST_LENGTH); - Curl_sha256it(output, (const unsigned char *) string2); + Curl_sha256it(output, (const unsigned char *) string2, strlen(string2)); verify_memory(testp, "\xcb\xb1\x6a\x8a\xb9\xcb\xb9\x35\xa8\xcb\xa0\x2e\x28\xc0\x26" |