mirror of
https://github.com/Noratrieb/tls.git
synced 2026-01-16 09:35:02 +01:00
more extensions
This commit is contained in:
parent
4b1d2805e6
commit
2266f6f8b6
2 changed files with 60 additions and 2 deletions
|
|
@ -36,6 +36,14 @@ impl ClientSetupConnection {
|
||||||
}]
|
}]
|
||||||
.into(),
|
.into(),
|
||||||
},
|
},
|
||||||
|
proto::ExtensionCH::ECPointFormat {
|
||||||
|
formats: vec![proto::ECPointFormat::Uncompressed].into(),
|
||||||
|
},
|
||||||
|
proto::ExtensionCH::SupportedGroups {
|
||||||
|
groups: vec![
|
||||||
|
proto::NamedGroup::X25519,
|
||||||
|
].into(),
|
||||||
|
},
|
||||||
proto::ExtensionCH::SupportedVersions {
|
proto::ExtensionCH::SupportedVersions {
|
||||||
versions: vec![proto::TLSV13].into(),
|
versions: vec![proto::TLSV13].into(),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
54
src/proto.rs
54
src/proto.rs
|
|
@ -71,7 +71,10 @@ impl TLSPlaintext {
|
||||||
let alert = Alert::read(r)?;
|
let alert = Alert::read(r)?;
|
||||||
Ok(Self::Alert { alert })
|
Ok(Self::Alert { alert })
|
||||||
}
|
}
|
||||||
Self::HANDSHAKE => todo!(),
|
Self::HANDSHAKE => {
|
||||||
|
let handshake = Handshake::read(r)?;
|
||||||
|
Ok(TLSPlaintext::Handshake { handshake })
|
||||||
|
}
|
||||||
Self::APPLICATION_DATA => todo!(),
|
Self::APPLICATION_DATA => todo!(),
|
||||||
_ => {
|
_ => {
|
||||||
return Err(crate::ErrorKind::InvalidFrame(Box::new(format!(
|
return Err(crate::ErrorKind::InvalidFrame(Box::new(format!(
|
||||||
|
|
@ -142,7 +145,12 @@ proto_enum! {
|
||||||
} = 0,
|
} = 0,
|
||||||
MaxFragmentLength = 1,
|
MaxFragmentLength = 1,
|
||||||
StatusRequest = 5,
|
StatusRequest = 5,
|
||||||
SupportedGroups = 10,
|
SupportedGroups {
|
||||||
|
groups: NamedGroupList,
|
||||||
|
} = 10,
|
||||||
|
ECPointFormat {
|
||||||
|
formats: ECPointFormatList,
|
||||||
|
} = 11,
|
||||||
SignatureAlgorithms = 13,
|
SignatureAlgorithms = 13,
|
||||||
UseSrtp = 14,
|
UseSrtp = 14,
|
||||||
Heartbeat = 15,
|
Heartbeat = 15,
|
||||||
|
|
@ -188,6 +196,34 @@ proto_enum! {
|
||||||
type HostName = List<u8, u16>;
|
type HostName = List<u8, u16>;
|
||||||
type ServerNameList = List<ServerName, u16>;
|
type ServerNameList = List<ServerName, u16>;
|
||||||
|
|
||||||
|
proto_enum! {
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum ECPointFormat: u8 {
|
||||||
|
Uncompressed = 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type ECPointFormatList = List<ECPointFormat, u8>;
|
||||||
|
|
||||||
|
proto_enum! {
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum NamedGroup: u16 {
|
||||||
|
/* Elliptic Curve Groups (ECDHE) */
|
||||||
|
Secp256r1 = 0x0017,
|
||||||
|
Secp384r1 = 0x0018,
|
||||||
|
Secp521r1 = 0x0019,
|
||||||
|
X25519 = 0x001D,
|
||||||
|
X448 = 0x001E,
|
||||||
|
|
||||||
|
/* Finite Field Groups (DHE) */
|
||||||
|
Ffdhe2048 = 0x0100,
|
||||||
|
Ffdhe3072 = 0x0101,
|
||||||
|
Ffdhe4096 = 0x0102,
|
||||||
|
Ffdhe6144 = 0x0103,
|
||||||
|
Ffdhe8192 = 0x0104,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type NamedGroupList = List<NamedGroup, u16>;
|
||||||
|
|
||||||
proto_struct! {
|
proto_struct! {
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct Alert {
|
pub struct Alert {
|
||||||
|
|
@ -492,6 +528,20 @@ impl Value for u16 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Value for u32 {
|
||||||
|
fn write<W: Write>(&self, w: &mut W) -> io::Result<()> {
|
||||||
|
w.write_u32::<B>(*self)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read<R: Read>(r: &mut R) -> crate::Result<Self> {
|
||||||
|
r.read_u32::<B>().map_err(Into::into)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn byte_size(&self) -> usize {
|
||||||
|
4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: Value, U: Value> Value for (T, U) {
|
impl<T: Value, U: Value> Value for (T, U) {
|
||||||
fn write<W: Write>(&self, w: &mut W) -> io::Result<()> {
|
fn write<W: Write>(&self, w: &mut W) -> io::Result<()> {
|
||||||
T::write(&self.0, w)?;
|
T::write(&self.0, w)?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue