Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose functions for use in network-time-pester #1296

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions ntp-proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ mod exports {

#[cfg(feature = "__internal-fuzz")]
pub use super::keyset::test_cookie;
#[cfg(feature = "__internal-fuzz")]
#[cfg(any(feature = "__internal-fuzz", feature = "__internal-test"))]
pub use super::packet::ExtensionField;
pub use super::packet::{
Cipher, CipherProvider, EncryptResult, ExtensionHeaderVersion, NoCipher,
NtpAssociationMode, NtpLeapIndicator, NtpPacket, PacketParsingError,
crypto::AesSivCmac256, Cipher, CipherProvider, EncryptResult, ExtensionHeaderVersion,
NoCipher, NtpAssociationMode, NtpHeader, NtpLeapIndicator, NtpPacket, PacketParsingError,
};
#[cfg(feature = "__internal-fuzz")]
pub use super::peer::fuzz_measurement_from_packet;
Expand All @@ -71,18 +71,15 @@ mod exports {
#[cfg(feature = "__internal-fuzz")]
pub use super::nts_record::fuzz_key_exchange_server_decoder;
pub use super::nts_record::{
KeyExchangeClient, KeyExchangeError, KeyExchangeResult, KeyExchangeServer, NtsRecord,
NtsRecordDecoder, WriteError,
AeadAlgorithm, KeyExchangeClient, KeyExchangeError, KeyExchangeResult, KeyExchangeServer,
NtsKeys, NtsRecord, NtsRecordDecoder, ProtocolId, WriteError,
};

#[cfg(feature = "ntpv5")]
pub mod v5 {
pub use crate::packet::v5::server_reference_id::{BloomFilter, ServerId};
}

#[cfg(feature = "nts-pool")]
pub use super::nts_record::AeadAlgorithm;

#[cfg(feature = "nts-pool")]
pub use super::nts_pool_ke::{
ClientToPoolData, ClientToPoolDecoder, PoolToServerData, PoolToServerDecoder,
Expand Down
6 changes: 3 additions & 3 deletions ntp-proto/src/nts_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ impl AeadAlgorithm {
const IN_ORDER_OF_PREFERENCE: &'static [Self] =
&[Self::AeadAesSivCmac512, Self::AeadAesSivCmac256];

pub(crate) fn extract_nts_keys<ConnectionData>(
pub fn extract_nts_keys<ConnectionData>(
&self,
protocol: ProtocolId,
tls_connection: &rustls::ConnectionCommon<ConnectionData>,
Expand Down Expand Up @@ -835,8 +835,8 @@ impl AeadAlgorithm {
}

pub struct NtsKeys {
c2s: Box<dyn Cipher>,
s2c: Box<dyn Cipher>,
pub c2s: Box<dyn Cipher>,
pub s2c: Box<dyn Cipher>,
}

impl NtsKeys {
Expand Down
30 changes: 15 additions & 15 deletions ntp-proto/src/packet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{

use self::{error::ParsingError, extension_fields::ExtensionFieldData, mac::Mac};

mod crypto;
pub mod crypto;
mod error;
mod extension_fields;
mod mac;
Expand Down Expand Up @@ -127,27 +127,27 @@ pub enum NtpHeader {

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct NtpHeaderV3V4 {
leap: NtpLeapIndicator,
mode: NtpAssociationMode,
stratum: u8,
poll: PollInterval,
precision: i8,
root_delay: NtpDuration,
root_dispersion: NtpDuration,
reference_id: ReferenceId,
reference_timestamp: NtpTimestamp,
pub leap: NtpLeapIndicator,
pub mode: NtpAssociationMode,
pub stratum: u8,
pub poll: PollInterval,
pub precision: i8,
pub root_delay: NtpDuration,
pub root_dispersion: NtpDuration,
pub reference_id: ReferenceId,
pub reference_timestamp: NtpTimestamp,
/// Time at the client when the request departed for the server
origin_timestamp: NtpTimestamp,
pub origin_timestamp: NtpTimestamp,
/// Time at the server when the request arrived from the client
receive_timestamp: NtpTimestamp,
pub receive_timestamp: NtpTimestamp,
/// Time at the server when the response left for the client
transmit_timestamp: NtpTimestamp,
pub transmit_timestamp: NtpTimestamp,
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct RequestIdentifier {
expected_origin_timestamp: NtpTimestamp,
uid: Option<[u8; 32]>,
pub expected_origin_timestamp: NtpTimestamp,
pub uid: Option<[u8; 32]>,
}

impl NtpHeaderV3V4 {
Expand Down