B \Úæ`ä ã@s\ddlmZmZmZddlmZddlmZmZddl m Z e  e j ¡Gdd„de ƒƒZdS)é)Úabsolute_importÚdivisionÚprint_function)Úutils)ÚUnsupportedAlgorithmÚ_Reasons)Úhashesc@s8eZdZd dd„Ze d¡Zdd„Zdd„Zd d „Z dS) Ú _HashContextNcCs¢||_||_|dkr˜|jj ¡}|jj ||jjj¡}|j |¡}|jj |¡}||jjj krpt d  |¡t j ƒ‚|jj |||jjj ¡}|j |dk¡||_dS)Nz,{0} is not a supported hash on this backend.r)Ú _algorithmÚ_backendÚ_libÚCryptography_EVP_MD_CTX_newÚ_ffiÚgcÚCryptography_EVP_MD_CTX_freeZ_build_openssl_digest_nameZEVP_get_digestbynameZNULLrÚformatrZUNSUPPORTED_HASHZEVP_DigestInit_exÚopenssl_assertÚ_ctx)ÚselfZbackendÚ algorithmÚctxÚnameZevp_mdÚres©rú^/opt/alt/python37/lib64/python3.7/site-packages/cryptography/hazmat/backends/openssl/hashes.pyÚ__init__s"    z_HashContext.__init__r cCsV|jj ¡}|jj ||jjj¡}|jj ||j¡}|j |dk¡t |j|j |dS)Nr)r) r r r rrrZEVP_MD_CTX_copy_exrrr r)rZ copied_ctxrrrrÚcopy)s  z_HashContext.copycCs,|jj |j|t|ƒ¡}|j |dk¡dS)Nr)r r ZEVP_DigestUpdaterÚlenr)rÚdatarrrrÚupdate2sz_HashContext.updatecCsz|jj d|jjj¡}|jj d¡}|jj |j||¡}|j |dk¡|j |d|jj k¡|jj  |¡d|d…S)Nzunsigned char[]zunsigned int *r) r rÚnewr ZEVP_MAX_MD_SIZEZEVP_DigestFinal_exrrrZ digest_sizeÚbuffer)rZbufZoutlenrrrrÚfinalize6s  z_HashContext.finalize)N) Ú__name__Ú __module__Ú __qualname__rrZread_only_propertyrrrr"rrrrr s    r N)Z __future__rrrZ cryptographyrZcryptography.exceptionsrrZcryptography.hazmat.primitivesrZregister_interfaceZ HashContextÚobjectr rrrrÚs