diff options
author | Joost Rijneveld <joost@joostrijneveld.nl> | 2017-10-13 11:39:54 +0200 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2018-02-05 11:01:52 +0100 |
commit | fa9b7875c561d7bc566ebaf143805cdf747b0420 (patch) | |
tree | 7aa8681c59b5c72d9b57cb9d252dc454f818c275 | |
parent | 2c1d51210ca713c8ba3c39cab49e7d958fa7f9f6 (diff) | |
download | rsa-git-fa9b7875c561d7bc566ebaf143805cdf747b0420.tar.gz |
Remove duplicate hash method definition
There is no need to specify this list in PKCS1_v2 when it is
already specified in PKCS1. This does rely on the digest_size
attribute being available, but pkcs1.py already depends heavily
on the specific API of hashlib.
-rw-r--r-- | rsa/pkcs1_v2.py | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/rsa/pkcs1_v2.py b/rsa/pkcs1_v2.py index 4ae69b3..d6d2423 100644 --- a/rsa/pkcs1_v2.py +++ b/rsa/pkcs1_v2.py @@ -27,14 +27,6 @@ from rsa import ( transform, ) -HASH_METHOD_TO_BYTE_LENGTH = { - 'MD5': 16, - 'SHA-1': 20, - 'SHA-256': 28, - 'SHA-384': 48, - 'SHA-512': 64, -} - def mgf1(seed, length, hasher='SHA-1'): """ @@ -59,11 +51,11 @@ def mgf1(seed, length, hasher='SHA-1'): """ try: - hash_length = HASH_METHOD_TO_BYTE_LENGTH[hasher] + hash_length = pkcs1.HASH_METHODS[hasher]().digest_size except KeyError: raise ValueError( 'Invalid `hasher` specified. Please select one of: {hash_list}'.format( - hash_list=', '.join(sorted(HASH_METHOD_TO_BYTE_LENGTH.keys())) + hash_list=', '.join(sorted(pkcs1.HASH_METHODS.keys())) ) ) |