fix(ffi): reject private JWKs in RSA public imports - #333
Conversation
b25583b to
9707d6e
Compare
HamdaanAliQuatil
left a comment
There was a problem hiding this comment.
This looks correct. An RSA JWK with d is a private key, so the public import APIs should reject it instead of silently using only n and e. Keeping the check in the shared RSA importer covers OAEP, PSS, and PKCS#1 and brings the native backend in line with Web Crypto.
I ran the focused test on VM and Chromium, the full VM suite, and dart analyze locally; all passed. Could you also add a short entry under 0.6.2-wip in the changelog?
I have added a short entry under 0.6.2-wip in the changelog to document the RSA public JWK import fix. |
Summary
Root cause
The shared native RSA JWK importer required
dfor private-key imports but did not require it to be absent for public-key imports. Public-key import methods therefore accepted private JWKs and silently discarded their private parameters.The new validation rejects the JWK before allocating or parsing the native RSA key.
Validation
dart analyzedart test test/rsa_jwk_validation_test.dart -p vmdart test test/rsa_jwk_validation_test.dart -p chromedart test -p vmFixes #332