Skip to content

Commit bc36202

Browse files
committed
TLS_hmac: when no raw hash, make sure maxSz is not neg
When padding byte is invalid, the maxSz can be negative. Make maxSz 0 in this case so that blocks doesn't get very large and cause delays.
1 parent 0306d07 commit bc36202

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/tls.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,8 @@ static int Hmac_UpdateFinal(Hmac* hmac, byte* digest, const byte* in,
11391139
msgSz &= ~(0 - (msgSz >> 31));
11401140
realSz = WOLFSSL_TLS_HMAC_INNER_SZ + msgSz;
11411141
maxSz = WOLFSSL_TLS_HMAC_INNER_SZ + (sz - 1) - macSz;
1142+
/* Make negative result 0 */
1143+
maxSz &= ~(0 - (maxSz >> 31));
11421144

11431145
/* Calculate #blocks processed in HMAC for max and real data. */
11441146
blocks = maxSz >> blockBits;

0 commit comments

Comments
 (0)