python-jose
python-jose copied to clipboard
invalid IV lengths
A user of this library was having an issue decrypting JWE tokens produced by it in my javascript library. See https://github.com/panva/jose/issues/314
Despite a few hurdles overcome they are not able to interoperate the libraries due to a non-conform JWE implementation in python-jose.
Namely, the Initialization Vectors used for encryption are not conform, their bit lengths are not according to specification.
How about this?
if self._algorithm in ['A128GCM', 'A192GCM', 'A256GCM', 'A128GCMKW', 'A192GCMKW', 'A256GCMKW']:
#print("generating IV of length 96bit")
iv = get_random_bytes(12)
else:
#print("generating IV of length 128bit")
iv = get_random_bytes(16)