Summary
The FFI backend accepts JWK properties that are not valid unpadded base64url.
For example, both of these are currently accepted:
AQ==, which contains padding
+w, which uses the standard Base64 + character
Browser WebCrypto rejects both values. JWK fields must use the URL-safe Base64 alphabet without trailing padding, as specified by RFC 7515.
Reproduction
await HmacSecretKey.importJsonWebKey({
'kty': 'oct',
'alg': 'HS256',
'k': 'AQ==',
}, Hash.sha256);
await HmacSecretKey.importJsonWebKey({
'kty': 'oct',
'alg': 'HS256',
'k': '+w',
}, Hash.sha256);
Expected Behavior
Both imports throw FormatException consistently across FFI and browser backends.
Actual Behavior
The FFI backend imports both keys, while the browser backend rejects them. The issue is in the shared FFI JWK decoder, so it can affect HMAC, AES, EC, and RSA JWK fields.
Summary
The FFI backend accepts JWK properties that are not valid unpadded base64url.
For example, both of these are currently accepted:
AQ==, which contains padding+w, which uses the standard Base64+characterBrowser WebCrypto rejects both values. JWK fields must use the URL-safe Base64 alphabet without trailing padding, as specified by RFC 7515.
Reproduction
Expected Behavior
Both imports throw FormatException consistently across FFI and browser backends.
Actual Behavior
The FFI backend imports both keys, while the browser backend rejects them. The issue is in the shared FFI JWK decoder, so it can affect HMAC, AES, EC, and RSA JWK fields.