Managing encryption key pairs
You can use Key Management Service to create, update, and delete asymmetric encryption key pairs.
Creating an encryption key pair
-
In the management console
, select the folder where you want to create your key pair. -
Navigate
to Key Management Service. -
In the left-hand panel, select Asymmetric keys.
-
Click Create key. In the window that opens:
- Enter a name and, optionally, a description.
- In the Type field, select
Encryption. - In the Algorithm field, select the encryption algorithm.
- Enable deletion protection, if required.
- Click Create.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id.
If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
-
See the description of the CLI command for creating an encryption key pair:
yc kms asymmetric-encryption-key create --help -
Get the ID of the folder where you want to create your key pair.
-
Create your key pair:
yc kms asymmetric-encryption-key create \ --name <key_pair_name> \ --encryption-algorithm <encryption_algorithm> \ --folder-id <folder_ID>Where:
-
--name: Name of the encryption key pair. -
--folder-id: ID of the folder where the key pair will be created. -
--encryption-algorithm: Encryption algorithm. Here are available options:rsa-2048-enc-oaep-sha-256rsa-3072-enc-oaep-sha-256rsa-4096-enc-oaep-sha-256
Result:
id: abjfmo5enqlr******** folder_id: b1gt6g8ht345******** created_at: "2023-08-16T18:10:03Z" name: sample-encryption-key status: ACTIVE encryption_algorithm: RSA_2048_ENC_OAEP_SHA_256 -
To create an encryption key pair, use the AsymmetricEncryptionKeyService/Create gRPC API call.
Updating an encryption key pair
After creating an encryption key pair, you can change its name, description, and labels, as well as enable or disable deletion protection.
-
In the management console
, select the folder containing the key pair. -
Navigate
to Key Management Service. -
In the left-hand panel, select Asymmetric keys.
-
Navigate to the Encryption tab.
-
In the key pair row, click
and select Edit. In the window that opens:- Change the key pair attributes as appropriate.
- Click Save.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id.
If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
-
See the description of the CLI command for updating an encryption key pair:
yc kms asymmetric-encryption-key update --help -
Get the ID of the folder containing the key pair.
-
Get the ID of the required encryption key pair by specifying the folder ID:
yc kms asymmetric-encryption-key list \ --folder-id <folder_ID>Result:
+----------------------+-----------------------+---------------------------+---------------------+--------+ | ID | NAME | ENCRYPTION ALGORITHM | CREATED AT | STATUS | +----------------------+-----------------------+---------------------------+---------------------+--------+ | abjfmo5enqlr******** | sample-encryption-key | RSA_2048_ENC_OAEP_SHA_256 | 2023-08-16 18:10:03 | ACTIVE | +----------------------+-----------------------+---------------------------+---------------------+--------+ -
Update your key pair:
yc kms asymmetric-encryption-key update \ --id <key_pair_ID> \ --new-name <new_key_pair_name> \ --deletion-protectionWhere:
--id: ID of the encryption key pair.--new-name: New name for the key pair.--deletion-protection: Flag to enable deletion protection. To disable key pair deletion protection, use the--no-deletion-protectionflag.
Result:
id: abjfmo5enqlr******** folder_id: b1gt6g8ht345******** created_at: "2023-08-16T18:10:03Z" name: new-encryption-key status: ACTIVE encryption_algorithm: RSA_2048_ENC_OAEP_SHA_256 deletion_protection: trueThe above command renamed the encryption key pair and enabled its deletion protection.
To update an encryption key pair, use the AsymmetricEncryptionKeyService/Update gRPC API call.
Deleting an encryption key pair
- In the management console
, select the folder containing the key pair. - Navigate
to Key Management Service. - In the left-hand panel, select Asymmetric keys.
- Navigate to the Encryption tab.
- In the key pair row, click
and select Delete. - Confirm the deletion.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id.
If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
-
See the description of the CLI command for deleting an encryption key pair:
yc kms asymmetric-encryption-key delete --help -
Get the ID of the folder containing the key pair.
-
Get the ID of the required encryption key pair by specifying the folder ID:
yc kms asymmetric-encryption-key list \ --folder-id <folder_ID>Result:
+----------------------+-----------------------+---------------------------+---------------------+--------+ | ID | NAME | ENCRYPTION ALGORITHM | CREATED AT | STATUS | +----------------------+-----------------------+---------------------------+---------------------+--------+ | abjfmo5enqlr******** | sample-encryption-key | RSA_2048_ENC_OAEP_SHA_256 | 2023-08-16 18:10:03 | ACTIVE | +----------------------+-----------------------+---------------------------+---------------------+--------+ -
Delete the key pair by specifying its ID:
yc kms asymmetric-encryption-key delete \ --id <key_pair_ID>Result:
id: abjfmo5enqlr******** folder_id: b1gt6g8ht345******** created_at: "2023-08-16T18:10:03Z" name: new-encryption-key encryption_algorithm: RSA_2048_ENC_OAEP_SHA_256
To delete an encryption key pair, use the AsymmetricEncryptionKeyService/Delete gRPC API call.