@@ -31,40 +31,17 @@ fn try_split_at(data: &[u8], at: usize) -> Option<(&[u8], &[u8])> {
3131pub struct Ticketer { }
3232
3333impl Ticketer {
34- /// Make the recommended `Ticketer`.
35- ///
36- /// This produces tickets:
37- ///
38- /// - where each lasts for at least 6 hours,
39- /// - with randomly generated keys, and
40- /// - where keys are rotated every 6 hours.
41- ///
42- /// The encryption mechanism used is Chacha20Poly1305.
43-
4434 pub fn new ( ) -> Result < Arc < dyn ProducesTickets > , Error > {
4535 Ok ( Arc :: new ( TicketRotator :: new (
46- time:: Duration :: from_hours ( 6 ) . as_secs ( ) as u32 ,
36+ time:: Duration :: from_secs ( 6 * 60 * 60 ) . as_secs ( ) as u32 ,
4737 || Ok ( Box :: new ( AeadTicketProducer :: new ( ) ?) ) ,
4838 ) ?) )
4939 }
5040}
5141
52- /// This is a `ProducesTickets` implementation which uses
53- /// ChaCha20Poly1305 to encrypt and authenticate
54- /// the ticket payload. It does not enforce any lifetime
55- /// constraint.
5642struct AeadTicketProducer {
5743 key : ChaCha20Poly1305 ,
5844 key_name : [ u8 ; 16 ] ,
59-
60- /// Tracks the largest ciphertext produced by `encrypt`, and
61- /// uses it to early-reject `decrypt` queries that are too long.
62- ///
63- /// Accepting excessively long ciphertexts means a "Partitioning
64- /// Oracle Attack" (see <https://eprint.iacr.org/2020/1491.pdf>)
65- /// can be more efficient, though also note that these are thought
66- /// to be cryptographically hard if the key is full-entropy (as it
67- /// is here).
6845 maximum_ciphertext_len : AtomicUsize ,
6946}
7047
0 commit comments