Skip to content

Commit 3481baf

Browse files
committed
Fix auto saltlen when WOLFSSL_PSS_SALT_LEN_DISCOVER is not defined
1 parent 56c841f commit 3481baf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/wp_rsa_sig.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,10 @@ static int wp_pss_salt_len_to_wc(int saltLen, enum wc_HashType hashType,
391391
}
392392
else if (saltLen == RSA_PSS_SALTLEN_AUTO) {
393393
#ifndef WOLFSSL_PSS_SALT_LEN_DISCOVER
394-
saltLen = wc_HashGetDigestSize(hashType);
394+
saltLen = wc_RsaEncryptSize(key) - wc_HashGetDigestSize(hashType) - 2;
395+
if (((mp_count_bits(&key->n) - 1) & 0x7) == 0) {
396+
saltLen--;
397+
}
395398
#else
396399
saltLen = RSA_PSS_SALT_LEN_DISCOVER;
397400
#endif

0 commit comments

Comments
 (0)