summaryrefslogtreecommitdiffstats
path: root/rust/vendor/tls-parser/src/tls_dh.rs
blob: b0b6d892067fe4c09975ebc47328608cf6b12a49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use nom::multi::length_data;
use nom::number::streaming::be_u16;
use nom::IResult;
use nom_derive::*;

/// Diffie-Hellman parameters, defined in [RFC5246] section 7.4.3
#[derive(PartialEq, NomBE)]
pub struct ServerDHParams<'a> {
    /// The prime modulus used for the Diffie-Hellman operation.
    #[nom(Parse = "length_data(be_u16)")]
    pub dh_p: &'a [u8],
    /// The generator used for the Diffie-Hellman operation.
    #[nom(Parse = "length_data(be_u16)")]
    pub dh_g: &'a [u8],
    /// The server's Diffie-Hellman public value (g^X mod p).
    #[nom(Parse = "length_data(be_u16)")]
    pub dh_ys: &'a [u8],
}

#[inline]
pub fn parse_dh_params(i: &[u8]) -> IResult<&[u8], ServerDHParams> {
    ServerDHParams::parse(i)
}