latchset / jwcrypto

Implements JWK,JWS,JWE specifications using python-cryptography
GNU Lesser General Public License v3.0
438 stars 118 forks source link

Key size on generation is not always computed correctly #302

Closed simo5 closed 1 year ago

simo5 commented 2 years ago

For algorithms like A256CBC-HS512 the output keysize is 256 bits, but the input keysize is expected to be 512 bits.

When a JWK(generate='oct', alg='A256CBC-HS512') command is invoked the code tries to determine the default key size to be used, and it does that by inquiring the JWA algorithm for its keysize.

Unfortunately the reported key size for these algorithms is the output key size and not the input keysize ...