Esempio n. 1
0
 def test_compact_rsa(self):
     jwe = JWE(algorithms=JWE_ALGORITHMS)
     s = jwe.serialize_compact({
         'alg': 'RSA-OAEP',
         'enc': 'A256GCM'
     }, 'hello', read_file_path('rsa_public.pem'))
     data = jwe.deserialize_compact(s, read_file_path('rsa_private.pem'))
     header, payload = data['header'], data['payload']
     self.assertEqual(payload, b'hello')
     self.assertEqual(header['alg'], 'RSA-OAEP')
Esempio n. 2
0
 def test_aes_gcm_jwe(self):
     jwe = JWE(algorithms=JWE_ALGORITHMS)
     sizes = [128, 192, 256]
     _enc_choices = [
         'A128CBC-HS256', 'A192CBC-HS384', 'A256CBC-HS512',
         'A128GCM', 'A192GCM', 'A256GCM'
     ]
     for s in sizes:
         alg = 'A{}GCMKW'.format(s)
         key = os.urandom(s // 8)
         for enc in _enc_choices:
             protected = {'alg': alg, 'enc': enc}
             data = jwe.serialize_compact(protected, b'hello', key)
             rv = jwe.deserialize_compact(data, key)
             self.assertEqual(rv['payload'], b'hello')