Skip to content

make pylama happier #7

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

Merged
merged 1 commit into from
Mar 26, 2018
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
1 change: 0 additions & 1 deletion src/cryptojwt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,3 @@ def payload(self):
pass

return _msg

6 changes: 3 additions & 3 deletions src/cryptojwt/jwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
21 changes: 10 additions & 11 deletions src/cryptojwt/jwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/cryptojwt/jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/cryptojwt/jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down