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

Function open_ticket

src/pq.rs:264–273  ·  view source on GitHub ↗

Open a resumption ticket. Returns the recovered ticket plaintext, or an error on any failure (the caller MUST silently drop the query).

(tk: &TicketKey, ticket: &[u8])

Source from the content-addressed store, hash-verified

262/// Open a resumption ticket. Returns the recovered ticket plaintext, or an
263/// error on any failure (the caller MUST silently drop the query).
264pub fn open_ticket(tk: &TicketKey, ticket: &[u8]) -> Result<Vec<u8>, Error> {
265 ensure!(
266 ticket.len() > TICKET_KEY_ID_SIZE + TICKET_NONCE_SIZE + MAC_SIZE,
267 "Short ticket"
268 );
269 ensure!(ticket[0..TICKET_KEY_ID_SIZE] == tk.id, "Unknown ticket key");
270 let nonce = &ticket[TICKET_KEY_ID_SIZE..TICKET_KEY_ID_SIZE + TICKET_NONCE_SIZE];
271 let sealed = &ticket[TICKET_KEY_ID_SIZE + TICKET_NONCE_SIZE..];
272 tk.key.open_raw(nonce, sealed)
273}
274
275/// Build the response control block that carries a freshly issued ticket.
276pub fn control_block(ticket_lifetime: u32, ticket: &[u8]) -> Vec<u8> {

Callers 2

appendix3_vectorsFunction · 0.85
decrypt_pq_resumedFunction · 0.85

Calls 1

open_rawMethod · 0.80

Tested by 1

appendix3_vectorsFunction · 0.68