Ë
    ùmxi¢  ã                   ó²   — 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        úL/home/htdocs/ttos/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   € à�z‰z× Ñ  ¨)Ó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äÐ>¼tÀKÓ?PÐ>QÐRÓSÐSØ×'Ñ'¨¸FÐ'ÓCˆ�
r   c                 ó.   — | j                   j                  S r   )r   r2   )r   s    r   r2   zRSASigner.key_idj   s   € ð �z‰z× Ñ Ð r   c                 ó8   — | j                   j                  |«      S r   )r   Úsign)r   r    s     r   r6   zRSASigner.signo   s   € à�z‰z�‰˜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   