I am creating the key using
openssl ecparam -out ec-private-key.bin -outform DER -name prime256v1 -genkey -param_enc explicit
Followed in the instructions mentioned in importing-keys-encrypt-key-material to encrypt the key and try to import it but it fails with the error : ImportKeyMaterial request failed: InvalidCiphertextException
Steps followed:
- Download wrapping public key and import token from AWS console
- Wrapping key spec: RSA_4096
- Wrapping algorithm: RSAES_OAEP_SHA_256
- Encrypt key materials using
openssl pkeyutl -encrypt -in ec-private-key.bin -out EncryptedKeyMaterial.bin -inkey WrappingPublicKey.bin -keyform DER -pubin -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha256 -pkeyopt rsa_mgf1_md:sha256
- Upload the EncryptedKeyMaterial.bin and ImportToken.bin to KMS console.