tls_parser/
tls_dh.rs

1use nom::multi::length_data;
2use nom::number::streaming::be_u16;
3use nom::IResult;
4use nom_derive::*;
5
6/// Diffie-Hellman parameters, defined in \[RFC5246\] section 7.4.3
7#[derive(PartialEq, NomBE)]
8pub struct ServerDHParams<'a> {
9    /// The prime modulus used for the Diffie-Hellman operation.
10    #[nom(Parse = "length_data(be_u16)")]
11    pub dh_p: &'a [u8],
12    /// The generator used for the Diffie-Hellman operation.
13    #[nom(Parse = "length_data(be_u16)")]
14    pub dh_g: &'a [u8],
15    /// The server's Diffie-Hellman public value (g^X mod p).
16    #[nom(Parse = "length_data(be_u16)")]
17    pub dh_ys: &'a [u8],
18}
19
20#[inline]
21pub fn parse_dh_params(i: &[u8]) -> IResult<&[u8], ServerDHParams> {
22    ServerDHParams::parse(i)
23}