
    xi                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dZ	 G d d	ej                        Z G d
 dej                  ej                        Zy)z
RSA cryptography signer and verifier.

This file provides a shared wrapper, that defers to _python_rsa or _cryptography_rsa
for implmentations using different third party libraries
    )RSAPrivateKey)RSAPublicKey)_helpers)_cryptography_rsa)basezrsa.keyc                   j    e Zd ZdZd Z ej                  ej                        d        Z	e
d        Zy)RSAVerifiera  Verifies RSA cryptographic signatures using public keys.

    Args:
        public_key (Union["rsa.key.PublicKey", cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey]):
            The public key used to verify signatures.
    Raises:
        ImportError: if called with an rsa.key.PublicKey, when the rsa library is not installed
        ValueError: if an unrecognized public key is provided
    c                     |j                   j                  }t        |t              rt        }n5|j                  t              r	ddlm} |}nt        dt        |             |j                  |      | _        y )Nr   _python_rsazunrecognized public key type: )	__class__
__module__
isinstancer   r   
startswithRSA_KEY_MODULE_PREFIXgoogle.auth.cryptr   
ValueErrortyper	   _impl)self
public_key
module_strimpl_libr   s        a/var/www/html/chatbot/card-advisor-bot/venv/lib/python3.12/site-packages/google/auth/crypt/rsa.py__init__zRSAVerifier.__init__+   sd    ))44
j,/(H""#895"H=d:>N=OPQQ))*5
    c                 :    | j                   j                  ||      S N)r   verify)r   message	signatures      r   r   zRSAVerifier.verify7   s    zz  )44r   c                 p    | j                  |       }t        j                  j                  |      |_        |S )a  Construct a 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:
            google.auth.crypt.Verifier: The constructed verifier.

        Raises:
            ValueError: If the public_key can't be parsed.
        )__new__r   r	   from_stringr   )clsr   instances      r   r$   zRSAVerifier.from_string;   s/     ;;s#*66BB:Nr   N)__name__r   __qualname____doc__r   r   copy_docstringr   Verifierr   classmethodr$    r   r   r	   r	       sE    
6 XT]]+5 ,5  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y)	RSASignera=  Signs messages with an RSA private key.

    Args:
        private_key (Union["rsa.key.PrivateKey", 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.

    Raises:
        ImportError: if called with an rsa.key.PrivateKey, when the rsa library is not installed
        ValueError: if an unrecognized public key is provided
    Nc                     |j                   j                  }t        |t              rt        }n5|j                  t              r	ddlm} |}nt        dt        |             |j                  ||      | _        y )Nr   r   zunrecognized private key type: key_id)r   r   r   r   r   r   r   r   r   r   r   r/   r   )r   private_keyr2   r   r   r   s         r   r   zRSASigner.__init__^   si     **55
k=1(H""#895"H>tK?P>QRSS''F'C
r   c                 .    | j                   j                  S r   )r   r2   )r   s    r   r2   zRSASigner.key_idj   s     zz   r   c                 8    | j                   j                  |      S r   )r   sign)r   r    s     r   r6   zRSASigner.signo   s    zzw''r   c                 t    | j                  |       }t        j                  j                  ||      |_        |S )a  Construct a Signer instance from a private key in PEM format.

        Args:
            key (str): Private key in PEM format.
            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 as PKCS#1 or PKCS#8 in
                PEM format.
        r1   )r#   r   r/   r$   r   )r%   keyr2   r&   s       r   r$   zRSASigner.from_strings   s4     ;;s#*44@@V@Tr   r   )r'   r   r(   r)   r   propertyr   r*   r   Signerr2   r6   r,   r$   r-   r   r   r/   r/   O   ss    
D XT[[)! * ! XT[[)( *(  r   r/   N)r)   -cryptography.hazmat.primitives.asymmetric.rsar   r   google.authr   r   r   r   r   r+   r	   r:   FromServiceAccountMixinr/   r-   r   r   <module>r>      sK    H F   / "! ,$-- ,^5T99 5r   