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.
Scenario |
Procedure |
|---|---|
Using existing key materials |
|
Downloading key materials by calling APIs |
|
Downloading key materials on the KMS console |
|
in the upper left corner of the management console and select a region or project.
on the left and choose .{
"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
in the upper left corner of the management console and select a region or project.
on the left and choose .
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. |
The wrapping key expires in 24 hours. If the wrapping key is invalid, download it again.
The console automatically passes the import token. Therefore, do not close or exit the Import Key Material dialog box after the key material is downloaded. Otherwise, the imported token will automatically become invalid.
After downloading wrapping key, use it to encrypt the key material. Then, import the key material in the Import Key Material dialog box. For details, see Importing Key Materials.
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 |
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.
The import method varies depending on the key material download method.
in the upper left corner of the management console and select a region or project.
on the left and choose .
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. |

Scenario |
Description |
|---|---|
Symmetric key |
Use the key material encrypted by wrapping key. For example, the EncryptedKeyMaterial.bin file in Step 3: Using Wrapping Key to Encrypt Key Materials. |
Asymmetric key |
Use the temporary key material and private key ciphertext encrypted by wrapping key. For example, the temporary key material EncryptedKeyMaterial.bin and private key ciphertext out_rsa_private_key.der in Step 3: Using Wrapping Key to Encrypt Key Materials. |
Parameter |
Description |
|---|---|
Key ID |
Random ID of a CMK generated during the CMK creation |
Key import token |
Enter the import token obtained in Downloading the Wrapping Key By Calling APIs. |
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.

Scenario |
Description |
|---|---|
Symmetric key |
Use the key material encrypted by wrapping key. For example, the EncryptedKeyMaterial.bin file in Step 3: Using Wrapping Key to Encrypt Key Materials. |
Asymmetric key |
Use the temporary key material and private key ciphertext encrypted by wrapping key. For example, the temporary key material EncryptedKeyMaterial.bin and private key ciphertext out_rsa_private_key.der in Step 3: Using Wrapping Key to Encrypt Key Materials. |
Parameter |
Description |
|---|---|
Key ID |
Random ID of a CMK generated during the CMK creation |
Key material expiration mode |
|
Key material can be successfully imported when it matches the corresponding key ID.
Your imported materials are displayed in the list of CMKs. The default status of an imported CMK is Enabled.