Skip to main content
The Vault Hardware Security Module (HSM) auto-unseal and Seal Wrap features require Vault Enterprise with the Governance & Policy Module.
To configure the Futurex PKCS #11 library with Vault, perform the following tasks:
  1. Download and install Vault.
  2. Configure Vault.
  3. Use Vault.
  4. Enable the Seal Wrap feature.
  5. Test the Seal Wrap feature.
  6. Enable and test the Entropy Augmentation feature.
The following sections describe how to perform these tasks.

Download Vault

Download precompiled Vault binaries at https://releases.hashicorp.com/vault/. To download Vault Enterprise binaries, follow the instructions HashiCorp provides Vault customers. This integration requires the Enterprise HSM binary, which is available for testing: https://releases.hashicorp.com/vault/1.7.2+ent.hsm/

Install Vault

Perform the following steps to install Vault:
1
Run the following command to unzip the downloaded package and then move the vault binary to /usr/local/bin:
Shell
2
Run the following command to set the owner of the Vault binary:
Shell
3
Check that vault is available on the system path.
Shell
4
Run the following command to verify the Vault version:
Shell
5
The vault command features opt-in autocompletion for flags, subcommands, and arguments (where supported).Install autocompletion using the following command:
Shell
6
Run the following command to enable autocompletion:
Shell
7
Run the following command to configure Vault to use the mlock syscall without running the process as root. This operation prevents the system from swapping memory to disk.
Shell
8
Run the following command to create a unique, non-privileged system user to run vault:
Shell

Configure Vault

To configure Vault, perform the following tasks:
  1. Configure systemd.
  2. Configure Vault settings.
  3. Configure HSM Auto-unseal and Entropy Augmentation

Configure systemd

Systemd uses documented sane defaults (www.freedesktop.org/software/systemd/man/systemd.directives.html), so you need to set only non-default values in the configuration file.
1
Run the following command to create a Vault service file at /etc/systemd/system/vault.service:
Shell
2
Add the following configuration to vault.service:
None

Configure Vault settings

Vault uses documented sane defaults, so you need to set only non-default values in the configuration file.
1
Run the following command to create /etc/vault.d directory:
Shell
2
Run the following command to create a Vault configuration file, vault.hcl:
Shell
3
Run the following command to set the ownership of the /etc/vault.d directory:
Shell
4
Run the following command to set the file permissions:
Shell

Configure HSM Auto-unseal and Entropy Augmentation

When you start a Vault server, it normally starts in a sealed state where you must have a quorum of existing unseal keys to unseal it. By integrating Vault with the KMES Series 3, a trusted HSM key provider can automatically unseal the Vault server. To integrate the Vault Enterprise server with a KMES Series 3, the configuration file must define the PKCS11 seal stanza and provide the necessary connection information, as shown in the following example: Example: vault.hcl
None
This guide sets the storage backend to the local file system (/tmp/vault) to make the verification step easy.
The example configuration defines the following in its seal stanza:
ParameterDescription
libThe path to the PKCS #11 library on the machine where Vault Enterprise is installed.
slotThe slot number to use. Set this value to 0 because the FXPKCS11 config file sets the slot to 01 by default.
key_labelThe label of the key to use.
hmac_key_labelThe label of the key to use for HMACing
generate_keyIf no existing key with the label specified by key_label exists at Vault initialization, Vault generates a key.
For this integration, set the generate\key parameter to true so that Vault automatically creates the encryption keys that it uses for the Seal Wrap functionality on the KMES. The values set for the key\label and hmac\key\label parameters correspond with the special key label defines that youneed to set in the <CONFIG> section of the fxpkcs11.cfg file).

Use Vault

To get started using Vault, perform the following tasks:
  1. Start the Vault server.
  2. Initialize Vault.
  3. Access the Vault UI.

Start the Vault server

Perform the following steps to start the Vault server:
1
Log in with the vault user.
2
Run the following command to set the PKCS #11 PIN to log in. Use the password of the user you created on the KMES and defined in the fxpkcs11.cfg file.
Shell
You can also set the PKCS #11 PIN in the Vault configuration file ( vault.hcl) with the pin parameter, but we do not recommend that method in a production setting. As a best practice, specify the pin with the VAULT\HSM\PIN environment variable, as shown here, to prevent password exposure if the config file is compromised or stored in an insecure location. If you set it through the environment variable, Vault obfuscates the environment variable after reading it. One caveat: You must reset the VAULT\HSM\PIN environment variable when Vault restarts.
3
Run the following command to start the Vault server:
Shell
If the command succeeds, expect output similar to the following example:
None
4
Open a new terminal window for later steps and leave this terminal running where you started the Vault server.

Initialize Vault

Perform the following steps to initialize Vault:
1
In the new terminal, run the following command to set the VAULT_ADDR environment variable
Shell
2
Run the following command to check the Vault status:
Shell
The output should be similar to the following example:
None
3
Run the following command to initialize Vault:
Shell
The output should be similar to the following example:
None
4
Run the following command to set the VAULT_TOKEN environment variable value to the generated Initial Root Token value displayed in the terminal output:
Shell
To interact with Vault, you must provide a valid token.

Access the Vault UI

Perform the following steps to access the Vault UI:
1
Go to http://localhost:8200 in a web browser.
2
Copy and paste the Initial Root Token output from the Vault initialization command into the Token field, and select [ Sign in ].
If the login succeeds, the Vault UI homepage displays.

Enable the Seal Wrap feature

You can enable Seal Wrap by using the following methods:
  • CLI command
  • Web UI
Perform one of the methods described in the following sections.

Method 1: CLI command

