3 lá˜_Üã@s˜ddlmZmZmZddlZddlmZddlmZm Z m Z m Z ddl m Z ddlmZddlmZddlmZejd ZejeƒGd d „d eƒƒZdS) é)Úabsolute_importÚdivisionÚprint_functionN)Úutils)ÚAlreadyFinalizedÚ InvalidKeyÚUnsupportedAlgorithmÚ_Reasons)Ú _get_backend)Ú ScryptBackend)Ú constant_time)ÚKeyDerivationFunctionéc@s&eZdZddd„Zdd„Zdd„ZdS) ÚScryptNcCs˜t|ƒ}t|tƒstdtjƒ‚||_tjd|ƒ|dksH||d@dkrPt dƒ‚|dkr`t dƒ‚|dkrpt dƒ‚d |_ ||_ ||_ ||_ ||_||_dS) Nz0Backend object does not implement ScryptBackend.Úsaltrérz-n must be greater than 1 and be a power of 2.z%r must be greater than or equal to 1.z%p must be greater than or equal to 1.F)r Ú isinstancer rr ZBACKEND_MISSING_INTERFACEÚ_lengthrÚ _check_bytesÚ ValueErrorÚ_usedÚ_saltÚ_nÚ_rÚ_pÚ_backend)ÚselfrZlengthÚnÚrÚpZbackend©r ú/usr/lib64/python3.6/scrypt.pyÚ__init__s&  zScrypt.__init__cCs@|jrtdƒ‚d|_tjd|ƒ|jj||j|j|j|j |j ƒS)Nz'Scrypt instances can only be used once.TÚ key_material) rrrZ_check_byteslikerZ derive_scryptrrrrr)rr#r r r!Úderive7s  z Scrypt.derivecCs"|j|ƒ}tj||ƒstdƒ‚dS)NzKeys do not match.)r$r Zbytes_eqr)rr#Z expected_keyZ derived_keyr r r!ÚverifyAs  z Scrypt.verify)N)Ú__name__Ú __module__Ú __qualname__r"r$r%r r r r!rs  r)Z __future__rrrÚsysZ cryptographyrZcryptography.exceptionsrrrr Zcryptography.hazmat.backendsr Z'cryptography.hazmat.backends.interfacesr Zcryptography.hazmat.primitivesr Z"cryptography.hazmat.primitives.kdfr ÚmaxsizeZ _MEM_LIMITZregister_interfaceÚobjectrr r r r!Ús