§
    &xÅj  ã                   ó^  — d dl mZ d dlZd dlZd dlmZ d dlmZ ej	        j
        Zej	        j        Zej	        j        Zej	        j        Zej	        j        Zej	        j        Zedz
  Zej	        j        Zej	        j        Zej	        j        Zej	        j        Zej	        j        Z ej	        j!        Z"ej	        j#        Z$ej	        j%        Z&ej	        j'        Z(ej	        j)        Z*de$z  Z+de&z  Z,e(e*ej-        j.        fde/de0d	e0d
e/de/dej-        j1        de0fd„Z2e$e&fde0d
e/de/de0fd„Z3de0de0de4fd„Z5dS )é    )ÚcastN)Ú
exceptions)Úensureé   é   ÚsizeÚpasswordÚsaltÚopslimitÚmemlimitÚencoderÚreturnc                 óÊ  — t          t          dt          j        ¬¦  «         t          t	          |¦  «        t
          k    dt
          ›dt	          |¦  «        ›d�t          j        ¬¦  «         t          j         	                    ||¦  «        \  }}}|dz   }	| 
                    t          j                             ||t          t          d|z  ¦  «        |||	| ¬¦  «        ¦  «        S )	al  
    Derive a ``size`` bytes long key from a caller-supplied
    ``password`` and ``salt`` pair using the scryptsalsa208sha256
    memory-hard construct.


    the enclosing module provides the constants

        - :py:const:`.OPSLIMIT_INTERACTIVE`
        - :py:const:`.MEMLIMIT_INTERACTIVE`
        - :py:const:`.OPSLIMIT_SENSITIVE`
        - :py:const:`.MEMLIMIT_SENSITIVE`
        - :py:const:`.OPSLIMIT_MODERATE`
        - :py:const:`.MEMLIMIT_MODERATE`

    as a guidance for correct settings respectively for the
    interactive login and the long term key protecting sensitive data
    use cases.

    :param size: derived key size, must be between
                 :py:const:`.BYTES_MIN` and
                 :py:const:`.BYTES_MAX`
    :type size: int
    :param password: password used to seed the key derivation procedure;
                     it length must be between
                     :py:const:`.PASSWD_MIN` and
                     :py:const:`.PASSWD_MAX`
    :type password: bytes
    :param salt: **RANDOM** salt used in the key derivation procedure;
                 its length must be exactly :py:const:`.SALTBYTES`
    :type salt: bytes
    :param opslimit: the time component (operation count)
                     of the key derivation procedure's computational cost;
                     it must be between
                     :py:const:`.OPSLIMIT_MIN` and
                     :py:const:`.OPSLIMIT_MAX`
    :type opslimit: int
    :param memlimit: the memory occupation component
                     of the key derivation procedure's computational cost;
                     it must be between
                     :py:const:`.MEMLIMIT_MIN` and
                     :py:const:`.MEMLIMIT_MAX`
    :type memlimit: int
    :rtype: bytes
    :raises nacl.exceptions.UnavailableError: If called when using a
        minimal build of libsodium.

    .. versionadded:: 1.2
    úNot available in minimal build©ÚraisingzThe salt must be exactly z, not z bytes longi   é   )ÚmaxmemÚdklen)r   Ú	AVAILABLEÚexcÚUnavailableErrorÚlenÚ	SALTBYTESÚ
