Skip to content

Commit 93f79a4

Browse files
committed
Ran isort
1 parent f51a2c9 commit 93f79a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+243
-176
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ ENV/
8989
.ropeproject
9090
/.project
9191
/.pydevproject
92-
.isort.cfg
9392
.isort.cfg~
9493
draft/eval.py
9594
draft/idfed.xml

.isort.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[settings]
2+
force_single_line = 1
3+
known_first_party = oic
4+
known_third_party = jwkest,pytest
5+
default_section = THIRDPARTY

.travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ language: python
33
sudo: false
44

55
python:
6+
- "3.7"
67
- "3.6"
78
- "3.5"
89

@@ -14,8 +15,8 @@ env:
1415

1516
matrix:
1617
include:
17-
- python: 3.6
18-
env: TOXENV=py36
18+
- python: 3.7
19+
env: TOXENV=py37
1920

2021
script:
2122
- tox -e $TOXENV

mypy.ini

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[mypy]
2+
check_untyped_defs = True
3+
4+
[mypy-jwkest.*]
5+
ignore_missing_imports = True
6+
7+
[mypy-saml2.*]
8+
ignore_missing_imports = True
9+
10+
[mypy-ldap.*]
11+
ignore_missing_imports = True
12+
13+
[mypy-cryptography.*]
14+
ignore_missing_imports = True
15+
16+
[mypy-defusedxml.*]
17+
ignore_missing_imports = True
18+
19+
[mypy-pytest.*]
20+
ignore_missing_imports = True
21+
22+
[mypy-responses.*]
23+
ignore_missing_imports = True
24+
25+
[mypy-freezegun.*]
26+
ignore_missing_imports = True
27+
28+
[mypy-testfixtures.*]
29+
ignore_missing_imports = True
30+
31+
[mypy-mako.*]
32+
ignore_missing_imports = True

setup.py

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
2727
fd.read(), re.MULTILINE).group(1)
2828

