2 * Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #ifndef OSSL_INTERNAL_QUIC_SRT_GEN_H
11 # define OSSL_INTERNAL_QUIC_SRT_GEN_H
14 # include "internal/e_os.h"
15 # include "internal/time.h"
16 # include "internal/quic_types.h"
17 # include "internal/quic_wire.h"
19 # ifndef OPENSSL_NO_QUIC
22 * QUIC Stateless Reset Token Generator
23 * ====================================
25 * This generates 16-byte QUIC Stateless Reset Tokens given a secret symmetric
26 * key and a DCID. Because the output is deterministic with regards to these
27 * inputs, assuming the same key is used between invocations of a process, we
28 * are able to generate the same stateless reset token in a subsequent process,
29 * thereby allowing us to achieve stateless reset of a peer which still thinks
30 * it is connected to a past process at the same UDP address.
32 typedef struct quic_srt_gen_st QUIC_SRT_GEN;
35 * Create a new stateless reset token generator using the given key as input.
36 * The key may be of arbitrary length.
38 * The caller is responsible for performing domain separation with regards to
39 * the key; i.e., the caller is responsible for ensuring the key is never used
40 * in any other context.
42 QUIC_SRT_GEN *ossl_quic_srt_gen_new(OSSL_LIB_CTX *libctx, const char *propq,
43 const unsigned char *key, size_t key_len);
45 /* Free the stateless reset token generator. No-op if srt_gen is NULL. */
46 void ossl_quic_srt_gen_free(QUIC_SRT_GEN *srt_gen);
49 * Calculates a token using the given DCID and writes it to *token. Returns 0 on
52 int ossl_quic_srt_gen_calculate_token(QUIC_SRT_GEN *srt_gen,
53 const QUIC_CONN_ID *dcid,
54 QUIC_STATELESS_RESET_TOKEN *token);