var/opt/nydus/ops/oscrypto/__pycache__/_ffi.cpython-38.pyc000064400000026066147205545430017551 0ustar00U afF/@s`dZddlmZmZmZmZddlZddlZddlm Z ddl m Z ddl m Z mZmZmZdd d d d d ddddddddddddddddddd d!d"gZe d#krdd$lmZiZeZ d%dZd&d'Zd(d Zd)d Zdfd*d"Zd+d Zd,dZd-dZdgd.dZd/dZd0d Zd1dZ d2d Z!d3dZ"d4dZ#d5dZ$dhd6dZ%did7dZ&d8dZ'd9dZ(d:d!Z)d;dZ*ddZ-d?dZ.d#Z/nddl0Z0dd@l0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6ee3e07e0j8fZ9dAdAdAdAdBZ:e5e6e3e07e3e2e4e0j;e0jZ>e:?dAdAdAdAdFe=?e0j8e3e6e3e6e>j@e>jAe07e0j8e07e07e0j8dG dHdIZBdJdZdKd ZdLd ZdjdMd"ZdNd ZdOdZdPdZdkdQdZdRdZdSd ZdTdZ dUd Z!dVdZ"dWdZ#dXdZ$dldYdZ%dmdZdZ&d[dZ'd\dZ(d]d!Z)d^dZ*d_dZ+d`d Z,dadZ-dbdZ.dcZ/dddZCGdeddeDZEdS)nzK Exceptions and compatibility shims for consistently using ctypes and cffi )unicode_literalsdivisionabsolute_importprint_functionN) find_library)ffi)str_clsbyte_cls int_types bytes_to_listarray_from_pointer array_setbuffer_from_bytesbuffer_from_unicodebuffer_pointer byte_arraybyte_string_from_bufferbytes_from_buffercallbackcastdereferrnoFFIEngineError get_libraryis_nullnativenewnull pointer_setref register_ffisizeofstruct struct_bytesstruct_from_bufferunwrapwrite_to_buffercffi)FFIcCs |t|<dSN) _ffi_registrylibraryffi_objr/>/opt/nydus/tmp/pip-target-53d1vnqk/lib/python/oscrypto/_ffi.pyr!8scCs|tkrt|StSr*)r+r)r-r/r/r0_get_ffi;sr1cCs"tjdkrtd|Std|S)Nwin32zunsigned char[]zchar[])sysplatformrr initializerr/r/r0r@s  cCs td|S)Nz wchar_t []rrr5r/r/r0rEscCs||||t|<dSr*)lenbufferdataoffsetr/r/r0r'HscCstd|gS)Nzchar *[]r7r:r/r/r0rKscCst|}|||Sr*)r1r)r-type_valuer.r/r/r0rNscCst|}||Sr*)r1r")r-r?r.r/r/r0r"RscCs.|dk rt||ddSt|ddSr*rr:r:maxlenr/r/r0rVscCs t|Sr*)rstringr=r/r/r0r[scCs|Sr*r/Z byte_stringr/r/r0r^scCs ||d<dSNrr/Zpointer_r?r/r/r0rascCst|D]\}}|||<qdSr* enumeratearrayr?indexvalr/r/r0rdscCstjSr*)rNULLr/r/r/r0rhscCsH|dkr dS|tjkrdStt|dkr2dS|dtjkrDdSdS)NTvoid *Fr)rrMZgetctypeZtypeofpointr/r/r0rks cCstjSr*)rrr/r/r/r0rvscCsJt|}g}|dk r|||tddgkr:||dS|j|f|S)NZBCRYPT_KEY_HANDLEZBCRYPT_ALG_HANDLEr)r1appendsetrr)r-r>r?r.paramsr/r/r0rys  cCs||Sr*r/r?r<r/r/r0r scCs4|tkrt|S|tkr,t|ddS||Sr*)r rrCr r:r>r?r/r/r0rs  cCs|dSrEr/rOr/r/r0rscCs|dSrEr/rOr/r/r0r&scCst|}|d|S)N%s *)r1r)r-namer.r/r/r0r#scCst|ddSr*r@Zstruct_r/r/r0r$scCsRt|}|d|}|d}t||}||}|||dd|dd<|S)NrVr)r1rr"r:)r-rWr:r.Znew_struct_pointerZ new_structZ struct_sizeZ struct_bufferr/r/r0r%s  c Cst|}|d||f|}||}|dkr2gSg}ddddddd}||k} td|D]$} || } | rt|| } || qZ|S)Nz%s[%s]rT)LPSTRLPCSTRLPWSTRLPCWSTRchar * wchar_t *)r1rr"rangerCrQ) r-rWrPsizer.rJ total_bytesoutput string_typesZ string_typeir?r/r/r0r s(   cCst|}|||Sr*)r1r)r-Zsignature_namefuncr.r/r/r0rs)pointerc_intc_char_pc_uintc_void_p c_wchar_pT)rNr^r]char **)rNr^r]rlintz unsigned intZsize_tZuint32_tr2)wintypes)rYr[rZr\) ZBYTErYr[rZr\ULONGDWORDr]rlcCs|dddk}|r |dd}|dddko6|tk}|rH|dd}|ddk}|r||dd|d}|d krd }nt|}|d |d}|tkrt|}n t||}|rt|}|||fS) Nz **z *[r]Tr)_pointer_typesfindrm _type_mapgetattrctypesPOINTER)r-r>Zis_double_pointer is_pointeris_arrayr/r/r0 _type_infos&     rcCsdSr*r/r,r/r/r0r!scCs t|Sr*)r{create_string_bufferr5r/r/r0r scCs t|Sr*)r{create_unicode_bufferr5r/r/r0rscCsPt|ttjr(t||t|dS|dkr8||_n|jd|||_dSrE) isinstancer{r|c_bytememmover8r?rawr9r/r/r0r's cCstt|tSr*)rfr{rrhr=r/r/r0rscCs8t||\}}}|r t|}n |r,||}t||Sr*)rr{r|r)r-r>r?r}r~r/r/r0rs  cCs t|Sr*)r{r")r-r?r/r/r0r"(scCs2t|trt||S|dk r,|jd|S|jSrE)r_pointer_int_typesr{ string_atrrAr/r/r0r+s   cCs|jSr*)r?r=r/r/r0r2scCstjt|t|Sr*)r{rr8r rDr/r/r0r5scCs ||j_dSr*)contentsr?rFr/r/r0r8scCst|D]\}}|||<qdSr*rGrIr/r/r0r;scCsdSr*r/r/r/r/r0r?scCs t| Sr*)boolrOr/r/r0rBscCstSr*)r{ get_errnor/r/r/r0rEscCs`t||\}}}|r2|dkr*||}d}n||}g}|dk rH||||}|r\t|}|S)NT)rrQrf)r-r>r?r}r~rSrbr/r/r0rHs cCs0|dkrt|Stt||ttjSrE)r{byrefr addressofr|rrTr/r/r0r [s cCsdt||r|Stjdkr.|tkr.t|tr.|St|tjrZ|jtjkrZt t ||j S||j S)N)) rr3 version_informr r{Array_type_rrr_length_r?rUr/r/r0r`s cCs|dSrEr/rOr/r/r0riscCs|jSr*)rrOr/r/r0r&lscCstt||Sr*)rfrz)r-rWr/r/r0r#oscCst|t|jSr*)r{rr"rrXr/r/r0r$rscCs4t||}|}tt||t|t|Sr*)rzr{rrr"rf)r-r>r:class_r?r/r/r0r%us cCsHt||\}}}t|t|}g}td|D]}|||q0|SrE)rr{rr|r_rQ)r-r>rPr`_rJrbrdr/r/r0r {s cCst|||Sr*)rz)r-Zsignature_typerer/r/r0rsr{cCspt|}tjdkrld|}|dd|}ttttdd}|sX|dkrX|}n|dkrl||krl|}|S) a Retrieve the C library path with special handling for Mac :param name: A unicode string of the library to search the system for :param dylib_name: Mac only - a unicode string of the unversioned dylib name :param version: Mac only - a unicode string of the dylib version to use. Used on macOS 10.15+ when the unversioned dylib is found, since unversioned OpenSSL/LibreSSL are just placeholders, and a versioned dylib must be imported. Used on macOS 10.16+ when find_library() doesn't return a result, due to system dylibs not being present on the filesystem any longer. :return: A unicode string of the path to the library darwinz /usr/lib/%sz.dylibz .%s.dylibr.) )r) rr3r4replacetuplemaprmmac_versplit)rWZ dylib_nameversionr-Z unversionedZ versionedrr/r/r0rs  c@seZdZdZdS)rz@ An exception when trying to instantiate ctypes or cffi N)__name__ __module__ __qualname____doc__r/r/r/r0rs)r)N)N)r)r)N)N)r)Fr __future__rrrrr3r4 ctypes.utilrrvr_typesr r r r __all__r(r)r+r!r1rrr'rrr"rrrrrrrrrr rrr&r#r$r%r rZenginer{rfrgrhrirjrkr|rrrwc_size_tc_uint32ryrnupdaterorprr Exceptionrr/r/r/r0s                    &