
    hP              	       j   S SK r S SKrS SKrS SKrS SKrS SKJrJrJrJrJ	r	J
r
JrJrJr  S SKJr  SSKJr  \R$                  " 5       S    r\" \" \\R/                  S5      5      5      r\S:  a  \" S\S     S\S    35      e\S	:  rS
\S\S\4S jr\" SS5      r\" SS5      r\r\
r \r!\r"\r#\r$\r%\r&\r'\r(\" \'5      r)\r*\	r+\" \&5      r,\" \"5      r-\" \#5      r.\" \$5      r/\" \%5      r0\r1\r2\" \5      r3\" \5      r4\" \5      r5\r6\r7 \*\-/\Rp                  l9        \3\Rp                  l:        \3/\Rv                  l9        \-\Rv                  l:        \+\/\Rx                  l9        \.\Rx                  l:        \5\//\Rz                  l9        \+\Rz                  l:        \5\/\R|                  l9        \+\R|                  l:        \2/\R~                  l9        \4\R~                  l:        \\./\R                  l9        \4\R                  l:        \)\)\" \55      /\R                  l9        \+\R                  l:        \5\" \65      /\R                  l9        \+\R                  l:        \5\" \65      /\R                  l9        \+\R                  l:        \5\l5        \6\l6        \+\l+        SrDSrE\)/\R                  l9        S\R                  l:        \)/\R                  l9        \(\R                  l:        \*\\!/\R                  l9        \.\R                  l:        \.\!/\R                  l9        \\R                  l:        \.\\ \!/\R                  l9        \\R                  l:        \*\\ /\R                  l9        \-\R                  l:        \-/\R                  l9        \ \R                  l:        \-/\R                  l9        \\R                  l:        \*\" \)5      \ \1/\R                  l9        \/\R                  l:        \*\ \1/\R                  l9        \0\R                  l:        \0\/\R                  l9        S\R                  l:        \//\R                  l9        \ \R                  l:        \/\ /\R                  l9        \\R                  l:        \,/\R                  l9        \ \R                  l:        \,/\R                  l9        \.\R                  l:        \*R                  \S5      \lV        \R                  " \S5      \lW        \)\l)        \/\l/        \.\l.        \,\l,        \(       a+   \5\" \,5      /\R                  l9        \\R                  l:        S\+S\R                  S\R                  S\R                  4S jr\\\\R                  l]        \\\Rz                  l]        \\\R|                  l]        \\\R                  l]        \\\R                  l]         " S S5      r^S\_S\-4S jr`S\_S\#4S jraS \.S\S-  4S! jrbS"\c\_   S\04S# jrd\ R                  S$\R                  S\R                  S   4S% j5       rh S-S&\R                  S'\c\_   S(\S-  SS4S) jjriS&\R                  S*\R                  SS4S+ jrjS&\R                  S*\R                  SS4S, jrkg! \X a  rY\" S\Y 35      SeSrYCYff = f! \X a  rY\" S\Y 35      SeSrYCYff = f).    N)	CDLLPOINTERc_boolc_char_pc_int32c_longc_uint32c_ulongc_void_p)find_library   )_set_ssl_context_verify_mode.)
      z,Only OS X 10.8 and newer are supported, not )r      namemacos10_16_pathreturnc                      [         S:  a  UnO[        U 5      nU(       d  [        e[        USS9$ ! [         a    [	        SU  S35      Sef = f)z:Loads a CDLL by name, falling back to known path on 10.16+)r      T)	use_errnozThe library z failed to loadN)_mac_version_infor   OSErrorr   ImportError)r   r   paths      rC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\pip/_vendor/truststore/_macos.py
_load_cdllr      s]    J ("D%DMDD)) JLo>?TIJs	   .1 ASecurityz6/System/Library/Frameworks/Security.framework/SecurityCoreFoundationzB/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation   r   kCFAllocatorDefaultkCFTypeArrayCallBackszError initializing ctypes: result_argsc                 ~   [        U 5      S:X  a  U$ Sn [        R                  U S5      n[        R                  " U[        R
                  " [        R                  5      5      n[        R                  U[        R                  5      nUcZ  [        R                  " S5      n[        R                  UUS[        R                  5      n U (       d  [        S5      eUR                  nUb  [        R                  U5        Ub  US:X  a  SU  3n[         R"                  " U5      e! Ub  [        R                  U5        f f = f)z4
Raises an error if the OSStatus value is non-zero.
r   N   'Error copying C string from CFStringRef z8SecureTransport operation returned a non-zero OSStatus: )intr   SecCopyErrorMessageStringctypescastr   r   r    CFStringGetCStringPtrCFConstkCFStringEncodingUTF8create_string_bufferCFStringGetCStringr   value	CFReleasesslSSLError)r$   r%   r&   error_message_cfstringerror_message_cfstring_c_void_pmessagebuffers          r   _handle_osstatusr<      s%    6{a "!=!)!C!CFD!Q +1++"FNN6??$C+
' !66+W-J-J
 ?006F#66/--	F GHHllG "-$$%;< 'R-LVHU
,,w
 "-$$%;< .s   CD! !D<c                   8    \ rS rSrSr\" S5      rSrSrSr	Sr
Srg	)
r0   i  zCoreFoundation constantsi  iiii N)__name__
__module____qualname____firstlineno____doc__CFStringEncodingr1   #errSecIncompleteCertRevocationCheckerrSecHostNameMismatcherrSecCertificateExpirederrSecNotTrusted__static_attributes__r>       r   r0   r0     s(    ",Z8*0'#%rJ   r0   r4   c                 ^    [         R                  [         R                  U [        U 5      5      $ N)r    CFDataCreater"   len)r4   s    r   _bytes_to_cf_data_refrO   &  s&    &&**E3u: rJ   c                     [         R                  " U 5      n[        R                  [        R                  U[
        R                  5      nU$ )z]
Given a Python binary data, create a CFString.
The string must be CFReleased by the caller.
)r-   r   r    CFStringCreateWithCStringr"   r0   r1   )r4   c_strcf_strs      r   _bytes_to_cf_stringrT   ,  s>    
 OOE"E55**%%F
 MrJ   cf_string_refc                 .   [         R                  U [        R                  5      nUcY  [        R
                  " S5      n[         R                  XS[        R                  5      nU(       d  [        S5      eUR                  nUb  UR                  S5      nU$ )z
Creates a Unicode string from a CFString object. Used entirely for error
reporting.
Yes, it annoys me quite a lot that this function is this complex.
r(   r)   zutf-8)
r    r/   r0   r1   r-   r2   r3   r   r4   decode)rU   stringr;   r$   s       r   _cf_string_ref_to_strrY   :  s     11w44F ~,,T2224)F)F
 CDDw'MrJ   certsc                 L   [         R                  [         R                  S[        R                  " [         R
                  5      5      nU(       d  [        S5      eU  H  nSnSn [        U5      n[        R                  [         R                  U5      n[         R                  X5        U(       a  [         R                  U5        U(       a  [         R                  U5        M  M     U$ ! U(       a  [         R                  U5        U(       a  [         R                  U5        f f = f)zBuilds a CFArray of SecCertificateRefs from a list of DER-encoded certificates.
Responsibility of the caller to call CoreFoundation.CFRelease on the CFArray.
r   zUnable to allocate memory!N)r    CFArrayCreateMutabler"   r-   byrefr#   MemoryErrorrO   r   SecCertificateCreateWithDataCFArrayAppendValuer5   )rZ   cf_array	cert_datacf_datasec_cert_refs        r   _der_certs_to_cf_cert_arrayre   Q  s     22**	^99:H
 677	
	7+I6G#@@22GL --hE((1((6   O ((1((6 s   $AC((;D#ctxc              #      #    U R                   nU R                  nSU l         [        U [        R                  5         S v   Xl         [        X5        g ! Xl         [        X5        f = f7f)NF)check_hostnameverify_moder   r6   	CERT_NONE)rf   rh   ri   s      r   _configure_contextrk   o  sV     ''N//KC cmm47+$S6 ,$S6s   :A)A A)A&&A)ssl_context
cert_chainserver_hostnamec                    S nS nS n Uba  U R                   (       aP  S n [        UR                  S5      5      n[        R	                  SU5      nU(       a  [
        R                  U5        O[        R	                  SS 5      nUnU R                  [        R                  -  (       a  [
        R                  [
        R                  S[        R                  " [
        R                  5      5      n[
        R                  XG5        [
        R                  U5        [        R!                  ["        [$        -  5      n[
        R                  XH5        [
        R                  U5        O-U R                  [        R&                  -  (       a  [)        S5      eS n [+        U5      n[        R-                  5       n[        R/                  X4[        R                  " U5      5        U(       a  [
        R                  U5        U R1                  SS9n	U	(       a?  S n
 [+        U	5      n
[        R3                  XZ5        U
(       a  [
        R                  U
5        [        R5                  US5        [6        (       a  [9        X5        O[;        X5        U(       a  [
        R                  U5        U(       a  [
        R                  U5        g g ! U(       a  [
        R                  U5        f f = f! U(       a  [
        R                  U5        f f = f! U
(       a  [
        R                  U
5        f f = f! U(       a  [
        R                  U5        U(       a  [
        R                  U5        f f = f)NasciiTr   z/VERIFY_CRL_CHECK_LEAF not implemented for macOS)binary_formF)rh   rT   encoder   SecPolicyCreateSSLr    r5   verify_flagsr6   VERIFY_CRL_CHECK_CHAINr\   r"   r-   r]   r#   r`   SecPolicyCreateRevocation#kSecRevocationUseAnyAvailableMethod%kSecRevocationRequirePositiveResponseVERIFY_CRL_CHECK_LEAFNotImplementedErrorre   SecTrustRefSecTrustCreateWithCertificatesget_ca_certsSecTrustSetAnchorCertificates!SecTrustSetAnchorCertificatesOnly _is_macos_version_10_14_or_later"_verify_peercerts_impl_macos_10_14"_verify_peercerts_impl_macos_10_13)rl   rm   rn   rZ   policiestrustcf_str_hostname
ssl_policyrevocation_policyctx_ca_certs_derctx_ca_certss              r   _verify_peercerts_implr   |  s   
 EHEN, &;+E+E"O>"5o6L6LW6U"V%88O
"",,_=!44T4@J##c&@&@@%::22^AABH
 --hC$$Z0 ( B B378! --hJ$$%67%%(A(AA%&WXX	0/
;E ((*E33e!4 ((/ 0;/G/G 0H 0
 L;:;KL66uK",,\: 	225%@
 ,+.{B.{B$$X.$$U+ I #",,_= #L ((/   ",,\:   $$X.$$U+ sU   L$ 0J> EL$ A	K  4L$  L 0AL$ >KL$  K??L$ L!!L$ $;Msec_trust_refc                    [         R                  5       n[         R                  U[        R                  " U5      5         [        UR                  5      nU R                  [        R                  :X  aI  US;  aB  SSSSSSS	.nUR                  US
U 35      n[        R                  " U5      nXVl        X6l        Uegg! [        [        4 a    Sn N|f = f)zxVerify using 'SecTrustEvaluate' API for macOS 10.13 and earlier.
macOS 10.14 added the 'SecTrustEvaluateWithError' API.
)r      zInvalid trust result typezUser confirmation requiredz.User specified that certificate is not trustedz"Recoverable trust failure occurredzFatal trust failure occurredz0Other error occurred, certificate may be revoked)r      r!            zUnknown trust result: N)r   SecTrustResultTypeSecTrustEvaluater-   r]   r+   r4   
ValueError	TypeErrorri   r6   CERT_REQUIREDgetSSLCertVerificationErrorverify_messageverify_code)rl   r   sec_trust_result_typesec_trust_result_type_as_int sec_trust_result_type_to_messageerror_messageerrs          r   r   r     s     %779mV\\:O-PQ*'*+@+F+F'G$ 	3#4#44(6 ++?3-A	,
( 9<<($%A$BC

 **=9*6	/ 7 	5 	" *')$*s    B= =CCc                    [         R                  5       n[        R                  U[        R
                  " U5      5      nUS:X  a  SnO#US:X  a  SnO[        R                  " SU< 35      eSnU(       d]  [         R                  U5      nU R                  [        R                  :w  a*  U[        R                  :X  d  U[        R                  :X  a  SnU(       d  Sn [         R                  U5      n[        U5      =(       d    Sn[        R!                  5       n[        R#                  U[        R
                  " U5      5        [        R$                  " U5      n	Xyl        XYl        U	eg! U(       a  [         R+                  U5        f f = f)z>Verify using 'SecTrustEvaluateWithError' API for macOS 10.14+.r   Tr   Fz8Unknown result from Security.SecTrustEvaluateWithError: NzCertificate verification failed)r    
CFErrorRefr   SecTrustEvaluateWithErrorr-   r]   r6   r7   CFErrorGetCoderi   r   r0   rH   rG   CFErrorCopyDescriptionrY   r   SecTrustGetTrustResultr   r   r   r5   )
rl   r   cf_errorsec_trust_eval_result
is_trustedcf_error_codecf_error_string_refcf_error_messager   r   s
             r   r   r     se    ((*H$>>v||H-
 !
	!	#
llFG\F_`
 	
 M&55h?
 ""c&7&77W555 @ @@J "	>"0"G"G"Q &&9: 54  %-$?$?$A!++v||,AB ../?@C!1+OI+ . #(()<= #s   BE' 'FrL   )l
contextlibr-   platformr6   typingr   r   r   r   r   r   r	   r
   r   ctypes.utilr   _ssl_constantsr   mac_ver_mac_versiontuplemapr+   splitr   r   r   strr   r   r    BooleanCFIndexrD   CFDataCFStringCFArrayCFMutableArrayCFErrorCFTypeCFTypeID	CFTypeRefCFAllocatorRefOSStatusr   	CFDataRefCFStringRef
CFArrayRefCFMutableArrayRefCFArrayCallBacksCFOptionFlagsSecCertificateRefSecPolicyRefr{   r   SecTrustOptionFlagsr_   argtypesrestypeSecCertificateCopyDatar,   r~   r   rv   rs   r|   r   r   rw   rx   r5   CFGetTypeIDrQ   r/   r3   rM   CFDataGetLengthCFDataGetBytePtrCFArrayCreater\   r`   CFArrayGetCountCFArrayGetValueAtIndexr   r   in_dllr"   r#   AttributeErrorer   Anyr<   errcheckr0   bytesrO   rT   rY   listre   contextmanager
SSLContextIteratorrk   r   r   r   r>   rJ   r   <module>r      s      
 
 
 
 % 8!!$#c<#5#5c#:;< w

67H7K6LAN_`aNbMcd  $5#@  JS J3 J4 J" H H
 
 	

	FO	W
FO	hW
N+  H% x h  |C6Di5PH))24EH))10A/BH##,.7H##+3;X2FH&&/1<H&&.7BJ6OH**35=H**2;F:PH..79AH..63@/H&&/1=H&&.,3[+AH(*6H' 	8H++4
 7?H++3 	"#0H##, /7H##+ 	"#*H& )1H%&H"4H H*+',-))2N%'+N$+4+N')1N& 	9N,,5
 8CN,,45@BR4SN((13;N((0 		2N%%. 17N%%-,:Hg+NN(*3N'/8kN""+-4N""*09{N##,.6N##+ 			-N  ) ,6N  ( 	4N''0
 3DN''/2CX1NN%%.04N%%-/9lN""+-4N""*6@'5JN))24<N))1.8\N!!*,3N!!)6@\N))24?N))1)7)>)>-*N& ,4??/,N(  )N *N!,N *N $GJ7
**3 6<**2
2 X 2 &** 2 FJJ 2 6:: 2 j 4D ' ' 02B & & /6F * * 3+;   (%5   "  9 u   t .tE{ 7H < 	7CNN 	7vt/D 	7 	7 #'V,V,UV, 4ZV, 
	V,r))06

)	)X:>:>06

:>	:>c	  C
3A37
8dBC  G7s;<$FGs1   O?Z *Z ZZZZ2!Z--Z2