JWK and PEM Key Support

The rfc9180.jwk module provides JSON Web Key (JWK) and PEM support for HPKE keys. Keys can be loaded from JWK (EC, X25519, X448) or PEM format and used directly with the HPKE API.

class rfc9180.jwk.KEMKeyInterface(key)[source]

Bases: ABC

__init__(key)[source]
property raw: EllipticCurvePublicKey | X25519PublicKey | X448PublicKey | EllipticCurvePrivateKey | X25519PrivateKey | X448PrivateKey
abstractmethod to_private_bytes()[source]
Return type:

bytes

abstractmethod to_public_bytes()[source]
Return type:

bytes

class rfc9180.jwk.ECKey(key)[source]

Bases: KEMKeyInterface

__init__(key)[source]
classmethod from_jwk(jwk)[source]
Return type:

ECKey

to_private_bytes()[source]
Return type:

bytes

to_public_bytes()[source]
Return type:

bytes

class rfc9180.jwk.X25519Key(key)[source]

Bases: KEMKeyInterface

__init__(key)[source]
classmethod from_jwk(jwk)[source]
Return type:

X25519Key

to_private_bytes()[source]
Return type:

bytes

to_public_bytes()[source]
Return type:

bytes

class rfc9180.jwk.X448Key(key)[source]

Bases: KEMKeyInterface

__init__(key)[source]
classmethod from_jwk(jwk)[source]
Return type:

X448Key

to_private_bytes()[source]
Return type:

bytes

to_public_bytes()[source]
Return type:

bytes

class rfc9180.jwk.KEMKey[source]

Bases: object

classmethod from_pyca_cryptography_key(key)[source]
Return type:

KEMKeyInterface

classmethod from_jwk(data)[source]
Return type:

KEMKeyInterface

classmethod from_pem(data)[source]
Return type:

KEMKeyInterface