|
Server : LiteSpeed System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64 User : nandedex ( 1060) PHP Version : 8.1.33 Disable Function : NONE Directory : /opt/cppython/lib/python3.8/site-packages/google/auth/crypt/__pycache__/ |
U
O��g^ � @ sp d Z ddlZddlZddlZddlmZ dZdZG dd� dejd�Z G d d
� d
ejd�Z
G dd� dejd�ZdS )
z5Base classes for cryptographic signers and verifiers.� N)�
exceptionsZprivate_keyZprivate_key_idc @ s e Zd ZdZejdd� �ZdS )�Verifierz9Abstract base class for crytographic signature verifiers.c C s t d��dS )a� Verifies a message against a cryptographic signature.
Args:
message (Union[str, bytes]): The message to verify.
signature (Union[str, bytes]): The cryptography signature to check.
Returns:
bool: True if message was signed by the private key associated
with the public key that this object was constructed with.
zVerify must be implementedN��NotImplementedError)�self�message� signature� r �C/opt/cppython/lib/python3.8/site-packages/google/auth/crypt/base.py�verify s zVerifier.verifyN)�__name__�
__module__�__qualname__�__doc__�abc�abstractmethodr r r r r
r s r )� metaclassc @ s, e Zd ZdZejdd� �Zejdd� �ZdS )�Signerz.Abstract base class for cryptographic signers.c C s t d��dS )z<Optional[str]: The key ID used to identify this private key.zKey id must be implementedNr )r r r r
�key_id2 s z
Signer.key_idc C s t d��dS )z�Signs a message.
Args:
message (Union[str, bytes]): The message to be signed.
Returns:
bytes: The signature of the message.
zSign must be implementedNr )r r r r r
�sign7 s zSigner.signN) r r
r r r �abstractpropertyr r r r r r r
r / s
r c @ s8 e Zd ZdZejd dd��Zedd� �Zedd� �Z dS )
�FromServiceAccountMixinz3Mix-in to enable factory constructors for a Signer.Nc C s t d��dS )ad Construct an Signer instance from a private key string.
Args:
key (str): Private key as a string.
key_id (str): An optional key id used to identify the private key.
Returns:
google.auth.crypt.Signer: The constructed signer.
Raises:
ValueError: If the key cannot be parsed.
zfrom_string must be implementedNr )�cls�keyr r r r
�from_stringI s z#FromServiceAccountMixin.from_stringc C s( t |krt�d��| �|t |�t��S )a� Creates a Signer instance instance from a dictionary containing
service account info in Google format.
Args:
info (Mapping[str, str]): The service account info in Google
format.
Returns:
google.auth.crypt.Signer: The constructed signer.
Raises:
ValueError: If the info is not in the expected format.
z@The private_key field was not found in the service account info.)�_JSON_FILE_PRIVATE_KEYr ZMalformedErrorr �get�_JSON_FILE_PRIVATE_KEY_ID)r �infor r r
�from_service_account_infoY s � �z1FromServiceAccountMixin.from_service_account_infoc C s0 t j|ddd��}t�|�}W 5 Q R X | �|�S )a Creates a Signer instance from a service account .json file
in Google format.
Args:
filename (str): The path to the service account .json file.
Returns:
google.auth.crypt.Signer: The constructed signer.
�rzutf-8)�encoding)�io�open�json�loadr )r �filenameZ json_file�datar r r
�from_service_account_fileq s z1FromServiceAccountMixin.from_service_account_file)N)
r r
r r r r r �classmethodr r( r r r r
r F s
r )r r r"