GetParametersForImport
Returns the items you need to import key material into a symmetric encryption KMS key. For more information about importing key material into Amazon KMS, see Importing key material in the Amazon Key Management Service Developer Guide.
This operation returns a public key and an import token. Use the public key to encrypt the symmetric key material. Store the import token to send with a subsequent ImportKeyMaterial request.
You must specify the key ID of the symmetric encryption KMS key into which you will import
key material. The KMS key Origin
must be EXTERNAL
. You must also
specify the wrapping algorithm and type of wrapping key (public key) that you will use to
encrypt the key material. You cannot perform this operation on an asymmetric KMS key, an HMAC KMS key, or on any KMS key in a different Amazon Web Services account.
To import key material, you must use the public key and import token from the same
response. These items are valid for 24 hours. The expiration date and time appear in the
GetParametersForImport
response. You cannot use an expired token in an ImportKeyMaterial request. If your key and token expire, send another
GetParametersForImport
request.
The KMS key that you use for this operation must be in a compatible key state. For details, see Key states of Amazon KMS keys in the Amazon Key Management Service Developer Guide.
Cross-account use: No. You cannot perform this operation on a KMS key in a different Amazon Web Services account.
Required permissions: kms:GetParametersForImport (key policy)
Related operations:
Request Syntax
{
"KeyId": "string
",
"WrappingAlgorithm": "string
",
"WrappingKeySpec": "string
"
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
In the following list, the required parameters are described first.
- KeyId
-
The identifier of the symmetric encryption KMS key into which you will import key material. The
Origin
of the KMS key must beEXTERNAL
.Specify the key ID or key ARN of the KMS key.
For example:
-
Key ID:
1234abcd-12ab-34cd-56ef-1234567890ab
-
Key ARN:
arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab
To get the key ID and key ARN for a KMS key, use ListKeys or DescribeKey.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 2048.
Required: Yes
-
- WrappingAlgorithm
-
The algorithm you will use to encrypt the key material before using the ImportKeyMaterial operation to import it. For more information, see Encrypt the key material in the Amazon Key Management Service Developer Guide.
Important The
RSAES_PKCS1_V1_5
wrapping algorithm is deprecated. We recommend that you begin using a different wrapping algorithm immediately. Amazon KMS will end support forRSAES_PKCS1_V1_5
by October 1, 2023 pursuant to cryptographic key management guidancefrom the National Institute of Standards and Technology (NIST). Type: String
Valid Values:
RSAES_PKCS1_V1_5 | RSAES_OAEP_SHA_1 | RSAES_OAEP_SHA_256
Required: Yes
- WrappingKeySpec
-
The type of wrapping key (public key) to return in the response. Only 2048-bit RSA public keys are supported.
Type: String
Valid Values:
RSA_2048
Required: Yes
Response Syntax
{
"ImportToken": blob,
"KeyId": "string",
"ParametersValidTo": number,
"PublicKey": blob
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- ImportToken
-
The import token to send in a subsequent ImportKeyMaterial request.
Type: Base64-encoded binary data object
Length Constraints: Minimum length of 1. Maximum length of 6144.
- KeyId
-
The Amazon Resource Name (key ARN) of the KMS key to use in a subsequent ImportKeyMaterial request. This is the same KMS key specified in the
GetParametersForImport
request.Type: String
Length Constraints: Minimum length of 1. Maximum length of 2048.
- ParametersValidTo
-
The time at which the import token and public key are no longer valid. After this time, you cannot use them to make an ImportKeyMaterial request and you must send another
GetParametersForImport
request to get new ones.Type: Timestamp
- PublicKey
-
The public key to use to encrypt the key material before importing it with ImportKeyMaterial.
Type: Base64-encoded binary data object
Length Constraints: Minimum length of 1. Maximum length of 4096.
Errors
For information about the errors that are common to all actions, see Common Errors.
- DependencyTimeoutException
-
The system timed out while trying to fulfill the request. You can retry the request.
HTTP Status Code: 500
- InvalidArnException
-
The request was rejected because a specified ARN, or an ARN in a key policy, is not valid.
HTTP Status Code: 400
- KMSInternalException
-
The request was rejected because an internal exception occurred. The request can be retried.
HTTP Status Code: 500
- KMSInvalidStateException
-
The request was rejected because the state of the specified resource is not valid for this request.
This exceptions means one of the following:
-
The key state of the KMS key is not compatible with the operation.
To find the key state, use the DescribeKey operation. For more information about which key states are compatible with each Amazon KMS operation, see Key states of Amazon KMS keys in the Amazon Key Management Service Developer Guide .
-
For cryptographic operations on KMS keys in custom key stores, this exception represents a general failure with many possible causes. To identify the cause, see the error message that accompanies the exception.
HTTP Status Code: 400
-
- NotFoundException
-
The request was rejected because the specified entity or resource could not be found.
HTTP Status Code: 400
- UnsupportedOperationException
-
The request was rejected because a specified parameter is not supported or a specified resource is not valid for this operation.
HTTP Status Code: 400
Examples
The following examples are formatted for legibility.
Example Request
This example illustrates one usage of GetParametersForImport.
POST / HTTP/1.1 Host: kms.us-east-2.amazonaws.com Content-Length: 121 X-Amz-Target: TrentService.GetParametersForImport X-Amz-Date: 20161130T225216Z Content-Type: application/x-amz-json-1.1 Authorization: AWS4-HMAC-SHA256\ Credential=AKIAI44QH8DHBEXAMPLE/20161130/us-east-2/kms/aws4_request,\ SignedHeaders=content-type;host;x-amz-date;x-amz-target,\ Signature=5bcc8e7669b6de719091ad27ae0145daa319f881010958208e960329341421d5 { "WrappingAlgorithm": "RSAES_OAEP_SHA_1", "KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab", "WrappingKeySpec": "RSA_2048" }
Example Response
This example illustrates one usage of GetParametersForImport.
HTTP/1.1 200 OK Server: Server Date: Wed, 30 Nov 2016 22:52:17 GMT Content-Type: application/x-amz-json-1.1 Content-Length: 2892 Connection: keep-alive x-amzn-RequestId: a46d61e0-b74f-11e6-b0c0-3343f53dee45 { "ImportToken": "AQECAHgybIx2X9LNs5ADpvmFm5Sv//daUB9ZeCKoiJxmiw09YQAABrQwggawBgkqhkiG9w0BBwagggahMIIGnQIBADCCBpYGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMv9Fgs/U4Wg2Vw+RMAgEQgIIGZ/wOYGszlrjopP6BW63jlYYn+gd7jpdpx0dxPmPC5Ka6uuUomx1yMKVdgtMiX85jHr8or7RoLISwsyQH+CRD33V+pQs+Rm0+XkinHj5Zl371ibHytqM1DwhCs5FdQJM+8kLau7EXTcar7XLQj86DWJRj/dQW0nDdkQXgXvz7GFWkbYs3IELvTAc5lHOLHgkXeoXom3NtHMvbR2V34tYwaT86gdira9Qj0FDouNaTesEOJN/QjBedXcnuWumwOzK+w/OL+MD4tR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0dv7Jd9OemBNTZSlEoQ8U5+sKbvmSrtFvPIj7zWDpDT9bkZFHcCvwlIE6AflbgBS8z0+xllVgbZHjbNE4f1vaW5mB7Eny19GZrh0f7Gt4bWaPdelyZoWBHDARNLnAh7RKQjRVF/phBgaiRlDQdDmJmGD1yl+dxnIcoPs14xlcIwBdpw/M+lvUuX8K4tqLMKzi1MOE0heBhGL0uEebYSkSQSUXUTTCk9hEkqslw0VXgwpgnGBXAOnVtYdUaqFMx5RIVxW471bnU0CYW5MrTTJ7o2jY3HW87Toear3HscuBt020tIdoITFY3Ftu0cx0lxZg5CNx3F0a0hnqeRdbuPBA8QYR9dNf5spiCWLSUQQM3W/H4KrdRPdvevc8kTG6I8fdK/ArYCvTk/yYL3L6YZbeqbActUTADX0iBijX/T5QYz/Dd4H1eX4abHV70CnxftxCHuLMnwR8DpJVnkouQAqb4N7Ap6JIYkvNKFWb8HBlygq5kKcg5dTMAMiPRz80qsQm/IwGG9JVbKeyhqlKtQOIerspm8J99lcn5s0aB180LKrtXAaFD1AyO3nDZxB3I71QKvOulr1BZ6K4meBKkEw3VqW4PpmxmBKnQVUK1jqwQUGF3AWHpU+2ytZAdDox9zLT7YW457esjUQC6zibfBwb8G97leh704m37Stq6Z752u46frBNSPQlypGuSbqCw1peKeqf/AVehk+j8RKBegOQSCvEja4KPmQrayXVzu3h1tDktA1/Wj21ercJaW20fcZ1KQG/GPHuScFgBsWawQf1spqKwZyHAHPaWZCymD9Fo2yHBHi+/ARPwM02iuqDLi9Tqv/g0=", "KeyId": "arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab", "ParametersValidTo": 1.480632737044E9, "PublicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvH3Yj0wbkLEpUl95Cv1cJVjsVNSjwGq3tCLnzXfhVwVvmzGN8pYj3U8nKwgouaHbBWNJYjP5VutbbkKS4Kv4GojwZBJyHN17kmxo8yTjRmjR15SKIQ8cqRA2uaERMLnpztIXdZp232PQPbWGxDyXYJ0aJ5EFSag+iSK341kr2kFTpINN7T1ZaX9vfXBdGR+VtkRKMWoHQeWzHrPZ+3irvpXNCKxGUxmPNsJSjPUhuSXT5+0VrY/LEYLQ5lUTrhU6z5/OK0kzaCc66DXc5ipSloS4Xyg+QcYSMxe9xuqO5HtzFImUSKBm1W6eDT6lHnSbpi7vXzNbIX7pWxKw9nmQvQIDAQAB" }
See Also
For more information about using this API in one of the language-specific Amazon SDKs, see the following: