use crate::tls::rustls::msgs::enums::ProtocolVersion;
#[derive(Debug, PartialEq)]
pub struct SupportedProtocolVersion {
pub version: ProtocolVersion,
is_private: (),
}
pub static TLS12: SupportedProtocolVersion = SupportedProtocolVersion {
version: ProtocolVersion::TLSv1_2,
is_private: (),
};
pub static TLS13: SupportedProtocolVersion = SupportedProtocolVersion {
version: ProtocolVersion::TLSv1_3,
is_private: (),
};
pub static ALL_VERSIONS: &[&SupportedProtocolVersion] = &[&TLS13, &TLS12];
pub static DEFAULT_VERSIONS: &[&SupportedProtocolVersion] = ALL_VERSIONS;
#[derive(Debug, Clone)]
pub struct EnabledVersions {
tls12: Option<&'static SupportedProtocolVersion>,
tls13: Option<&'static SupportedProtocolVersion>,
}
impl EnabledVersions {
pub fn new(versions: &[&'static SupportedProtocolVersion]) -> Self {
let mut ev = Self {
tls12: None,
tls13: None,
};
for v in versions {
match v.version {
ProtocolVersion::TLSv1_2 => ev.tls12 = Some(v),
ProtocolVersion::TLSv1_3 => ev.tls13 = Some(v),
_ => {}
}
}
ev
}
pub fn contains(&self, version: ProtocolVersion) -> bool {
match version {
ProtocolVersion::TLSv1_2 => self.tls12.is_some(),
ProtocolVersion::TLSv1_3 => self.tls13.is_some(),
_ => false,
}
}
}