File tree Expand file tree Collapse file tree 4 files changed +14
-1
lines changed
Expand file tree Collapse file tree 4 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
77[ Unreleased] [ unreleased ]
88-------------------------------------------------------------------------
99### Changed
10+ - Add support for ECDSA public keys in RFC 4253 (OpenSSH) format [ #244 ] [ 244 ]
1011- Renamed commandline script ` jwt ` to ` jwt-cli ` to avoid issues with the script clobbering the ` jwt ` module in some circumstances.
1112- Better error messages when using an algorithm that requires the cryptography package, but it isn't available [ #230 ] [ 230 ]
1213
@@ -129,3 +130,4 @@ rarely used. Users affected by this should upgrade to 3.3+.
129130[ 182 ] : https://github.com/jpadilla/pyjwt/pull/182
130131[ 183 ] : https://github.com/jpadilla/pyjwt/pull/183
131132[ 213 ] : https://github.com/jpadilla/pyjwt/pull/214
133+ [ 244 ] : https://github.com/jpadilla/pyjwt/pull/244
Original file line number Diff line number Diff line change @@ -356,7 +356,10 @@ def prepare_key(self, key):
356356 # a Signing Key or a Verifying Key, so we try
357357 # the Verifying Key first.
358358 try :
359- key = load_pem_public_key (key , backend = default_backend ())
359+ if key .startswith (b'ecdsa-sha2-' ):
360+ key = load_ssh_public_key (key , backend = default_backend ())
361+ else :
362+ key = load_pem_public_key (key , backend = default_backend ())
360363 except ValueError :
361364 key = load_pem_private_key (key , password = None , backend = default_backend ())
362365
Original file line number Diff line number Diff line change 1+ ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBAFZwnA8QCdL+TiQWBSHE0XsnRJBCFkb6c2DL7+ZfCFDk9khSYh3VrVOOQ1eIrO/oOm20Gp24dvP9XQS0f5B9bLQHgGFnkydPIMaNzPUNCop17F5uHOhtuFIhmOlh3lpTjyj2ten86cCetqN12kawnRs1/iu0wsGoVgk3os6yUAHvFMFGA==
Original file line number Diff line number Diff line change @@ -375,6 +375,13 @@ def test_ec_should_accept_pem_private_key_bytes(self):
375375 with open (key_path ('testkey_ec' ), 'rb' ) as ec_key :
376376 algo .prepare_key (ec_key .read ())
377377
378+ @pytest .mark .skipif (not has_crypto , reason = 'Not supported without cryptography library' )
379+ def test_ec_should_accept_ssh_public_key_bytes (self ):
380+ algo = ECAlgorithm (ECAlgorithm .SHA256 )
381+
382+ with open (key_path ('testkey_ec_ssh.pub' ), 'r' ) as ec_key :
383+ algo .prepare_key (ec_key .read ())
384+
378385 @pytest .mark .skipif (not has_crypto , reason = 'Not supported without cryptography library' )
379386 def test_ec_verify_should_return_false_if_signature_invalid (self ):
380387 algo = ECAlgorithm (ECAlgorithm .SHA256 )
You can’t perform that action at this time.
0 commit comments