Skip to content

Commit 7fdd177

Browse files
author
sebastian-carpenter
committed
fixed oss-fuzz warnings
1 parent 46a7719 commit 7fdd177

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/internal.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23523,7 +23523,7 @@ static int SSL_hmac(WOLFSSL* ssl, byte* digest, const byte* in, word32 sz,
2352323523

2352423524
wc_Md5Free(&md5);
2352523525
}
23526-
else {
23526+
else if (ssl->specs.mac_algorithm == sha_mac) {
2352723527
ret = wc_InitSha_ex(&sha, ssl->heap, ssl->devId);
2352823528
if (ret != 0)
2352923529
return ret;
@@ -23573,6 +23573,10 @@ static int SSL_hmac(WOLFSSL* ssl, byte* digest, const byte* in, word32 sz,
2357323573

2357423574
wc_ShaFree(&sha);
2357523575
}
23576+
else {
23577+
WOLFSSL_ERROR_VERBOSE(VERIFY_MAC_ERROR);
23578+
return VERIFY_MAC_ERROR;
23579+
}
2357623580
return 0;
2357723581
}
2357823582
#endif /* !NO_OLD_TLS && !WOLFSSL_AEAD_ONLY */

src/keys.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ int SetCipherSpecs(WOLFSSL* ssl)
4444
ssl->options.cipherSuite, &ssl->specs,
4545
&ssl->options);
4646
if (ret == 0) {
47+
#ifdef WOLFSSL_ALLOW_SSLV3
48+
/* SSLv3 (RFC 6101) defines MAC algorithms as MD5 and SHA-1. SHA-256
49+
* was introduced in TLS 1.2 (RFC 5246). SSL_hmac for old SSLv3
50+
* connections can not handle newer cipher suites that use digest sizes
51+
* larger than SHA-1 */
52+
if (ssl->version.major == SSLv3_MAJOR &&
53+
ssl->version.minor == SSLv3_MINOR &&
54+
ssl->specs.hash_size > WC_SHA_DIGEST_SIZE) {
55+
WOLFSSL_MSG("SSLv3 does not support SHA-256 or higher MAC");
56+
WOLFSSL_ERROR_VERBOSE(UNSUPPORTED_SUITE);
57+
return UNSUPPORTED_SUITE;
58+
}
59+
#endif /* WOLFSSL_ALLOW_SSLV3 */
60+
4761
/* set TLS if it hasn't been turned off */
4862
if (ssl->version.major == SSLv3_MAJOR &&
4963
ssl->version.minor >= TLSv1_MINOR) {

0 commit comments

Comments
 (0)