Skip to content

Commit

Permalink
Add test to generate key with algorithm
Browse files Browse the repository at this point in the history
This uses an algorithm that has different input_keysize and output
keysize.

Signed-off-by: Simo Sorce <simo@redhat.com>
  • Loading branch information
simo5 committed May 30, 2023
1 parent e08cbf1 commit db1f9f4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions jwcrypto/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,15 @@ def test_generate_oct_key(self):
e.deserialize(enc, key)
self.assertEqual(e.payload.decode('utf-8'), 'test')

# also test key generation with input_keysize != keysize
key = jwk.JWK.generate(kty='oct', alg="A128CBC-HS256")
self.assertEqual(len(base64url_decode(key['k'])), 32)
e = jwe.JWE('test', '{"alg":"A256KW","enc":"A128CBC-HS256"}')
e.add_recipient(key)
enc = e.serialize()
e.deserialize(enc, key)
self.assertEqual(e.payload.decode('utf-8'), 'test')

def test_generate_EC_key(self):
# Backwards compat curve
key = jwk.JWK.generate(kty='EC', curve='P-256')
Expand Down

0 comments on commit db1f9f4

Please sign in to comment.