pub(crate) mod flight0;
pub(crate) mod flight1;
pub(crate) mod flight2;
pub(crate) mod flight3;
pub(crate) mod flight4;
pub(crate) mod flight4b;
pub(crate) mod flight5;
pub(crate) mod flight5b;
pub(crate) mod flight6;
use crate::alert::*;
use crate::handshake::handshake_cache::*;
use crate::handshaker::*;
use crate::record_layer::*;
use crate::state::*;
use shared::error::Error;
use crate::config::HandshakeConfig;
use std::fmt;
pub(crate) fn pull_failure(err: PullError) -> (Option<Alert>, Option<Error>) {
match err {
PullError::OutOfOrder => (
Some(Alert {
alert_level: AlertLevel::Fatal,
alert_description: AlertDescription::UnexpectedMessage,
}),
Some(Error::ErrHandshakeMessageOutOfOrder),
),
PullError::Incomplete | PullError::Decode(_) => (None, None),
}
}
#[derive(Clone, Debug)]
pub(crate) struct Packet {
pub(crate) record: RecordLayer,
pub(crate) should_encrypt: bool,
pub(crate) reset_local_sequence_number: bool,
}
pub(crate) trait Flight: fmt::Display + fmt::Debug + Send + Sync {
fn is_last_send_flight(&self) -> bool {
false
}
fn is_last_recv_flight(&self) -> bool {
false
}
fn has_retransmit(&self) -> bool {
true
}
fn verifies_cookie(&self) -> bool {
false
}
fn parse(
&self,
state: &mut State,
cache: &HandshakeCache,
cfg: &HandshakeConfig,
) -> Result<Box<dyn Flight>, (Option<Alert>, Option<Error>)>;
fn generate(
&self,
state: &mut State,
cache: &HandshakeCache,
cfg: &HandshakeConfig,
) -> Result<Vec<Packet>, (Option<Alert>, Option<Error>)>;
}