(tp: &[u8])
| 231 | } |
| 232 | |
| 233 | pub 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. |
| 253 | pub fn seal_ticket(tk: &TicketKey, ticket_nonce: &[u8; TICKET_NONCE_SIZE], ticket_plain: &[u8]) -> Vec<u8> { |
no outgoing calls