def test_4_KEMClient_SET(self):
     server_keys = [JWK(**test_keys[kem.KEY_USAGE_SIG]), None]
     client_keys = [JWK(**self.client_keys[kem.KEY_USAGE_SIG]),
                    JWK(**self.client_keys[kem.KEY_USAGE_ENC])]
     cli = kem.KEMClient(server_keys, client_keys)
     kh = kem.KEMHandler({'KEMKeysStore': self.kk})
     req = cli.make_request("key name", "key value")
     kh.parse(req, "key name")
     self.assertEqual(kh.payload, "key value")
 def test_2_KEMClient(self):
     server_keys = [JWK(**test_keys[kem.KEY_USAGE_SIG]), None]
     client_keys = [JWK(**self.client_keys[kem.KEY_USAGE_SIG]),
                    JWK(**self.client_keys[kem.KEY_USAGE_ENC])]
     cli = kem.KEMClient(server_keys, client_keys)
     kh = kem.KEMHandler({'KEMKeysStore': self.kk})
     req = cli.make_request("key name")
     kh.parse(req, "key name")
     msg = kh.reply('key value')
     self.assertEqual(msg, json_decode(json_encode(msg)))
     rep = cli.parse_reply("key name", msg['value'])
     self.assertEqual(rep, 'key value')
Beispiel #3
0
 def test_1_Parse_GET(self):
     cli_skey = JWK(**self.client_keys[0])
     jtok = kem.make_sig_kem("mykey", None, cli_skey, "RS256")
     kh = kem.KEMHandler({'KEMKeysStore': self.kk})
     kh.parse(jtok, "mykey")
     msg = kh.reply('output')
     self.assertEqual(msg, json_decode(json_encode(msg)))
     jtok = JWT(jwt=msg['value'])
     cli_ekey = JWK(**self.client_keys[1])
     jtok.token.decrypt(cli_ekey)
     nested = jtok.token.payload
     jtok = JWT(jwt=nested.decode('utf-8'))
     jtok.token.verify(JWK(**test_keys[0]))
     payload = json_decode(jtok.token.payload)['value']
     self.assertEqual(payload, 'output')