
    Eh                       S r SSKJr  SSKJr  SSKJrJr  SSKJ	r	J
r
  SSKJrJrJr  / SQr\
R                   r  " S	 S
\5      r\4                 SS jjr\4                 SS jjrSS jrSS jrSS jrg)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                  `    \ rS rSrSr\R                  r\R                  r	\R                  rSrg)r   (   zL
Enum of Argon2 variants.

Please see :doc:`parameters` on how to pick one.
 N)__name__
__module____qualname____firstlineno____doc__r   Argon2_dDArgon2_iI	Argon2_idID__static_attributes__r       cC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\argon2/low_level.pyr   r   (   s$     	AA	Br!   r   c                   [         R                  " UUU[        U5      UUR                  5      S-   n[        R
                  " SU5      n	[         R                  " UUU[        R
                  " SU 5      [        U 5      [        R
                  " SU5      [        U5      [        R                  UU	UUR                  U5      n
U
[         R                  :w  a  [        [        U
5      5      e[        R                  " U	5      $ )ae  
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)secretsalt	time_costmemory_costparallelismhash_lentypeversionsizebufrvs              r"   r   r   4   s    N 	IJJ	
 	 	 ''(D
!C	V$FT"D	


B 
S]]<+,,::c?r!   c                   [         R                  " SU5      n[        R                  " UUU[         R                  " SU 5      [	        U 5      [         R                  " SU5      [	        U5      UU[         R
                  SUR                  U5      n	U	[        R                  :w  a  [        [        U	5      5      e[        [         R                  " X5      5      $ )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   r)   r   r*   r'   r+   r(   r,   r
   r-   bytesbuffer)
r/   r0   r1   r2   r3   r4   r5   r6   r8   r9   s
             r"   r   r   {   s    " ''+x
(C	V$FT"D		


B 
S]]<+,,C*++r!   c                P   [         R                  " [        R                  " SU 5      [        R                  " SU5      [	        U5      UR
                  5      nU[         R                  :X  a  gU[         R                  :X  a  [        [        U5      5      e[        [        U5      5      e)a  
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   r)   r'   r(   r,   ARGON2_VERIFY_MISMATCHr   r-   r   )hashr/   r5   r9   s       r"   r   r      s}    < 
		$V$F

	
B 
S]]	S'''!,r"233
L,
--r!   c                .    [         R                  " X5      $ )aR  
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)contextr5   s     r"   corerD      s    : >>'((r!   c                t    [         R                  " [        R                  " U 5      5      R	                  S5      $ )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   r.   r   argon2_error_messagedecode)errors    r"   r-   r-      s)     ::c..u56==gFFr!   N)r/   r;   r0   r;   r1   intr2   rJ   r3   rJ   r4   rJ   r5   r   r6   rJ   returnr;   )r@   r;   r/   r;   r5   r   rK   zLiteral[True])rC   r   r5   rJ   rK   rJ   )rI   rJ   rK   str)r   
__future__r   enumr   typingr   r   _argon2_cffi_bindingsr   r   
exceptionsr
   r   r   __all__ARGON2_VERSION_NUMBERr   r   r   r   r   rD   r-   r   r!   r"   <module>rT      s!   #   * L L **	4 	( "DD
D D 	D
 D D D D D^ "%,%,
%, %, 	%,
 %, %, %, %, %,P+.\)@Gr!   