o
    	cD                  	   @   s  d Z ddlmZ ddlZddlmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZ ddlmZ ddlmZ e dkr>ed	e d Zeeeed
Zedk r^eded ed f dd ZeddZ eddZ!eZ"eZ#eZ$eZ%eZ&eZ'eZ(eZ)eZ*eZ+eZ,ee+Z-eZ.eZ/ee%Z0ee&Z1ee'Z2ee(Z3ee)Z4eZ5eZ6eZ7eeZ8eZ9eZ:eeZ;eZ<eZ=eeZ>eZ?eZ@eeZAeeZBeZCeZDeZEeZFeZGeZHze0e1ee9ee:e<ee=e>ee2ge jI_Je/e jI_Kg e jL_Je,e jL_Kg e jM_Je,e jM_Kg e jN_Je,e jN_Ke.e0ge jO_Je8e jO_Ke8ge jP_Je0e jP_Ke/ege jQ_Je1e jQ_Ke-e8ee;ge jR_Je/e jR_Ke
eee"eee>ge jS_Je/e jS_Ke>ge jT_Je/e jT_Ke0e4ee2ge jU_Je/e jU_Kee/eCeeeZVee/eCee	eeZWeAeVeWge jX_Je/e jX_KeAe
ege jY_Je/e jY_KeAe2ge jZ_Je/e jZ_KeAe-e"ge j[_Je/e j[_KeAeCge j\_Je/e j\_KeAe
ege j]_Je/e j]_KeAge j^_Je/e j^_KeAe
eeege j__Je/e j__KeAe
eeege j`_Je/e j`_KeAge ja_Je/e ja_KeAeege jb_Je/e jb_KeAee@eege jc_Je/e jc_KeAee@ege jd_Je/e jd_KeAeege je_fe/e je_KeAee@eege jg_Je/e jg_KeAee@ge jh_Je/e jh_KeAee?ge ji_Je/e ji_KeAeeBge jj_Je/e jj_KeBe2ge jk_Je/e jk_KeBe"ge jl_me/e jl_KeBeeDge jn_Je/e jn_KeBge jo_Je#e jo_KeBe#ge jp_Je8e jp_Ke.eFeGge jq_JeAe jq_KeAeHe"ge jr_Je/e jr_KeAe?ge js_Je/e js_KeAe?ge jt_Je/e jt_KzeAe2ge ju_Je/e ju_KW n
 evy   Y nw e/ege jQ_Je1e jQ_KeVe _VeWe _WeAe _Ae?e _?e@e _@e;e _;e>e _>eBe _BeDe _De9e _9e/e _/e1we de _xe1we de _ye-ge!jz_Je-e!jz_Ke-ge!j{_Jde!j{_Ke-ge!j|_Je,e!j|_Ke.e
e$ge!j}_Je1e!j}_Ke1e$ge!j~_Je
e!j~_Ke1e
e#e$ge!j_Jee!j_Ke.e
e#ge!j_Je0e!j_Ke0ge!j_Je#e!j_Ke0ge!j_Jee!j_Ke.ee-ee-e#e6e7ge!j_Je4e!j_Ke4e-ge!j_Je-e!j_Ke.ee-e#e5ge!j_Je2e!j_Ke.e#e5ge!j_Je3e!j_Ke3ege!j_Jde!j_Ke2ge!j_Je#e!j_Ke2e#ge!j_Jee!j_Ke.we!de!_ewe!de!_ewe!de!_ewe!de!_e-e!_-e2e!_2e1e!_1e4e!_4W n evy   edw G dd deZG dd deZdS )ay  
This module uses ctypes to bind a whole bunch of functions and constants from
SecureTransport. The goal here is to provide the low-level API to
SecureTransport. These are essentially the C-level functions and constants, and
they're pretty gross to work with.

