Skip to content

Conversation

@dnamaz
Copy link

@dnamaz dnamaz commented Dec 4, 2025

To help us get this pull request reviewed and merged quickly, please be sure to include the following items:

  • Tests (if applicable)
  • Documentation (if applicable)
  • Changelog entry
  • A full explanation here in the PR description of the work done

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Tests
  • Other

Backward Compatibility

Is this change backward compatible with the most recently released version? Does it introduce changes which might change the user experience in any way? Does it alter the API in any way?

  • Yes (backward compatible)
  • No (breaking changes)

Issue Linking

  • NA

What's new?

This pull request introduces several improvements and updates to the Java app-encryption SDK, focusing on enhanced cryptographic performance, dependency upgrades, and improved documentation. The most significant change is the addition of a comprehensive crypto benchmark document comparing BouncyCastle and JDK crypto engines across Java versions, highlighting the dramatic performance benefits of using JDK crypto with newer Java releases. The release also upgrades several dependencies, adds JMH for benchmarking, and introduces support for selecting the crypto engine in SessionFactory.

Documentation and Benchmarking Enhancements:

  • Added a detailed CryptoBenchmarks.md documenting performance comparisons between BouncyCastle and JDK crypto engines, Java version impacts, secure memory improvements (FFM vs JNA), and actionable recommendations for users. The document includes raw benchmark data, analysis, migration guidance, and related file references.
  • Integrated JMH (Java Microbenchmark Harness) dependencies into the project to enable robust performance benchmarking of cryptographic operations.

Dependency and Version Upgrades:

  • Upgraded multiple dependencies to their latest versions, including BouncyCastle (1.83), AWS SDKs, Apache Commons, Jackson, Micrometer, Logback, and others. The securememory library is updated to 0.1.7, which brings FFM support for secure memory on Java 22+. The project version is incremented to 0.3.4. [1] [2]

Core SDK Improvements:

  • Enhanced the SessionFactory class to support selection of the crypto engine via a new CryptoEngineType parameter, allowing users to choose between BouncyCastle and JDK crypto implementations. The default remains BouncyCastle for backward compatibility. [1] [2] [3]

Build and Telemetry:

  • Minor fix to the Maven Checkstyle plugin configuration for correct execution order.
  • Added a new dynamodb-local-metadata.json file enabling telemetry for local DynamoDB usage.

dnamaz added 12 commits December 3, 2025 16:51
- Add FFM (Foreign Function & Memory) implementation for Java 22+
- Use multi-release JAR to support both FFM and JNA
- Auto-detect Java version and select best implementation
- FFM provides 1.2x-2.7x performance improvement for secure memory ops
- Update TransientSecretFactory with setPreferJna() option
- Bump secure-memory to 0.1.7
- Update app-encryption to use secure-memory 0.1.7
- Add FFM benchmark results to CryptoBenchmarks.md

FFM files (Java 22+):
- FfmAllocator, FfmProtectedMemoryAllocator
- LinuxFfmProtectedMemoryAllocator, MacOSFfmProtectedMemoryAllocator
- FfmProtectedMemorySecret, FfmSecretFactory
- Exception classes for FFM operations
- Create native-app sample using GraalVM 25 native-image
- Use JDK crypto provider only (no BouncyCastle)
- Use FFM for secure memory (falls back to JNA in JVM mode)
- Include native-image configuration (reachability-metadata, reflect-config)
- Add build scripts and comprehensive README

Features:
- 62MB standalone native executable
- ~16x faster startup (20ms vs 327ms)
- ~11x faster encryption (112µs vs 1271µs)
- ~4.4x faster decryption (86µs vs 381µs)

Files:
- App.java - Main application
- NativeStaticKeyManagementService.java - KMS using TransientSecretFactory
- pom.xml - Maven config with native-maven-plugin
- META-INF/native-image/* - GraalVM configuration
- scripts/*.sh - Build scripts
- README.md - Documentation with benchmarks
The 62MB native binary should not be in the repository.
Build artifacts are already ignored via .gitignore patterns.
secure-memory:
- JUnit Jupiter: 5.13.4 → 6.0.1
- Logback Classic: 1.5.20 → 1.5.21
- maven-source-plugin: 3.3.1 → 3.4.0

app-encryption:
- JUnit Jupiter: 5.13.4 → 6.0.1

JUnit 6.0.1 (released Oct 31, 2025):
- Unified versioning across Platform, Jupiter, Vintage
- Removed separate junit.platform.version property
- Minimum Java 17 (already met)

All tests pass:
- secure-memory: 40 tests
- app-encryption: 298 tests
These auto-generated files in target/generated-sources/ were accidentally
modified in a previous commit. Restored to match upstream/main.
secure-memory:
- Add FfmProtectedMemorySecretTest (9 tests)
- Add FfmSecretFactoryTest (6 tests)
- Update TransientSecretFactoryTest with FFM auto-detection tests
- Add java22-ffm Maven profile for conditional compilation/testing
- Tests skip gracefully on Java 17, run on Java 22+

app-encryption:
- Fix BouncyCastle deprecation: use factory methods
  GCMBlockCipher.newInstance(AESEngine.newInstance())
- Fix RandomStringGenerator deprecation: .build() -> .get()
- Remove unused import in SessionFactoryGenerator

Test results:
- Java 17: 356 tests (17 FFM skipped), 0 failures
- Java 25: 356 tests (1 skipped), 0 failures
@aka-bo aka-bo self-requested a review January 8, 2026 05:38
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.

1 participant