§
    ÁÞMh  ã                  óº   — d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
 ddlmZmZmZ g d¢Ze
j        Z	  G d	„ d
e¦  «        Zefd"d„Zefd"d„Zd#d„Zd$d„Zd%d „Zd!S )&a>  
Low-level functions if you want to build your own higher level abstractions.

.. warning::
    This is a "Hazardous Materials" module.  You should **ONLY** use it if
    you're 100% absolutely sure that you know what you're doing because this
    module is full of land mines, dragons, and dinosaurs with laser guns.
é    )Úannotations)ÚEnum)ÚAnyÚLiteral)ÚffiÚlibé   )ÚHashingErrorÚVerificationErrorÚVerifyMismatchError)ÚARGON2_VERSIONÚTyper   Úhash_secretÚhash_secret_rawÚverify_secretc                  ó<   — e Zd ZdZej        Zej        Zej	        Z
dS )r   zX
    Enum of Argon2 variants.

    Please see :doc:`parameters` on how to pick one.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚArgon2_dÚDÚArgon2_iÚIÚ	Argon2_idÚID© ó    úP/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/argon2/low_level.pyr   r   (   s/   € € € € € ðð ð 	Œ€AØŒ€AØ	Œ€B€B€Br   r   ÚsecretÚbytesÚsaltÚ	time_costÚintÚmemory_costÚparallelismÚhash_lenÚtypeÚversionÚreturnc                óæ  — t          j        |||t          |¦  «        ||j        ¦  «        dz   }t	          j        d|¦  «        }	t          j        |||t	          j        d| ¦  «        t          | ¦  «        t	          j        d|¦  «        t          |¦  «        t          j        ||	||j        |¦  «        }
|
t           j        k    rt          t          |
¦  «        ¦  «        ‚t	          j        |	¦  «        S )a©  
    Hash *secret* and return an **encoded** hash.

    An encoded hash can be directly passed into :func:`verify_secret` as it
    contains all parameters and the salt.

    Args:
        secret: Secret to hash.

        salt: A salt_. Should be random and different for each secret.

        type: Which Argon2 variant to use.

        version: Which Argon2 version to use.

    For an explanation of the Argon2 parameters see
    :class:`argon2.PasswordHasher`.

    Returns:
        An encoded Argon2 hash.

    Raises:
        argon2.exceptions.HashingError: If hashing fails.

    .. versionadded:: 16.0.0

    .. _salt: https://en.wikipedia.org/wiki/Salt_(cryptography)
    r	   úchar[]ú	uint8_t[])r   Úargon2_encodedlenÚlenÚvaluer   ÚnewÚargon2_hashÚNULLÚ	ARGON2_OKr
   Úerror_to_strÚstring)r    r"   r#   r%   r&   r'   r(   r)   ÚsizeÚbufÚrvs              r   r   r   4   sä   € õN 	ÔØØØÝ‰IŒIØØŒJñ	
ô 	
ð ñ	ð 	õ Œ'(˜DÑ
!Ô
!€CÝ	ŒØØØÝŒ˜VÑ$Ô$ÝˆF‰ŒÝŒ˜TÑ"Ô"ÝˆD‰	Œ	ÝŒØØØØŒ
Øñ
ô 
€Bð 
SŒ]ÒÐÝ<¨Ñ+Ô+Ñ,Ô,Ð,åŒ:c‰?Œ?Ðr   c                ó¦  — t          j        d|¦  «        }t          j        |||t          j        d| ¦  «        t	          | ¦  «        t          j        d|¦  «        t	          |¦  «        ||t           j        d|j        |¦  «        }	|	t          j        k    rt          t          |	¦  «        ¦  «        ‚t          t          j        ||¦  «        ¦  «        S )z—
    Hash *password* and return a **raw** hash.

    This function takes the same parameters as :func:`hash_secret`.

    .. versionadded:: 16.0.0
    r-   r   )r   r1   r   r2   r/   r3   r0   r4   r
   r5   r!   Úbuffer)