This code is a bastardised version of the code found in Will Bond's oscrypto
library. An enormous debt is owed to him for blazing this trail for us. For
that reason, this code should be considered to be covered both by urllib3's
license and by oscrypto's:

    Copyright (c) 2015-2016 Will Bond <will@wbond.net>

    Permission is hereby granted, free of charge, to any person obtaining a
    copy of this software and associated documentation files (the "Software"),
    to deal in the Software without restriction, including without limitation
    the rights to use, copy, modify, merge, publish, distribute, sublicense,
    and/or sell copies of the Software, and to permit persons to whom the
    Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    DEALINGS IN THE SOFTWARE.
    )absolute_importN)CDLL	CFUNCTYPEPOINTERc_boolc_bytec_char_pc_int32c_longc_size_tc_uint32c_ulongc_void_p)find_library   )
raise_fromDarwinzOnly macOS is supported.)
      z1Only OS X 10.8 and newer are supported, not %s.%s   c                 C   sT   zt dkr|}nt| }|stt|ddW S  ty)   ttd|  d Y dS w )z:Loads a CDLL by name, falling back to known path on 10.16+)r      T)	use_errnozThe library %s failed to loadN)version_infor   OSErrorr   r   ImportError)namemacos10_16_pathpath r   V/opt/certbot/lib/python3.10/site-packages/urllib3/contrib/_securetransport/bindings.py	load_cdllA   s   r!   Securityz6/System/Library/Frameworks/Security.framework/SecurityCoreFoundationzB/System/Library/Frameworks/CoreFoundation.framework/CoreFoundationkSecImportExportPassphrasekSecImportItemIdentitykCFAllocatorDefaultkCFTypeArrayCallBackskCFTypeDictionaryKeyCallBackskCFTypeDictionaryValueCallBackszError initializing ctypesc                   @   s   e Zd ZdZedZdS )CFConstz_
    A class object that acts as essentially a namespace for CoreFoundation
    constants.
    i  N)__name__
