o
    .j                     @  s   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
r6d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 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                   @  s  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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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d8d9 d&Z&d:ed;< 	 dZ'd/ed<< dZ(d ed=< 	 		dJdKdFdGZ)			dLdMdHdIZ*dS )N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                   C  s   t jgS )N)r   	VERSION_1 r>   r>   K/home/thesage/.local/lib/python3.10/site-packages/qh3/quic/configuration.py<lambda>   s   zQuicConfiguration.<lambda>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           
      C  sj  t |tr
| }nt |trt| }|dur.t |tr#| }nt |tr.t| }d|vrht|d}| }W d   n1 sFw   Y  |durht|d}| }W d   n1 scw   Y  d|v }|spdnd}td| |}t|d }t|d	kr||d
  }	t	|	| _
|d | _|d
d | _|durt	|t |tr|dn|d| _
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)rH   )
isinstancestrencoder   openreadr   r   lenr   r;   r0   r2   )
selfrD   rF   rH   fpis_crlfboundarychunkscertificatesr;   r>   r>   r?   load_cert_chain   sF   










z!QuicConfiguration.load_cert_chainc                 C  s   || _ || _|| _dS )z
        Load a set of "certification authority" (CA) certificates used to
        validate other peers' certificates.
        N)r.   r/   r-   )rU   r.   r/   r-   r>   r>   r?   load_verify_locations   s   

z'QuicConfiguration.load_verify_locations)NN)rD   rE   rF   rG   rH   rI   rJ   rK   )NNN)r.   r&   r/   r&   r-   r,   rJ   rK   )+__name__
__module____qualname____doc__r   __annotations__r   r   r   r    r   r!   r"   r#   r$   r%   r'   r(   r)   r*   r+   r-   r.   r/   r0   r   listr2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   rA   rB   rC   r[   r\   r>   r>   r>   r?   r      s~   
 
	
8r   N)
__future__r   dataclassesr   r   osr   rer   typingr   r   _hazmatr
   X509Certificater   r   r   r   tlsr   r   r   r   loggerr   packetr   packet_builderr   r   r>   r>   r>   r?   <module>   s    