σ Ϋ_e[c@`s^ddlmZddlmZddlZddlZddlmZddlm Z ej j Z ej j Zej jZej jZej jZe dZej jZej jZej jZej jZej jZej j Z!ej j"Z#ej j$Z%ej j&Z'ej j(Z)de#Z*de%Z+e'e)ej,j-d„Z.e#e%d „Z/d „Z0dS( i(tabsolute_import(tdivisionN(t exceptions(tensureiic C`stt|ƒtkdtt|ƒfdtjƒtjj||ƒ\}}}|d} |jtjj ||d|||d| d|ƒƒS(s 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 .. versionadded:: 1.2 s.The salt must be exactly %s, not %s bytes longtraisingiitmaxmemtdkleni( Rtlent SALTBYTEStexct ValueErrortnacltbindingst nacl_bindings_pick_scrypt_paramstencodet%crypto_pwhash_scryptsalsa208sha256_ll( tsizetpasswordtsalttopslimittmemlimittencodertn_log2trtpR((s4/tmp/pip-install-KP2Jbq/pynacl/nacl/pwhash/scrypt.pytkdf6s3    cC`stjj|||ƒS(s» 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 .. versionadded:: 1.2 (R R t&crypto_pwhash_scryptsalsa208sha256_str(RRR((s4/tmp/pip-install-KP2Jbq/pynacl/nacl/pwhash/scrypt.pytstr|s cC`s?tt|ƒtkdtjjdtjƒtjj||ƒS(sξ 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 .. versionadded:: 1.2 s/The password hash must be exactly %s bytes longR( RRt PWHASH_SIZER R t+crypto_pwhash_scryptsalsa208sha256_STRBYTESR R t-crypto_pwhash_scryptsalsa208sha256_str_verify(t password_hashR((s4/tmp/pip-install-KP2Jbq/pynacl/nacl/pwhash/scrypt.pytverify”s    (1t __future__RRt nacl.bindingsR t nacl.encodingRR tnacl.exceptionsRR Rt_strbytes_plus_onet,crypto_pwhash_scryptsalsa208sha256_STRPREFIXt STRPREFIXt,crypto_pwhash_scryptsalsa208sha256_SALTBYTESRt-crypto_pwhash_scryptsalsa208sha256_PASSWD_MINt PASSWD_MINt-crypto_pwhash_scryptsalsa208sha256_PASSWD_MAXt PASSWD_MAXRt,crypto_pwhash_scryptsalsa208sha256_BYTES_MINt BYTES_MINt,crypto_pwhash_scryptsalsa208sha256_BYTES_MAXt BYTES_MAXt/crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MINt MEMLIMIT_MINt/crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAXt MEMLIMIT_MAXt/crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MINt OPSLIMIT_MINt/crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAXt OPSLIMIT_MAXt7crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVEtOPSLIMIT_INTERACTIVEt7crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVEtMEMLIMIT_INTERACTIVEt5crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVEtOPSLIMIT_SENSITIVEt5crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVEtMEMLIMIT_SENSITIVEtOPSLIMIT_MODERATEtMEMLIMIT_MODERATEtencodingt RawEncoderRRR (((s4/tmp/pip-install-KP2Jbq/pynacl/nacl/pwhash/scrypt.pyts:                    D