Skip to content

Commit d7cd0bf

Browse files
committed
isort & black
1 parent 94ea39a commit d7cd0bf

16 files changed

+122
-33
lines changed

src/cryptojwt/jwe/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@
2222
"ECDH-ES+A192KW",
2323
"ECDH-ES+A256KW",
2424
],
25-
"enc": ["A128CBC-HS256", "A192CBC-HS384", "A256CBC-HS512", "A128GCM", "A192GCM", "A256GCM",],
25+
"enc": [
26+
"A128CBC-HS256",
27+
"A192CBC-HS384",
28+
"A256CBC-HS512",
29+
"A128GCM",
30+
"A192GCM",
31+
"A256GCM",
32+
],
2633
}
2734

2835
DEPRECATED = {

src/cryptojwt/jwe/jwe_ec.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ def dec_setup(self, token, key=None, **kwargs):
157157
raise Exception("Unknown key length for algorithm")
158158

159159
self.cek = ecdh_derive_key(
160-
key, epubkey.pub_key, apu, apv, str(self.headers["enc"]).encode(), dk_len,
160+
key,
161+
epubkey.pub_key,
162+
apu,
163+
apv,
164+
str(self.headers["enc"]).encode(),
165+
dk_len,
161166
)
162167
elif self.headers["alg"] in [
163168
"ECDH-ES+A128KW",

src/cryptojwt/jwe/rsa.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ def encrypt(self, msg, key, sign_padding="pkcs1_padding"):
2020
return key.encrypt(
2121
msg,
2222
_padding(
23-
mgf=padding.MGF1(algorithm=_chosen_hash()), algorithm=_chosen_hash(), label=None,
23+
mgf=padding.MGF1(algorithm=_chosen_hash()),
24+
algorithm=_chosen_hash(),
25+
label=None,
2426
),
2527
)
2628

src/cryptojwt/jwk/jwk.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ def key_from_jwk_dict(jwk_dict, private=None):
9393
else:
9494
# Ecdsa public key.
9595
ec_pub_numbers = ec.EllipticCurvePublicNumbers(
96-
base64url_to_long(_jwk_dict["x"]), base64url_to_long(_jwk_dict["y"]), curve,
96+
base64url_to_long(_jwk_dict["x"]),
97+
base64url_to_long(_jwk_dict["y"]),
98+
curve,
9799
)
98100
_jwk_dict["pub_key"] = ec_pub_numbers.public_key(backends.default_backend())
99101
return ECKey(**_jwk_dict)

src/cryptojwt/jws/jws.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,11 @@ def verify_json(self, jws, keys=None, allow_none=False, at_least_one=False):
321321
for _sign in _signs:
322322
protected_headers = _sign.get("protected", "")
323323
token = b".".join(
324-
[protected_headers.encode(), _payload.encode(), _sign["signature"].encode(),]
324+
[
325+
protected_headers.encode(),
326+
_payload.encode(),
327+
_sign["signature"].encode(),
328+
]
325329
)
326330

327331
unprotected_headers = _sign.get("header", {})

src/cryptojwt/jws/pss.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def sign(self, msg, key):
3838
sig = key.sign(
3939
digest,
4040
padding.PSS(
41-
mgf=padding.MGF1(self.hash_algorithm()), salt_length=padding.PSS.MAX_LENGTH,
41+
mgf=padding.MGF1(self.hash_algorithm()),
42+
salt_length=padding.PSS.MAX_LENGTH,
4243
),
4344
utils.Prehashed(self.hash_algorithm()),
4445
)
@@ -59,7 +60,8 @@ def verify(self, msg, signature, key):
5960
signature,
6061
msg,
6162
padding.PSS(
62-
mgf=padding.MGF1(self.hash_algorithm()), salt_length=padding.PSS.MAX_LENGTH,
63+
mgf=padding.MGF1(self.hash_algorithm()),
64+
salt_length=padding.PSS.MAX_LENGTH,
6365
),
6466
self.hash_algorithm(),
6567
)

src/cryptojwt/key_bundle.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,9 @@ def do_remote(self):
484484
self.time_out = time.time() + self.cache_time
485485
else:
486486
LOGGER.warning(
487-
"HTTP status %d reading remote JWKS from %s", _http_resp.status_code, self.source,
487+
"HTTP status %d reading remote JWKS from %s",
488+
_http_resp.status_code,
489+
self.source,
488490
)
489491
self.ignore_errors_until = time.time() + self.ignore_errors_period
490492
raise UpdateFailed(REMOTE_FAILED.format(self.source, _http_resp.status_code))

src/cryptojwt/key_jar.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,10 @@ def dumps(self, exclude_issuers: Optional[List[str]] = None):
690690
return json.dumps(_dict)
691691

692692
def load(
693-
self, info: dict, init_args: Optional[dict] = None, load_args: Optional[dict] = None,
693+
self,
694+
info: dict,
695+
init_args: Optional[dict] = None,
696+
load_args: Optional[dict] = None,
694697
):
695698
"""
696699
@@ -811,7 +814,11 @@ def build_keyjar(key_conf, kid_template="", keyjar=None, issuer_id=""):
811814

812815
@deprecated_alias(issuer="issuer_id", owner="issuer_id")
813816
def init_key_jar(
814-
public_path="", private_path="", key_defs="", issuer_id="", read_only=True,
817+
public_path="",
818+
private_path="",
819+
key_defs="",
820+
issuer_id="",
821+
read_only=True,
815822
):
816823
"""
817824
A number of cases here:
@@ -853,7 +860,10 @@ def init_key_jar(
853860
"""
854861

855862
_issuer = init_key_issuer(
856-
public_path=public_path, private_path=private_path, key_defs=key_defs, read_only=read_only,
863+
public_path=public_path,
864+
private_path=private_path,
865+
key_defs=key_defs,
866+
read_only=read_only,
857867
)
858868

859869
if _issuer is None:

src/cryptojwt/tools/keyconv.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ def pem2jwk(
115115

116116

117117
def export_jwk(
118-
jwk: JWK, private: bool = False, encrypt: bool = False, passphrase: Optional[str] = None,
118+
jwk: JWK,
119+
private: bool = False,
120+
encrypt: bool = False,
121+
passphrase: Optional[str] = None,
119122
) -> bytes:
120123
"""Export JWK as PEM/bin"""
121124

tests/test_01_simplejwt.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ def _eq(l1, l2):
1010
def test_pack_jwt():
1111
_jwt = SimpleJWT(**{"alg": "none", "cty": "jwt"})
1212
jwt = _jwt.pack(
13-
parts=[{"iss": "joe", "exp": 1300819380, "http://example.com/is_root": True}, "",]
13+
parts=[
14+
{"iss": "joe", "exp": 1300819380, "http://example.com/is_root": True},
15+
"",
16+
]
1417
)
1518

1619
p = jwt.split(".")

0 commit comments

Comments
 (0)