You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in a mock for local testing we're using a randomly generated EC key to sign tokens.
Sometimes the key that's generated does not seem to be usable by pyjwt though, which seems odd.
Expected Result
Keys generated via cryptography, dumped to and loaded as jwk should be valid keys.
Actual Result
Some keys seem to be not supported or maybe wrongly exported/imported as jwk, leading to an InvalidKeyError.
See example below:
This fails very quickly with e.g. (the key data is obviously different each time):
Failedkey:
{
"kty": "EC",
"crv": "P-256",
"x": "oUU2SoDzIpcux68yJAih8kCiObMKp159_j1viE2rkRQ",
"y": "z7Os4ZxXJbpuuZD8ASTm9i5EoCAhlv_hWz2A6gG-HA"
}
Traceback (mostrecentcalllast):
File"/xyz/jwk_error.py", line16, in<module>ECAlgorithm.from_jwk(jwk)
File"/xyz/venv/lib/python3.9/site-packages/jwt/algorithms.py", line630, infrom_jwkraiseInvalidKeyError("Coords should be 32 bytes for curve P-256")
jwt.exceptions.InvalidKeyError: Coordsshouldbe32bytesforcurveP-256
System Information
$ python -m jwt.help
❯ python -m "jwt.help"
{
"cryptography": {
"version": "41.0.5"
},
"implementation": {
"name": "CPython",
"version": "3.9.16"
},
"platform": {
"release": "23.1.0",
"system": "Darwin"
},
"pyjwt": {
"version": "2.8.0"
}
}```
This command is only available on PyJWT v1.6.3 and greater. Otherwise,
please provide some basic information about your system.
The text was updated successfully, but these errors were encountered:
sebbegg
changed the title
Unusable EC key generated
Cryptography generated EC key is invalid
Nov 13, 2023
Hi there,
in a mock for local testing we're using a randomly generated EC key to sign tokens.
Sometimes the key that's generated does not seem to be usable by pyjwt though, which seems odd.
Expected Result
Keys generated via cryptography, dumped to and loaded as jwk should be valid keys.
Actual Result
Some keys seem to be not supported or maybe wrongly exported/imported as jwk, leading to an
InvalidKeyError
.See example below:
Reproduction Steps
This fails very quickly with e.g. (the key data is obviously different each time):
System Information
The text was updated successfully, but these errors were encountered: