Get & Export

The Get and Export operations retrieve the key material from the HSM. Only the user identified by the hsm-admin argument or a user granted the Get operation (by the HSM admin) can retrieve keys from the HSM.

Private keys or symmetric keys marked as sensitive cannot be retrieved from the HSM. The public key of a keypair can always be retrieved.

To export the public key hsm::4::my_rsa_key_pk in PKCS#8 PEM format, the following command can be used:

❯ cosmian kms rsa keys export --key-id hsm::4::my_rsa_key_pk --key-format pkcs8-pem /tmp/pubkey.pem

The key hsm::4::my_rsa_key_pk of type PublicKey was exported to "/tmp/pubkey.pem"

   Unique identifier: hsm::4::my_rsa_key_pk

To export the private key hsm::4::mykey in PKCS#8 PEM format, the following command can be used:

❯ cosmian kms rsa keys export --key-id hsm::4::my_rsa_key --key-format pkcs8-pem /tmp/privkey.pem

The key hsm::4::my_rsa_key of type PrivateKey was exported to "/tmp/privkey.pem"

   Unique identifier: hsm::4::my_rsa_key

To export the symmetric key hsm::4::my_aes_key in raw format (i.e. raw bytes), the following command can be used:

❯ cosmian kms sym keys export --key-id hsm::4::my_aes_key --key-format raw /tmp/symkey.raw

The key hsm::4::my_aes_key of type SymmetricKey was exported to "/tmp/symkey.raw"

   Unique identifier: hsm::4::my_aes_key