feat: introduce AWS KMS types.MessageTypeRaw for AWS KMS signing operations #573
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi
smallstep/cryptoreviewers! 👋This is my first contributing PR, please feel free to provide any feedback! I'm happy to change things up where required!
Name of feature:
Implement a means for callers to specify
types.MessageTypeRawin AWS KMS Sign operations.Pain or issue this feature alleviates:
Currently, the
awskms.Signoperation exclusively supports the signing of messages, where the message is expected to be atypes.MessageTypeDigest.This limitation prevents callers from being able to specify that their message is un-hashed, and thus unable to inform the AWS KMS API that the Sign operation should have a
types.MessageTypeoftypes.MessageTypeRaw(RAW).Limitations
The objective of this package, (and the other Signing packages) is to provide an implementation of the
crypto.Signerinterface that performs the relevant cloud based signing operations.As a part of the
crypto.Signerinterface, thecrypto.SignerOptsinterface is include as the third and final argument to theSign()method.A perk of the
crypto.SignerOptsinterface is the promise that:However, within the
awskmsimplementation of thecrypto.Signerinterface, this promise cannot be fulfilled, as the AWS KMSSignoperation requires atypes.SigningAlgorithmSpecmust be provided when performing an AWS KMS Signing operation.AWS KMS Go SDK v2 Documentation:
The only exclusion to this limitation is when signing with ECDSA keys. As AWS does not enable the user to specify arbirtary signing algorithms, but rather the specified signing algorithm for that ECDSA key type. See The ECDSA AWS Key Spec
As such, when calling the
awskmsSign()we must always provide a non-zerocrypto.Hashas ourcrypto.SignerOptsargument.Mitigation
To mitigate this limitation, a new
AWSOptionstype is introduced to theawskmspackage.This
AWSOptionstype implements thecrypto.SignerOptsinterface, and allows callers to specify whether or not the message isRAW.Additionally, it posses a
crypto.SignerOptsfieldOptionswhere callers can provide the underlyingcrypto.Hashthat can be matched with the appropriatetypes.SigningAlgorithmSpecthat is expected by the AWS KMS Sign API.Approach
I have opted to use a more generic
AWSOptionsstruct with theRawfield as a boolean to indicate if thetypes.MessageTypeistypes.MessageTypeRawor not. I did consider using a struct such asAWSRawMessageOptionsand removing the field (since the only logical difference is the truthy value of theRawfield.) However I decided against it such that we open ourselves up to adding or removing additional options in the future.Why is this important to the project (if not answered above):
Allow callers to have the additional flexibility of using both
types.MessageTypeRawandtypes.MessageTypeDigestwhen using theawskmsSigner.Is there documentation on how to use this feature? If so, where?
GoDoc comments on the
awskms.AWSOptionsstruct has been introduced.In what environments or workflows is this feature supported?
AWS Environments that leverage AWS KMS Sign operations.
In what environments or workflows is this feature explicitly NOT supported (if any)?
Non-AWS Environments.
Supporting links/other PRs/issues:
N/a