r    r"   r#   r%   r&   r'   r(   r)   r8   r9   s
             r   r   r   {   s´   € õ" Œ'+˜xÑ
(Ô
(€Cå	ŒØØØÝŒ˜VÑ$Ô$ÝˆF‰ŒÝŒ˜TÑ"Ô"ÝˆD‰	Œ	ØØÝŒØ	ØŒ
Øñ
ô 
€Bð 
SŒ]ÒÐÝ<¨Ñ+Ô+Ñ,Ô,Ð,å•”˜C Ñ*Ô*Ñ+Ô+Ð+r   ÚhashúLiteral[True]c                óT  — t          j        t          j        d| ¦  «        t          j        d|¦  «        t	          |¦  «        |j        ¦  «        }|t           j        k    rdS |t           j        k    rt          t          |¦  «        ¦  «        ‚t          t          |¦  «        ¦  «        ‚)aB  
    Verify whether *secret* is correct for *hash* of *type*.

    Args:
        hash:
            An encoded Argon2 hash as returned by :func:`hash_secret`.

        secret:
            The secret to verify whether it matches the one in *hash*.

        type: Type for *hash*.

    Raises:
        argon2.exceptions.VerifyMismatchError:
            If verification fails because *hash* is not valid for *secret* of
            *type*.

        argon2.exceptions.VerificationError:
            If verification fails for other reasons.

    Returns:
        ``True`` on success, raise :exc:`~argon2.exceptions.VerificationError`
        otherwise.

    .. versionadded:: 16.0.0
    .. versionchanged:: 16.1.0
        Raise :exc:`~argon2.exceptions.VerifyMismatchError` on mismatches
        instead of its more generic superclass.
    r,   r-   T)r   Úargon2_verifyr   r1   r/   r0   r4   ÚARGON2_VERIFY_MISMATCHr   r5   r   )r<   r    r(   r9   s       r   r   r   £   s   € õ< 
Ô	ÝŒ˜$ÑÔÝŒ˜VÑ$Ô$ÝˆF‰ŒØŒ
ñ	
ô 
€Bð 
SŒ]ÒÐØˆtà	SÔ'Ò'Ð'Ý!¥,¨rÑ"2Ô"2Ñ3Ô3Ð3å
L¨Ñ,Ô,Ñ
-Ô
-Ð-r   Úcontextr   c                ó,   — t          j        | |¦  «        S )a¦  
    Direct binding to the ``argon2_ctx`` function.

    .. warning::
        This is a strictly advanced function working on raw C data structures.
        Both Argon2's and *argon2-cffi*'s higher-level bindings do a lot of
        sanity checks and housekeeping work that *you* are now responsible for
        (e.g. clearing buffers). The structure of the *context* object can,
        has, and will change with *any* release!

        Use at your own peril; *argon2-cffi* does *not* use this binding
        itself.

    Args:
        context:
            A CFFI Argon2 context object (i.e. an ``struct Argon2_Context`` /
            ``argon2_context``).

        type:
            Which Argon2 variant to use.  You can use the ``value`` field of
            :class:`Type`'s fields.

    Returns:
        An Argon2 error code.  Can be transformed into a string using
        :func:`error_to_str`.

    .. versionadded:: 16.0.0
    )r   Ú
argon2_ctx)rA   r(   s     r   ÚcorerD   Ñ   s   € õ: Œ>˜' 4Ñ(Ô(Ð(r   ÚerrorÚstrc                ót   — t          j        t          j        | ¦  «        ¦  «                             d¦  «        S )zê
    Convert an Argon2 error code into a native string.

    Args:
        error: An Argon2 error code as returned by :func:`core`.

    Returns:
        A human-readable string describing the error.

    .. versionadded:: 16.0.0
    Úascii)r   r6   r   Úargon2_error_messageÚdecode)rE   s    r   r5   r5   ñ   s-   € õ Œ:•cÔ.¨uÑ5Ô5Ñ6Ô6×=Ò=¸gÑFÔFÐFr   N)r    r!   r"   r!   r#   r$   r%   r$   r&   r$   r'   r$   r(   r   r)   r$   r*   r!   )r<   r!   r    r!   r(   r   r*   r=   )rA   r   r(   r$   r*   r$   )rE   r$   r*   rF   )r   Ú
__future__r   Úenumr   Útypingr   r   Ú_argon2_cffi_bindingsr   r   Ú
exceptionsr
   r   r   Ú__all__ÚARGON2_VERSION_NUMBERr   r   r   r   r   rD   r5   r   r   r   ú<module>rR      s^  ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ð Ð à *Ð *Ð *Ð *Ð *Ð *Ð *Ð *à LÐ LÐ LÐ LÐ LÐ LÐ LÐ LÐ LÐ Lðð ð €ð Ô*€ðð	ð 	ð 	ð 	ð 	ˆ4ñ 	ô 	ð 	ð( "ðDð Dð Dð Dð Dð^ "ð%,ð %,ð %,ð %,ð %,ðP+.ð +.ð +.ð +.ð\)ð )ð )ð )ð@Gð Gð Gð Gð Gð Gr   