Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GenerateDataKeyWithoutPlaintext now does not send KeySpec when sending NumberOfBytes #15

Merged
merged 1 commit into from
Aug 17, 2024

Conversation

stevegrossi
Copy link
Contributor

Thanks for your work on ex_aws_kms, I hope this contribution is helpful and I'd be grateful for any feedback on it.

The Issue

I've run into an apparent issue when calling ExAws.KMS.generate_data_key_without_plaintext(number_of_bytes: 128): the response returned is {"ValidationException", "Please specify either number of bytes or key spec."}. That function adds a default "KeySpec" even when "NumberOfBytes" is provided in the options. Per the docs, AWS KMS expects a "KeySpec" or a "NumberOfBytes" but not both:

You must also specify the length of the data key. Use either the KeySpec or NumberOfBytes parameters (but not both).

The Fix

ExAws.KMS.generate_data_key avoids this issue by only adding the default "KeySpec" when "NumberOfBytes" is not given. This pull request applies that same approach to ExAws.KMS.generate_data_key_without_plaintext and adds a test to confirm it.

…mberOfBytes

This behavior is now consistent with GenerateDataKey and fixes `GenerateDataKeyWithoutPlaintext` with a `NumberOfBytes` specified causing KMS to return `{"ValidationException", "Please specify either number of bytes or key spec."}`.
@artkay
Copy link
Collaborator

artkay commented Aug 17, 2024

Thanks, @stevegrossi

@artkay artkay merged commit bdbc084 into ex-aws:master Aug 17, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants