Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid IV lengths #281

Open
panva opened this issue Nov 9, 2021 · 3 comments
Open

invalid IV lengths #281

panva opened this issue Nov 9, 2021 · 3 comments

Comments

@panva
Copy link

panva commented Nov 9, 2021

A user of this library was having an issue decrypting JWE tokens produced by it in my javascript library. See panva/jose#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.

  • A128GCM, A192GCM, A256GCM are REQUIRED to use a 96 bit IV
  • A128CBC-HS256, A192CBC-HS384, A256CBC-HS512 are REQUIRED to use a 128 bit IV
@securedimensions
Copy link

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)

jkamp-aws added a commit to jkamp-aws/python-jose that referenced this issue Aug 24, 2022
Use a 12 byte IV for GCM based algorithms and 16 byte IV for CBC based ones. This makes a JWE compatible with other libraries based on OpenSSL which can only use a 12 byte IV for GCM.
@twwildey
Copy link
Collaborator

Folks - is there a concern for resolving this issue, or is the problem that no one has executed on this?

I've opened the following issue for jose here: panva/jose#678

However, the primary maintainer of that package (who also opened this issue) has identified that python-jose is not following the RFC spec for JWE. It seems like this package should follow the specification. If there is no concern for following the JWE spec to adhere to the IV length requirements for AES GCM modes, I will open a PR to do so.

@panva
Copy link
Author

panva commented May 28, 2024

I will open a PR to do so.

#300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants