
    \Ah                     N   S SK r S SKrS SKr S SKJr  SS jrSS jr
S rS rS	 rS
 rS rS rS r1 Skr\R&                  " SSR)                  S \ 5       5      -   S-   5      rS\S\4S jrSr\R&                  " S5      r/ SQrS\S\4S jrg! \ a    S SKJ	r  SS jr Nf = f)    N)int_to_bytesc                 *    [        X=(       d    S 5      $ N)_long_to_bytes)n	blocksizes     QC:\Users\julio\Documents\inmobiliaria_backend\env\Lib\site-packages\jose/utils.pylong_to_bytesr
   
   s    a!2d33    )int_to_stringc                 v    [        U 5      nUS:X  a  U$ [        U5      U::  d   eU[        U5      -
  nSU-  U-   $ )Nr       )r   len)r   r   retpaddings       r	   r
   r
      sH    Q>Js8y(((#c(*GW$s**r   c                 ^    [         R                  " [        X5      5      R                  S5      $ )N   =)base64urlsafe_b64encoder
   strip)datasizes     r	   long_to_base64r      s#    ##M$$=>DDTJJr   c           	      j    [        SR                  U  Vs/ s H  nSU-  PM
     sn5      S5      $ s  snf )N z%02x   )intjoin)arrbytes     r	   int_arr_to_longr!      s.    rww#6#$#67<<6s   0c                     [        U [        5      (       a  U R                  S5      n [        R                  " [        U 5      S-   5      n[        [        R                  " S[        U5      -  U5      5      $ )Nasciis   ==z%sB)

isinstancestrencoder   urlsafe_b64decodebytesr!   structunpackr   )r   _ds     r	   base64_to_longr,   "   sV    ${{7# 
	!	!%+"5	6B6==R"=>>r   c                     U" U R                  S5      5      R                  5       n[        [        U5      S-  5      nUSU n[	        U5      nUR                  S5      $ )a  Helper method for calculating an access token
hash, as described in http://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken

Its value is the base64url encoding of the left-most half of the hash of the octets
of the ASCII representation of the access_token value, where the hash algorithm
used is the hash algorithm used in the alg Header Parameter of the ID Token's JOSE
Header. For instance, if the alg is RS256, hash the access_token value with SHA-256,
then take the left-most 128 bits and base64url encode them. The at_hash value is a
case sensitive string.

Args:
    access_token (str): An access token string.
    hash_alg (callable): A callable returning a hash object, e.g. hashlib.sha256

utf-8   N)r&   digestr   r   base64url_encodedecode)access_tokenhash_alghash_digestcut_at	truncatedat_hashs         r	   calculate_at_hashr9   +   s[      <..w78??AK[!A%&FGV$Iy)G>>'""r   c                 l    [        U 5      S-  nUS:  a  U SSU-
  -  -  n [        R                  " U 5      $ )zuHelper method to base64url_decode a string.

Args:
    input (bytes): A base64url_encoded string (bytes) to decode.

   r   r   )r   r   r'   )inputrems     r	   base64url_decoder>   B   s<     e*q.C
QwS!!##E**r   c                 N    [         R                  " U 5      R                  SS5      $ )zuHelper method to base64url_encode a string.

Args:
    input (bytes): A base64url_encoded string (bytes) to encode.

r   r   )r   r   replace)r<   s    r	   r1   r1   Q   s"     ##E*224==r   c                 F    U R                   S-  S-  S-  U R                  -   $ )zHelper method to determine the total number of seconds
from a timedelta.

Args:
    delta (timedelta): A timedelta to convert to seconds.
   <   )daysseconds)deltas    r	   timedelta_total_secondsrG   [   s%     ::?R"$u}}44r   c                     [        U [        5      (       a  U $ [        U [        5      (       a  U R                  SS5      $ [	        S[        U 5       S35      e)zCoerce **s** to bytes.r.   strictznot expecting type '')r$   r(   r%   r&   	TypeErrortype)ss    r	   ensure_binaryrN   e   sM     !U!Sxx**
*47)15
66r   >      X509 CRL
   PUBLIC KEY   CERTIFICATE   PRIVATE KEY   DH PARAMETERS   EC PRIVATE KEY   RSA PUBLIC KEY   DSA PRIVATE KEY   RSA PRIVATE KEY   SSH2 PUBLIC KEY   CERTIFICATE REQUEST   OPENSSH PRIVATE KEY   TRUSTED CERTIFICATE   ENCRYPTED PRIVATE KEY   NEW CERTIFICATE REQUEST   SSH2 ENCRYPTED PRIVATE KEYs   ----[- ]BEGIN (   |c              #   N   #    U  H  n[         R                  " U5      v   M     g 7fr   )reescape).0pems     r	   	<genexpr>re      s     "CUc299S>>Us   #%s	   )[- ]----keyreturnc                 >    [        [        R                  U 5      5      $ r   )bool_PEM_REsearch)rf   s    r	   is_pem_formatrl      s    s#$$r   s   -cert-v01@openssh.coms   \A(\S+)[ \t]+(\S+))s   ssh-ed25519s   ssh-rsas   ssh-dsss   ecdsa-sha2-nistp256s   ecdsa-sha2-nistp384s   ecdsa-sha2-nistp521c                    ^  [        U 4S j[         5       5      (       a  g[        R                  T 5      nU(       a-  UR	                  S5      n[
        U[        [
        5      * S  :X  a  gg)Nc              3   ,   >#    U  H	  oT;   v   M     g 7fr    )rc   string_valuerf   s     r	   re   is_ssh_key.<locals>.<genexpr>   s     
D3C<33Cs   T   F)any_SSH_KEY_FORMATS_SSH_PUBKEY_RCmatchgroup_CERT_SUFFIXr   )rf   ssh_pubkey_matchkey_types   `  r	   
is_ssh_keyr{      sZ    

D3C
DDD%++C0#))!,8S%6$6$899r   )r   )r   ra   r)   cryptography.utilsr   r   r
   ImportErrorecdsa.ecdsar   r   r!   r,   r9   r>   r1   rG   rN   _PEMScompiler   rj   r(   ri   rl   rx   ru   rt   r{   ro   r   r	   <module>r      s     	 +A4 K=?#.+>57	$ **"CU"CCClR
%u % % (23 E d a  
+;+
+s   B B$#B$