MCPcopy Create free account
hub / github.com/DNSCrypt/encrypted-dns-server / parse_ticket_plain

Function parse_ticket_plain

src/pq.rs:233–250  ·  view source on GitHub ↗
(tp: &[u8])

Source from the content-addressed store, hash-verified

231}
232
233pub fn parse_ticket_plain(tp: &[u8]) -> Result<TicketFields, Error> {
234 ensure!(tp.len() == 32 + 2 + 8 + 4 + 4 + 4 + 32, "Bad ticket plaintext length");
235 let mut resume_secret = [0u8; 32];
236 resume_secret.copy_from_slice(&tp[0..32]);
237 let mut es_version = [0u8; 2];
238 es_version.copy_from_slice(&tp[32..34]);
239 let mut client_magic = [0u8; 8];
240 client_magic.copy_from_slice(&tp[34..42]);
241 let mut expiry_bytes = [0u8; 4];
242 expiry_bytes.copy_from_slice(&tp[50..54]);
243 let ticket_expiry = u32::from_be_bytes(expiry_bytes);
244 Ok(TicketFields {
245 resume_secret,
246 es_version,
247 client_magic,
248 ticket_expiry,
249 })
250}
251
252/// Seal a resumption ticket under a ticket key.
253pub fn seal_ticket(tk: &TicketKey, ticket_nonce: &[u8; TICKET_NONCE_SIZE], ticket_plain: &[u8]) -> Vec<u8> {

Callers 2

appendix3_vectorsFunction · 0.85
decrypt_pq_resumedFunction · 0.85

Calls

no outgoing calls

Tested by 1

appendix3_vectorsFunction · 0.68