If you want to use your own key materials instead of the KMS-generated materials, you can use the console to import your key materials to KMS. CMKs created using imported materials and KMS-generated materials are managed together by KMS.
This section describes how to import key materials on the KMS console.
You can enter up to 255 characters.
Algorithm |
Description |
Configuration |
---|---|---|
RSAES_OAEP_SHA_256 |
RSA algorithm that uses OAEP and has the SHA-256 hash function |
Select an algorithm based on your HSM functions. If the HSMs support the RSAES_OAEP_SHA_256 algorithm, use RSAES_OAEP_SHA_256 to encrypt key materials. |
If you stop a key material import process and want to try again, click Import Key Material in the row of the required custom key, and import key material in the displayed dialog box.
The wrapping key expires in 24 hours. If the wrapping key is invalid, download it again.
The import wizard automatically transfers the import token. If you close the wizard before completing the import, the token will automatically become invalid. To retry import, open the import wizard again.
{ "key_id": "43f1ffd7-18fb-4568-9575-602e009b7ee8", "wrapping_algorithm":"RSAES_OAEP_SHA_256" }
{ "key_id": "43f1ffd7-18fb-4568-9575-602e009b7ee8", "public_key":"public key base64 encoded data", "import_token":"import token base64 encoded data", "expiration_time":1501578672 }
openssl enc -d -base64 -A -in PublicKey.b64 -out PublicKey.bin
After performing this step, you will obtain either of the following files:
Symmetric key scenario: EncryptedKeyMaterial.bin (key material)
Asymmetric key scenario: EncryptedKeyMaterial.bin (temporary key material) and out_rsa_private_key.der (private key ciphertext)
Method 1: Use the downloaded wrapping key to encrypt key materials on your HSM. For details, see the operation guide of your HSM.
If you need to run the openssl pkeyutl command, ensure your OpenSSL version is 1.0.2 or later.
If the wrapping key was downloaded from the console, replace PublicKey.bin in the following command with the wrapping key name wrappingKey_keyID.
Wrapping Key Algorithm |
Key Material Encryption |
---|---|
RSAES_OAEP_SHA_256 |
openssl pkeyutl -in PlaintextKeyMaterial.bin -inkey PublicKey.bin -out EncryptedKeyMaterial.bin -keyform der -pubin -encrypt -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha256 |
openssl pkcs8 -topk8 -inform PEM -in pkcs1_rsa_private_key.pem -outform pem -nocrypt -out rsa_private_key.pem
openssl pkcs8 -topk8 -inform PEM -outform DER -in rsa_private_key.pem -out rsa_private_key.der -nocrypt
openssl enc -id-aes256-wrap-pad -K $(cat 0xPlaintextKeyMaterial.bin) -iv A65959A6 -in rsa_private_key.der -out out_rsa_private_key.der
By default, the -id-aes256-wrap-pad algorithm is not enabled in OpenSSL. To wrap a key, upgrade OpenSSL to the latest version and patch it first. For details, see FAQs.
Parameter |
Description |
---|---|
Key ID |
Random ID of a CMK generated during the CMK creation |
Key material |
Import a key material. For example, use the EncryptedKeyMaterial.bin file in 10.b.ii. |
Parameter |
Description |
---|---|
Key ID |
Random ID of a CMK generated during the CMK creation |
Temporary key material |
Import a temporary key material. For example, select the EncryptedKeyMaterial.bin file in 10.b.ii. |
Private key ciphertext |
Select private key ciphertext. For example, select the out_rsa_private_key.der file in 10.b.iii. |
Parameter |
Description |
---|---|
Key ID |
Random ID of a CMK generated during the CMK creation |
Key import token |
Select the import token obtained via API in 12.b. |
Key material expiration mode |
|
Key materials can be successfully imported when they match the corresponding CMK ID and token.
Your imported materials are displayed in the list of CMKs. The default status of an imported CMK is Enabled.