Skip to content

KMS sign: Avoid rehashing the already hashed message#7817

Closed
paullallier wants to merge 2 commits intolocalstack:masterfrom
paullallier:kms_sign_digest_alt
Closed

KMS sign: Avoid rehashing the already hashed message#7817
paullallier wants to merge 2 commits intolocalstack:masterfrom
paullallier:kms_sign_digest_alt

Conversation

@paullallier
Copy link

This may be an improvement on issue #6815 - hopefully.
May also relate to issue #7158.

Copy link
Contributor

@localstack-bot localstack-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to LocalStack! Thanks for raising your first Pull Request and landing in your contributions. Our team will reach out with any reviews or feedbacks that we have shortly. We recommend joining our Slack Community and share your PR on the #community channel to share your contributions with us. Please make sure you are following our contributing guidelines and our Code of Conduct.

@localstack-bot
Copy link
Contributor

localstack-bot commented Mar 7, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@paullallier
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@paullallier
Copy link
Author

paullallier commented Mar 7, 2023

Not sure why the CI tests fail on something that doesn't seem KMS related... But is there a CI configuration error, more generally?

As far as I can see it's not run the tests in tests/integration/test_kms.py - or several other files in that folder. Is that intentional? (I was trying to double-check that my changes had been tested by the existing test.)

EDIT: I guess the full suite of integration tests didn't run because one of the previous tests failed.

@paullallier
Copy link
Author

I believe my fix is correct though - I've manually applied the change to the localstack docker container I'm running, restarted python, and my JWTs now verify after being signed by localstack KMS in 'RAW' messageType mode - as they do with AWS.

@laszlovandenhoek
Copy link
Contributor

I can confirm that running your branch locally (using python -m localstack.cli.main start --host) now allows me to create (externally) valid signatures using the Sign operation. This is a must-have for verifying JWT tokens. Thanks a lot for finding and fixing this problem just in time for me :) Now let's get this merged ASAP ;)

@laszlovandenhoek
Copy link
Contributor

laszlovandenhoek commented Mar 14, 2023

recheck didn't work, worth a try...

@viren-nadkarni viren-nadkarni self-requested a review March 14, 2023 10:54
@viren-nadkarni viren-nadkarni added the aws:kms AWS Key Management Service label Mar 14, 2023
@paullallier
Copy link
Author

paullallier commented Mar 14, 2023

Hmm. That test suite failed again, but on a different test. I guess it's possible that S3 and firehose (which I don't know) both use KMS sign internally for something, and my change has broken it?

@viren-nadkarni
Copy link
Member

The failures don't seem related to your change.

Thanks for contributing @paullallier !

@paullallier
Copy link
Author

paullallier commented Mar 14, 2023

Thanks @viren-nadkarni. What do we need to do, if anything, to get it mergeable? I think there are some actual KMS tests tha would run in the "integration-tests-against-pro / run-integration-tests" step - and I might genuinely have broken those (though failures there might be that the tests aren't testing the right thing).

@viren-nadkarni
Copy link
Member

@paullallier: We need to add some tests. I'm trying to reproduce the issue so that we can compare the behaviour against AWS. Since you mentioned you're not fluent with Python, I'm happy to take this over.

@paullallier
Copy link
Author

@viren-nadkarni: Sounds good to me. There's some information about it here, which might be useful if you haven't seen it already. #6815 (comment)

Since we can't extract the private key from AWS, I was struggling a bit to come up with a way to do a like-for-like test. And I've, personally, only really tested it with EC256 keys so far, since that's what I'm interested in.

@viren-nadkarni
Copy link
Member

Closing in favour of #7878

Thanks again @paullallier for the findings!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws:kms AWS Key Management Service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants