Skip to content

feat(impl_jni): add JCA AES-CTR implementation#316

Open
mfazrinizar wants to merge 1 commit into
google:android-jca-branchfrom
mfazrinizar:feat/impl-jni-aes-ctr
Open

feat(impl_jni): add JCA AES-CTR implementation#316
mfazrinizar wants to merge 1 commit into
google:android-jca-branchfrom
mfazrinizar:feat/impl-jni-aes-ctr

Conversation

@mfazrinizar

Copy link
Copy Markdown
Contributor

Summary

Adds the JNI/JCA AES-CTR implementation on top of the existing Android JCA backend skeleton.

This PR implements:

  • AES-CTR raw key import/export
  • AES-CTR JWK import/export
  • AES-CTR key generation using the shared AES helper
  • byte and stream encryption/decryption
  • JCA Cipher("AES/CTR/NoPadding") wiring with IvParameterSpec
  • WebCrypto counter-length rollover handling so counter increments do not carry into nonce bits
  • focused desktop JNI tests
  • Android integration smoke test through the public API

Testing

For the desktop JNI-specific test, run this once first if JNI has not been set up locally:

  • dart run jni:setup

Verified with:

  • dart analyze
  • dart test test/impl_jni_aesctr_test.dart
  • dart test test/webcrypto_test.dart -p vm -n AES-CTR
  • dart test test/aes_ctr_counter_wrap_test.dart
  • flutter test integration_test/jni_aesctr_test.dart -d emulator-name

@mfazrinizar mfazrinizar force-pushed the feat/impl-jni-aes-ctr branch 2 times, most recently from 46a4e76 to 05b5ddb Compare July 12, 2026 18:15
@mfazrinizar mfazrinizar force-pushed the feat/impl-jni-aes-ctr branch from 05b5ddb to 22a7fc8 Compare July 12, 2026 18:23
@mfazrinizar mfazrinizar marked this pull request as ready for review July 12, 2026 18:25
}

int _minBigIntAndInt(BigInt value, int limit) {
// Avoid converting huge counter-space values, such as 2^128,

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: there is trailing whitespace here, which causes dart format --output=none --set-exit-if-changed and git diff --check to fail. please remove it.

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