- Newest
- Most votes
- Most comments
Thank you for providing the details of your situation. I understand you're trying to import an asymmetric external key material (BYOK - Bring Your Own Key) into AWS KMS for electronic invoicing purposes. The error you're encountering (InvalidCiphertextException) suggests there might be an issue with the key material encryption process.
Based on the information provided, there are a few potential issues to consider:
-
Key Material Format: AWS KMS requires the key material to be in a specific format. For asymmetric keys, you need to ensure you're importing the private key material in the correct format.
-
Encryption Algorithm: The encryption method you're using for the key material might not be compatible with what AWS KMS expects. AWS KMS supports specific wrapping algorithms for imported key material.
-
Key Specification: Make sure the key you're trying to import matches the key specification of the KMS key you created to receive the imported material.
-
Import Token: Ensure you're using a valid and recent import token obtained from the GetParametersForImport operation.
To address these issues, consider the following adjustments to your process:
-
Use the RSA_AES_KEY_WRAP_SHA_256 algorithm for wrapping the key material, as it's supported by AWS KMS for asymmetric keys.
-
Ensure your private key is in the correct format (typically DER-encoded PKCS#8).
-
Double-check that you're using the correct wrapping key and import token from a recent GetParametersForImport request.
-
Verify that the key specification of your KMS key matches the type of key you're importing (e.g., RSA_2048, ECC_NIST_P256, etc.).
If you continue to encounter issues after making these adjustments, you may want to review the AWS documentation on importing key material or consider reaching out to AWS support for further assistance, as they can provide more specific guidance based on your exact setup and requirements.
Sources
Unable to import an ECC_NIST_P256 asymmetric private key to KMS | AWS re:Post
How to migrate asymmetric keys from CloudHSM to AWS KMS | AWS Security Blog
Unable to import an RSA 2048 private key to KMS | AWS re:Post
answered 2 years ago
At a quick glance, seems like you are wrapping the key using aes-cbc and not using rsa-aes key wrap scheme. Try following the import guide shown here: https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys-encrypt-key-material.html
answered 2 years ago
Relevant content
asked 2 years ago
asked 2 years ago
asked 3 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
