Skip to content

feat(impl_jni): add JCA RSA-PSS implementation - #341

Open
mfazrinizar wants to merge 3 commits into
google:android-jca-branchfrom
mfazrinizar:feat/impl-jni-rsa-pss
Open

feat(impl_jni): add JCA RSA-PSS implementation#341
mfazrinizar wants to merge 3 commits into
google:android-jca-branchfrom
mfazrinizar:feat/impl-jni-rsa-pss

Conversation

@mfazrinizar

Copy link
Copy Markdown
Contributor

Summary

Adds the JNI/JCA RSA-PSS implementation on top of the Android JCA backend and the persistent RSA key ownership introduced in #323.

This PR implements:

  • RSA key generation with public exponents 3 and 65537
  • PKCS#8 private-key and SPKI public-key import/export
  • RSA-PSS JWK import/export
  • byte and stream signing and verification
  • explicit digest, MGF1 digest, salt-length, and trailer-field parameters
  • standard RSASSA-PSS provider lookup with hash-specific Android aliases
  • focused desktop JNI tests and an Android smoke test covering all supported hashes

Persistent JCA keys are retained through the shared isolate-unsendable key
owner. JNI arenas are used only for temporary values created by an operation.

Testing

Desktop JNI setup, if it has not been run already:

dart run jni:setup

Verified:

dart format --output=none --set-exit-if-changed .
dart analyze
dart test test/impl_jni_rsapss_test.dart
dart test test/webcrypto_test.dart -p vm -n RSA-PSS
cd example/webcrypto_demo_flutter_app
flutter test integration_test/jni_rsapss_test.dart -d emulator-name
git diff --check

@mfazrinizar
mfazrinizar marked this pull request as ready for review July 24, 2026 18:52
Comment on lines +270 to +274
throw ArgumentError.value(
saltLength,
'saltLength',
'must be a positive integer',
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: zero is a valid rsa-pss salt length, including in our shared vectors, so this should say must be a non-negative integer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Updated the message to must be a non-negative integer.

@HamdaanAliQuatil

Copy link
Copy Markdown
Collaborator

non-blocking follow-up: please record RSA-PSS as a provider/API-level limitation. Android’s hash-specific SHAxxxwithRSA/PSS aliases begin at API 23, while the generic RSASSA-PSS entry is not available on API 9-22. so API 21-22 support is provider-dependent and cannot be guaranteed by this implementation alone.

see https://developer.android.com/reference/java/security/Signature

@mfazrinizar
mfazrinizar force-pushed the feat/impl-jni-rsa-pss branch from 956a0b7 to 418c42b Compare July 25, 2026 07:31
@mfazrinizar

Copy link
Copy Markdown
Contributor Author

non-blocking follow-up: please record RSA-PSS as a provider/API-level limitation. Android’s hash-specific SHAxxxwithRSA/PSS aliases begin at API 23, while the generic RSASSA-PSS entry is not available on API 9-22. so API 21-22 support is provider-dependent and cannot be guaranteed by this implementation alone.

see https://developer.android.com/reference/java/security/Signature

Noted. Recorded this as an inline TODO next to the RSA-PSS provider selection. It documents API 21–22 as provider-dependent and leaves the eventual policy open: document limited support, require API 23, or route unsupported cases through another backend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants