RSAKeyPair¶
- class gafaelfawr.keypair.RSAKeyPair(private_key)¶
Bases:
object
An RSA key pair with some simple helper functions.
Notes
Created by calling
generate()
orfrom_pem()
rather than the constructor.- Parameters:
private_key (
RSAPrivateKey
)
Methods Summary
from_pem
(pem)Import an RSA key pair from a PEM-encoded private key.
generate
()Generate a new RSA key pair.
Return the serialized private key.
public_key_as_jwks
([kid])Return the public key in JWKS format.
Return the PEM-encoded public key.
Return the public numbers for the key pair.
Methods Documentation
- classmethod from_pem(pem)¶
Import an RSA key pair from a PEM-encoded private key.
- Parameters:
pem (
bytes
) – The PEM-encoded key (must not be password-protected).- Returns:
The corresponding key pair.
- Return type:
- Raises:
cryptography.exceptions.UnsupportedAlgorithm – Raised if the provided key is not an RSA private key.
- classmethod generate()¶
Generate a new RSA key pair.
- Returns:
Newly-generated key pair.
- Return type:
- private_key_as_pem()¶
Return the serialized private key.
- Returns:
Private key encoded using PKCS#8 with no encryption.
- Return type:
- public_key_as_jwks(kid=None)¶
Return the public key in JWKS format.
- public_key_as_pem()¶
Return the PEM-encoded public key.
- Returns:
The public key in PEM encoding and SubjectPublicKeyInfo format.
- Return type:
- public_numbers()¶
Return the public numbers for the key pair.
- Returns:
The public numbers.
- Return type:
cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicNumbers