diff --git a/jwcrypto/jwa.py b/jwcrypto/jwa.py index 13b0697..eb00c89 100644 --- a/jwcrypto/jwa.py +++ b/jwcrypto/jwa.py @@ -870,10 +870,10 @@ def verify(self, key, payload, signature): class _RawJWE: - def encrypt(self, k, ai, m): + def encrypt(self, k, aa, m): raise NotImplementedError - def decrypt(self, k, ai, iv, e, t): + def decrypt(self, k, aa, iv, e, t): raise NotImplementedError diff --git a/jwcrypto/jwk.py b/jwcrypto/jwk.py index de89dae..649588b 100644 --- a/jwcrypto/jwk.py +++ b/jwcrypto/jwk.py @@ -1028,26 +1028,26 @@ def export_to_pem(self, private_key=False, password=False): :return: A serialized bytes buffer containing a PEM formatted key. :rtype: `bytes` """ - _e = serialization.Encoding.PEM + enc = serialization.Encoding.PEM if private_key: if not self.has_private: raise InvalidJWKType("No private key available") f = serialization.PrivateFormat.PKCS8 if password is None: - _a = serialization.NoEncryption() + enc_alg = serialization.NoEncryption() elif isinstance(password, bytes): - _a = serialization.BestAvailableEncryption(password) + enc_alg = serialization.BestAvailableEncryption(password) elif password is False: raise ValueError("The password must be None or a bytes string") else: raise TypeError("The password string must be bytes") return self._get_private_key().private_bytes( - encoding=_e, format=f, encryption_algorithm=_a) + encoding=enc, format=f, encryption_algorithm=enc_alg) else: if not self.has_public: raise InvalidJWKType("No public key available") f = serialization.PublicFormat.SubjectPublicKeyInfo - return self._get_public_key().public_bytes(encoding=_e, format=f) + return self._get_public_key().public_bytes(encoding=enc, format=f) @classmethod def from_pyca(cls, key): diff --git a/jwcrypto/jws.py b/jwcrypto/jws.py index 64b5b2e..c0203c7 100644 --- a/jwcrypto/jws.py +++ b/jwcrypto/jws.py @@ -283,14 +283,14 @@ def _verify(self, alg, key, payload, signature, protected, header=None): '"alg" mismatch, requested' f''' "{alg}", found "{p['alg']}"''' ) - _alg = alg + resulting_alg = alg else: - _alg = p['alg'] + resulting_alg = p['alg'] # the following will verify the "alg" is supported and the signature # verifies if isinstance(key, JWK): - signer = JWSCore(_alg, key, protected, payload, self._allowed_algs) + signer = JWSCore(resulting_alg, key, protected, payload, self._allowed_algs) signer.verify(signature) self.verifylog.append("Success") elif isinstance(key, JWKSet): @@ -305,7 +305,7 @@ def _verify(self, alg, key, payload, signature, protected, header=None): for k in keys: try: signer2 = JWSCore( - _alg, k, protected, + resulting_alg, k, protected, payload, self._allowed_algs ) signer2.verify(signature) diff --git a/jwcrypto/tests.py b/jwcrypto/tests.py index c44123e..0a383ba 100644 --- a/jwcrypto/tests.py +++ b/jwcrypto/tests.py @@ -681,10 +681,10 @@ def test_pem_okp(self): pubkey = jwk.JWK.from_pem(Ed25519PublicPEM) self.assertTrue(pubkey.has_public) self.assertFalse(pubkey.has_private) - _jws = jws.JWS() - _jws.deserialize(sig, pubkey, alg="EdDSA") - self.assertTrue(_jws.objects['valid']) - self.assertEqual(_jws.payload, payload) + jws_token = jws.JWS() + jws_token.deserialize(sig, pubkey, alg="EdDSA") + self.assertTrue(jws_token.objects['valid']) + self.assertEqual(jws_token.payload, payload) def test_jwk_as_dict(self): key = jwk.JWK(**PublicKeys['keys'][0])