U q`e@sddlmZmZmZddlZddlZddlmZej j Z ej j Z ej jZej jZej jZej jZej jZej jZej jZej jZej jZej j Z!Gddde"Z#dd d Z$dS))absolute_importdivisionprint_functionN)bytes_as_stringc@seZdZdZeZeZeZ e Z dedddfddZ e ddZe ddZe d d Zd d Zd dZddZddZddZdS)blake2bzK :py:mod:`hashlib` API compatible blake2b algorithm implementation cCs*t||||d|_||_|r&||dS)ab :py:class:`.blake2b` algorithm initializer :param data: :type data: bytes :param int digest_size: the requested digest size; must be at most :py:attr:`.MAX_DIGEST_SIZE`; the default digest size is :py:data:`.BYTES` :param key: the key to be set for keyed MAC/PRF usage; if set, the key must be at most :py:data:`.KEYBYTES_MAX` long :type key: bytes :param salt: a initialization salt at most :py:attr:`.SALT_SIZE` long; it will be zero-padded if needed :type salt: bytes :param person: a personalization string at most :py:attr:`.PERSONAL_SIZE` long; it will be zero-padded if needed :type person: bytes )keysaltperson digest_sizeN) _b2b_init_state _digest_sizeupdate)selfdatar rr r r3/tmp/pip-target-nv4zd3e_/lib/python/nacl/hashlib.py__init__/s zblake2b.__init__cCs|jSN)rrrrrr Mszblake2b.digest_sizecCsdS)Nrrrrr block_sizeQszblake2b.block_sizecCsdS)NrrrrrrnameUsz blake2b.namecCst|j|dSr) _b2b_updater )rrrrrrYszblake2b.updatecCs|j}t|Sr)r copy _b2b_final)r_strrrdigest\s zblake2b.digestcCstt|Sr)rbinasciihexlifyrrrrr hexdigest`szblake2b.hexdigestcCs$t||jd}|j}||_|S)N)r )typer r r)rZ_cprrrrrcs z blake2b.copycCstd|jjdS)zc Raise the same exception as hashlib's blake implementation on copy.copy() zcan't pickle {} objectsN) TypeErrorformat __class____name__rrrr __reduce__iszblake2b.__reduce__N)r& __module__ __qualname____doc__BYTESMAX_DIGEST_SIZE KEYBYTES_MAX MAX_KEY_SIZE PERSONALBYTES PERSON_SIZE SALTBYTES SALT_SIZErpropertyr rrrrr!rr'rrrrr&s(    r@c Cstjj|||||||dS)a Derive a cryptographic key using the scrypt KDF. :raises nacl.exceptions.UnavailableError: If called when using a minimal build of libsodium. Implements the same signature as the ``hashlib.scrypt`` implemented in cpython version 3.6 )maxmemdklen)naclbindingsZ%crypto_pwhash_scryptsalsa208sha256_ll)passwordr nrpr:r;rrrscryptrs rB)r4r5r6r7r8r9)% __future__rrrrZ nacl.bindingsr<Z nacl.utilsrr=Zcrypto_generichash_BYTESr+Zcrypto_generichash_BYTES_MINZ BYTES_MINZcrypto_generichash_BYTES_MAXZ BYTES_MAXZcrypto_generichash_KEYBYTESZKEYBYTESZcrypto_generichash_KEYBYTES_MINZ KEYBYTES_MINZcrypto_generichash_KEYBYTES_MAXr-Zcrypto_generichash_SALTBYTESr1Z crypto_generichash_PERSONALBYTESr/Z&has_crypto_pwhash_scryptsalsa208sha256ZSCRYPT_AVAILABLEZcrypto_generichash_blake2b_initr Z crypto_generichash_blake2b_finalrZ!crypto_generichash_blake2b_updaterobjectrrBrrrrs( L