
    i                         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dlm	Z	 dZ
 G d	 d
e	j                  Z G d de	j        e	j                  ZdS )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)_python_rsa)basezrsa.keyc                   j    e Zd ZdZd Z ej        ej                  d             Z	e
d             ZdS )RSAVerifiera5  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:
        ValueError: if an unrecognized public key is provided
    c                    |j         j        }t          |t                    rt          }nA|                    t                    rt          }nt          dt          |                     |
                    |          | _        d S )Nzunrecognized public key type: )	__class__
__module__
isinstancer   r   
startswithRSA_KEY_MODULE_PREFIXr   
ValueErrortyper
   _impl)self
public_key
module_strimpl_libs       P/root/projects/butler/venv/lib/python3.11/site-packages/google/auth/crypt/rsa.py__init__zRSAVerifier.__init__+   s~    )4
j,// 	R(HH""#899 	R"HHPd:>N>NPPQQQ))*55


    c                 8    | j                             ||          S N)r   verify)r   message	signatures      r   r   zRSAVerifier.verify5   s    z  )444r   c                 x    |                      |           }t          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_string9   s2     ;;s##*6BB:NNr   N)__name__r   __qualname____doc__r   r   copy_docstringr   Verifierr   classmethodr"    r   r   r
   r
   !   ss         6 6 6 XT]++5 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dS )	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:
        ValueError: if an unrecognized public key is provided
    Nc                    |j         j        }t          |t                    rt          }nA|                    t                    rt          }nt          dt          |                     |
                    ||          | _        d S )Nzunrecognized private key type: key_id)r   r   r   r   r   r   r   r   r   r   r-   r   )r   private_keyr0   r   r   s        r   r   zRSASigner.__init__[   s     *5
k=11 	T(HH""#899 	T"HHRtK?P?PRRSSS''F'CC


r   c                     | j         j        S r   )r   r0   )r   s    r   r0   zRSASigner.key_ide   s     z  r   c                 6    | j                             |          S r   )r   sign)r   r   s     r   r4   zRSASigner.signj   s    zw'''r   c                 |    |                      |           }t          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.
        r/   )r!   r   r-   r"   r   )r#   keyr0   r$   s       r   r"   zRSASigner.from_stringn   s7     ;;s##*4@@V@TTr   r   )r%   r   r&   r'   r   propertyr   r(   r   Signerr0   r4   r*   r"   r+   r   r   r-   r-   M   s         D D D D XT[))! ! *) X! XT[))( ( *)(    [  r   r-   N)r'   -cryptography.hazmat.primitives.asymmetric.rsar   r   google.authr   google.auth.cryptr   r   r   r   r)   r
   r8   FromServiceAccountMixinr-   r+   r   r   <module>r=      s     H G G G G G F F F F F F             / / / / / / ) ) ) ) ) ) " " " " " "! ) ) ) ) )$- ) ) )X2 2 2 2 2T9 2 2 2 2 2r   