Skip to main content
Use a retrievable CryptoHub key store to obtain the active AES key and perform encryption inside the C++ application process.

What you’ll build

The example performs this lifecycle:
  1. Create a retrievable AES-256 key store.
  2. Retrieve the active key through KeyStore.
  3. Encrypt and decrypt data locally with AES-CBC and PKCS #7 padding.
  4. Rotate the active key.
  5. Delete the test key store.

Before you begin

Complete Install and authenticate FXCL. The authenticated partition must permit key-store create, retrieve, rotate, and delete operations.
AES-CBC provides confidentiality but not authenticated integrity. Protect the ciphertext with a separate integrity control, or use an approved authenticated construction that your application and Futurex product version support.

Create a retrievable key store

setRetrievable(true) permits FXCL to return the active key for a client-side operation. The clear key can enter application memory. You should receive a valid KeyStore with an active SecretKey.

Encrypt and decrypt locally

Store the initialization vector and cipher parameters with the ciphertext. Decryption must use the same parameters and the key version that encrypted the data. You should recover the original byte sequence exactly.

Rotate the key store

Rotation creates a new active key and expires the prior active key. Keep the key identifier or DPM header with existing ciphertext so the application can select the correct historical key for decryption.

Delete a test key store

Deleting a key store can make its ciphertext unrecoverable. Delete only test-owned stores or stores that completed the approved retention and destruction process.

Build the application

The FXCL_OSSL_3 definition must match the installed OpenSSL 3 package.

Verify it works

Use a dedicated test store and a known plaintext. Require all of these results:
  • createStore returns a valid store.
  • getKey returns the active AES key.
  • The decrypt result exactly matches the input.
  • rotateStore succeeds.
  • deleteStore removes the test store.
Do not record the API key, active key, plaintext, ciphertext, or decrypted value in application logs.

Troubleshooting

Version and scope

This procedure was validated with FXCL 1.9.5, CryptoHub 7.2.0.7, Ubuntu 22.04, GCC 11, and the OpenSSL 3 FXCL package.