Skip to content
Open
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
5 changes: 5 additions & 0 deletions wolfcrypt/src/rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -3455,6 +3455,11 @@ static int RsaPublicEncryptEx(const byte* in, word32 inLen, byte* out,
/* In the case that no padding is used the input length can and should
* be the same size as the RSA key. */
if (pad_type != WC_RSA_NO_PAD)
#endif
#ifdef WC_RSA_PSS
/* PSS performs its own input-length check inside RsaPad_PSS; the
* RSA_MIN_PAD_SZ guard applies only to PKCS#1 v1.5 padding. */
if (pad_type != WC_RSA_PSS_PAD)
#endif
return RSA_BUFFER_E;
Comment on lines 3455 to 3464
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

This relies on an implicit nesting effect where the second if becomes the statement-body of the first if when both WC_RSA_NO_PADDING and WC_RSA_PSS are enabled. That’s fragile (any future added statement between them would change control flow) and hard to read. Make the intent explicit by restructuring (e.g., a single boolean/compound condition that returns RSA_BUFFER_E only when padding is neither WC_RSA_NO_PAD nor WC_RSA_PSS_PAD, or by using braces with an explicit combined condition under the relevant #ifdefs).

Copilot uses AI. Check for mistakes.
}
Expand Down
Loading