29+
tests_requires = ['responses', 'pytest']
30+
2931
setup(
3032
name="cryptojwt",
3133
version=version,
@@ -41,10 +43,16 @@
4143
"Topic :: Software Development :: Libraries :: Python Modules",
4244
"Programming Language :: Python :: 3.5",
4345
"Programming Language :: Python :: 3.6"
46+
"Programming Language :: Python :: 3.7"
4447
],
4548
install_requires=["cryptography", "requests"],
4649
tests_require=['pytest'],
4750
zip_safe=False,
51+
extras_require={
52+
'testing': tests_requires,
53+
'docs': ['Sphinx', 'sphinx-autobuild', 'alabaster'],
54+
'quality': ['isort'],
55+
},
4856
scripts=glob.glob('script/*.py'),
4957
entry_points={
5058
"console_scripts": [

src/cryptojwt/__init__.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
"""JSON Web Token"""
22
import logging
33

4-
from .exception import BadSyntax
5-
from .utils import as_unicode
6-
from .utils import b64encode_item
7-
from .utils import b64d
8-
from .utils import split_token
9-
4+
from cryptojwt.jwe.jwe import JWE
105
from cryptojwt.jwk import JWK
116
from cryptojwt.jws.jws import JWS
12-
from cryptojwt.jwe.jwe import JWE
137
from cryptojwt.jwt import JWT
14-
from cryptojwt.key_jar import KeyJar
158
from cryptojwt.key_bundle import KeyBundle
9+
from cryptojwt.key_jar import KeyJar
10+
11+
from .exception import BadSyntax
12+
from .utils import as_unicode
13+
from .utils import b64d
14+
from .utils import b64encode_item
15+
from .utils import split_token
1616

1717
try:
1818
from builtins import zip
@@ -31,4 +31,3 @@
3131
"iat": int, "jti": str, "typ": str}
3232

3333
JWT_HEADERS = ["typ", "cty"]
34-

src/cryptojwt/exception.py

-1
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,3 @@ class WrongUsage(JWKESTException):
105105

106106
class HTTPException(JWKESTException):
107107
pass
108-

src/cryptojwt/jwe/aes.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33

44
from cryptography.hazmat.backends import default_backend
55
from cryptography.hazmat.primitives import hmac
6-
from cryptography.hazmat.primitives.ciphers import algorithms
76
from cryptography.hazmat.primitives.ciphers import Cipher
7+
from cryptography.hazmat.primitives.ciphers import algorithms
88
from cryptography.hazmat.primitives.ciphers import modes
99
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
1010
from cryptography.hazmat.primitives.padding import PKCS7
1111

12-
from ..exception import VerificationError, Unsupported, MissingKey
13-
from .exception import UnsupportedBitLength
14-
12+
from ..exception import MissingKey
13+
from ..exception import Unsupported
14+
from ..exception import VerificationError
1515
from . import Encrypter
16+
from .exception import UnsupportedBitLength
1617
from .utils import get_keys_seclen_dgst
1718

1819

src/cryptojwt/jwe/jwe.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66
from ..jwk.jwk import key_from_jwk_dict
77
from ..jwk.rsa import RSAKey
88
from ..jwx import JWx
9-
109
from .exception import DecryptionFailed
1110
from .exception import NoSuitableDecryptionKey
12-
from .exception import NoSuitableEncryptionKey
1311
from .exception import NoSuitableECDHKey
12+
from .exception import NoSuitableEncryptionKey
1413
from .exception import NotSupportedAlgorithm
1514
from .exception import WrongEncryptionAlgorithm
16-
from .jwenc import JWEnc
17-
from .jwe_rsa import JWE_RSA
18-
from .jwe_hmac import JWE_SYM
1915
from .jwe_ec import JWE_EC
16+
from .jwe_hmac import JWE_SYM
17+
from .jwe_rsa import JWE_RSA
18+
from .jwenc import JWEnc
2019
from .utils import alg2keytype
2120

2221
logger = logging.getLogger(__name__)

src/cryptojwt/jwe/jwe_ec.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@
22

33
from cryptography.hazmat.backends import default_backend
44
from cryptography.hazmat.primitives.asymmetric import ec
5-
from cryptography.hazmat.primitives.keywrap import aes_key_wrap
65
from cryptography.hazmat.primitives.keywrap import aes_key_unwrap
6+
from cryptography.hazmat.primitives.keywrap import aes_key_wrap
77

8+
from ..jwk.ec import NIST2SEC
9+
from ..jwk.ec import ECKey
10+
from ..utils import as_bytes
11+
from ..utils import as_unicode
12+
from ..utils import b64d
13+
from ..utils import b64e
814
from . import KEY_LEN
915
from .jwekey import JWEKey
1016
from .jwenc import JWEnc
1117
from .utils import concat_sha256
1218
from .utils import get_random_bytes
1319

14-
from ..jwk.ec import NIST2SEC
15-
from ..jwk.ec import ECKey
16-
17-
from ..utils import b64d
18-
from ..utils import b64e
19-
from ..utils import as_unicode
20-
from ..utils import as_bytes
21-
2220

2321
def ecdh_derive_key(key, epk, apu, apv, alg, dk_len):
2422
"""

src/cryptojwt/jwe/jwe_hmac.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
from cryptography.hazmat.primitives.keywrap import aes_key_unwrap
66
from cryptography.hazmat.primitives.keywrap import aes_key_wrap
77

8-
from .jwekey import JWEKey
9-
from .jwenc import JWEnc
10-
118
from ..exception import MissingKey
129
from ..exception import WrongNumberOfParts
1310
from ..jwk.hmac import SYMKey
14-
from ..utils import intarr2str, as_bytes
11+
from ..utils import as_bytes
12+
from ..utils import intarr2str
13+
from .jwekey import JWEKey
14+
from .jwenc import JWEnc
1515

1616
logger = logging.getLogger(__name__)
1717

@@ -97,4 +97,4 @@ def decrypt(self, token, key=None, cek=None):
9797
if "zip" in self and self["zip"] == "DEF":
9898
msg = zlib.decompress(msg)
9999

100-
return msg
100+
return msg

src/cryptojwt/jwe/jwe_rsa.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import zlib
21
import logging
2+
import zlib
33

4+
from ..utils import as_bytes
45
from . import SUPPORTED
5-
from .exception import ParameterError
66
from .exception import NotSupportedAlgorithm
7+
from .exception import ParameterError
78
from .jwekey import JWEKey
89
from .jwenc import JWEnc
910
from .rsa import RSAEncrypter
1011

11-
from ..utils import as_bytes
12-
1312
logger = logging.getLogger(__name__)
1413

1514
__author__ = 'Roland Hedberg'
@@ -116,4 +115,4 @@ def decrypt(self, token, key, cek=None):
116115
if "zip" in jwe.headers and jwe.headers["zip"] == "DEF":
117116
msg = zlib.decompress(msg)
118117

119-
return msg
118+
return msg

src/cryptojwt/jwe/jwekey.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
from ..jwx import JWx
12
from . import KEY_LEN_BYTES
2-
33
from .aes import AES_CBCEncrypter
44
from .aes import AES_GCMEncrypter
55
from .exception import DecryptionFailed
@@ -8,8 +8,6 @@
88
from .utils import get_random_bytes
99
from .utils import split_ctx_and_tag
1010

11-
from ..jwx import JWx
12-
1311

1412
class JWEKey(JWx):
1513
@staticmethod
@@ -84,4 +82,4 @@ def _decrypt(enc, key, ctxt, iv, tag, auth_data=b''):
8482
try:
8583
return aes.decrypt(ctxt, iv=iv, auth_data=auth_data, tag=tag)
8684
except DecryptionFailed:
87-
raise
85+
raise

src/cryptojwt/jwe/jwenc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import logging
22

3-
from . import SUPPORTED
43
from ..simple_jwt import SimpleJWT
54
from ..utils import b64encode_item
5+
from . import SUPPORTED
66

77
logger = logging.getLogger(__name__)
88

@@ -56,4 +56,4 @@ def is_jwe(self):
5656
return True
5757

5858
def __len__(self):
59-
return len(self.part)
59+
return len(self.part)

src/cryptojwt/jwe/utils.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import struct
3-
43
from math import ceil
54

65
from cryptography.hazmat.backends import default_backend
@@ -11,7 +10,6 @@
1110

1211
from ..utils import b64e
1312

14-
1513
LENMET = {
1614
32: (16, SHA256),
1715
48: (24, SHA384),
@@ -37,8 +35,8 @@ def get_keys_seclen_dgst(key, iv):
3735
return ka, ke, seclen, hash_method
3836

3937

40-
def int2big_endian(n):
41-
return [ord(c) for c in struct.pack('>I', n)]
38+
# def int2big_endian(n):
39+
# return [ord(c) for c in struct.pack('>I', n)]
4240

4341

4442
# def party_value(pv):
@@ -119,4 +117,3 @@ def concat_sha256(secret, dk_len, other_info):
119117
digest.update(other_info)
120118
dkm += digest.finalize()
121119
return dkm[:dk_bytes]
122-

0 commit comments

Comments
 (0)