Ë
    ¸Å:j¯%  ã                  óÞ   — d dl mZ d dlmZ d dlZd dlZd dl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  G d	„ d
«      Z G d„ de«      Zddd„Z G d„ de«      Z	 	 	 	 dd„Z G d„ d«      Zy)é    )ÚannotationsNé   )Ú_base64_alphabet)Úbase64_decode)Úbase64_encode)Ú
want_bytes)ÚBadSignaturec                  ó    — e Zd ZdZdd„Zdd„Zy)ÚSigningAlgorithmzgSubclasses must implement :meth:`get_signature` to provide
    signature generation functionality.
    c                ó   — t        «       ‚)z2Returns the signature for the given key and value.)ÚNotImplementedError©ÚselfÚkeyÚvalues      úh/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/itsdangerous/signer.pyÚget_signaturezSigningAlgorithm.get_signature   s   € ä!Ó#Ð#ó    c                óN   — t        j                  || j                  ||«      «      S )zMVerifies the given signature matches the expected
        signature.
        )ÚhmacÚcompare_digestr   )r   r   r   Úsigs       r   Úverify_signaturez!SigningAlgorithm.verify_signature   s$   € ô ×"Ñ" 3¨×(:Ñ(:¸3ÀÓ(FÓGÐGr   N©r   Úbytesr   r   Úreturnr   )r   r   r   r   r   r   r   Úbool)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   © r   r   r   r      s   „ ñó$ôHr   r   c                  ó   — e Zd ZdZdd„Zy)ÚNoneAlgorithmz`Provides an algorithm that does not perform any signing and
    returns an empty signature.
    c                 ó   — y)Nr   r"   r   s      r   r   zNoneAlgorithm.get_signature$   s   € Ør   Nr   )r   r   r    r!   r   r"   r   r   r$   r$      s   „ ñôr   r$   c                ó,   — t        j                  | «      S )zÈDon't access ``hashlib.sha1`` until runtime. FIPS builds may not include
    SHA-1, in which case the import and use as a default would fail before the
    developer can configure something else.
    )ÚhashlibÚsha1)Ústrings    r   Ú
_lazy_sha1r*   (   s   € ô
 �<‰<˜ÓÐr   c                  ó>   — e Zd ZU dZ ee«      Zded<   ddd„Zd	d„Z	y)
ÚHMACAlgorithmz*Provides signature generation using HMACs.út.AnyÚdefault_digest_methodNc                ó.   — |€| j                   }|| _        y ©N)r.   Údigest_method)r   r1   s     r   Ú__init__zHMACAlgorithm.__init__8   s   € ØÐ Ø ×6Ñ6ˆMà$1ˆÕr   c                óf   — t        j                  ||| j                  ¬«      }|j                  «       S )N)ÚmsgÚ	digestmod)r   Únewr1   Údigest)r   r   r   Úmacs       r   r   zHMACAlgorithm.get_signature>   s&   € Ü�h‰h�s °×1CÑ1CÔDˆØ�z‰z‹|Ðr   r0   )r1   r-   r   )
r   r   r    r!   Ústaticmethodr*   r.   Ú__annotations__r2   r   r"   r   r   r,   r,   0   s!   … Ù4ñ
 $0°
Ó#;Ð˜5Ó;ô2ôr   r,   c                ó‚   — t        | t        t        f«      rt        | «      gS | D �cg c]  }t        |«      ‘Œ c}S c c}w r0   )Ú
isinstanceÚstrr   r   )Ú
secret_keyÚss     r   Ú_make_keys_listr@   C   s8   € ô �*œs¤E˜lÔ+Ü˜:Ó&Ð'Ð'à#-Ö.˜aŒJ�q�MÒ.Ð.ùÒ.s   §<c                  ó¨   — e Zd ZU dZ ee«      Zded<   dZded<   	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 dd„Z	e
dd	„«       Zddd
„Zdd„Zdd„Zdd„Zdd„Zdd„Zy)ÚSigneraÖ  A signer securely signs bytes, then unsigns them to verify that
    the value hasn't been changed.

    The secret key should be a random string of ``bytes`` and should not
    be saved to code or version control. Different salts should be used
    to distinguish signing in different contexts. See :doc:`/concepts`
    for information about the security of the secret key and salt.

    :param secret_key: The secret key to sign and verify with. Can be a
        list of keys, oldest to newest, to support key rotation.
    :param salt: Extra key to combine with ``secret_key`` to distinguish
        signatures in different contexts.
    :param sep: Separator between the signature and value.
    :param key_derivation: How to derive the signing key from the secret
        key and salt. Possible values are ``concat``, ``django-concat``,
        or ``hmac``. Defaults to :attr:`default_key_derivation`, which
        defaults to ``django-concat``.
    :param digest_method: Hash function to use when generating the HMAC
        signature. Defaults to :attr:`default_digest_method`, which
        defaults to :func:`hashlib.sha1`. Note that the security of the
        hash alone doesn't apply when used intermediately in HMAC.
    :param algorithm: A :class:`SigningAlgorithm` instance to use
        instead of building a default :class:`HMACAlgorithm` with the
        ``digest_method``.

    .. versionchanged:: 2.0
        Added support for key rotation by passing a list to
        ``secret_key``.

    .. versionchanged:: 0.18
        ``algorithm`` was added as an argument to the class constructor.

    .. versionchanged:: 0.14
        ``key_derivation`` and ``digest_method`` were added as arguments
        to the class constructor.
    r-   r.   údjango-concatr=   Údefault_key_derivationNc                ó<  — t        |«      | _        t        |«      | _        | j                  t        v rt        d«      ‚|�t        |«      }nd}|| _        |€| j                  }|| _        |€| j                  }|| _
        |€t        | j                  «      }|| _        y )NzŠThe given separator cannot be used because it may be contained in the signature itself. ASCII letters, digits, and '-_=' must not be used.ó   itsdangerous.Signer)r@   Úsecret_keysr   Úsepr   Ú
ValueErrorÚsaltrD   Úkey_derivationr.   r1   r,   Ú	algorithm)r   r>   rJ   rH   rK   r1   rL   s          r   r2   zSigner.__init__�   s¨   € ô )8¸
Ó(CˆÔÜ$ S›/ˆŒà�8‰8Ô'Ñ'Üð7óð ð ÐÜ˜dÓ#‰Dà)ˆDàˆŒ	àÐ!Ø!×8Ñ8ˆNà#1ˆÔàÐ Ø ×6Ñ6ˆMà$1ˆÔàÐÜ% d×&8Ñ&8Ó9ˆIà+4ˆ�r   c                ó    — | j                   d   S )z�The newest (last) entry in the :attr:`secret_keys` list. This
        is for compatibility from before key rotation support was added.
        éÿÿÿÿ)rG   )r   s    r   r>   zSigner.secret_key¯   s   € ð
 ×Ñ Ñ#Ð#r   c                ó|  — |€| j                   d   }nt        |«      }| j                  dk(  rDt        j                  t
        | j                  | j                  |z   «      j                  «       «      S | j                  dk(  rGt        j                  t
        | j                  | j                  dz   |z   «      j                  «       «      S | j                  dk(  rLt        j                  || j                  ¬«      }|j                  | j                  «       |j                  «       S | j                  dk(  r|S t        d«      ‚)	aü  This method is called to derive the key. The default key
        derivation choices can be overridden here. Key derivation is not
        intended to be used as a security method to make a complex key
        out of a short password. Instead you should use large random
        secret keys.

        :param secret_key: A specific secret key to derive from.
            Defaults to the last item in :attr:`secret_keys`.

        .. versionchanged:: 2.0
            Added the ``secret_key`` parameter.
        rN   ÚconcatrC   s   signerr   )r5   ÚnonezUnknown key derivation method)rG   r   rK   ÚtÚcastr   r1   rJ   r7   r   r6   ÚupdateÚ	TypeError)r   r>   r8   s      r   Ú
derive_keyzSigner.derive_key¶   s  € ð ÐØ×)Ñ)¨"Ñ-‰Jä# JÓ/ˆJà×Ñ (Ò*Ü—6‘6œ% ×!3Ñ!3°D·I±IÀ
Ñ4JÓ!K×!RÑ!RÓ!TÓUÐUØ× Ñ  OÒ3Ü—6‘6Ü�t×)Ñ)¨$¯)©)°iÑ*?À*Ñ*LÓM×TÑTÓVóð ð × Ñ  FÒ*Ü—(‘(˜:°×1CÑ1CÔDˆCØ�J‰J�t—y‘yÔ!Ø—:‘:“<ÐØ× Ñ  FÒ*ØÐäÐ;Ó<Ð<r   c                ó†   — t        |«      }| j                  «       }| j                  j                  ||«      }t	        |«      S )z*Returns the signature for the given value.)r   rV   rL   r   r   )r   r   r   r   s       r   r   zSigner.get_signature×   s9   € ä˜5Ó!ˆØ�o‰oÓˆØ�n‰n×*Ñ*¨3°Ó6ˆÜ˜SÓ!Ð!r   c                óZ   — t        |«      }|| j                  z   | j                  |«      z   S )zSigns the given string.)r   rH   r   )r   r   s     r   ÚsignzSigner.signÞ   s+   € ä˜5Ó!ˆØ�t—x‘xÑ $×"4Ñ"4°UÓ";Ñ;Ð;r   c                óä   — 	 t        |«      }t        |«      }t        | j                  «      D ]2  }| j                  |«      }| j                  j                  |||«      sŒ2 y y# t        $ r Y yw xY w)z+Verifies the signature for the given value.FT)r   Ú	Exceptionr   ÚreversedrG   rV   rL   r   )r   r   r   r>   r   s        r   r   zSigner.verify_signatureã   sw   € ð	Ü Ó$ˆCô ˜5Ó!ˆä" 4×#3Ñ#3Ó4ò 	ˆJØ—/‘/ *Ó-ˆCà�~‰~×.Ñ.¨s°E¸3Õ?Ùð		ð øô ò 	Ùð	ús   ‚A# Á#	A/Á.A/c                óî   — t        |«      }| j                  |vrt        d| j                  ›d�«      ‚|j                  | j                  d«      \  }}| j	                  ||«      r|S t        d|›d�|¬«      ‚)zUnsigns the given string.zNo z found in valuer   z
Signature z does not match)Úpayload)r   rH   r	   Úrsplitr   )r   Úsigned_valuer   r   s       r   ÚunsignzSigner.unsignô   su   € ä! ,Ó/ˆà�8‰8˜<Ñ'Ü  T§X¡X L°Ð@ÓAÐAà!×(Ñ(¨¯©°1Ó5‰
ˆˆsà× Ñ  ¨Ô,ØˆLä˜Z¨ w¨oÐ>ÈÔNÐNr   c                óF   — 	 | j                  |«       y# t        $ r Y yw xY w)znOnly validates the given signed value. Returns ``True`` if
        the signature exists and is valid.
        TF)ra   r	   )r   r`   s     r   ÚvalidatezSigner.validate  s(   € ð	Ø�K‰K˜Ô%ØøÜò 	Ùð	ús   ‚ ”	 Ÿ )rF   ó   .NNN)r>   ú7str | bytes | cabc.Iterable[str] | cabc.Iterable[bytes]rJ   ústr | bytes | NonerH   ústr | bytesrK   z
