Fixes #964: Validate key against allowed types for Algorithm family#985
Merged
auvipy merged 15 commits intojpadilla:masterfrom Feb 11, 2025
Merged
Fixes #964: Validate key against allowed types for Algorithm family#985auvipy merged 15 commits intojpadilla:masterfrom
auvipy merged 15 commits intojpadilla:masterfrom
Conversation
dbf2c25 to
20e81e2
Compare
for more information, see https://pre-commit.ci
Contributor
Author
|
@auvipy I think this is ready for review, though I'm working on the tests today. Been a while since I opened this PR, so some decisions may not be as good anymore; generally, I tried to keep the same "logic" of the code (keeping multiple returns, etc) while just inserting the |
pachewise
commented
Feb 6, 2025
| else: | ||
| return bytes(hash_alg(bytestr).digest()) | ||
|
|
||
| def check_crypto_key_type(self, key: PublicKeyTypes | PrivateKeyTypes): |
Contributor
Author
There was a problem hiding this comment.
I also considered putting this in a sub-ABC "CryptoAlgorithm", but that seemed like more changes for not as much value. Let me know if you'd rather I do that instead, or if you would prefer an alternate approach.
for more information, see https://pre-commit.ci
pachewise
commented
Feb 6, 2025
auvipy
approved these changes
Feb 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Following discussion in #964, this PR adds checks to make sure the key loaded by any of the
has_crypto = TrueAlgorithm children is of the correct type for that Algorithm family. I still need to figure out how to check whether it's the right "flavor" of the algo family (for example, that the SHA256 algo is encoding/decoding using a key generated via SHA256).