Skip to content
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

Fix incorrectly named ECDSA algorithm #219

Merged
merged 4 commits into from
Oct 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/algorithms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This library currently supports:
* HS512 - HMAC using SHA-512 hash algorithm
* ES256 - ECDSA signature algorithm using SHA-256 hash algorithm
* ES384 - ECDSA signature algorithm using SHA-384 hash algorithm
* ES512 - ECDSA signature algorithm using SHA-512 hash algorithm
* ES521 - ECDSA signature algorithm using SHA-512 hash algorithm
* RS256 - RSASSA-PKCS1-v1_5 signature algorithm using SHA-256 hash algorithm
* RS384 - RSASSA-PKCS1-v1_5 signature algorithm using SHA-384 hash algorithm
* RS512 - RSASSA-PKCS1-v1_5 signature algorithm using SHA-512 hash algorithm
Expand Down
2 changes: 1 addition & 1 deletion jwt/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_default_algorithms():
'RS512': RSAAlgorithm(RSAAlgorithm.SHA512),
'ES256': ECAlgorithm(ECAlgorithm.SHA256),
'ES384': ECAlgorithm(ECAlgorithm.SHA384),
'ES512': ECAlgorithm(ECAlgorithm.SHA512),
'ES521': ECAlgorithm(ECAlgorithm.SHA512),
'PS256': RSAPSSAlgorithm(RSAPSSAlgorithm.SHA256),
'PS384': RSAPSSAlgorithm(RSAPSSAlgorithm.SHA384),
'PS512': RSAPSSAlgorithm(RSAPSSAlgorithm.SHA512)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_api_jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def test_encode_decode_with_ecdsa_sha512(self, jws, payload):
with open('tests/keys/testkey_ec', 'r') as ec_priv_file:
priv_eckey = load_pem_private_key(ensure_bytes(ec_priv_file.read()),
password=None, backend=default_backend())
jws_message = jws.encode(payload, priv_eckey, algorithm='ES512')
jws_message = jws.encode(payload, priv_eckey, algorithm='ES521')

with open('tests/keys/testkey_ec.pub', 'r') as ec_pub_file:
pub_eckey = load_pem_public_key(ensure_bytes(ec_pub_file.read()), backend=default_backend())
Expand All @@ -553,7 +553,7 @@ def test_encode_decode_with_ecdsa_sha512(self, jws, payload):
# string-formatted key
with open('tests/keys/testkey_ec', 'r') as ec_priv_file:
priv_eckey = ec_priv_file.read()
jws_message = jws.encode(payload, priv_eckey, algorithm='ES512')
jws_message = jws.encode(payload, priv_eckey, algorithm='ES521')

with open('tests/keys/testkey_ec.pub', 'r') as ec_pub_file:
pub_eckey = ec_pub_file.read()
Expand All @@ -566,11 +566,11 @@ def test_ecdsa_related_algorithms(self, jws):
if has_crypto:
assert 'ES256' in jws_algorithms
assert 'ES384' in jws_algorithms
assert 'ES512' in jws_algorithms
assert 'ES521' in jws_algorithms
else:
assert 'ES256' not in jws_algorithms
assert 'ES384' not in jws_algorithms
assert 'ES512' not in jws_algorithms
assert 'ES521' not in jws_algorithms

def test_skip_check_signature(self, jws):
token = ("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
Expand Down