1414from jwt .utils import base64url_decode , force_bytes , force_unicode
1515
1616try :
17- from cryptography .hazmat .backends import default_backend
1817 from cryptography .hazmat .primitives .serialization import (
1918 load_pem_private_key ,
2019 load_pem_public_key ,
@@ -494,16 +493,12 @@ def test_encode_decode_with_rsa_sha256(self, jws, payload):
494493 # PEM-formatted RSA key
495494 with open ("tests/keys/testkey_rsa.priv" , "r" ) as rsa_priv_file :
496495 priv_rsakey = load_pem_private_key (
497- force_bytes (rsa_priv_file .read ()),
498- password = None ,
499- backend = default_backend (),
496+ force_bytes (rsa_priv_file .read ()), password = None ,
500497 )
501498 jws_message = jws .encode (payload , priv_rsakey , algorithm = "RS256" )
502499
503500 with open ("tests/keys/testkey_rsa.pub" , "r" ) as rsa_pub_file :
504- pub_rsakey = load_ssh_public_key (
505- force_bytes (rsa_pub_file .read ()), backend = default_backend ()
506- )
501+ pub_rsakey = load_ssh_public_key (force_bytes (rsa_pub_file .read ()))
507502
508503 jws .decode (jws_message , pub_rsakey , algorithms = ["RS256" ])
509504
@@ -523,16 +518,12 @@ def test_encode_decode_with_rsa_sha384(self, jws, payload):
523518 # PEM-formatted RSA key
524519 with open ("tests/keys/testkey_rsa.priv" , "r" ) as rsa_priv_file :
525520 priv_rsakey = load_pem_private_key (
526- force_bytes (rsa_priv_file .read ()),
527- password = None ,
528- backend = default_backend (),
521+ force_bytes (rsa_priv_file .read ()), password = None ,
529522 )
530523 jws_message = jws .encode (payload , priv_rsakey , algorithm = "RS384" )
531524
532525 with open ("tests/keys/testkey_rsa.pub" , "r" ) as rsa_pub_file :
533- pub_rsakey = load_ssh_public_key (
534- force_bytes (rsa_pub_file .read ()), backend = default_backend ()
535- )
526+ pub_rsakey = load_ssh_public_key (force_bytes (rsa_pub_file .read ()))
536527 jws .decode (jws_message , pub_rsakey , algorithms = ["RS384" ])
537528
538529 # string-formatted key
@@ -551,16 +542,12 @@ def test_encode_decode_with_rsa_sha512(self, jws, payload):
551542 # PEM-formatted RSA key
552543 with open ("tests/keys/testkey_rsa.priv" , "r" ) as rsa_priv_file :
553544 priv_rsakey = load_pem_private_key (
554- force_bytes (rsa_priv_file .read ()),
555- password = None ,
556- backend = default_backend (),
545+ force_bytes (rsa_priv_file .read ()), password = None ,
557546 )
558547 jws_message = jws .encode (payload , priv_rsakey , algorithm = "RS512" )
559548
560549 with open ("tests/keys/testkey_rsa.pub" , "r" ) as rsa_pub_file :
561- pub_rsakey = load_ssh_public_key (
562- force_bytes (rsa_pub_file .read ()), backend = default_backend ()
563- )
550+ pub_rsakey = load_ssh_public_key (force_bytes (rsa_pub_file .read ()))
564551 jws .decode (jws_message , pub_rsakey , algorithms = ["RS512" ])
565552
566553 # string-formatted key
@@ -599,16 +586,12 @@ def test_encode_decode_with_ecdsa_sha256(self, jws, payload):
599586 # PEM-formatted EC key
600587 with open ("tests/keys/testkey_ec.priv" , "r" ) as ec_priv_file :
601588 priv_eckey = load_pem_private_key (
602- force_bytes (ec_priv_file .read ()),
603- password = None ,
604- backend = default_backend (),
589+ force_bytes (ec_priv_file .read ()), password = None ,
605590 )
606591 jws_message = jws .encode (payload , priv_eckey , algorithm = "ES256" )
607592
608593 with open ("tests/keys/testkey_ec.pub" , "r" ) as ec_pub_file :
609- pub_eckey = load_pem_public_key (
610- force_bytes (ec_pub_file .read ()), backend = default_backend ()
611- )
594+ pub_eckey = load_pem_public_key (force_bytes (ec_pub_file .read ()))
612595 jws .decode (jws_message , pub_eckey , algorithms = ["ES256" ])
613596
614597 # string-formatted key
@@ -628,16 +611,12 @@ def test_encode_decode_with_ecdsa_sha384(self, jws, payload):
628611 # PEM-formatted EC key
629612 with open ("tests/keys/testkey_ec.priv" , "r" ) as ec_priv_file :
630613 priv_eckey = load_pem_private_key (
631- force_bytes (ec_priv_file .read ()),
632- password = None ,
633- backend = default_backend (),
614+ force_bytes (ec_priv_file .read ()), password = None ,
634615 )
635616 jws_message = jws .encode (payload , priv_eckey , algorithm = "ES384" )
636617
637618 with open ("tests/keys/testkey_ec.pub" , "r" ) as ec_pub_file :
638- pub_eckey = load_pem_public_key (
639- force_bytes (ec_pub_file .read ()), backend = default_backend ()
640- )
619+ pub_eckey = load_pem_public_key (force_bytes (ec_pub_file .read ()))
641620 jws .decode (jws_message , pub_eckey , algorithms = ["ES384" ])
642621
643622 # string-formatted key
@@ -656,16 +635,12 @@ def test_encode_decode_with_ecdsa_sha512(self, jws, payload):
656635 # PEM-formatted EC key
657636 with open ("tests/keys/testkey_ec.priv" , "r" ) as ec_priv_file :
658637 priv_eckey = load_pem_private_key (
659- force_bytes (ec_priv_file .read ()),
660- password = None ,
661- backend = default_backend (),
638+ force_bytes (ec_priv_file .read ()), password = None ,
662639 )
663640 jws_message = jws .encode (payload , priv_eckey , algorithm = "ES512" )
664641
665642 with open ("tests/keys/testkey_ec.pub" , "r" ) as ec_pub_file :
666- pub_eckey = load_pem_public_key (
667- force_bytes (ec_pub_file .read ()), backend = default_backend ()
668- )
643+ pub_eckey = load_pem_public_key (force_bytes (ec_pub_file .read ()))
669644 jws .decode (jws_message , pub_eckey , algorithms = ["ES512" ])
670645
671646 # string-formatted key
0 commit comments