ValueErrorÚnaclÚbindingsÚ nacl_bindings_pick_scrypt_paramsÚencodeÚ%crypto_pwhash_scryptsalsa208sha256_llr   Úint)
r   r	   r
   r   r   r   Ún_log2ÚrÚpr   s
             úCC:\Projects\Historical\venv\Lib\site-packages\nacl/pwhash/scrypt.pyÚkdfr&   ;   sô   € õr ÝØ(ÝÔ$ðñ ô ð õ ÝˆD‰	Œ	•YÒÐåˆ9ˆ9•c˜$‘i”i�i�ið	!å”ð	ñ ô ð õ ”=×AÒAØ�(ñô �L€FˆAˆqð ˜Ñ€Fà�>Š>ÝŒ×;Ò;ØØõ •�a˜‘iÑ Ô ØØØØð 	<ñ 	
ô 	
ñô ð ó    c                 ó†   — t          t          dt          j        ¬¦  «         t          j                             | ||¦  «        S )a$  
    Hashes a password with a random salt, using the memory-hard
    scryptsalsa208sha256 construct and returning an ascii string
    that has all the needed info to check against a future password

    The default settings for opslimit and memlimit are those deemed
    correct for the interactive user login case.

    :param bytes password:
    :param int opslimit:
    :param int memlimit:
    :rtype: bytes
    :raises nacl.exceptions.UnavailableError: If called when using a
        minimal build of libsodium.

    .. versionadded:: 1.2
    r   r   )r   r   r   r   r   r   Ú&crypto_pwhash_scryptsalsa208sha256_str)r	   r   r   s      r%   Ústrr*   –   sJ   € õ, ÝØ(ÝÔ$ðñ ô ð õ Œ=×?Ò?Ø�(˜Hñô ð r'   Úpassword_hashc                 ó  — t          t          dt          j        ¬¦  «         t          t	          | ¦  «        t
          k    dt          j        j        z  t          j	        ¬¦  «         t          j         
                    | |¦  «        S )aW  
    Takes the output of scryptsalsa208sha256 and compares it against
    a user provided password to see if they are the same

    :param password_hash: bytes
    :param password: bytes
    :rtype: boolean
    :raises nacl.exceptions.UnavailableError: If called when using a
        minimal build of libsodium.

    .. versionadded:: 1.2
    r   r   z/The password hash must be exactly %s bytes long)r   r   r   r   r   ÚPWHASH_SIZEr   r   Ú+crypto_pwhash_scryptsalsa208sha256_STRBYTESr   Ú-crypto_pwhash_scryptsalsa208sha256_str_verify)r+   r	   s     r%   Úverifyr0   ·   s‡   € õ ÝØ(ÝÔ$ðñ ô ð õ ÝˆMÑÔ�kÒ)Ø9Ý
Œ-Ô
Cñ	Då”ð	ñ ô ð õ Œ=×FÒFØ�xñô ð r'   )6Útypingr   Únacl.bindingsr   Únacl.encodingr   r   Únacl.exceptionsr   r   r.   Ú_strbytes_plus_oneÚ&has_crypto_pwhash_scryptsalsa208sha256r   Ú,crypto_pwhash_scryptsalsa208sha256_STRPREFIXÚ	STRPREFIXÚ,crypto_pwhash_scryptsalsa208sha256_SALTBYTESr   Ú-crypto_pwhash_scryptsalsa208sha256_PASSWD_MINÚ
PASSWD_MINÚ-crypto_pwhash_scryptsalsa208sha256_PASSWD_MAXÚ
PASSWD_MAXr-   Ú,crypto_pwhash_scryptsalsa208sha256_BYTES_MINÚ	BYTES_MINÚ,crypto_pwhash_scryptsalsa208sha256_BYTES_MAXÚ	BYTES_MAXÚ/crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MINÚMEMLIMIT_MINÚ/crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAXÚMEMLIMIT_MAXÚ/crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MINÚOPSLIMIT_MINÚ/crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAXÚOPSLIMIT_MAXÚ7crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVEÚOPSLIMIT_INTERACTIVEÚ7crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVEÚMEMLIMIT_INTERACTIVEÚ5crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVEÚOPSLIMIT_SENSITIVEÚ5crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVEÚMEMLIMIT_SENSITIVEÚOPSLIMIT_MODERATEÚMEMLIMIT_MODERATEÚencodingÚ
RawEncoderr!   ÚbytesÚEncoderr&   r*   Úboolr0   © r'   r%   ú<module>rZ      s$  ðð Ð Ð Ð Ð Ð à Ð Ð Ð Ø Ð Ð Ð Ø "Ð "Ð "Ð "Ð "Ð "Ø "Ð "Ð "Ð "Ð "Ð "à”]ÔNÐ àŒMÔ@€	àŒMÔF€	àŒMÔF€	àŒ]ÔH€
ØŒ]ÔH€
à  1Ñ$€àŒMÔF€	ØŒMÔF€	àŒ}ÔL€ØŒ}ÔL€ØŒ}ÔL€ØŒ}ÔL€ð 	„MÔIð ð 	„MÔIð ð 	„MÔGð ð 	„MÔGð ð Ð,Ñ,Ð ØÐ,Ñ,Ð ð 'Ø&Ø%)¤]Ô%=ðXð XØ
ðXàðXð ðXð ð	Xð
 ðXð Œ]Ô"ðXð ðXð Xð Xð Xðz )Ø(ðð Øðàðð ðð ð	ð ð ð ðB˜%ð ¨5ð °Tð ð ð ð ð ð r'   