U q`@sddlZddlZddlZddlZddlZddlmZddlmZddlm Z m Z ddl m Z e dddd d d gZGd d d eZddZddZddZdddZddZGdddeZddZeejedS)N)utils) InternalError)ffilib)CONDITIONAL_NAMES_OpenSSLErrorWithTextcoderfuncreasonZ reason_textc@sDeZdZddZddZedZedZedZ edZ d S) _OpenSSLErrorcCs||_||_||_||_dSN)_code_lib_func_reason)selfrrr r rS/tmp/pip-target-nv4zd3e_/lib/python/cryptography/hazmat/bindings/openssl/binding.py__init__sz_OpenSSLError.__init__cCs||jko||jkSr )rr )rrr rrr_lib_reason_matchsz_OpenSSLError._lib_reason_matchr rrrN) __name__ __module__ __qualname__rrrZread_only_propertyrrr r rrrrr s    r cCsNg}|}|dkrqJ||}||}||}|t||||q|S)Nr)Z ERR_get_errorZ ERR_GET_LIBZ ERR_GET_FUNCZERR_GET_REASONappendr )rerrorsrZerr_libZerr_funcZ err_reasonrrr_consume_errors&s   rc CsZg}|D]L}tdd}t|j|t|t|}|t|j|j|j |j |q|S)Nzchar[]) rnewrZERR_error_string_nrlenstringrrr r )rerrors_with_texterrbufZerr_text_reasonrrr_errors_with_text6s  r#cCs tt|Sr )r#r)rrrr_consume_errors_with_textFsr$cCs0|s,|dkrt|}t|}td||dS)NaiUnknown OpenSSL error. This error is commonly encountered when another library is not cleaning up the OpenSSL error stack. If you are using cryptography with another library that uses OpenSSL try disabling it before reporting a bug. Otherwise please file an issue at https://github.com/pyca/cryptography/issues with information on how to reproduce this. ({0!r}))rr#rformat)rokrr rrr_openssl_assertJsr'cCsjtd}||_t}|D]\}}t||s||qt|D]}||krFt||t||qF|S)Nr) types ModuleTypeZ _original_libsetitemsgetattrupdatedirsetattr)rZconditional_namesZconditional_libZexcluded_names conditionZnames_cbattrrrrbuild_conditional_library\s   r2c@s\eZdZUdZdZejed<eZdZ e Z ddZ eddZed d Zed d ZdS) Bindingz OpenSSL API wrapper. NrFcCs |dSr _ensure_ffi_initialized)rrrrruszBinding.__init__cCs0|j|jjr,|j}t|j|dkdS)N))rZERR_clear_errorZ"CRYPTOGRAPHY_NEEDS_OSRANDOM_ENGINEZ Cryptography_add_osrandom_enginer')clsresultrrr_register_osrandom_enginexs  z!Binding._register_osrandom_enginec CsJ|j:|jsrrrrr3ks   r3cCs.ttj}|d|kr*td||dS)NasciiaThe version of cryptography does not match the loaded shared object. This can happen if you have multiple copies of cryptography installed in your Python path. Please try creating a new virtual environment to resolve this issue. Loaded python version: {}, shared object version: {})rrrZCRYPTOGRAPHY_PACKAGE_VERSIONencode ImportErrorr%)versionZso_package_versionrrr_verify_package_versions rJ)N) collectionsrCr(r@Z cryptographyrZcryptography.exceptionsrZ%cryptography.hazmat.bindings._opensslrrZ1cryptography.hazmat.bindings.openssl._conditionalr namedtuplerobjectr rr#r$r'r2r3rJ __version__r>rrrrs,     *