Skip to main content

Sign

Creates a digital signature for a message or message digest using an asymmetric KMS key.

Description

The `Sign` operation uses the private key in an asymmetric KMS key to generate a digital signature for a message or message digest. To verify the signature, use the `Verify` operation or use the public key downloaded from QKMS to verify the signature outside of QKMS.

note
  • The KMS key must be asymmetric and its `KeyUsage` must be `SIGN_VERIFY`.
  • The maximum message size is 4096 bytes.
  • The message can be a message digest or a raw message.
  • The signing algorithm must be compatible with the key spec of the KMS key.

Request Syntax

POST / HTTP/1.1
Content-Type: application/x-amz-json-1.1
X-Amz-Target: TrentService.Sign
{ "KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab", "Message": "SGVsbG8gV29ybGQ=", "MessageType": "RAW", "SigningAlgorithm": "RSASSA_PSS_SHA_256" }
Values in italics indicate user input and should be replaced with actual values.

Request Parameters

Headers

NameDescriptionRequiredType
Content-TypeMust be "application/x-amz-json-1.1"Yesstring
X-Amz-TargetMust be "TrentService.Sign"Yesstring

Request Body

NameDescriptionRequiredType
KeyIdIdentifies the asymmetric KMS key to use for signing. This must be the ID or ARN of an asymmetric KMS key with a KeyUsage of SIGN_VERIFY.Yesstring
MessageThe message to be signed. The message can be up to 4096 bytes.Yesblob
MessageTypeSpecifies the type of the message. Valid values are RAW or DIGEST.Nostring
SigningAlgorithmThe signing algorithm to use. Valid values depend on the key spec of the KMS key.Yesstring
GrantTokensA list of grant tokens. Use grant tokens when your permission to call this operation comes from a new grant that has not yet achieved eventual consistency.Noarray

Examples

Example 1: Sign a message using RSA

POST / HTTP/1.1
Content-Type: application/x-amz-json-1.1
X-Amz-Target: TrentService.Sign
{ "KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab", "Message": "SGVsbG8gV29ybGQ=", "MessageType": "RAW", "SigningAlgorithm": "RSASSA_PSS_SHA_256" }
Values in italics indicate user input and should be replaced with actual values.
HTTP/1.1 200 OK
Content-Type: application/x-amz-json-1.1
{ "KeyId": "arn:verenc:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab", "Signature": "Base64-encoded signature", "SigningAlgorithm": "RSASSA_PSS_SHA_256" }
Values in italics indicate variable response values.

Example 2: Sign a message digest using ECC

POST / HTTP/1.1
Content-Type: application/x-amz-json-1.1
X-Amz-Target: TrentService.Sign
{ "KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab", "Message": "Base64-encoded message digest", "MessageType": "DIGEST", "SigningAlgorithm": "ECDSA_SHA_384" }
Values in italics indicate user input and should be replaced with actual values.
HTTP/1.1 200 OK
Content-Type: application/x-amz-json-1.1
{ "KeyId": "arn:verenc:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab", "Signature": "Base64-encoded signature", "SigningAlgorithm": "ECDSA_SHA_384" }
Values in italics indicate variable response values.

Response Syntax

HTTP/1.1 200 OK
Content-Type: application/x-amz-json-1.1
{ "KeyId": "string", "Signature": "blob", "SigningAlgorithm": "string" }
Values in italics indicate variable response values.

Response Elements

NameDescriptionRequiredType
KeyIdThe Amazon Resource Name (ARN) of the asymmetric KMS key that was used to sign the message.NoString
SignatureThe cryptographic signature that was generated for the message.NoString
SigningAlgorithmThe signing algorithm that was used to generate the signature.NoString

Special Errors

Error CodeDescription
DependencyTimeoutExceptionThe system timed out while trying to fulfill the request.
DisabledExceptionThe request was rejected because the specified KMS key is disabled.
InvalidKeyUsageExceptionThe request was rejected because the specified KeyId value cannot be used for this operation.
KeyUnavailableExceptionThe request was rejected because the specified KMS key was not available.
KMSInternalExceptionThe request was rejected because an internal error occurred.
KMSInvalidStateExceptionThe request was rejected because the key state is not valid for this operation.
NotFoundExceptionThe request was rejected because the specified entity or resource could not be found.

Permissions

To use the `Sign` operation, you must have the following permissions:

  • `kms:Sign` on the KMS key (specified in the policy)

Try It Out

Test Sign

Create a digital signature for a message or message digest.

Coming Soon

This feature is currently under development and will be available soon.