Initial commit
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
33
src/handshake/new_session_ticket.rs
Normal file
33
src/handshake/new_session_ticket.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use crate::extensions::messages::NewSessionTicketExtension;
|
||||
use crate::parse_buffer::ParseBuffer;
|
||||
use crate::{ProtocolError, unused};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
pub struct NewSessionTicket<'a> {
|
||||
_todo: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
impl<'a> NewSessionTicket<'a> {
|
||||
pub fn parse(buf: &mut ParseBuffer<'a>) -> Result<NewSessionTicket<'a>, ProtocolError> {
|
||||
let lifetime = buf.read_u32()?;
|
||||
let age_add = buf.read_u32()?;
|
||||
|
||||
let nonce_length = buf.read_u8()?;
|
||||
let nonce = buf
|
||||
.slice(nonce_length as usize)
|
||||
.map_err(|_| ProtocolError::InvalidNonceLength)?;
|
||||
|
||||
let ticket_length = buf.read_u16()?;
|
||||
let ticket = buf
|
||||
.slice(ticket_length as usize)
|
||||
.map_err(|_| ProtocolError::InvalidTicketLength)?;
|
||||
|
||||
let extensions = NewSessionTicketExtension::parse_vector::<1>(buf)?;
|
||||
|
||||
unused((lifetime, age_add, nonce, ticket, extensions));
|
||||
Ok(Self { _todo: PhantomData })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user