σ Ϋ_e[c@`s,ddlmZmZmZddlmZddlmZddl m Z m Z ddl m Z e jƒZe jƒZe jƒZe jƒZe jƒZe jƒZe jƒZe jƒZe jƒZdZ dZ!d„Z"ed d d d „Z#d d d ed „Z$d „Z%d „Z&d„Z'dS(i(tabsolute_importtdivisiontprint_function(t integer_types(t exceptions(tffitlib(tensures!{0} length greater than {1} bytess{0} greater than {1}cC`s2tt|tƒddtjƒtt|tƒddtjƒtt|tƒddtjƒtt|tƒddtjƒt|tktjdtƒdtj ƒtt |ƒt kt jdt ƒdtj ƒtt |ƒt kt jdt ƒdtj ƒtt |ƒtkt jd tƒdtj ƒd S( sCheck hash paramterssKey must be a bytes sequencetraisingsSalt must be a bytes sequencesPerson must be a bytes sequences%Digest size must be an integer numbert Digest_sizetKeytSalttPersonN(Rt isinstancetbytestexct TypeErrorRtcrypto_generichash_BYTES_MAXt_TOOBIGtformatt ValueErrortlentcrypto_generichash_KEYBYTES_MAXt _OVERLONGtcrypto_generichash_SALTBYTESt crypto_generichash_PERSONALBYTES(t digest_sizetkeytsalttperson((sB/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_generichash.pyt _checkparams's0        tc C`sχt||||ƒtt|tƒddtjƒtjd|ƒ}tjdtƒ}tjdt ƒ}tj ||t |ƒƒtj ||t |ƒƒt j |||t |ƒ|t |ƒ||ƒ}t|dkddtjƒtj||ƒS(sbOne shot hash interface :param data: the input data to the hash function :param digest_size: must be at most :py:data:`.crypto_generichash_BYTES_MAX`; the default digest size is :py:data:`.crypto_generichash_BYTES` :type digest_size: int :param key: must be at most :py:data:`.crypto_generichash_KEYBYTES_MAX` long :type key: bytes :param salt: must be at most :py:data:`.crypto_generichash_SALTBYTES` long; will be zero-padded if needed :type salt: bytes :param person: must be at most :py:data:`.crypto_generichash_PERSONALBYTES` long: will be zero-padded if needed :type person: bytes :return: digest_size long digest :rtype: bytes s#Input data must be a bytes sequenceRsunsigned char[]sunsigned char []isUnexpected failure(RRR RRRRtnewRRtmemmoveRRt(crypto_generichash_blake2b_salt_personalt RuntimeErrortbuffer( tdataRRRRtdigestt_saltt_persontrc((sB/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_generichash.pyt!generichash_blake2b_salt_personalJs       cC`sΏt||||ƒtjdtƒ}tjdtƒ}tjdtƒ}tj||t|ƒƒtj||t|ƒƒtj ||t|ƒ|||ƒ}t |dkddt j ƒ|S(s6 Create a new initialized blake2b hash state :param key: must be at most :py:data:`.crypto_generichash_KEYBYTES_MAX` long :type key: bytes :param salt: must be at most :py:data:`.crypto_generichash_SALTBYTES` long; will be zero-padded if needed :type salt: bytes :param person: must be at most :py:data:`.crypto_generichash_PERSONALBYTES` long: will be zero-padded if needed :type person: bytes :param digest_size: must be at most :py:data:`.crypto_generichash_BYTES_MAX`; the default digest size is :py:data:`.crypto_generichash_BYTES` :type digest_size: int :return: an initizialized state buffer :rtype: bytes sunsigned char[]sunsigned char []isUnexpected failureR( RRR tcrypto_generichash_STATEBYTESRRR!RRt-crypto_generichash_blake2b_init_salt_personalRRR#(RRRRtstatebufR'R(R)((sB/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_generichash.pytgenerichash_blake2b_init|s    cC`sZtt|tƒddtjƒtj||t|ƒƒ}t|dkddtjƒdS(sλUpdate the blake2b hash state :param statebuf: an initialized blake2b state buffer as returned from :py:func:`.crypto_generichash_blake2b_init` :type name: bytes :param data: :type data: bytes s#Input data must be a bytes sequenceRisUnexpected failureN( RR RRRRt!crypto_generichash_blake2b_updateRR#(R-R%R)((sB/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_generichash.pytgenerichash_blake2b_update«s  cC`sTtjdtƒ}tj|||ƒ}t|dkddtjƒtj||ƒS(sμFinalize the blake2b hash state and return the digest. :param statebuf: :type statebuf: bytes :param digest_size: :type digest_size: int :return: the blake2 digest of the passed-in data stream :rtype: bytes sunsigned char[]isUnexpected failureR( RR RRt crypto_generichash_blake2b_finalRRR#R$(R-Rt_digestR)((sB/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_generichash.pytgenerichash_blake2b_finalΎs  cC`s)tjdtƒ}tj||tƒ|S(s-Return a copy of the given blake2b hash statesunsigned char[](RR R+R!(R-tnewstate((sB/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_generichash.pytgenerichash_blake2b_state_copyΡsN((t __future__RRRtsixRtnaclRRt nacl._sodiumRRtnacl.exceptionsRt crypto_generichash_blake2b_bytestcrypto_generichash_BYTESt$crypto_generichash_blake2b_bytes_mintcrypto_generichash_BYTES_MINt$crypto_generichash_blake2b_bytes_maxRt#crypto_generichash_blake2b_keybytestcrypto_generichash_KEYBYTESt'crypto_generichash_blake2b_keybytes_mintcrypto_generichash_KEYBYTES_MINt'crypto_generichash_blake2b_keybytes_maxRt$crypto_generichash_blake2b_saltbytesRt(crypto_generichash_blake2b_personalbytesRtcrypto_generichash_statebytesR+RRRR*R.R0R3R5(((sB/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_generichash.pyts0          $0 -