-
Notifications
You must be signed in to change notification settings - Fork 16
JCE: add optional KEK caching to WolfSSLKeyStore for performance #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds optional KEK (Key Encryption Key) caching to WolfSSLKeyStore to significantly improve performance for repeated getKey() calls by avoiding redundant PBKDF2 computations. The cache is disabled by default and can be enabled via Security properties with configurable TTL.
Key Changes:
- Implements in-memory cache for derived KEK keys with SHA-256-based cache keys and TTL expiration
- Adds cache lifecycle management with automatic clearing on entry deletion, overwrite, KeyStore reload, and TTL expiration
- Includes comprehensive JUnit tests covering cache behavior, invalidation scenarios, and performance characteristics
- Provides benchmark tool and updated documentation for the new feature
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/wolfssl/provider/jce/WolfSSLKeyStore.java | Core KEK cache implementation including cache data structures, key generation, retrieval/storage logic, and integration with key decryption methods |
| src/test/java/com/wolfssl/provider/jce/test/WolfSSLKeyStoreTest.java | Comprehensive test suite covering cache enabled/disabled behavior, performance improvements, invalidation scenarios, and edge cases |
| examples/provider/WolfSSLKeyStoreGetKeyBenchmark.java | Benchmark application for measuring getKey() performance with and without cache enabled |
| examples/provider/WolfSSLKeyStoreGetKeyBenchmark.sh | Shell script wrapper for running the benchmark |
| docs/design/WolfSSLKeyStore.md | Design documentation covering cache architecture, security properties, lifecycle, and security considerations |
| README_JCE.md | User-facing documentation describing the new Security properties and usage examples |
| jni/include/com_wolfssl_provider_jce_WolfSSLKeyStore.h | JNI header update to export KEK_CACHE_DEFAULT_TTL_MS constant |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/test/java/com/wolfssl/provider/jce/test/WolfSSLKeyStoreTest.java
Outdated
Show resolved
Hide resolved
fc06fd3 to
9f4d153
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9f4d153 to
df874b2
Compare
df874b2 to
5336dec
Compare
This PR adds optional KEK (Key Encryption Key) caching to
WolfSSLKeyStoreto avoid repeated PBKDF2 computations on subsequentgetKey()calls. JUnit tests have been added for testing and regression.Performance
On a Macbook Pro Intel Core i9 2.4 GHz machine, for PrivateKey
getKey()operations:Without KEK cache:
With KEK cache enabled:
Configuration
KEK cache is disabled by default. Can be enabled and TTL adjusted using the following Security properties. The cache TTL defaults to 5 minutes (300 sec), and is set in seconds:
Cache Lifecycle
Cache is automatically cleared on:
Benchmark
A benchmark app is included: