You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Format decoders such as SSH and PuTTY hold RSA private keys as n, e, d, p and q, while PKCS#8 also needs dP, dQ and qInv.
Add the picky-crypto-rsa-crt crate, which computes these parameters with constant-time crypto-bigint arithmetic and checks that the components are consistent before returning them: p and q are odd and at least 3, p * q = n, q is invertible modulo p, and e * dP and e * dQ are 1 modulo p - 1 and q - 1. Secret intermediates and outputs are zeroized. Known-answer and error tests use published Wycheproof keys.
Cargo.lock only gains the new package entry; no version changes.
Vectors: testGroups[i].privateKey from C2SP Wycheproof at 12fd3aaf33eb5fa1f52e026912ee00c054f9d984 (1024 to 8192-bit keys, including 2688, 3104 and 4032 bits), copied verbatim and cited per constant. Error cases only substitute whole fields between cited keys.
Callers in picky (SSH, PuTTY, generate_rsa) only pass two-prime keys.
Not tested: empty n and n above MAX_MODULUS_LEN, since that would require constructed inputs.
Limitation: crypto-bigint does not zeroize some internal temporaries (safegcd state, multiplication and division scratch); documented in the README.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The swapped-prime test does not verify the computed coefficient’s defining modular-inverse relation.
0 open findings
Previously missed (1)
In code that hasn't changed since last review
Test q > p inverse correctness, not just coefficient length
picky-crypto-rsa-crt/tests/crt.rs:61
This is the only case exercising q > p, but it checks only the coefficient's length. Since complete_crt_params validates that an inverse exists rather than validating the returned coefficient, an incorrect reduction or inversion result would still pass this test. Verify the defining relation q × qInv ≡ 1 (mod p) for the swapped key.
Format decoders such as SSH and PuTTY hold RSA private keys as n, e, d,
p and q, while PKCS#8 also needs dP, dQ and qInv.
Add the picky-crypto-rsa-crt crate, which computes these parameters
with constant-time crypto-bigint arithmetic and checks that the
components are consistent before returning them: p and q are odd and
at least 3, p * q = n, q is invertible modulo p, and e * dP and e * dQ
are 1 modulo p - 1 and q - 1. Secret intermediates and outputs are
zeroized. Known-answer and error tests use published Wycheproof keys.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Reject 2049-byte moduli whose first byte is not a zero sign byte, and
cover even and small primes with substituted published fields.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add empty, oversized, zero and one inputs with their specified errors,
align the zeroization limitation with the crate intent, and pin the
cargo-hack version installed in CI.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Load the cited private keys through the conformance suite's Wycheproof
accessor instead of embedding their hexadecimal encodings.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep one known-answer key per modulus and prime alignment class and one
case per check and error variant.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A substituted published prime also breaks p * q = n, which hides the
other checks. Add small structural keys that each fail one check, and
drop the published cases they supersede.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Assert with independent crypto-bigint arithmetic that each hand-written
key fails only its targeted check, and check that an extra leading zero
on p pads dP and qInv byte for byte.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…eature check
The crate has no Cargo features, so the MSRV matrix already covers its
only build configuration.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Format decoders such as SSH and PuTTY hold RSA private keys as n, e, d, p and q, while PKCS#8 also needs dP, dQ and qInv.
Add the picky-crypto-rsa-crt crate, which computes these parameters with constant-time crypto-bigint arithmetic and checks that the components are consistent before returning them: p and q are odd and at least 3, p * q = n, q is invertible modulo p, and e * dP and e * dQ are 1 modulo p - 1 and q - 1. Secret intermediates and outputs are zeroized. Known-answer and error tests use published Wycheproof keys.