§
    BP„jÿ   ã                   ó�  — d Z ddlZddlZddlZddlmZ ddlmZ ej        Zej        ZdZ	dZ
dZ ej        e¦  «        Z G d„ de¦  «        Zd	„ Z	 dd
lmZ ej        Zej        Zej        Zn# e$ r	 dZdZeZY nw xY w	 ddlmZ ej        Zej        Zn# e$ r dZdZY nw xY wereZeZnereZeZneZeZdd„Zd„ Zd„ Zd„ Zdd„Z dS )z)Crypto-related routines for oauth2client.é    N)Ú_helpers)Ú_pure_python_crypti,  i€Q c                   ó   — e Zd ZdZdS )ÚAppIdentityErrorz!Error to indicate crypto failure.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úW/root/disk_3tb/conda_envs/Huy-visual/lib/python3.11/site-packages/oauth2client/crypt.pyr   r   $   s   € € € € € Ø+Ð+Ð+Ð+r   r   c                  ó    — t          d¦  «        ‚)Nz#pkcs12_key_as_pem requires OpenSSL.)ÚNotImplementedError)ÚargsÚkwargss     r   Ú_bad_pkcs12_key_as_pemr   (   s   € Ý
ÐCÑ
DÔ
DÐDr   )Ú_openssl_crypt)Ú_pycrypto_cryptc                 óÌ  — dddœ}|�||d<   t          j        t          j        |¦  «        ¦  «        t          j        t          j        |¦  «        ¦  «        g}d                     |¦  «        }|                      |¦  «        }|                     t          j        |¦  «        ¦  «         t                               t          |¦  «        ¦  «         d                     |¦  «        S )aR  Make a signed JWT.

    See http://self-issued.info/docs/draft-jones-json-web-token.html.

    Args:
        signer: crypt.Signer, Cryptographic signer.
        payload: dict, Dictionary of data to convert to JSON and then sign.
        key_id: string, (Optional) Key ID header.

    Returns:
        string, The JWT for the payload.
    ÚJWTÚRS256)ÚtypÚalgNÚkidó   .)	r   Ú_urlsafe_b64encodeÚ_json_encodeÚjoinÚsignÚappendÚloggerÚdebugÚstr)ÚsignerÚpayloadÚkey_idÚheaderÚsegmentsÚsigning_inputÚ	signatures          r   Úmake_signed_jwtr+   J   sÆ   € ð  7Ð+Ð+€FØÐØˆˆu‰õ 	Ô#¥HÔ$9¸&Ñ$AÔ$AÑBÔBÝÔ#¥HÔ$9¸'Ñ$BÔ$BÑCÔCð€Hð —I’I˜hÑ'Ô'€Mà—’˜MÑ*Ô*€IØ‡O‚O•HÔ/°	Ñ:Ô:Ñ;Ô;Ð;å
‡L‚L•�X‘”ÑÔÐà�9Š9�XÑÔÐr   c                 ó”   — |D ]7}t                                |d¬¦  «        }|                     | |¦  «        r dS Œ8t          d¦  «        ‚)a€  Verifies signed content using a list of certificates.

    Args:
        message: string or bytes, The message to verify.
        signature: string or bytes, The signature on the message.
        certs: iterable, certificates in PEM format.

    Raises:
        AppIdentityError: If none of the certificates can verify the message
                          against the signature.
    T)Úis_x509_certNzInvalid token signature)ÚVerifierÚfrom_stringÚverifyr   )Úmessager*   ÚcertsÚpemÚverifiers        r   Ú_verify_signaturer5   i   s^   € ð ð ð ˆÝ×'Ò'¨¸$Ð'Ñ?Ô?ˆØ�?Š?˜7 IÑ.Ô.ð 	ØˆFˆFð	õ Ð4Ñ
5Ô
5Ð5r   c                 óÔ   — |€dS |                       d¦  «        }|€"t          d                     | ¦  «        ¦  «        ‚||k    r$t          d                     ||| ¦  «        ¦  «        ‚dS )aA  Checks audience field from a JWT payload.

    Does nothing if the passed in ``audience`` is null.

    Args:
        payload_dict: dict, A dictionary containing a JWT payload.
        audience: string or NoneType, an audience to check for in
                  the JWT payload.

    Raises:
        AppIdentityError: If there is no ``'aud'`` field in the payload
                          dictionary but there is an ``audience`` to check.
        AppIdentityError: If the ``'aud'`` field in the payload dictionary
                          does not match the ``audience``.
    NÚaudzNo aud field in token: {0}z Wrong recipient, {0} != {1}: {2})Úgetr   Úformat)Úpayload_dictÚaudienceÚaudience_in_payloads      r   Ú_check_audiencer=   ~   s‹   € ð  ÐØˆà&×*Ò*¨5Ñ1Ô1ÐØÐ"ÝØ(×/Ò/°Ñ=Ô=ñ?ô ?ð 	?à˜hÒ&Ð&ÝÐA×HÒHØ ¨<ñ 9ô  9ñ :ô :ð 	:ð 'Ð&r   c                 óZ  — t          t          j        ¦   «         ¦  «        }|                      d¦  «        }|€"t          d                     | ¦  «        ¦  «        ‚|                      d¦  «        }|€"t          d                     | ¦  «        ¦  «        ‚||t
          z   k    r"t          d                     | ¦  «        ¦  «        ‚|t          z
  }||k     r$t          d                     ||| ¦  «        ¦  «        ‚|t          z   }||k    r$t          d                     ||| ¦  «        ¦  «        ‚dS )	aÜ  Verifies the issued at and expiration from a JWT payload.

    Makes sure the current time (in UTC) falls between the issued at and
    expiration for the JWT (with some skew allowed for via
    ``CLOCK_SKEW_SECS``).

    Args:
        payload_dict: dict, A dictionary containing a JWT payload.

    Raises:
        AppIdentityError: If there is no ``'iat'`` field in the payload
                          dictionary.
        AppIdentityError: If there is no ``'exp'`` field in the payload
                          dictionary.
        AppIdentityError: If the JWT expiration is too far in the future (i.e.
                          if the expiration would imply a token lifetime
                          longer than what is allowed.)
        AppIdentityError: If the token appears to have been issued in the
                          future (up to clock skew).
        AppIdentityError: If the token appears to have expired in the past
                          (up to clock skew).
    ÚiatNzNo iat field in token: {0}ÚexpzNo exp field in token: {0}z exp field too far in future: {0}z$Token used too early, {0} < {1}: {2}z#Token used too late, {0} > {1}: {2})ÚintÚtimer8   r   r9   ÚMAX_TOKEN_LIFETIME_SECSÚCLOCK_SKEW_SECS)r:   ÚnowÚ	issued_atÚ
