Skip to content

Conversation

harrytmthy
Copy link
Owner

@harrytmthy harrytmthy commented Jun 7, 2025

Summary

This PR enables concurrent access to key material in both SafeSecretKey and SecureRandomKeyProvider, aligning with the goals of #26. While both classes were technically thread-safe via synchronized blocks, they did not scale well in concurrent environments, blocking all threads during common operations like getOrCreateKey() or getEncoded().


Implementation Details

✅ SecureRandomKeyProvider

  • Replaces decryptedKey with an AtomicReference<SecretKey>.
  • Moves the early get() check outside the synchronized block.
  • Rechecks the atomic value inside to avoid duplicate construction.

✅ SafeSecretKey


Closes

@harrytmthy harrytmthy self-assigned this Jun 7, 2025
@harrytmthy harrytmthy added the enhancement New feature or request label Jun 7, 2025
@harrytmthy harrytmthy merged commit 511f36d into main Jun 7, 2025
3 checks passed
@harrytmthy harrytmthy deleted the refactor/enable-concurrent-key-access branch June 7, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant