diff --git a/src/cryptojwt/__init__.py b/src/cryptojwt/__init__.py index 864b191c..80291524 100644 --- a/src/cryptojwt/__init__.py +++ b/src/cryptojwt/__init__.py @@ -283,4 +283,3 @@ def payload(self): pass return _msg - diff --git a/src/cryptojwt/jwe.py b/src/cryptojwt/jwe.py index c7f9624f..39524ae9 100644 --- a/src/cryptojwt/jwe.py +++ b/src/cryptojwt/jwe.py @@ -709,9 +709,9 @@ def ecdh_derive_key(key, epk, apu, apv, alg, dk_len): # Derive the key # AlgorithmID || PartyUInfo || PartyVInfo || SuppPubInfo otherInfo = bytes(alg) + \ - struct.pack("!I", len(apu)) + apu + \ - struct.pack("!I", len(apv)) + apv + \ - struct.pack("!I", dk_len) + struct.pack("!I", len(apu)) + apu + \ + struct.pack("!I", len(apv)) + apv + \ + struct.pack("!I", dk_len) return concat_sha256(shared_key, dk_len, otherInfo) diff --git a/src/cryptojwt/jwk.py b/src/cryptojwt/jwk.py index 68499b5d..a1dd8c21 100644 --- a/src/cryptojwt/jwk.py +++ b/src/cryptojwt/jwk.py @@ -66,21 +66,20 @@ def sha512_digest(msg): def generate_and_store_rsa_key(key_size=2048, filename='rsa.key', passphrase=''): - private_key = rsa.generate_private_key(public_exponent = 65537, - key_size = key_size, - backend = default_backend()) + private_key = rsa.generate_private_key(public_exponent=65537, + key_size=key_size, + backend=default_backend()) with open(filename, "wb") as keyfile: if passphrase: pem = private_key.private_bytes( - encoding = serialization.Encoding.PEM, - format = serialization.PrivateFormat.PKCS8, - encryption_algorithm = serialization.BestAvailableEncryption( - passphrase)) + encoding=serialization.Encoding.PEM, + format=serialization.PrivateFormat.PKCS8, + encryption_algorithm=serialization.BestAvailableEncryption(passphrase)) else: pem = private_key.private_bytes( - encoding = serialization.Encoding.PEM, - format = serialization.PrivateFormat.PKCS8, + encoding=serialization.Encoding.PEM, + format=serialization.PrivateFormat.PKCS8, encryption_algorithm=serialization.NoEncryption()) keyfile.write(pem) keyfile.close() @@ -968,7 +967,7 @@ def __eq__(self, other): if isinstance(other.key, ec.EllipticCurvePublicKey): if self.key.curve != other.key.curve: return False - if self.key.key_size != other.key.key_size : + if self.key.key_size != other.key.key_size: return False if self.key.public_numbers() != other.key.public_numbers(): return False @@ -978,7 +977,7 @@ def __eq__(self, other): if isinstance(other.key, ec.EllipticCurvePrivateKey): if self.key.curve != other.key.curve: return False - if self.key.key_size != other.key.key_size : + if self.key.key_size != other.key.key_size: return False if self.key.private_numbers() != other.key.private_numbers(): return False diff --git a/src/cryptojwt/jws.py b/src/cryptojwt/jws.py index 11ad5c92..866c6393 100644 --- a/src/cryptojwt/jws.py +++ b/src/cryptojwt/jws.py @@ -743,9 +743,7 @@ def is_jws(self, jws): def _is_json_serialized_jws(self, json_jws): json_ser_keys = {"payload", "signatures"} flattened_json_ser_keys = {"payload", "signature"} - if not json_ser_keys.issubset( - json_jws.keys()) and not flattened_json_ser_keys.issubset( - json_jws.keys()): + if not json_ser_keys.issubset(json_jws.keys()) and not flattened_json_ser_keys.issubset(json_jws.keys()): return False return True diff --git a/src/cryptojwt/jwt.py b/src/cryptojwt/jwt.py index 04c7dafb..1366985c 100755 --- a/src/cryptojwt/jwt.py +++ b/src/cryptojwt/jwt.py @@ -221,10 +221,10 @@ def _verify(self, rj, token): def _decrypt(self, rj, token): """ Decrypt an encrypted JsonWebToken - - :param rj: :py:class:`jwkest.jwe.JWE` instance + + :param rj: :py:class:`jwkest.jwe.JWE` instance :param token: The encrypted JsonWebToken - :return: + :return: """ keys = get_jwt_keys(rj.jwt, self.my_keys(), 'enc') return rj.decrypt(token, keys=keys)