Skip to content
Merged
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
27 changes: 27 additions & 0 deletions dtls/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ struct SerializedState {
is_client: bool,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct KeyLogData {
pub local_random: Vec<u8>,
pub remote_random: Vec<u8>,
pub master_secret: Vec<u8>,
}

impl Default for State {
fn default() -> Self {
State {
Expand Down Expand Up @@ -249,6 +256,26 @@ impl State {

Ok(())
}

/// key_log_data returns the key log data for the current state.
pub fn key_log_data(&self) -> Result<KeyLogData> {
let mut local_random = vec![];
{
let mut writer = BufWriter::<&mut Vec<u8>>::new(local_random.as_mut());
self.local_random.marshal(&mut writer)?;
}
let mut remote_random = vec![];
{
let mut writer = BufWriter::<&mut Vec<u8>>::new(remote_random.as_mut());
self.remote_random.marshal(&mut writer)?;
}

Ok(KeyLogData {
local_random,
remote_random,
master_secret: self.master_secret.clone(),
})
}
}

#[async_trait]
Expand Down
Loading