All Products
Search
Document Center

Key Management Service:unWrapKey

Last Updated:Mar 31, 2026

Import an encrypted symmetric key or private key from a file into the Hardware Security Module (HSM). Use unWrapKey together with wrapKey to back up and migrate keys between HSMs.

Prerequisites

Before you begin, ensure that you have:

Syntax

unWrapKey -f <key-file-name>
          -w <wrapping-key-handle>
          [-sess]
          [-min_srv <minimum-number-of-HSMs>]
          [-timeout <number-of-seconds>]
          [-tag_size <tag size>]
          [-iv_file <IV file>]
          [-attest]
          [-m <wrapping-mechanism>]
          [-t <hash-type>]
          [-nex]
          [-noheader]
          [-l <key-label>]
          [-id <key-id>]
          [-kt <key-type>]
          [-kc <key-class>]
          [-i <unwrapping-IV>]
Important

Enter parameters in the order shown above.

Example

This example imports an AES-encrypted key file. The key is decrypted using the AES key with handle 6 and mechanism 4 (AES_KEY_WRAP_PAD_PKCS5). The imported key is assigned handle 22.

Command:   unWrapKey -f aes-encrypted.key -w 6 -m 4

           Cfm2UnWrapKey5 returned: 0x00 : HSM Return: SUCCESS

           Key Unwrapped.  Key Handle: 22

           Cluster Status:
           Node id 0 status: 0x00000000 : HSM Return: SUCCESS

Parameters

ParameterRequiredDescription
-fYesPath and filename of the encrypted key file.
-wYesHandle of the decryption key.
-mYesUnwrapping mechanism. See Unwrapping mechanisms.
-sessNoMarks the imported key as a session key (valid only for the current session).
-attestNoPerforms an integrity check on the firmware response.
-min_srvNoMinimum number of HSMs the key must synchronize to within the time set by -timeout. If synchronization does not complete in time, the key is not imported.
-timeoutNoTime limit in seconds for the key to synchronize to the number of servers set by -min_srv. Only valid when used with -min_srv. Default: no timeout (waits indefinitely).
-tag_sizeNoBlock size. Applies only to AES_GCM and CLOUDHSM_AES_GCM mechanisms.
-iv_fileNoLength of the AES initialization vector (IV). Applies only to the AES_GCM mechanism.
-tNoHash algorithm. See Hash algorithms.
-nexNoMarks the imported key as non-exportable.
-noheaderNoOmits the header for specific key properties. When specified, the following parameters are applicable: -l, -kc, -kt, -id, -i.
-lNoLabel for the imported key. Only applicable when -noheader is specified.
-idNoID for the imported key. Only applicable when -noheader is specified.
-kcNoClass of the imported key. Only applicable when -noheader is specified. Valid values: 3 (private key), 4 (symmetric key).
-ktNoType of the imported key. Only applicable when -noheader is specified. Valid values: 0 (RSA), 1 (DSA), 3 (ECC), 16 (GENERIC_SECRET), 21 (DES3), 31 (AES).
-iNoInitialization vector (IV) for the unwrapping operation. Only applicable when -noheader is specified and the mechanism is CLOUDHSM_AES_KEY_WRAP or NIST_AES_WRAP.

Unwrapping mechanisms

ValueMechanism
4AES_KEY_WRAP_PAD_PKCS5
5NIST_AES_WRAP_NO_PAD
6NIST_AES_WRAP_PAD
7RSA_AES
8RSA_OAEP
9NIST_TDEA_WRAP
10AES_GCM
11CLOUDHSM_AES_GCM

Hash algorithms

ValueAlgorithm
2SHA1
3SHA-256
4SHA-384
5SHA-512
6SHA224 (valid for RSA_AES and RSA_OAEP only)

What's next

  • wrapKey — Export and encrypt a key from the HSM before migration or backup