jpadilla / pyjwt

JSON Web Token implementation in Python
https://pyjwt.readthedocs.io
MIT License
5.05k stars 676 forks source link

`EllipticCurvePublicKey` has no `sign` method #842

Closed Viicos closed 1 year ago

Viicos commented 1 year ago

The prepare_key method of ECAlgorithm can return a EllipticCurvePublicKey object, which does not implement the sign method, resulting in an AttributeError when ECAlgorithm.sign is called with this prepared key.

https://github.com/jpadilla/pyjwt/blob/50c763c67e93b63fb199c4c9b3c4a05ed90b5172/jwt/algorithms.py#L429-L455

Edit: Same thing for the following public keys, used in other algorithm classes: RSAPublicKey, Ed25519PublicKey, Ed448PublicKey.