
    F2j                        d dl mZ d dlmZmZ d dlmZ d dlmZ d dl	m
Z
mZ e
rddlmZ ddlmZmZmZmZ dd	lmZmZmZmZ d
dlmZ d
dlmZ d
dlmZ e G d d                      ZdS )    )annotations)	dataclassfield)PathLike)split)TYPE_CHECKINGTextIO   )Certificate)DsaPrivateKeyEcPrivateKeyEd25519PrivateKeyRsaPrivateKey)CipherSuiteSessionTicketload_pem_private_keyload_pem_x509_certificates   )
QuicLogger)QuicProtocolVersion)PACKET_MAX_SIZEc                  N   e Zd ZU dZdZded<   	 dZded<   	 dZd	ed
<   	 dZded<   	 dZ	ded<   	 e
Zded<   	 dZded<   	 dZded<   	 dZded<   	 dZded<   	 dZded<   	 dZded<   	 dZded<   dZded<   dZded<   dZd ed!<   dZded"<   dZded#<   dZd$ed%<    ee&          Zd'ed(<   dZd)ed*<   dZd+ed,<   	 dZded-<   	 dZded.<   	 dZ d/ed0<   	 d1Z!d	ed2<   dZ"d/ed3<   dZ#d/ed4<   dZ$d5ed6<   dZ%ded7<    ed8 &          Z&d9ed:<   	 dZ'd/ed;<   dZ(d ed<<   	 	 	 dGdHdEZ)	 	 	 dIdJdFZ*dS )KQuicConfigurationz
    A QUIC configuration.
    Nzlist[str] | Nonealpn_protocols   intconnection_id_lengthg      >@floatidle_timeoutTbool	is_clienti   max_datamax_datagram_sizeprobe_datagram_sizei  ` max_stream_datazQuicLogger | Nonequic_loggerr	   secrets_log_file
str | Noneserver_namezSessionTicket | Nonesession_ticketFhostname_checks_common_nameassert_fingerprintverify_hostnamebytes | NonecadatacafilecapathzX509Certificate | Nonecertificate)default_factoryzlist[X509Certificate]certificate_chainzlist[CipherSuite] | Nonecipher_suiteszlist[int] | Nonesignature_algorithmsoffer_ec_key_shares offer_certificate_status_requestz
int | Noneactive_connection_id_limitgZd;O?initial_rttmax_datagram_frame_sizeoriginal_versionzGEcPrivateKey | Ed25519PrivateKey | DsaPrivateKey | RsaPrivateKey | Noneprivate_keyquantum_readiness_testc                     t           j        gS )N)r   	VERSION_1     ^/home/thesage/.hermes/hermes-agent/venv/lib/python3.11/site-packages/qh3/quic/configuration.py<lambda>zQuicConfiguration.<lambda>   s    )!
 rB   z	list[int]supported_versionsverify_modeech_config_listcertfilestr | bytes | PathLikekeyfilestr | bytes | PathLike | Nonepasswordbytes | str | NonereturnNonec                   t          |t                    r|                                }n6t          |t                    r!t          |                                          }|`t          |t                    r|                                }n6t          |t                    r!t          |                                          }d|vrzt	          |d          5 }|                                }ddd           n# 1 swxY w Y   |<t	          |d          5 }|                                }ddd           n# 1 swxY w Y   d|v }|sdnd}t          d|z   |          }t          |d                   }t          |          d	k    r||d
         z   }	t          |	          | _
        |d         | _        |d
d         | _        |Bt          |t          |t                    r|                    d          n|          | _
        dS dS )zG
        Load a private key and the corresponding certificate.
        Ns
   -----BEGINrbs   -----
s   -----BEGIN PRIVATE KEY-----
s   -----BEGIN PRIVATE KEY-----
   
r   r
   r   utf8)rL   )
isinstancestrencoder   openreadr   r   lenr   r=   r2   r4   )
selfrH   rJ   rL   fpis_crlfboundarychunkscertificatesr=   s
             rC   load_cert_chainz!QuicConfiguration.load_cert_chain   s{    h$$ 	.((HH(++ 	.8}}++--H'3'' 0!..**GX.. 0g,,--// ((h%% %7799% % % % % % % % % % % % % % %"'4(( (B ggiiG( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (* 4,,3 	
 ux'221&)<<v;;!"VAY.K3K@@D'?!-abb!13/9(C/H/HVHOOF+++h     D s$   C88C<?C<D66D:=D:c                0    || _         || _        || _        dS )z
        Load a set of "certification authority" (CA) certificates used to
        validate other peers' certificates.
        N)r0   r1   r/   )rZ   r0   r1   r/   s       rC   load_verify_locationsz'QuicConfiguration.load_verify_locations   s     rB   )NN)rH   rI   rJ   rK   rL   rM   rN   rO   )NNN)r0   r(   r1   r(   r/   r.   rN   rO   )+__name__
__module____qualname____doc__r   __annotations__r   r   r!   r"   r   r#   r$   r%   r&   r'   r)   r*   r+   r,   r-   r/   r0   r1   r2   r   listr4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   rE   rF   rG   r`   rb   rA   rB   rC   r   r      sc          (,N++++ !"!!!! L I H -,,,, !%$$$$ #O"""" &*K))))  $#### #K"""" ,0N//// ).----%))))) O    FFF*.K..../4uT/J/J/JJJJJ.2M2222-11111 !&%%%%
 .3$2222 .21111	 K*.....#''''' 	      $)(((($)E
 
% % %    

 #K""""$(O((((	 26'+	4 4 4 4 4p "!#	      rB   r   N)
__future__r   dataclassesr   r   osr   rer   typingr   r	   _hazmatr   X509Certificater   r   r   r   tlsr   r   r   r   loggerr   packetr   packet_builderr   r   rA   rB   rC   <module>rt      sf   " " " " " " ( ( ( ( ( ( ( (             ( ( ( ( ( ( ( ( X888888WWWWWWWWWWWW                  ' ' ' ' ' ' + + + + + + h h h h h h h h h hrB   