Perform the following steps to execute the CLI command method:
1
To compare seal-wrapped data against unwrapped data, enable key/value v1 secrets engine at two different paths: kv-unwrapped and kv-seal-wrapped.Run the following command to enable k/v v1 without seal wrap at kv-unwrapped:
Shell
Run the following command to enable k/v v1 with seal wrap by using the -seal-wrap flag when you enable the KV workflow:
Shell
To enable seal wrap, pass the -seal-wrap flag when you enable a secrets engine
2
Run the following command to list the enabled secrets engines with details:
Shell
If the command succeeds, the output is similar the the following example:
None
Notice that the Seal Wrap parameter value is true for kv-seal-wrapped/.

Method 2: Web UI

Perform the following steps to execute the Web UI method:
1
Open a web browser and launch the Vault UI (for example, http://127.0.0.1:8200/ui) and then log in.
2
Select Enable new engine.
3
Select KV from the list, and then select [ Next ].
4
Enter kv-unwrapped in the path field and select Version 1 for KV version.
5
Return to the Secrets Engines page and select [ Enable Engine ].
6
Select KV from the list, and then select [ Next ].
7
Enter kv-seal-wrapped in the path field. Select Version 1 for KV version.
8
Select [ Method Options ] to expand, and select the check box for Seal Wrap.
9
Select [ Enable Engine ].

Test the Seal Wrap feature

You can test Seal Wrap and view encrypted secrets by using one of the following methods:
  • CLI command
  • Web UI
Perform one of the methods described in the following sections.

Method 1: CLI command

Perform the following steps to execute the CLI command method:
1
Run the following command to write a secret at kv-unwrapped/unwrapped for testing:
Shell
2
Run the following command to read the path to verify:
Shell
If the command succeeds, the output is similar the the following example:
None
3
Run the following command to write the same secret at kv-seal-wrapped/wrapped for testing:
Shell
4
Run the following command to read the path to verify:
Shell
If the command succeeds, the output is similar the the following example:
None
Use a valid token to write and read secrets the same way, regardless of the seal wrap.

View the encrypted secrets

Remember that you configured the Vault server to use the local file system (/tmp/vault) as its storage backend, as shown in the following example:
None
Perform the following steps to view the encrypted secrets:
1
SSH into the machine where the Vault server is running, and check the stored values in the /tmp/vault directory:
Shell
The /tmp/vault/logical directory has two sub-directories. One maps to kv-unwrapped/ and another maps to kv-seal-wrapped/ although you cannot tell by the folder names.
2
View the secret at rest. One of the directories maps to kv-unwrapped/unwrapped.

Example of viewing encrypted secrets

The following example demonstrates viewing encrypted secrets:
1
Go the first directory:
Shell
2
Run the following command to view its content. The password value is encrypted.
Shell
3
Go to the other directory that maps to kv-seal-wrapped/wrapped. Then, run the following command to view its content. The password value is encrypted.
4
Shell
Secrets are encrypted, but the seal-wrapped value is significantly longer even though both values are the same: my-long-password.

Method 2: Web UI

Perform the following steps to execute the Web UI method:
1
Select kv-unwrapped and select [ Create secret ].
2
Enter unwrapped in the Path for this secret field. Use password in the secret key field and my-longpassword in the value field.
3
Select [ Save ].
4
Repeat the same step for kv-seal-wrapped to write the same secret at the kv-seal-wrapped/wrapped path.
5
Select [ Save ].
You can write and read secrets the same way regardless of the seal wrap by using a valid token.

View the encrypted secrets

Remember that you configured the Vault server to use the local file system (/tmp/vault) as its storage backend, as shown in the following example:
None
1
SSH into the machine where the Vault server is running, and check the stored values in the /tmp/vault directory.
Shell
The /tmp/vault/logical directory has two sub-directories. One maps to kv-unwrapped/ and another maps to kv-seal-wrapped/ although you cannot tell by the folder names.
2
View the secret at rest. One of the directories maps to kv-unwrapped/unwrapped.

Example of viewing encrypted secrets

The following example demonstrates viewing encrypted secrets:
1
Go to the first directory:
Shell
2
Run the following command to view its content. The password value is encrypted.
Shell
3
Another directory maps to kv-seal-wrapped/wrapped.
Shell
4
Run the following command to view its content. The password value is encrypted.
Shell
Secrets are encrypted, but the seal-wrapped value is significantly longer even though both values are the same: my-long-password.

Enable and test the Entropy Augmentation feature

To leverage an external entropy source, you must set the external_entropy_access parameter to true when you enable a secrets engine or auth method. Perform the following steps to enable the KMES as the external entropy source on a transit secrets engine:
You must enable the Entropy Augmentation feature through the CLI because we do not support using the Web UI at this time.
1
Run the following command to enable the transit secrets engine with an external entropy source by using the -external-entropy-access flag:
Shell
2
Run the following command to list the enabled secrets engine with -detailed flag:
Shell
Example output:
None
Notice that the External Entropy Access is set to true for transit/.
3
You can start using the transit secrets engine to encrypt your sensitive data which leverages the KMES as its external entropy source. Regardless, the user experience remains the same as before.

Example workflow

The following example demonstrates the workflow:
1
Run the following command to create a new encryption key named orders:
Shell
2
Run the following command to send a base64-encoded string for Vault to encrypt:
Shell
3
Run the following command to test and verify that you can decrypt the string:
Shell
4
Run the following command to decode to get the original data:
Shell
When you enable the external entropy access, you must set the connectivity to the KMES. If the KMES becomes unreachable for any reason, the transit secrets engine fails to generate new keys or rotate the existing keys, displaying an error similar to the following example
Shell