Ë
    ùmxi&  ã                   ó4  — d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
ZddlmZ ddlmZ d	Z ej                   «       Z e	j$                  «       Z ej(                  «       Z G d
„ dej,                  «      Z G d„ dej0                  ej2                  «      Zy)zÐRSA verifier and signer that use the ``cryptography`` library.

This is a much faster implementation than the default (in
``google.auth.crypt._python_rsa``), which depends on the pure-Python
``rsa`` library.
é    N)Úbackends)Úhashes)Úserialization)Úpadding)Ú_helpers)Úbases   -----BEGIN CERTIFICATE-----c                   ój   — e Zd ZdZd„ Z ej                  ej                  «      d„ «       Z	e
d„ «       Zy)ÚRSAVerifierzàVerifies RSA cryptographic signatures using public keys.

    Args:
        public_key (
                cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey):
            The public key used to verify signatures.
    c                 ó   — || _         y ©N)Ú_pubkey)ÚselfÚ
public_keys     úZ/home/htdocs/ttos/venv/lib/python3.12/site-packages/google/auth/crypt/_cryptography_rsa.pyÚ__init__zRSAVerifier.__init__/   s	   € Ø!ˆ�ó    c                 óÎ   — t        j                  |«      }	 | j                  j                  ||t        t
        «       y# t        t        j                  j                  f$ r Y yw xY w)NTF)
r   Úto_bytesr   ÚverifyÚ_PADDINGÚ_SHA256Ú
ValueErrorÚcryptographyÚ
exceptionsÚInvalidSignature)r   ÚmessageÚ	signatures      r   r   zRSAVerifier.verify2   sU   € ä×#Ñ# GÓ,ˆð	Ø�L‰L×Ñ 	¨7´H¼gÔFØøÜœL×3Ñ3×DÑDÐEò 	Ùð	ús   —&> ¾#A$Á#A$c                 óê   — t        j                  |«      }t        |v r5t        j                  j                  |t        «      }|j                  «       }nt        j                  |t        «      } | |«      S )ay  Construct 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   Úx509Úload_pem_x509_certificateÚ_BACKENDr   r   Úload_pem_public_key)Úclsr   Úpublic_key_dataÚcertÚpubkeys        r   Úfrom_stringzRSAVerifier.from_string;   sc   € ô #×+Ñ+¨JÓ7ˆä /Ñ1Ü×$Ñ$×>Ñ>Ø¤óˆDð —_‘_Ó&‰Fô #×6Ñ6°ÌÓQˆFá�6‹{Ðr   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Úcopy_docstringr   ÚVerifierr   Úclassmethodr(   © r   r   r
   r
   &   sE   „ ñò"ð €X×Ñ˜TŸ]™]Ó+ñó ,ðð ñó ñr   r
   c                   óÈ   — e Zd ZdZd	d„Ze ej                  ej                  «      d„ «       «       Z
 ej                  ej                  «      d„ «       Zed	d„«       Zd„ Zd„ Zy)
Ú	RSASignera…  Signs messages with an RSA private key.

    Args:
        private_key (
                cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey):
            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.
    Nc                 ó    — || _         || _        y r   )Ú_keyÚ_key_id)r   Úprivate_keyÚkey_ids      r   r   zRSASigner.__init__d   s   € ØˆŒ	Øˆ�r   c                 ó   — | j                   S r   )r5   )r   s    r   r7   zRSASigner.key_idh   s   € ð �|‰|Ðr   c                 óv   — t        j                  |«      }| j                  j                  |t        t
        «      S r   )r   r   r4   Úsignr   r   )r   r   s     r   r:   zRSASigner.signm   s)   € ä×#Ñ# GÓ,ˆØ�y‰y�~‰~˜g¤x´Ó9Ð9r   c                 óx   — t        j                  |«      }t        j                  |dt        ¬«      } | ||¬«      S )al  Construct 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   r   r   Úload_pem_private_keyr"   )r$   Úkeyr7   r6   s       r   r(   zRSASigner.from_stringr   s:   € ô$ ×Ñ Ó$ˆÜ#×8Ñ8Ø˜$¬ô
ˆñ �; vÔ.Ð.r   c                 ó   — | j                   j                  «       }| j                  j                  t        j
                  j                  t        j                  j                  t	        j                  «       ¬«      |d<   |S )z1Pickle helper that serializes the _key attribute.)ÚencodingÚformatÚencryption_algorithmr4   )
Ú__dict__Úcopyr4   Úprivate_bytesr   ÚEncodingÚPEMÚPrivateFormatÚPKCS8ÚNoEncryption©r   Ústates     r   Ú__getstate__zRSASigner.__getstate__Š   sb   € à—‘×"Ñ"Ó$ˆØŸ	™	×/Ñ/Ü"×+Ñ+×/Ñ/Ü ×.Ñ.×4Ñ4Ü!.×!;Ñ!;Ó!=ð 0ó 
ˆˆf‰ð
 ˆr   c                 ór   — t        j                  |d   d«      |d<   | j                  j                  |«       y)z3Pickle helper that deserializes the _key attribute.r4   N)r   r>   rD   ÚupdaterL   s     r   Ú__setstate__zRSASigner.__setstate__”   s.   € ä%×:Ñ:¸5À¹=È$ÓOˆˆf‰Ø�‰×Ñ˜UÕ#r   r   )r)   r*   r+   r,   r   Úpropertyr   r-   r   ÚSignerr7   r:   r/   r(   rN   rQ   r0   r   r   r2   r2   X   s|   „ ñ	óð Ø€X×Ñ˜TŸ[™[Ó)ñó *ó ðð €X×Ñ˜TŸ[™[Ó)ñ:ó *ð:ð ò/ó ð/ò.ó$r   r2   )r,   Úcryptography.exceptionsr   Úcryptography.hazmatr   Úcryptography.hazmat.primitivesr   r   Ú)cryptography.hazmat.primitives.asymmetricr   Úcryptography.x509Úgoogle.authr   Úgoogle.auth.cryptr   r   Údefault_backendr"   ÚPKCS1v15r   ÚSHA256r   r.   r
   rS   ÚFromServiceAccountMixinr2   r0   r   r   ú<module>r_      s€   ðñó Ý (Ý 1Ý 8Ý =Û å  Ý "à4Ð Ø#ˆ8×#Ñ#Ó%€Øˆ7×ÑÓ€Ø
ˆ&�-‰-‹/€ô/�$—-‘-ô /ôd?$�—‘˜T×9Ñ9õ ?$r   