summaryrefslogtreecommitdiff
path: root/jwt/algorithms.py
diff options
context:
space:
mode:
authorMark Adams <mark@markadams.me>2015-03-17 08:21:58 -0500
committerMark Adams <madams@atlassian.com>2015-03-17 08:21:58 -0500
commit7c4e96b3a56e7d8b8a4b05b086639c1e2ac25cca (patch)
treee54406da15ec10ee11f2d69c9352419fa3e512a3 /jwt/algorithms.py
parent975fa0f96b356bca74b0cc6933b3cd987fa72417 (diff)
downloadpyjwt-7c4e96b3a56e7d8b8a4b05b086639c1e2ac25cca.tar.gz
Rearranged the way the SHA hash functions were laid out.
Diffstat (limited to 'jwt/algorithms.py')
-rw-r--r--jwt/algorithms.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/jwt/algorithms.py b/jwt/algorithms.py
index d3bc11d..720d675 100644
--- a/jwt/algorithms.py
+++ b/jwt/algorithms.py
@@ -83,11 +83,13 @@ class HMACAlgorithm(Algorithm):
Performs signing and verification operations using HMAC
and the specified hash function.
"""
+ SHA256 = hashlib.sha256
+ SHA384 = hashlib.sha384
+ SHA512 = hashlib.sha512
+
def __init__(self, hash_alg):
self.hash_alg = hash_alg
- SHA256, SHA384, SHA512 = hashlib.sha256, hashlib.sha384, hashlib.sha512
-
def prepare_key(self, key):
if not isinstance(key, string_types) and not isinstance(key, bytes):
raise TypeError('Expecting a string- or bytes-formatted key.')
@@ -110,12 +112,13 @@ if has_crypto:
Performs signing and verification operations using
RSASSA-PKCS-v1_5 and the specified hash function.
"""
+ SHA256 = hashes.SHA256
+ SHA384 = hashes.SHA384
+ SHA512 = hashes.SHA512
def __init__(self, hash_alg):
self.hash_alg = hash_alg()
- SHA256, SHA384, SHA512 = hashes.SHA256, hashes.SHA384, hashes.SHA512
-
def prepare_key(self, key):
if isinstance(key, interfaces.RSAPrivateKey) or \
isinstance(key, interfaces.RSAPublicKey):
@@ -166,11 +169,13 @@ if has_crypto:
Performs signing and verification operations using
ECDSA and the specified hash function
"""
+ SHA256 = hashes.SHA256
+ SHA384 = hashes.SHA384
+ SHA512 = hashes.SHA512
+
def __init__(self, hash_alg):
self.hash_alg = hash_alg()
- SHA256, SHA384, SHA512 = hashes.SHA256, hashes.SHA384, hashes.SHA512
-
def prepare_key(self, key):
if isinstance(key, interfaces.EllipticCurvePrivateKey) or \
isinstance(key, interfaces.EllipticCurvePublicKey):