3 l_ @sdddlmZmZmZddlZddlmZddlmZddl m Z ddZ dd Z d d Z d d ZdS))absolute_importdivisionprint_functionN)utils)hashes) PrehashedcCs|jj||jj}|j||jjk|jj||jj}|jj|}|j|dk|jj||j }|j|dk|jj d}|jj ||jj|}|j|dk|j|ddk|jj d|d}|jj |||}|dkrt d|jj ||dddS)Nzsize_t *rzunsigned char[]z1Null shared key derived from public/private pair.)Z_libZEVP_PKEY_CTX_newZ_ffiZNULLZopenssl_assertgcZEVP_PKEY_CTX_freeZEVP_PKEY_derive_initZEVP_PKEY_derive_set_peerZ _evp_pkeynewZEVP_PKEY_derive ValueErrorbuffer)backendZevp_pkeyZpeer_public_keyZctxresZkeylenZbufr/usr/lib64/python3.6/utils.py_evp_pkey_derives   rcCsNt|ts*tj||}|j||j}n|j}t||jkrFt d||fS)NzNThe provided data must be the same length as the hash algorithm's digest size.) isinstancerrZHashupdatefinalizeZ _algorithmlenZ digest_sizer )r data algorithmZhash_ctxrrr_calculate_digest_and_algorithm"s    rcCst|trtddS)NzfPrehashed is only supported in the sign and verify methods. It cannot be used with signer or verifier.)rr TypeError)Zsignature_algorithmrrr_check_not_prehashed3s rcCstjdtjdddS)NzMsigner and verifier have been deprecated. Please use sign and verify instead.) stacklevel)warningswarnrZPersistentlyDeprecated2017rrrr_warn_sign_verify_deprecated;sr)Z __future__rrrrZ cryptographyrZcryptography.hazmat.primitivesrZ/cryptography.hazmat.primitives.asymmetric.utilsrrrrrrrrrs