mod data;
mod handshake;
mod header;
use serde::{Deserialize, Serialize};
pub use data::SessionData;
pub use handshake::{HandshakeSummary, HandshakeVerifyError};
pub use header::{SessionHeader, SessionHeaderVerifyError};
use crate::{
proof::{SessionInfo, SessionProof},
signature::Signature,
};
#[derive(Serialize, Deserialize)]
pub struct NotarizedSession {
header: SessionHeader,
signature: Option<Signature>,
data: SessionData,
}
opaque_debug::implement!(NotarizedSession);
impl NotarizedSession {
pub fn new(header: SessionHeader, signature: Option<Signature>, data: SessionData) -> Self {
Self {
header,
signature,
data,
}
}
pub fn session_proof(&self) -> SessionProof {
let session_info = SessionInfo {
server_name: self.data.session_info().server_name.clone(),
handshake_decommitment: self.data.session_info().handshake_decommitment.clone(),
};
SessionProof {
header: self.header.clone(),
signature: self.signature.clone(),
session_info,
}
}
pub fn header(&self) -> &SessionHeader {
&self.header
}
pub fn signature(&self) -> &Option<Signature> {
&self.signature
}
pub fn data(&self) -> &SessionData {
&self.data
}
}