fix: skip RSA_MIN_PAD_SZ check for PSS padding in RsaPublicEncryptEx#10255
fix: skip RSA_MIN_PAD_SZ check for PSS padding in RsaPublicEncryptEx#10255MarkAtwood wants to merge 2 commits into
Conversation
The RSA_MIN_PAD_SZ guard (inLen > sz - 11) is a PKCS#1 v1.5 constraint. PSS has its own length check inside RsaPad_PSS (emLen >= hLen + sLen + 2 per RFC 8017) and does not need this guard. For keys in the range [hLen+2, hLen+10] bytes, the outer guard fires and returns RSA_BUFFER_E before RsaPad_PSS ever runs, even though PSS with saltLen=0 would be geometrically valid for those key sizes. Add a WC_RSA_PSS ifdef that skips the RSA_BUFFER_E return when pad_type == WC_RSA_PSS_PAD, mirroring the existing WC_RSA_NO_PADDING exception for raw (no-pad) mode.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adjusts RsaPublicEncryptEx so the RSA_MIN_PAD_SZ (PKCS#1 v1.5) input-length guard does not preempt PSS padding’s own size validation, enabling certain non-standard small key sizes to proceed to RsaPad_PSS.
Changes:
- Skips the
RSA_BUFFER_Eearly-return whenpad_type == WC_RSA_PSS_PAD(underWC_RSA_PSS). - Keeps the existing exception path for
WC_RSA_NO_PADbehavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Restructured as a single compound condition — pushed f05d929. No more implicit nesting of preprocessor-guarded if-statements. Each exemption is now a |
Addresses review feedback: avoid fragile implicit nesting of preprocessor-guarded if-statements. Use a single compound condition with && clauses gated by #ifdef instead.
f05d929 to
91a1b28
Compare
|
Restructured per review feedback — the implicit preprocessor nesting is replaced with a |
Summary
The
RSA_MIN_PAD_SZguard (inLen > sz - 11→RSA_BUFFER_E) is a PKCS#1 v1.5 concept. PSS has its own length check insideRsaPad_PSS(emLen >= hLen + sLen + 2per RFC 8017 §9.1.1) and the outer guard fires first, beforeRsaPad_PSSever runs.For keys in the range
[hLen+2, hLen+10]bytes, the outer guard incorrectly returnsRSA_BUFFER_Efor combinations where PSS withsaltLen=0would be geometrically valid. Keys in this range are non-standard but valid — they can be loaded from external DER.Fix: add a
WC_RSA_PSS#ifdefthat skips theRSA_BUFFER_Ereturn whenpad_type == WC_RSA_PSS_PAD, mirroring the existingWC_RSA_NO_PADDINGexception for raw mode.Test plan
/cc @wolfSSL-Fenrir-bot please review