
    (ph&                     4   S r SSKrSSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
rSSKJr  SSKJr  S	r\R                   " 5       r\	R$                  " 5       r\R(                  " 5       r " S
 S\R,                  5      r " S S\R0                  \R2                  5      rg)zRSA 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                   r    \ rS rSrSrS r\R                  " \R                  5      S 5       r
\S 5       rSrg)RSAVerifier&   zVerifies RSA cryptographic signatures using public keys.

Args:
    public_key (
            cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey):
        The public key used to verify signatures.
c                     Xl         g N_pubkey)self
public_keys     V/var/www/html/venv/lib/python3.13/site-packages/google/auth/crypt/_cryptography_rsa.py__init__RSAVerifier.__init__/   s    !    c                     [         R                  " U5      n U R                  R                  X![        [
        5        g! [        [        R                  R                  4 a     gf = f)NTF)
r   to_bytesr   verify_PADDING_SHA256
ValueErrorcryptography
exceptionsInvalidSignature)r   message	signatures      r   r   RSAVerifier.verify2   sS    ##G,	LL	HgFL33DDE 		s   %> $A%$A%c                     [         R                  " U5      n[        U;   a5  [        R                  R                  U[        5      nUR                  5       nO[        R                  " U[        5      nU " U5      $ )a1  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_stringRSAVerifier.from_string;   sc     #++J7/1$$>>D __&F #66QF6{r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   copy_docstringr   Verifierr   classmethodr,   __static_attributes__ r   r   r
   r
   &   sC    " T]]+ ,  r   r
   c                       \ rS rSrSrSS jr\\R                  " \	R                  5      S 5       5       r\R                  " \	R                  5      S 5       r\SS j5       rS rS	 rS
rg)	RSASignerX   ae  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                     Xl         X l        g r   _key_key_id)r   private_keykey_ids      r   r   RSASigner.__init__d   s    	r   c                     U R                   $ r   )r>   )r   s    r   r@   RSASigner.key_idh   s     ||r   c                 x    [         R                  " U5      nU R                  R                  U[        [
        5      $ r   )r   r   r=   signr   r   )r   r   s     r   rE   RSASigner.signm   s)    ##G,yy~~gx99r   c                 n    [         R                  " U5      n[        R                  " US[        S9nU " X2S9$ )a  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)r@   )r   r   r   load_pem_private_keyr&   )r(   keyr@   r?   s       r   r,   RSASigner.from_stringr   s8    $ $#88$
 ;..r   c                     U R                   R                  5       nU R                  R                  [        R
                  R                  [        R                  R                  [        R                  " 5       S9US'   U$ )z1Pickle helper that serializes the _key attribute.)encodingformatencryption_algorithmr=   )
__dict__copyr=   private_bytesr   EncodingPEMPrivateFormatPKCS8NoEncryptionr   states     r   __getstate__RSASigner.__getstate__   sb    ""$		//"++// ..44!.!;!;!= 0 
f
 r   c                 t    [         R                  " US   S5      US'   U R                  R                  U5        g)z3Pickle helper that deserializes the _key attribute.r=   N)r   rJ   rQ   updaterY   s     r   __setstate__RSASigner.__setstate__   s.    %::5=$OfU#r   r<   r   )r.   r/   r0   r1   r2   r   propertyr   r3   r   Signerr@   rE   r5   r,   r[   r_   r6   r7   r   r   r9   r9   X   sx    	 T[[) *  T[[): *: / /.$r   r9   )r2   cryptography.exceptionsr   cryptography.hazmatr   cryptography.hazmat.primitivesr   r   )cryptography.hazmat.primitives.asymmetricr   cryptography.x509google.authr   google.auth.cryptr   r#   default_backendr&   PKCS1v15r   SHA256r   r4   r
   rb   FromServiceAccountMixinr9   r7   r   r   <module>rn      sz     ( 1 8 =    "4 ##%
--//$-- /d?$T99 ?$r   