-
-
Notifications
You must be signed in to change notification settings - Fork 694
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
Fixes #964: Validate key against allowed types for Algorithm family #985
Conversation
dbf2c25
to
20e81e2
Compare
for more information, see https://pre-commit.ci
@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 |
@@ -163,6 +199,30 @@ def compute_hash_digest(self, bytestr: bytes) -> bytes: | |||
else: | |||
return bytes(hash_alg(bytestr).digest()) | |||
|
|||
def check_crypto_key_type(self, key: PublicKeyTypes | PrivateKeyTypes): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Following discussion in #964, this PR adds checks to make sure the key loaded by any of the
has_crypto = True
Algorithm 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).