xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame^] | 1 | /*************************************************************************** |
| 2 | * _ _ ____ _ |
| 3 | * Project ___| | | | _ \| | |
| 4 | * / __| | | | |_) | | |
| 5 | * | (__| |_| | _ <| |___ |
| 6 | * \___|\___/|_| \_\_____| |
| 7 | * |
| 8 | * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, 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.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 | * SPDX-License-Identifier: curl |
| 22 | * |
| 23 | ***************************************************************************/ |
| 24 | #include "curlcheck.h" |
| 25 | |
| 26 | #include "curl_hmac.h" |
| 27 | #include "curl_md5.h" |
| 28 | |
| 29 | static CURLcode unit_setup(void) |
| 30 | { |
| 31 | return CURLE_OK; |
| 32 | } |
| 33 | |
| 34 | static void unit_stop(void) |
| 35 | { |
| 36 | |
| 37 | } |
| 38 | |
| 39 | UNITTEST_START |
| 40 | |
| 41 | #ifndef CURL_DISABLE_CRYPTO_AUTH |
| 42 | const char password[] = "Pa55worD"; |
| 43 | const char string1[] = "1"; |
| 44 | const char string2[] = "hello-you-fool"; |
| 45 | unsigned char output[HMAC_MD5_LENGTH]; |
| 46 | unsigned char *testp = output; |
| 47 | |
| 48 | Curl_hmacit(Curl_HMAC_MD5, |
| 49 | (const unsigned char *) password, strlen(password), |
| 50 | (const unsigned char *) string1, strlen(string1), |
| 51 | output); |
| 52 | |
| 53 | verify_memory(testp, |
| 54 | "\xd1\x29\x75\x43\x58\xdc\xab\x78\xdf\xcd\x7f\x2b\x29\x31\x13" |
| 55 | "\x37", HMAC_MD5_LENGTH); |
| 56 | |
| 57 | Curl_hmacit(Curl_HMAC_MD5, |
| 58 | (const unsigned char *) password, strlen(password), |
| 59 | (const unsigned char *) string2, strlen(string2), |
| 60 | output); |
| 61 | |
| 62 | verify_memory(testp, |
| 63 | "\x75\xf1\xa7\xb9\xf5\x40\xe5\xa4\x98\x83\x9f\x64\x5a\x27\x6d" |
| 64 | "\xd0", HMAC_MD5_LENGTH); |
| 65 | #endif |
| 66 | |
| 67 | |
| 68 | UNITTEST_STOP |