1
1
# from __future__ import print_function
2
+ import array
2
3
import hashlib
3
4
import os
4
5
import string
5
6
import sys
6
- import array
7
7
8
8
import pytest
9
9
from cryptography .hazmat .backends import default_backend
14
14
from cryptojwt .exception import MissingKey
15
15
from cryptojwt .exception import Unsupported
16
16
from cryptojwt .exception import VerificationError
17
+ from cryptojwt .jwe .aes import AES_CBCEncrypter
18
+ from cryptojwt .jwe .aes import AES_GCMEncrypter
17
19
from cryptojwt .jwe .exception import NoSuitableDecryptionKey
18
20
from cryptojwt .jwe .exception import NoSuitableEncryptionKey
19
21
from cryptojwt .jwe .exception import UnsupportedBitLength
20
22
from cryptojwt .jwe .exception import WrongEncryptionAlgorithm
21
- from cryptojwt .utils import b64e , as_bytes
22
-
23
- from cryptojwt .jwe .aes import AES_CBCEncrypter
24
- from cryptojwt .jwe .aes import AES_GCMEncrypter
25
23
from cryptojwt .jwe .jwe import JWE
26
24
from cryptojwt .jwe .jwe import factory
27
25
from cryptojwt .jwe .jwe_ec import JWE_EC
28
- from cryptojwt .jwe .jwe_rsa import JWE_RSA
29
26
from cryptojwt .jwe .jwe_hmac import JWE_SYM
27
+ from cryptojwt .jwe .jwe_rsa import JWE_RSA
30
28
from cryptojwt .jwe .utils import split_ctx_and_tag
31
-
32
29
from cryptojwt .jwk .ec import ECKey
33
30
from cryptojwt .jwk .hmac import SYMKey
34
- from cryptojwt .jwk .rsa import import_private_rsa_key_from_file
35
31
from cryptojwt .jwk .rsa import RSAKey
36
-
32
+ from cryptojwt .jwk .rsa import import_private_rsa_key_from_file
33
+ from cryptojwt .utils import as_bytes
34
+ from cryptojwt .utils import b64e
37
35
38
36
__author__ = 'rohe0002'
39
37
@@ -129,8 +127,8 @@ def test_jwe_09_a1():
129
127
assert bytes2intarr (tag ) == [130 , 17 , 32 , 198 , 120 , 167 , 144 , 113 , 0 ,
130
128
50 , 158 , 49 , 102 , 208 , 118 , 152 ]
131
129
132
- #tag = long2hexseq(tag)
133
- #iv = long2hexseq(iv)
130
+ # tag = long2hexseq(tag)
131
+ # iv = long2hexseq(iv)
134
132
res = b"." .join ([b64_header , b64_ejek , b64e (iv ), b64e (ctxt ), b64e (tag )])
135
133
136
134
# print(res.split(b'.'))
@@ -154,7 +152,7 @@ def test_aesgcm_bit_length():
154
152
enc_msg = encrypter .encrypt (b'Murder must advertise.' ,
155
153
b'Dorothy L. Sayers' )
156
154
ctx , tag = split_ctx_and_tag (enc_msg )
157
- _msg = encrypter .decrypt (ctx , iv = b'Dorothy L. Sayers' ,tag = tag )
155
+ _msg = encrypter .decrypt (ctx , iv = b'Dorothy L. Sayers' , tag = tag )
158
156
assert _msg == b'Murder must advertise.'
159
157
160
158
0 commit comments