1 #[cfg(feature = "logging")] 2 use crate::log::trace; 3 use crate::msgs::enums::ExtensionType; 4 use crate::msgs::handshake::CertificatePayload; 5 use crate::msgs::handshake::SCTList; 6 use crate::msgs::handshake::ServerExtension; 7 use crate::sign; 8 9 use std::sync::Arc; 10 11 pub(super) struct ServerCertDetails { 12 pub(super) cert_chain: CertificatePayload, 13 pub(super) ocsp_response: Vec<u8>, 14 pub(super) scts: Option<SCTList>, 15 } 16 17 impl ServerCertDetails { new( cert_chain: CertificatePayload, ocsp_response: Vec<u8>, scts: Option<SCTList>, ) -> Self18 pub(super) fn new( 19 cert_chain: CertificatePayload, 20 ocsp_response: Vec<u8>, 21 scts: Option<SCTList>, 22 ) -> Self { 23 Self { 24 cert_chain, 25 ocsp_response, 26 scts, 27 } 28 } 29 scts(&self) -> impl Iterator<Item = &[u8]>30 pub(super) fn scts(&self) -> impl Iterator<Item = &[u8]> { 31 self.scts 32 .as_deref() 33 .unwrap_or(&[]) 34 .iter() 35 .map(|payload| payload.0.as_slice()) 36 } 37 } 38 39 pub(super) struct ClientHelloDetails { 40 pub(super) sent_extensions: Vec<ExtensionType>, 41 } 42 43 impl ClientHelloDetails { new() -> Self44 pub(super) fn new() -> Self { 45 Self { 46 sent_extensions: Vec::new(), 47 } 48 } 49 server_may_send_sct_list(&self) -> bool50 pub(super) fn server_may_send_sct_list(&self) -> bool { 51 self.sent_extensions 52 .contains(&ExtensionType::SCT) 53 } 54 server_sent_unsolicited_extensions( &self, received_exts: &[ServerExtension], allowed_unsolicited: &[ExtensionType], ) -> bool55 pub(super) fn server_sent_unsolicited_extensions( 56 &self, 57 received_exts: &[ServerExtension], 58 allowed_unsolicited: &[ExtensionType], 59 ) -> bool { 60 for ext in received_exts { 61 let ext_type = ext.get_type(); 62 if !self.sent_extensions.contains(&ext_type) && !allowed_unsolicited.contains(&ext_type) 63 { 64 trace!("Unsolicited extension {:?}", ext_type); 65 return true; 66 } 67 } 68 69 false 70 } 71 } 72 73 pub(super) struct ClientAuthDetails { 74 pub(super) certkey: Option<Arc<sign::CertifiedKey>>, 75 pub(super) signer: Option<Box<dyn sign::Signer>>, 76 pub(super) auth_context: Option<Vec<u8>>, 77 } 78 79 impl ClientAuthDetails { new() -> Self80 pub(super) fn new() -> Self { 81 Self { 82 certkey: None, 83 signer: None, 84 auth_context: None, 85 } 86 } 87 } 88