summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoost Rijneveld <joost@joostrijneveld.nl>2017-10-13 11:39:54 +0200
committerSybren A. Stüvel <sybren@stuvel.eu>2018-02-05 11:01:52 +0100
commitfa9b7875c561d7bc566ebaf143805cdf747b0420 (patch)
tree7aa8681c59b5c72d9b57cb9d252dc454f818c275
parent2c1d51210ca713c8ba3c39cab49e7d958fa7f9f6 (diff)
downloadrsa-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.py12
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()))
)
)