google.auth.crypt.es256 module¶
ECDSA (ES256) verifier and signer that use the cryptography library.
- class ES256Verifier(public_key: EllipticCurvePublicKey)[source]¶
Bases:
EsVerifierVerifies ECDSA cryptographic signatures using public keys.
- Parameters:
public_key (cryptography.hazmat.primitives.asymmetric.ec.ECDSAPublicKey) – The public key used to verify signatures.
- classmethod from_string(public_key: str | bytes) EsVerifier¶
Construct a Verifier instance from a public key or public certificate string.
- Parameters:
public_key (
Unionstr,bytes) – The public key in PEM format or the x509 public key certificate.- Returns:
The constructed verifier.
- Return type:
- Raises:
ValueError – If the public key can’t be parsed.
- class ES256Signer(private_key: EllipticCurvePrivateKey, key_id: str | None = None)[source]¶
Bases:
EsSignerSigns messages with an ECDSA private key.
- Parameters:
( (private_key) – cryptography.hazmat.primitives.asymmetric.ec.ECDSAPrivateKey): The private key to sign with.
key_id (str) – Optional key ID used to identify this private key. This can be useful to associate the private key with its associated public key or certificate.
- property algorithm: str¶
Name of the algorithm used to sign messages. :returns: The algorithm name. :rtype: str
- classmethod from_service_account_file(filename)¶
Creates a Signer instance from a service account .json file in Google format.
- Parameters:
filename (str) – The path to the service account .json file.
- Returns:
The constructed signer.
- Return type:
- classmethod from_service_account_info(info)¶
Creates a Signer instance instance from a dictionary containing service account info in Google format.
- Parameters:
info (
Mappingstr,str) – The service account info in Google format.- Returns:
The constructed signer.
- Return type:
- Raises:
ValueError – If the info is not in the expected format.
- classmethod from_string(key: bytes | str, key_id: str | None = None) EsSigner¶
Construct a RSASigner from a private key in PEM format.
- Parameters:
- Returns:
The constructed signer.
- Return type:
google.auth.crypt._cryptography_rsa.RSASigner
- Raises:
ValueError – If
keyis notbytesorstr(unicode).UnicodeDecodeError – If
keyisbytesbut cannot be decoded into a UTF-8str.ValueError – If
cryptography“Could not deserialize key data.”