feat(signature): RsaPublicKey with RS256 and PS256 verification #489
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/110-rsa-public-key"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Step 1 of gap 6 in docs/design/FIRST-PARTY.md: the registry's private RS256 verifier becomes
RsaPublicKeyinstd/signature, andtools/registryuses it.RsaPublicKey.fromComponents(refuses moduli under 2048 bits, even moduli, unusable exponents;SignatureError.NotAnRsaKey) andverifiesPkcs1Sha256(RS256); registryrsa.trbremoved; tests with OpenSSL vectors (2048, 3072, 2049 bits) and Wycheproof-style malformed encodings.verifiesPssSha256(PS256, RFC 8017 9.1.2, MGF1, salt 32) with its tests.Closes #110
692a6cc795093b4fe570b5bdc0ebfcef86b4214bef86b4214b9ed4598cbe9ed4598cbe48d0f3c22348d0f3c2232120578a7bCI red on
2120578: ci / tier A (linux-x64) failed after 26m19s (gates failed as a consequence; every other required job is green). The job log is not readable with my account, so I cannot name the cause. Note that tier A also failed on the unrelated heads of #493 (docs-only), #491, #487 and #490, so it may be a shared or flaky failure on main rather than this change. Please check the log and re-run or fix; I looked at the diff meanwhile and found no other blocker, so the next CI run on this head brings me back for the review.CI cause found (job log via the actions API): tier A failed only on
docs skill --check—skills/torbscript-standard-library/references/standard-library/signature.mdwas stale (missingcase NotAnRsaKey(reason: String)). Fixed in89acfb0by adding that line (the generated page now differs fromdocs/standard-library/signature.mdonly by the usual link stripping, as on main). All other gates were green in run 1824. Review re-requested.Review of
89acfb0(round 1; the earlier CI-red note was a comment, not a review).std/signature/src/rsa.trbagainst RFC 8017: EMSA-PKCS1-v1_5 is compared whole,s < nand exact length are enforced, EMSA-PSS-VERIFY handles emBits/emLen (the 2049-bit case with the leading zero byte), the unused-bit mask, 0x01 separator, M' = 8 zeros || mHash || salt, and the fixed 32-byte salt of PS256. Montgomery CIOS limb bounds stay far below 2^63.RsaPublicKeyand its privatersa.trbis removed. Behaviour preserved: an invalid key in a JWKS is skipped as non-verifying, a short passkey key is still refused.Non-blocking:
fromComponentsaccepts an exponent of any length, andpowercosts one Montgomery step per exponent bit. A JWKS from a configured issuer with a hugeewould make one verification very slow. Consider capping the exponent (for example at 64 bits, as most libraries do) in a follow-up.