File manager - Edit - /usr/local/CyberCP/lib/python3.10/site-packages/google/auth/crypt/__pycache__/base.cpython-310.pyc
Back
o �h^ � @ 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)� exceptions�private_key�private_key_idc @ s e Zd ZdZejdd� �ZdS )�Verifierz9Abstract base class for crytographic signature verifiers.c C � t d��)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 implemented��NotImplementedError)�self�message� signature� r �I/usr/local/CyberCP/lib/python3.10/site-packages/google/auth/crypt/base.py�verify � 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 r )z<Optional[str]: The key ID used to identify this private key.zKey id must be implementedr )r r r r �key_id2 s z Signer.key_idc C r )z�Signs a message. Args: message (Union[str, bytes]): The message to be signed. Returns: bytes: The signature of the message. zSign must be implementedr )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 r )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 implementedr )�cls�keyr r r r �from_stringI r z#FromServiceAccountMixin.from_stringc C s( t |vr t�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 �MalformedErrorr �get�_JSON_FILE_PRIVATE_KEY_ID)r �infor r r �from_service_account_infoY s ��z1FromServiceAccountMixin.from_service_account_infoc C sD t j|ddd�� }t�|�}W d � n1 sw Y | �|�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)�encodingN)�io�open�json�loadr$ )r �filename� 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'