U q`K@sddlZddlmZddlmZddlmZmZmZm Z ddl m Z ddl m Z ddlmZmZmZddlmZGd d d eZGd d d eZGd ddeZdS)N)Enum)utils)AlreadyFinalized InvalidKeyUnsupportedAlgorithm_Reasons) _get_backend) HMACBackend) constant_timehasheshmac)KeyDerivationFunctionc@seZdZdZdS)ModeZctrN)__name__ __module__ __qualname__Z CounterModerrO/tmp/pip-target-nv4zd3e_/lib/python/cryptography/hazmat/primitives/kdf/kbkdf.pyrsrc@seZdZdZdZdS)CounterLocationZ before_fixedZ after_fixedN)rrr BeforeFixed AfterFixedrrrrrsrc @seZdZdejeeeejee eje eje eje d ddZ ee dddZ e e dd d Ze d d d Ze e ddddZdS) KBKDFHMACN) algorithmmodelengthrlenllenlocationlabelcontextfixedc CsFt| } t| tstdtjt|tjs6tdtj| |sLtdtjt|t s^t dt|t spt d|sx|r| rt d|dks||st d|dkr| dkrt d|dk rt|tst d |dkrd }|dkrd }td |td |||_||_||_||_||_||_||_||_| |_d |_| |_dS)Nz.Backend object does not implement HMACBackend.z5Algorithm supplied is not a supported hash algorithm.z5Algorithm supplied is not a supported hmac algorithm.zmode must be of type Modez(location must be of type CounterLocationz9When supplying fixed data, label and context are ignored.zrlen must be between 1 and 4zPlease specify an llenzllen must be an integerrrF)r isinstancer rrZBACKEND_MISSING_INTERFACEr HashAlgorithmZUNSUPPORTED_HASHZhmac_supportedr TypeErrorr ValueError_valid_byte_lengthintr _check_bytes _algorithm_mode_length_rlen_llen _location_label_context_backend_used _fixed_data) selfrrrrrrrrr backendrrr__init__ s^         zKBKDFHMAC.__init__)valuereturncCs@t|tstdtd|}dt|kr6dkss