mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
Fix HMAC compat layer function for SHA-1.
This function would only accept the string "SHA" for SHA-1-based HMAC, but it should also accept "SHA1." This is similar to how wolfSSL_EVP_get_digestbyname allows both "SHA" and "SHA1." We didn't have a test for this in api.c. I added one, and it failed before my fix here.
This commit is contained in:
@ -18299,10 +18299,11 @@ size_t wolfSSL_get_client_random(const WOLFSSL* ssl, unsigned char* out,
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef NO_SHA
|
#ifndef NO_SHA
|
||||||
if (XSTRCMP(evp_md, "SHA") == 0) {
|
if (XSTRCMP(evp_md, "SHA") == 0 || XSTRCMP(evp_md, "SHA1") == 0) {
|
||||||
type = WC_SHA;
|
type = WC_SHA;
|
||||||
mdlen = WC_SHA_DIGEST_SIZE;
|
mdlen = WC_SHA_DIGEST_SIZE;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -39202,6 +39202,9 @@ static int test_wolfSSL_HMAC(void)
|
|||||||
test_openssl_hmac(EVP_sha3_512(), (int)WC_SHA3_512_DIGEST_SIZE);
|
test_openssl_hmac(EVP_sha3_512(), (int)WC_SHA3_512_DIGEST_SIZE);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef NO_SHA
|
||||||
|
test_openssl_hmac(EVP_sha1(), (int)WC_SHA_DIGEST_SIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
printf(resultFmt, passed);
|
printf(resultFmt, passed);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user