JWKRSA -> JWKRSA.load is not RSA
- Dominant language
- Python
- Stars
- 48
- Forks
- 34
- Avg merge
- 6d 22h
- Merged PRs (30d)
- 2
Description
Hi colleagues,
with the code below, while I'm expecting `josepy.jwk.JWKRSA` and key kty `RSA`, I'm getting
```
Generating new key ...
Key generated account_key=JWKRSA(key=)>)
Loaded as:
Key kty: oct
```
the code (Python 3.13.7, josepy==2.2.0)
```
import json
import josepy as jose
from cryptography.hazmat.primitives.asymmetric import rsa
print("Generating new key ...")
private_key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048
)
account_key = jose.JWKRSA(key=private_key)
print(f"Key generated {account_key=}\n")
key_components = account_key.to_json()
restored_account_key = jose.JWKRSA.load(json.dumps(key_components).encode())
print(f"Loaded as: {type(restored_account_key)}")
print(f"Key kty: {restored_account_key.to_json().get('kty', 'unknown')}")
```
Is this bug or I'm missing / misinterpreting something?
Thank you
Contributor guide
Assessment
This issue has not been assessed yet.