forked from wolfSSL/wolfssl
ForceZero fix: encryption fail and not EtM
Zeroizing of plaintext on encryption failure will use wrong size when not using Encrypt-then-MAC. Size may go negative and cast to unsigned.
This commit is contained in:
@@ -20813,8 +20813,16 @@ int BuildMessage(WOLFSSL* ssl, byte* output, int outSz, const byte* input,
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Zeroize plaintext. */
|
/* Zeroize plaintext. */
|
||||||
ForceZero(output + args->headerSz,
|
#if defined(HAVE_ENCRYPT_THEN_MAC) && !defined(WOLFSSL_AEAD_ONLY)
|
||||||
(word16)(args->size - args->digestSz));
|
if (ssl->options.startedETMWrite) {
|
||||||
|
ForceZero(output + args->headerSz,
|
||||||
|
(word16)(args->size - args->digestSz));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
ForceZero(output + args->headerSz, (word16)args->size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
goto exit_buildmsg;
|
goto exit_buildmsg;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user