| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
use s2n_codec::{ |
| 5 |
DecoderBuffer, DecoderValue, |
| 6 |
decoder::{PrefixedBlob, PrefixedList}, |
| 7 |
}; |
| 8 |
|
| 9 |
use s2n_tls_metrics_schema::static_lists::{Cipher, Group, Signature, Version}; |
| 10 |
|
| 11 |
|
| 12 |
#[allow(dead_code)] |
| 13 |
pub(crate) struct ClientHello<'a> { |
| 14 |
pub protocol_version: Version, |
| 15 |
pub random: [u8; 32], |
| 16 |
pub legacy_session_id: PrefixedBlob<'a, u8>, |
| 17 |
pub cipher_suites: PrefixedList<'a, u16, Cipher>, |
| 18 |
pub compression_methods: PrefixedBlob<'a, u8>, |
| 19 |
pub extensions: Option<PrefixedBlob<'a, u16>>, |
| 20 |
} |
| 21 |
|
| 22 |
impl<'a> DecoderValue<'a> for ClientHello<'a> { |
| 23 |
fn decode(bytes: s2n_codec::DecoderBuffer<'a>) -> s2n_codec::DecoderBufferResult<'a, Self> { |
| 24 |
let (protocol_version, bytes) = bytes.decode()?; |
| 25 |
let (random, bytes) = bytes.decode()?; |
| 26 |
let (legacy_session_id, bytes) = bytes.decode()?; |
| 27 |
let (cipher_suites, bytes) = bytes.decode()?; |
| 28 |
let (compression_methods, bytes) = bytes.decode()?; |
| 29 |
let (extensions, bytes) = bytes.decode()?; |
| 30 |
|
| 31 |
let value = Self { |
| 32 |
protocol_version, |
| 33 |
random, |
| 34 |
legacy_session_id, |
| 35 |
cipher_suites, |
| 36 |
compression_methods, |
| 37 |
extensions, |
| 38 |
}; |
| 39 |
|
| 40 |
Ok((value, bytes)) |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
pub(crate) struct SupportedGroups<'a> { |
| 46 |
pub named_group_list: PrefixedList<'a, u16, Group>, |
| 47 |
} |
| 48 |
|
| 49 |
impl<'a> DecoderValue<'a> for SupportedGroups<'a> { |
| 50 |
fn decode(bytes: DecoderBuffer<'a>) -> s2n_codec::DecoderBufferResult<'a, Self> { |
| 51 |
let (named_group_list, bytes) = bytes.decode()?; |
| 52 |
let value = Self { named_group_list }; |
| 53 |
Ok((value, bytes)) |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
pub(crate) struct SupportedVersionsClientHello<'a> { |
| 59 |
pub versions: PrefixedList<'a, u8, Version>, |
| 60 |
} |
| 61 |
|
| 62 |
impl<'a> DecoderValue<'a> for SupportedVersionsClientHello<'a> { |
| 63 |
fn decode(bytes: DecoderBuffer<'a>) -> s2n_codec::DecoderBufferResult<'a, Self> { |
| 64 |
let (versions, bytes) = bytes.decode()?; |
| 65 |
let value = Self { versions }; |
| 66 |
Ok((value, bytes)) |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
pub(crate) struct SignatureSchemeList<'a> { |
| 72 |
pub supported_signature_algorithms: PrefixedList<'a, u16, Signature>, |
| 73 |
} |
| 74 |
|
| 75 |
impl<'a> DecoderValue<'a> for SignatureSchemeList<'a> { |
| 76 |
fn decode(bytes: DecoderBuffer<'a>) -> s2n_codec::DecoderBufferResult<'a, Self> { |
| 77 |
let (supported_signature_algorithms, bytes) = bytes.decode()?; |
| 78 |
let value = Self { |
| 79 |
supported_signature_algorithms, |
| 80 |
}; |
| 81 |
Ok((value, bytes)) |
| 82 |
} |
| 83 |
} |