Skip to content

Commit 0ff99ca

Browse files
ejohnstownpadelsbach
authored andcommitted
internal: guard each HMAC case by its build flag
Wrap the ID_HMAC_SHA2_256 case in CreateMac() and each HMAC case in VerifyMac() in its WOLFSSH_NO_HMAC_* gate, so a build without a MAC drops that case in both directions. Issue: F-12545
1 parent 96548ff commit 0ff99ca

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎src/internal.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14566,6 +14566,7 @@ static INLINE int CreateMac(WOLFSSH* ssh, const byte* in, word32 inSz,
1456614566
break;
1456714567
#endif
1456814568

14569+
#ifndef WOLFSSH_NO_HMAC_SHA2_256
1456914570
case ID_HMAC_SHA2_256:
1457014571
{
1457114572
Hmac hmac;
@@ -14584,6 +14585,7 @@ static INLINE int CreateMac(WOLFSSH* ssh, const byte* in, word32 inSz,
1458414585
wc_HmacFree(&hmac);
1458514586
}
1458614587
break;
14588+
#endif
1458714589

1458814590
#ifndef WOLFSSH_NO_HMAC_SHA2_512
1458914591
case ID_HMAC_SHA2_512:
@@ -14641,8 +14643,13 @@ static INLINE int VerifyMac(WOLFSSH* ssh, const byte* in, word32 inSz,
1464114643
ret = WS_SUCCESS;
1464214644
break;
1464314645

14646+
#ifndef WOLFSSH_NO_HMAC_SHA1
1464414647
case ID_HMAC_SHA1:
14648+
#endif
14649+
#ifndef WOLFSSH_NO_HMAC_SHA1_96
1464514650
case ID_HMAC_SHA1_96:
14651+
#endif
14652+
#if !defined(WOLFSSH_NO_HMAC_SHA1) || !defined(WOLFSSH_NO_HMAC_SHA1_96)
1464614653
ret = wc_HmacSetKey(&hmac, WC_SHA, ssh->peerKeys.macKey,
1464714654
ssh->peerKeys.macKeySz);
1464814655
if (ret == WS_SUCCESS)
@@ -14654,7 +14661,9 @@ static INLINE int VerifyMac(WOLFSSH* ssh, const byte* in, word32 inSz,
1465414661
if (ret == WS_SUCCESS && ConstantCompare(checkMac, mac, ssh->peerMacSz) != 0)
1465514662
ret = WS_VERIFY_MAC_E;
1465614663
break;
14664+
#endif
1465714665

14666+
#ifndef WOLFSSH_NO_HMAC_SHA2_256
1465814667
case ID_HMAC_SHA2_256:
1465914668
ret = wc_HmacSetKey(&hmac, WC_SHA256, ssh->peerKeys.macKey,
1466014669
ssh->peerKeys.macKeySz);
@@ -14667,7 +14676,9 @@ static INLINE int VerifyMac(WOLFSSH* ssh, const byte* in, word32 inSz,
1466714676
if (ret == WS_SUCCESS && ConstantCompare(checkMac, mac, ssh->peerMacSz) != 0)
1466814677
ret = WS_VERIFY_MAC_E;
1466914678
break;
14679+
#endif
1467014680

14681+
#ifndef WOLFSSH_NO_HMAC_SHA2_512
1467114682
case ID_HMAC_SHA2_512:
1467214683
ret = wc_HmacSetKey(&hmac, WC_SHA512, ssh->peerKeys.macKey,
1467314684
ssh->peerKeys.macKeySz);
@@ -14680,6 +14691,7 @@ static INLINE int VerifyMac(WOLFSSH* ssh, const byte* in, word32 inSz,
1468014691
if (ret == WS_SUCCESS && ConstantCompare(checkMac, mac, ssh->peerMacSz) != 0)
1468114692
ret = WS_VERIFY_MAC_E;
1468214693
break;
14694+
#endif
1468314695

1468414696
default:
1468514697
ret = WS_INVALID_ALGO_ID;

0 commit comments

Comments
 (0)