Use the FXCL Java API to manage CryptoHub key stores and choose between local application encryption and CryptoHub-backed encryption.
What you’ll build
You will:
- Create an AES-256 key store through Java.
- Encrypt and decrypt locally with a retrievable key.
- Encrypt and decrypt on CryptoHub with a non-retrievable key and DPM header.
- Rotate and delete a test key store.
Before you begin
Complete Install and authenticate FXCL. Confirm that Java can load both /usr/share/java/fxcl-java.jar and the native library in /usr/lib.
The validated AES-CBC examples do not provide authenticated integrity by themselves. Add an approved integrity control for application data.
Create a key store
KeyUsage.DEK creates a data-encryption key store. setRetrievable(true) permits local encryption.
Encrypt and decrypt locally
The operation runs in the Java process. Protect the endpoint and application memory as part of the key boundary.
Encrypt and decrypt on CryptoHub
Create a separate non-retrievable store:
Configure the remote operation and include a DPM header:
The DPM header identifies the key and cryptographic parameters required for decryption. Store the full header and ciphertext together.
Rotate and delete the store
Close JNI-backed objects when the application no longer needs them:
Prefer try-with-resources for KeyServer, Credential, and KeyStore.
Build and run
Verify it works
Require these results:
- The Java API authenticates the Host API session.
- A retrievable store completes the local round trip.
- A non-retrievable store completes the CryptoHub-backed round trip.
- DPM-header decryption recovers the original data.
- Rotation succeeds.
- The test stores are deleted.
Do not log API keys, passwords, clear keys, plaintext, ciphertext, or DPM header contents.
Troubleshooting
Version and scope
This procedure was validated with FXCL 1.9.5, CryptoHub 7.2.0.7, Ubuntu 22.04, OpenSSL 3, and OpenJDK 17.