| 1 |
/*************************************************************************** |
| 2 |
* _ _ ____ _ |
| 3 |
* Project ___| | | | _ \| | |
| 4 |
* / __| | | | |_) | | |
| 5 |
* | (__| |_| | _ <| |___ |
| 6 |
* \___|\___/|_| \_\_____| |
| 7 |
* |
| 8 |
* Copyright (C) 1998 - 2020, Daniel Stenberg, <[email protected]>, et al. |
| 9 |
* |
| 10 |
* This software is licensed as described in the file COPYING, which |
| 11 |
* you should have received as part of this distribution. The terms |
| 12 |
* are also available at https://curl.haxx.se/docs/copyright.html. |
| 13 |
* |
| 14 |
* You may opt to use, copy, modify, merge, publish, distribute and/or sell |
| 15 |
* copies of the Software, and permit persons to whom the Software is |
| 16 |
* furnished to do so, under the terms of the COPYING file. |
| 17 |
* |
| 18 |
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 19 |
* KIND, either express or implied. |
| 20 |
* |
| 21 |
***************************************************************************/ |
| 22 |
#include "curlcheck.h" |
| 23 |
|
| 24 |
#include "curl_sha256.h" |
| 25 |
|
| 26 |
static CURLcode unit_setup(void) |
| 27 |
{ |
| 28 |
return CURLE_OK; |
| 29 |
} |
| 30 |
|
| 31 |
static void unit_stop(void) |
| 32 |
{ |
| 33 |
|
| 34 |
} |
| 35 |
|
| 36 |
UNITTEST_START |
| 37 |
|
| 38 |
#ifndef CURL_DISABLE_CRYPTO_AUTH |
| 39 |
const char string1[] = "1"; |
| 40 |
const char string2[] = "hello-you-fool"; |
| 41 |
unsigned char output[SHA256_DIGEST_LENGTH]; |
| 42 |
unsigned char *testp = output; |
| 43 |
|
| 44 |
Curl_sha256it(output, (const unsigned char *) string1, strlen(string1)); |
| 45 |
|
| 46 |
verify_memory(testp, |
| 47 |
"\x6b\x86\xb2\x73\xff\x34\xfc\xe1\x9d\x6b\x80\x4e\xff\x5a\x3f" |
| 48 |
"\x57\x47\xad\xa4\xea\xa2\x2f\x1d\x49\xc0\x1e\x52\xdd\xb7\x87" |
| 49 |
"\x5b\x4b", SHA256_DIGEST_LENGTH); |
| 50 |
|
| 51 |
Curl_sha256it(output, (const unsigned char *) string2, strlen(string2)); |
| 52 |
|
| 53 |
verify_memory(testp, |
| 54 |
"\xcb\xb1\x6a\x8a\xb9\xcb\xb9\x35\xa8\xcb\xa0\x2e\x28\xc0\x26" |
| 55 |
"\x30\xd1\x19\x9c\x1f\x02\x17\xf4\x7c\x96\x20\xf3\xef\xe8\x27" |
| 56 |
"\x15\xae", SHA256_DIGEST_LENGTH); |
| 57 |
#endif |
| 58 |
|
| 59 |
|
| 60 |
UNITTEST_STOP |