tlspuffin/tls/rustls/server/
server_conn.rs

1/// A trait for the ability to encrypt and decrypt tickets.
2pub trait ProducesTickets: Send + Sync {
3    /// Returns true if this implementation will encrypt/decrypt
4    /// tickets.  Should return false if this is a dummy
5    /// implementation: the server will not send the SessionTicket
6    /// extension and will not call the other functions.
7    fn enabled(&self) -> bool;
8
9    /// Returns the lifetime in seconds of tickets produced now.
10    /// The lifetime is provided as a hint to clients that the
11    /// ticket will not be useful after the given time.
12    ///
13    /// This lifetime must be implemented by key rolling and
14    /// erasure, *not* by storing a lifetime in the ticket.
15    ///
16    /// The objective is to limit damage to forward secrecy caused
17    /// by tickets, not just limiting their lifetime.
18    fn lifetime(&self) -> u32;
19
20    /// Encrypt and authenticate `plain`, returning the resulting
21    /// ticket.  Return None if `plain` cannot be encrypted for
22    /// some reason: an empty ticket will be sent and the connection
23    /// will continue.
24    fn encrypt(&self, plain: &[u8]) -> Option<Vec<u8>>;
25
26    /// Decrypt `cipher`, validating its authenticity protection
27    /// and recovering the plaintext.  `cipher` is fully attacker
28    /// controlled, so this decryption must be side-channel free,
29    /// panic-proof, and otherwise bullet-proof.  If the decryption
30    /// fails, return None.
31    fn decrypt(&self, cipher: &[u8]) -> Option<Vec<u8>>;
32}