§
    8?Äjü  ã                   ó  — d Z ddlZddlZddlmZ ddlmZmZ ddl	m
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j        ej        ¦  «        ZdS )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dS )Ú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                 ó   — || _         d S ©N)Ú_pubkey)ÚselfÚ
public_keys     úTC:\Projects\Historical\venv\Lib\site-packages\google/auth/crypt/_cryptography_rsa.pyÚ__init__zRSAVerifier.__init__.   s   € Ø!ˆŒˆˆó    c                 óÂ   — t          j        |¦  «        }	 | j                             ||t          t
          ¦  «         dS # t          t          j        j	        f$ r Y dS w xY w)NTF)
r   Úto_bytesr   ÚverifyÚ_PADDINGÚ_SHA256Ú
ValueErrorÚcryptographyÚ
exceptionsÚInvalidSignature)r   ÚmessageÚ	signatures      r   r   zRSAVerifier.verify1   se   € åÔ# GÑ,Ô,ˆð	ØŒL×Ò 	¨7µH½gÑFÔFÐFØ�4øÝ�LÔ3ÔDÐEð 	ð 	ð 	Ø�5�5ð	øøøs   –'? ¿AÁAc                 óú   — t          j        |¦  «        }t          |v r:t          j                             |t          ¦  «        }|                     ¦   «         }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:   sq   € õ #Ô+¨JÑ7Ô7ˆå /Ð1Ð1ÝÔ$×>Ò>Ø¥ñô ˆDð —_’_Ñ&Ô&ˆFˆFõ #Ô6°ÍÑQÔQˆFàˆs�6‰{Œ{Ðr   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Úcopy_docstringr   ÚVerifierr   Úclassmethodr(   © r   r   r
   r
   %   ss   € € € € € ðð ð"ð "ð "ð €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dS )
Ú	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                 ó"   — || _         || _        d S r   )Ú_keyÚ_key_id)r   Úprivate_keyÚkey_ids      r   r   zRSASigner.__init__c   s   € ØˆŒ	ØˆŒˆˆr   c                 ó   — | j         S r   )r5   )r   s    r   r7   zRSASigner.key_idg   s   € ð Œ|Ðr   c                 óv   — t          j        |¦  «        }| j                             |t          t
          ¦  «        S r   )r   r   r4   Úsignr   r   )r   r   s     r   r:   zRSASigner.signl   s*   € åÔ# GÑ,Ô,ˆØŒy�~Š~˜g¥xµÑ9Ô9Ð9r   c                 ó|   — 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_stringq   sI   € õ$ Ô Ñ$Ô$ˆÝ#Ô8Ø˜$­ð
ñ 
ô 
ˆð ˆs�; vÐ.Ñ.Ô.Ð.r   c                 óÖ   — | 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__‰   sZ   € à”×"Ò"Ñ$Ô$ˆØœ	×/Ò/Ý"Ô+Ô/Ý Ô.Ô4Ý!.Ô!;Ñ!=Ô!=ð 0ñ 
ô 
ˆˆf‰ð
 ˆr   c                 óv   — t          j        |d         d¦  «        |d<   | j                             |¦  «         dS )z3Pickle helper that deserializes the _key attribute.r4   N)r   r>   rD   ÚupdaterL   s     r   Ú__setstate__zRSASigner.__setstate__“   s8   € å%Ô:¸5À¼=È$ÑOÔOˆˆf‰ØŒ×Ò˜UÑ#Ô#Ð#Ð#Ð#r   r   )r)   r*   r+   r,   r   Úpropertyr   r-   r   ÚSignerr7   r:   r/   r(   rN   rQ   r0   r   r   r2   r2   W   sÐ   € € € € € ð	ð 	ðð ð ð ð Ø€XÔ˜Tœ[Ñ)Ô)ðð ñ *Ô)ñ „Xðð €XÔ˜Tœ[Ñ)Ô)ð:ð :ñ *Ô)ð:ð ð/ð /ð /ñ „[ð/ð.ð ð ð$ð $ð $ð $ð $r   r2   )r,   Úcryptography.exceptionsr   Úcryptography.x509Úcryptography.hazmatr   Úcryptography.hazmat.primitivesr   r   Ú)cryptography.hazmat.primitives.asymmetricr   Úgoogle.authr   Úgoogle.auth.cryptr   r   Údefault_backendr"   ÚPKCS1v15r   ÚSHA256r   r.   r
   rS   ÚFromServiceAccountMixinr2   r0   r   r   ú<module>r_      s$  ððð ð Ð Ð Ð Ø Ð Ð Ð Ø (Ð (Ð (Ð (Ð (Ð (Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ø =Ð =Ð =Ð =Ð =Ð =à  Ð  Ð  Ð  Ð  Ð  Ø "Ð "Ð "Ð "Ð "Ð "à4Ð Ø#ˆ8Ô#Ñ%Ô%€Øˆ7ÔÑÔ€Ø
ˆ&Œ-‰/Œ/€ð/ð /ð /ð /ð /�$”-ñ /ô /ð /ðd?$ð ?$ð ?$ð ?$ð ?$�”˜TÔ9ñ ?$ô ?$ð ?$ð ?$ð ?$r   