str | Noner1   zt.Any | NonerL   zSigningAlgorithm | None)r   r   r0   )r>   rf   r   r   )r   rg   r   r   )r   rg   r   rg   r   r   )r`   rg   r   r   )r`   rg   r   r   )r   r   r    r!   r9   r*   r.   r:   rD   r2   Úpropertyr>   rV   r   rY   r   ra   rc   r"   r   r   rB   rB   L   s¬   … ñ#ñV $0°
Ó#;Ð˜5Ó;ð #2Ð˜CÓ1ð
 $:ØØ%)Ø&*Ø-1ð,5àKð,5ð !ð,5ð ð	,5ð
 #ð,5ð $ð,5ð +ó,5ð\ ò$ó ð$ô=óB"ó<ó
ó"Oôr   rB   )r   )r)   r   r   r-   )r>   re   r   zlist[bytes])Ú
__future__r   Úcollections.abcÚabcÚcabcr'   r   ÚtypingrR   Úencodingr   r   r   r   Úexcr	   r   r$   r*   r,   r@   rB   r"   r   r   ú<module>rp      so   ðÝ "å Û Û Û å &Ý #Ý #Ý  Ý ÷Hñ Hô Ð$ô ô ôÐ$ô ð&/ØGð/àó/÷~ò ~r   