Protect against invalid write in RsaPad_PSS

This commit is contained in:
Juliusz Sosinowicz
2020-09-17 13:45:25 +02:00
parent 2a9bb906a9
commit c405c3477f
2 changed files with 6 additions and 0 deletions

View File

@ -4251,6 +4251,7 @@ AC_ARG_ENABLE([libest],
if test "$ENABLED_LIBEST" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DHAVE_EX_DATA -DHAVE_LIBEST -DWOLFSSL_ALT_NAMES"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_PSS_SALT_LEN_DISCOVER"
# Requires opensslextra and opensslall
if test "x$ENABLED_OPENSSLALL" = "xno" && test "x$ENABLED_OPENSSLCOEXIST" = "xno"

View File

@ -1252,6 +1252,11 @@ static int RsaPad_PSS(const byte* input, word32 inputLen, byte* pkcsBlock,
m += inputLen;
o = 0;
if (saltLen > 0) {
if (pkcsBlockLen < RSA_PSS_PAD_SZ + inputLen + saltLen) {
WOLFSSL_MSG("RSA-PSS Output buffer too short. "
"Recommend using WOLFSSL_PSS_SALT_LEN_DISCOVER");
return PSS_SALTLEN_E;
}
ret = wc_RNG_GenerateBlock(rng, salt, saltLen);
if (ret == 0) {
XMEMCPY(m, salt, saltLen);