__module____qualname____doc__CFStringEncodingkCFStringEncodingUTF8r   r   r   r    r*     s    r*   c                   @   s(  e Zd ZdZdZdZdZdZdZdZ	dZ
d	ZdZdZdZdZdZd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(d Z)d!Z*d"Z+d#Z,d$Z-d%Z.d&Z/d'Z0d(Z1d)Z2d*Z3d+Z4d,Z5d-Z6d.Z7d/Z8d0Z9d1Z:d2Z;d3Z<d4Z=d5Z>d6Z?d7Z@d8ZAd9ZBd:ZCd;ZDd<ZEd=ZFd>ZGd?ZHd@ZIdAS )BSecurityConstzU
    A class object that acts as essentially a namespace for Security constants.
    r   r            r   r   i  r         iiiiiiiiiiiiiiiiiii iQi,iRi,  i0  i+  i/  i  i        i$  i(  i
  i  k   9   i#  i'  i	  i  g   3         =   <   5   /   i  i  i  i  N)Jr+   r,   r-   r.   "kSSLSessionOptionBreakOnServerAuthkSSLProtocol2kSSLProtocol3kTLSProtocol1kTLSProtocol11kTLSProtocol12kTLSProtocol13kTLSProtocolMaxSupportedkSSLClientSidekSSLStreamTypekSecFormatPEMSequencekSecTrustResultInvalidkSecTrustResultProceedkSecTrustResultDenykSecTrustResultUnspecified&kSecTrustResultRecoverableTrustFailure kSecTrustResultFatalTrustFailurekSecTrustResultOtherErrorerrSSLProtocolerrSSLWouldBlockerrSSLClosedGracefulerrSSLClosedNoNotifyerrSSLClosedAborterrSSLXCertChainInvaliderrSSLCryptoerrSSLInternalerrSSLCertExpirederrSSLCertNotYetValiderrSSLUnknownRootCerterrSSLNoRootCerterrSSLHostNameMismatcherrSSLPeerHandshakeFailerrSSLPeerUserCancellederrSSLWeakPeerEphemeralDHKeyerrSSLServerAuthCompletederrSSLRecordOverflowerrSecVerifyFailederrSecNoTrustSettingserrSecItemNotFounderrSecInvalidTrustSettings'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384%TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384'TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256%TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256-TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256+TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256#TLS_DHE_RSA_WITH_AES_256_GCM_SHA384#TLS_DHE_RSA_WITH_AES_128_GCM_SHA256'TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384%TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384$TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA#TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 TLS_DHE_RSA_WITH_AES_256_CBC_SHA'TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256%TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256$TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA#TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 TLS_DHE_RSA_WITH_AES_128_CBC_SHATLS_RSA_WITH_AES_256_GCM_SHA384TLS_RSA_WITH_AES_128_GCM_SHA256TLS_RSA_WITH_AES_256_CBC_SHA256TLS_RSA_WITH_AES_128_CBC_SHA256TLS_RSA_WITH_AES_256_CBC_SHATLS_RSA_WITH_AES_128_CBC_SHATLS_AES_128_GCM_SHA256TLS_AES_256_GCM_SHA384TLS_AES_128_CCM_8_SHA256TLS_AES_128_CCM_SHA256r   r   r   r    r1     s    r1   )r.   
__future__r   platformctypesr   r   r   r   r   r   r	   r
   r   r   r   r   ctypes.utilr   packages.sixr   systemr   mac_verversiontuplemapintsplitr   r   r!   r"   r#   BooleanCFIndexr/   CFDataCFStringCFArrayCFMutableArrayCFDictionaryCFErrorCFTypeCFTypeID	CFTypeRefCFAllocatorRefOSStatus	CFDataRefCFStringRef
CFArrayRefCFMutableArrayRefCFDictionaryRefCFArrayCallBacksCFDictionaryKeyCallBacksCFDictionaryValueCallBacksSecCertificateRefSecExternalFormatSecExternalItemTypeSecIdentityRefSecItemImportExportFlags SecItemImportExportKeyParametersSecKeychainRefSSLProtocolSSLCipherSuiteSSLContextRefSecTrustRefSSLConnectionRefSecTrustResultTypeSecTrustOptionFlagsSSLProtocolSideSSLConnectionTypeSSLSessionOptionSecItemImportargtypesrestypeSecCertificateGetTypeIDSecIdentityGetTypeIDSecKeyGetTypeIDSecCertificateCreateWithDataSecCertificateCopyDataSecCopyErrorMessageString SecIdentityCreateWithCertificateSecKeychainCreateSecKeychainDeleteSecPKCS12ImportSSLReadFuncSSLWriteFuncSSLSetIOFuncsSSLSetPeerIDSSLSetCertificateSSLSetCertificateAuthoritiesSSLSetConnectionSSLSetPeerDomainNameSSLHandshakeSSLReadSSLWriteSSLCloseSSLGetNumberSupportedCiphersSSLGetSupportedCiphersSSLSetEnabledCiphersSSLGetNumberEnabledCiphersargtypeSSLGetEnabledCiphersSSLGetNegotiatedCipherSSLGetNegotiatedProtocolVersionSSLCopyPeerTrustSecTrustSetAnchorCertificates!SecTrustSetAnchorCertificatesOnly	argstypesSecTrustEvaluateSecTrustGetCertificateCountSecTrustGetCertificateAtIndexSSLCreateContextSSLSetSessionOptionSSLSetProtocolVersionMinSSLSetProtocolVersionMaxSSLSetALPNProtocolsAttributeErrorin_dllr$   r%   CFRetain	CFReleaseCFGetTypeIDCFStringCreateWithCStringCFStringGetCStringPtrCFStringGetCStringCFDataCreateCFDataGetLengthCFDataGetBytePtrCFDictionaryCreateCFDictionaryGetValueCFArrayCreateCFArrayCreateMutableCFArrayAppendValueCFArrayGetCountCFArrayGetValueAtIndexr&   r'   r(   r)   objectr*   r1   r   r   r   r    <module>   s(   8












	