Skip to content

Commit 4870435

Browse files
committed
RSA PSS OpenSSL compatibility verification: support AUTO
When wolfSSL_RSA_verify_PKCS1_PSS() called with RSA_PSS_SALTLEN_AUTO (RSA_PSS_SALTLEN_MAX_SIGN) it wasn't using RSA_PSS_SALT_LEN_DISCOVER when available.
1 parent 7435d23 commit 4870435

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/pk.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3556,13 +3556,16 @@ int wolfSSL_RSA_verify_PKCS1_PSS(WOLFSSL_RSA *rsa, const unsigned char *mHash,
35563556

35573557
if (ret == 1) {
35583558
/* Calculate the salt length to use for special cases. */
3559-
/* TODO: use special case wolfCrypt values. */
35603559
switch (saltLen) {
35613560
/* Negative saltLen values are treated differently */
35623561
case RSA_PSS_SALTLEN_DIGEST:
35633562
saltLen = hashLen;
35643563
break;
3565-
case RSA_PSS_SALTLEN_MAX_SIGN:
3564+
case RSA_PSS_SALTLEN_AUTO:
3565+
#ifdef WOLFSSL_PSS_SALT_LEN_DISCOVER
3566+
saltLen = RSA_PSS_SALT_LEN_DISCOVER;
3567+
break;
3568+
#endif
35663569
case RSA_PSS_SALTLEN_MAX:
35673570
#ifdef WOLFSSL_PSS_LONG_SALT
35683571
saltLen = emLen - hashLen - 2;

wolfssl/openssl/rsa.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
#define RSA_PSS_SALTLEN_DIGEST (-1)
5555
/* Old max salt length */
5656
#define RSA_PSS_SALTLEN_MAX_SIGN (-2)
57+
/* Verification only value to indicate to discover salt length. */
58+
#define RSA_PSS_SALTLEN_AUTO (-2)
5759
/* Max salt length */
5860
#define RSA_PSS_SALTLEN_MAX (-3)
5961
#endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */

0 commit comments

Comments
 (0)