HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/google/auth/crypt/__pycache__/es256.cpython-37.pyc
B

��fk�@s�dZddlmZddlZddlmZddlmZddlmZddl	m
Z
ddl	mZdd	lm
Z
dd
lmZddlZddlmZddlmZd
Ze��Ze��ZGdd�dej�ZGdd�dejej�ZdS)zIECDSA (ES256) verifier and signer that use the ``cryptography`` library.
�)�utilsN)�backends)�hashes)�
serialization)�ec)�padding)�decode_dss_signature)�encode_dss_signature)�_helpers)�bases-----BEGIN CERTIFICATE-----c@s8eZdZdZdd�Ze�ej�dd��Z	e
dd��ZdS)	�
ES256Verifierz�Verifies ECDSA cryptographic signatures using public keys.

    Args:
        public_key (
                cryptography.hazmat.primitives.asymmetric.ec.ECDSAPublicKey):
            The public key used to verify signatures.
    cCs
||_dS)N)�_pubkey)�self�
public_key�r�H/opt/alt/python37/lib/python3.7/site-packages/google/auth/crypt/es256.py�__init__/szES256Verifier.__init__c	Cs�t�|�}t|�dkrdSt��r8tj|dd�dd�ntj|dd�dd�}t��rltj|dd�dd�ntj|dd�dd�}t||�}t�|�}y|j	�
||t�t
����dSttjjfk
r�dSXdS)N�@F� �big)�	byteorderT)r
�to_bytes�len�is_python_3�int�
from_bytesrZint_from_bytesr	r
�verifyr�ECDSAr�SHA256�
ValueError�cryptography�
exceptionsZInvalidSignature)r�message�	signatureZ	sig_bytes�r�sZasn1_sigrrrr2s


zES256Verifier.verifycCs>t�|�}t|kr*tj�|t�}|��}nt�	|t�}||�S)ayConstruct an Verifier instance from a public key or public
        certificate string.

        Args:
            public_key (Union[str, bytes]): The public key in PEM format or the
                x509 public key certificate.

        Returns:
            Verifier: The constructed verifier.

        Raises:
            ValueError: If the public key can't be parsed.
        )
r
r�_CERTIFICATE_MARKERr �x509Zload_pem_x509_certificate�_BACKENDrrZload_pem_public_key)�clsrZpublic_key_data�certZpubkeyrrr�from_stringKs

zES256Verifier.from_stringN)�__name__�
__module__�__qualname__�__doc__rr
�copy_docstringr�Verifierr�classmethodr+rrrrr&src@sdeZdZdZddd�Zee�ej	�dd���Z
e�ej	�dd��Zedd	d
��Z
dd�Zd
d�ZdS)�ES256Signera�Signs messages with an ECDSA private key.

    Args:
        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.
    NcCs||_||_dS)N)�_key�_key_id)r�private_key�key_idrrrrtszES256Signer.__init__cCs|jS)N)r5)rrrrr7xszES256Signer.key_idcCsjt�|�}|j�|t�t����}t|�\}}t�	�rR|jddd�|jddd�St
�|d�t
�|d�S)Nrr)r)r
rr4�signrrrrrrrZint_to_bytes)rr"Zasn1_signaturer$r%rrrr8}s

$zES256Signer.signcCs&t�|�}tj|dtd�}|||d�S)alConstruct a RSASigner from a private key in PEM format.

        Args:
            key (Union[bytes, str]): Private key in PEM format.
            key_id (str): An optional key id used to identify the private key.

        Returns:
            google.auth.crypt._cryptography_rsa.RSASigner: The
            constructed signer.

        Raises:
            ValueError: If ``key`` is not ``bytes`` or ``str`` (unicode).
            UnicodeDecodeError: If ``key`` is ``bytes`` but cannot be decoded
                into a UTF-8 ``str``.
            ValueError: If ``cryptography`` "Could not deserialize key data."
        N)�password�backend)r7)r
rr�load_pem_private_keyr()r)�keyr7r6rrrr+�s
zES256Signer.from_stringcCs0|j��}|jjtjjtjjt�	�d�|d<|S)z1Pickle helper that serializes the _key attribute.)�encoding�formatZencryption_algorithmr4)
�__dict__�copyr4Z
private_bytesr�EncodingZPEMZ
PrivateFormatZPKCS8ZNoEncryption)r�staterrr�__getstate__�s
zES256Signer.__getstate__cCs$t�|dd�|d<|j�|�dS)z3Pickle helper that deserializes the _key attribute.r4N)rr;r?�update)rrBrrr�__setstate__�szES256Signer.__setstate__)N)N)r,r-r.r/r�propertyr
r0r�Signerr7r8r2r+rCrErrrrr3hs



r3)r/r rZcryptography.exceptionsZcryptography.hazmatrZcryptography.hazmat.primitivesrrZ)cryptography.hazmat.primitives.asymmetricrrZ/cryptography.hazmat.primitives.asymmetric.utilsrr	Zcryptography.x509Zgoogle.authr
Zgoogle.auth.cryptrr&Zdefault_backendr(ZPKCS1v15Z_PADDINGr1rrGZFromServiceAccountMixinr3rrrr�<module>s"B