Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/pk.c
Original file line number Diff line number Diff line change
Expand Up @@ -3556,13 +3556,16 @@ int wolfSSL_RSA_verify_PKCS1_PSS(WOLFSSL_RSA *rsa, const unsigned char *mHash,

if (ret == 1) {
/* Calculate the salt length to use for special cases. */
/* TODO: use special case wolfCrypt values. */
switch (saltLen) {
/* Negative saltLen values are treated differently */
case RSA_PSS_SALTLEN_DIGEST:
saltLen = hashLen;
break;
case RSA_PSS_SALTLEN_MAX_SIGN:
case RSA_PSS_SALTLEN_AUTO:
#ifdef WOLFSSL_PSS_SALT_LEN_DISCOVER
saltLen = RSA_PSS_SALT_LEN_DISCOVER;
break;
#endif
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the #else case should return an error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No case now when WOLFSSL_PSS_SALT_LEN_DISCOVER not defined.
Will go to default which errors out on negative.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd really like a test case for this... Could we add one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually that doesn't work.
-2 is RSA_PSS_SALTLEN_MAX_SIGN for signing and using -2 should have the same semantics in verify.
Discovery will handle anything.

case RSA_PSS_SALTLEN_MAX:
#ifdef WOLFSSL_PSS_LONG_SALT
saltLen = emLen - hashLen - 2;
Expand Down
2 changes: 2 additions & 0 deletions wolfssl/openssl/rsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
#define RSA_PSS_SALTLEN_DIGEST (-1)
/* Old max salt length */
#define RSA_PSS_SALTLEN_MAX_SIGN (-2)
/* Verification only value to indicate to discover salt length. */
#define RSA_PSS_SALTLEN_AUTO (-2)
/* Max salt length */
#define RSA_PSS_SALTLEN_MAX (-3)
#endif /* OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL */
Expand Down