expirationÚearliestÚlatests         r   Ú_verify_time_rangerJ   š   sS  € õ0 �dŒi‰kŒkÑ
Ô
€Cð × Ò  Ñ'Ô'€IØÐÝØ(×/Ò/°Ñ=Ô=ñ?ô ?ð 	?à×!Ò! %Ñ(Ô(€JØÐÝØ(×/Ò/°Ñ=Ô=ñ?ô ?ð 	?ð �SÕ2Ñ2Ò2Ð2ÝØ.×5Ò5°lÑCÔCñEô Eð 	Eð �?Ñ*€HØ
ˆX‚~€~ÝÐE×LÒLØ�˜<ñ )ô  )ñ *ô *ð 	*ð �/Ñ)€FØ
ˆV‚|€|ÝÐD×KÒKØ�˜ñ 'ô  'ñ (ô (ð 	(ð €|r   c                 óX  — t          j        | ¦  «        } |                      d¦  «        dk    r"t          d                     | ¦  «        ¦  «        ‚|                      d¦  «        \  }}}|dz   |z   }t          j        |¦  «        }t          j        |¦  «        }	 t          j        t          j	        |¦  «        ¦  «        }n'#  t          d                     |¦  «        ¦  «        ‚xY wt          |||                     ¦   «         ¦  «         t          |¦  «         t          ||¦  «         |S )aþ  Verify a JWT against public certs.

    See http://self-issued.info/docs/draft-jones-json-web-token.html.

    Args:
        jwt: string, A JWT.
        certs: dict, Dictionary where values of public keys in PEM format.
        audience: string, The audience, 'aud', that this JWT should contain. If
                  None then the JWT's 'aud' parameter is not verified.

    Returns:
        dict, The deserialized JSON payload in the JWT.

    Raises:
        AppIdentityError: if any checks are failed.
    r   é   z&Wrong number of segments in token: {0}zCan't parse token: {0})r   Ú	_to_bytesÚcountr   r9   ÚsplitÚ_urlsafe_b64decodeÚjsonÚloadsÚ_from_bytesr5   ÚvaluesrJ   r=   )	Újwtr2   r;   r'   r%   r*   Úmessage_to_signÚpayload_bytesr:   s	            r   Úverify_signed_jwt_with_certsrX   Ï   s$  € õ" Ô
˜SÑ
!Ô
!€Cà
‡y‚y��„˜!ÒÐÝØ4×;Ò;¸CÑ@Ô@ñBô Bð 	Bð "%§¢¨4¡¤Ñ€FˆG�YØ˜t‘m gÑ-€OÝÔ+¨IÑ6Ô6€Iõ Ô/°Ñ8Ô8€MðPÝ”z¥(Ô"6°}Ñ"EÔ"EÑFÔFˆˆøðPÝÐ8×?Ò?ÀÑNÔNÑOÔOÐOøøøõ �o y°%·,²,±.´.ÑAÔAÐAõ �|Ñ$Ô$Ð$õ �L (Ñ+Ô+Ð+àÐs   Â&C Ã$C%)N)!r
   rQ   ÚloggingrB   Úoauth2clientr   r   Ú	RsaSignerÚRsaVerifierrD   ÚAUTH_TOKEN_LIFETIME_SECSrC   Ú	getLoggerr   r!   Ú	Exceptionr   r   r   ÚOpenSSLSignerÚOpenSSLVerifierÚpkcs12_key_as_pemÚImportErrorr   ÚPyCryptoSignerÚPyCryptoVerifierÚSignerr.   r+   r5   r=   rJ   rX   r   r   r   ú<module>rg      s
  ðð  0Ð /à €€€Ø €€€Ø €€€à !Ð !Ð !Ð !Ð !Ð !Ø +Ð +Ð +Ð +Ð +Ð +ð Ô(€	Ø Ô,€à€ØÐ ØÐ à	ˆÔ	˜8Ñ	$Ô	$€ð,ð ,ð ,ð ,ð ,�yñ ,ô ,ð ,ðEð Eð Eð/Ø+Ð+Ð+Ð+Ð+Ð+Ø"Ô0€MØ$Ô4€OØ&Ô8ÐÐøØð /ð /ð /Ø€OØ€MØ.ÐÐÐð/øøøð
Ø,Ð,Ð,Ð,Ð,Ð,Ø$Ô3€NØ&Ô7ÐÐøØð ð ð ØÐØ€N€N€Nðøøøð
 ð Ø€FØ€H€HØð Ø€FØ€H€Hà€FØ€Hðð ð ð ð>6ð 6ð 6ð*:ð :ð :ð82(ð 2(ð 2(ðj+ð +ð +ð +ð +ð +s$   ÁA- Á-A;Á:A;Á?B Â	B ÂB 