quic_record_rx.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. /*
  2. * Copyright 2022-2023 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  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
  8. */
  9. #ifndef OSSL_QUIC_RECORD_RX_H
  10. # define OSSL_QUIC_RECORD_RX_H
  11. # include <openssl/ssl.h>
  12. # include "internal/quic_wire_pkt.h"
  13. # include "internal/quic_types.h"
  14. # include "internal/quic_record_util.h"
  15. # include "internal/quic_demux.h"
  16. # ifndef OPENSSL_NO_QUIC
  17. /*
  18. * QUIC Record Layer - RX
  19. * ======================
  20. */
  21. typedef struct ossl_qrx_st OSSL_QRX;
  22. typedef struct ossl_qrx_args_st {
  23. OSSL_LIB_CTX *libctx;
  24. const char *propq;
  25. /* Demux to receive datagrams from. */
  26. QUIC_DEMUX *demux;
  27. /* Length of connection IDs used in short-header packets in bytes. */
  28. size_t short_conn_id_len;
  29. /*
  30. * Maximum number of deferred datagrams buffered at any one time.
  31. * Suggested value: 32.
  32. */
  33. size_t max_deferred;
  34. /* Initial reference PN used for RX. */
  35. QUIC_PN init_largest_pn[QUIC_PN_SPACE_NUM];
  36. /* Initial key phase. For debugging use only; always 0 in real use. */
  37. unsigned char init_key_phase_bit;
  38. } OSSL_QRX_ARGS;
  39. /* Instantiates a new QRX. */
  40. OSSL_QRX *ossl_qrx_new(const OSSL_QRX_ARGS *args);
  41. /*
  42. * Frees the QRX. All packets obtained using ossl_qrx_read_pkt must already
  43. * have been released by calling ossl_qrx_release_pkt.
  44. *
  45. * You do not need to call ossl_qrx_remove_dst_conn_id first; this function will
  46. * unregister the QRX from the demuxer for all registered destination connection
  47. * IDs (DCIDs) automatically.
  48. */
  49. void ossl_qrx_free(OSSL_QRX *qrx);
  50. /* Setters for the msg_callback and msg_callback_arg */
  51. void ossl_qrx_set_msg_callback(OSSL_QRX *qrx, ossl_msg_cb msg_callback,
  52. SSL *msg_callback_ssl);
  53. void ossl_qrx_set_msg_callback_arg(OSSL_QRX *qrx,
  54. void *msg_callback_arg);
  55. /*
  56. * DCID Management
  57. * ===============
  58. */
  59. /*
  60. * Adds a given DCID to the QRX. The QRX will register the DCID with the demuxer
  61. * so that incoming packets with that DCID are passed to the given QRX. Multiple
  62. * DCIDs may be associated with a QRX at any one time. You will need to add at
  63. * least one DCID after instantiating the QRX. A zero-length DCID is a valid
  64. * input to this function. This function fails if the DCID is already
  65. * registered.
  66. *
  67. * Returns 1 on success or 0 on error.
  68. */
  69. int ossl_qrx_add_dst_conn_id(OSSL_QRX *qrx,
  70. const QUIC_CONN_ID *dst_conn_id);
  71. /*
  72. * Remove a DCID previously registered with ossl_qrx_add_dst_conn_id. The DCID
  73. * is unregistered from the demuxer. Fails if the DCID is not registered with
  74. * the demuxer.
  75. *
  76. * Returns 1 on success or 0 on error.
  77. */
  78. int ossl_qrx_remove_dst_conn_id(OSSL_QRX *qrx,
  79. const QUIC_CONN_ID *dst_conn_id);
  80. /*
  81. * Secret Management
  82. * =================
  83. *
  84. * A QRX has several encryption levels (Initial, Handshake, 0-RTT, 1-RTT) and
  85. * two directions (RX, TX). At any given time, key material is managed for each
  86. * (EL, RX/TX) combination.
  87. *
  88. * Broadly, for a given (EL, RX/TX), the following state machine is applicable:
  89. *
  90. * WAITING_FOR_KEYS --[Provide]--> HAVE_KEYS --[Discard]--> | DISCARDED |
  91. * \-------------------------------------[Discard]--> | |
  92. *
  93. * To transition the RX side of an EL from WAITING_FOR_KEYS to HAVE_KEYS, call
  94. * ossl_qrx_provide_secret (for the INITIAL EL, use of
  95. * ossl_quic_provide_initial_secret is recommended).
  96. *
  97. * Once keys have been provisioned for an EL, you call
  98. * ossl_qrx_discard_enc_level to transition the EL to the DISCARDED state. You
  99. * can also call this function to transition directly to the DISCARDED state
  100. * even before any keys have been provisioned for that EL.
  101. *
  102. * The DISCARDED state is terminal for a given EL; you cannot provide a secret
  103. * again for that EL after reaching it.
  104. *
  105. * Incoming packets cannot be processed and decrypted if they target an EL
  106. * not in the HAVE_KEYS state. However, there is a distinction between
  107. * the WAITING_FOR_KEYS and DISCARDED states:
  108. *
  109. * - In the WAITING_FOR_KEYS state, the QRX assumes keys for the given
  110. * EL will eventually arrive. Therefore, if it receives any packet
  111. * for an EL in this state, it buffers it and tries to process it
  112. * again once the EL reaches HAVE_KEYS.
  113. *
  114. * - In the DISCARDED state, the QRX assumes no keys for the given
  115. * EL will ever arrive again. If it receives any packet for an EL
  116. * in this state, it is simply discarded.
  117. *
  118. * If the user wishes to instantiate a new QRX to replace an old one for
  119. * whatever reason, for example to take over for an already established QUIC
  120. * connection, it is important that all ELs no longer being used (i.e., INITIAL,
  121. * 0-RTT, 1-RTT) are transitioned to the DISCARDED state. Otherwise, the QRX
  122. * will assume that keys for these ELs will arrive in future, and will buffer
  123. * any received packets for those ELs perpetually. This can be done by calling
  124. * ossl_qrx_discard_enc_level for all non-1-RTT ELs immediately after
  125. * instantiating the QRX.
  126. *
  127. * The INITIAL EL is not setup automatically when the QRX is instantiated. This
  128. * allows the caller to instead discard it immediately after instantiation of
  129. * the QRX if it is not needed, for example if the QRX is being instantiated to
  130. * take over handling of an existing connection which has already passed the
  131. * INITIAL phase. This avoids the unnecessary derivation of INITIAL keys where
  132. * they are not needed. In the ordinary case, ossl_quic_provide_initial_secret
  133. * should be called immediately after instantiation.
  134. */
  135. /*
  136. * Provides a secret to the QRX, which arises due to an encryption level change.
  137. * enc_level is a QUIC_ENC_LEVEL_* value. To initialise the INITIAL encryption
  138. * level, it is recommended to use ossl_quic_provide_initial_secret instead.
  139. *
  140. * You should seek to call this function for a given EL before packets of that
  141. * EL arrive and are processed by the QRX. However, if packets have already
  142. * arrived for a given EL, the QRX will defer processing of them and perform
  143. * processing of them when this function is eventually called for the EL in
  144. * question.
  145. *
  146. * suite_id is a QRL_SUITE_* value which determines the AEAD function used for
  147. * the QRX.
  148. *
  149. * The secret passed is used directly to derive the "quic key", "quic iv" and
  150. * "quic hp" values.
  151. *
  152. * secret_len is the length of the secret buffer in bytes. The buffer must be
  153. * sized correctly to the chosen suite, else the function fails.
  154. *
  155. * This function can only be called once for a given EL, except for the INITIAL
  156. * EL, which can need rekeying when a connection retry occurs. Subsequent calls
  157. * for non-INITIAL ELs fail, as do calls made after a corresponding call to
  158. * ossl_qrx_discard_enc_level for that EL. The secret for a non-INITIAL EL
  159. * cannot be changed after it is set because QUIC has no facility for
  160. * introducing additional key material after an EL is setup. QUIC key updates
  161. * are managed semi-automatically by the QRX but do require some caller handling
  162. * (see below).
  163. *
  164. * md is for internal use and should be NULL.
  165. *
  166. * Returns 1 on success or 0 on failure.
  167. */
  168. int ossl_qrx_provide_secret(OSSL_QRX *qrx,
  169. uint32_t enc_level,
  170. uint32_t suite_id,
  171. EVP_MD *md,
  172. const unsigned char *secret,
  173. size_t secret_len);
  174. /*
  175. * Informs the QRX that it can now discard key material for a given EL. The QRX
  176. * will no longer be able to process incoming packets received at that
  177. * encryption level. This function is idempotent and succeeds if the EL has
  178. * already been discarded.
  179. *
  180. * Returns 1 on success and 0 on failure.
  181. */
  182. int ossl_qrx_discard_enc_level(OSSL_QRX *qrx, uint32_t enc_level);
  183. /*
  184. * Packet Reception
  185. * ================
  186. */
  187. /* Information about a received packet. */
  188. typedef struct ossl_qrx_pkt_st {
  189. /*
  190. * Points to a logical representation of the decoded QUIC packet header. The
  191. * data and len fields point to the decrypted QUIC payload (i.e., to a
  192. * sequence of zero or more (potentially malformed) frames to be decoded).
  193. */
  194. QUIC_PKT_HDR *hdr;
  195. /*
  196. * Address the packet was received from. If this is not available for this
  197. * packet, this field is NULL (but this can only occur for manually injected
  198. * packets).
  199. */
  200. const BIO_ADDR *peer;
  201. /*
  202. * Local address the packet was sent to. If this is not available for this
  203. * packet, this field is NULL.
  204. */
  205. const BIO_ADDR *local;
  206. /*
  207. * This is the length of the datagram which contained this packet. Note that
  208. * the datagram may have contained other packets than this. The intended use
  209. * for this is so that the user can enforce minimum datagram sizes (e.g. for
  210. * datagrams containing INITIAL packets), as required by RFC 9000.
  211. */
  212. size_t datagram_len;
  213. /* The PN which was decoded for the packet, if the packet has a PN field. */
  214. QUIC_PN pn;
  215. /*
  216. * Time the packet was received, or ossl_time_zero() if the demuxer is not
  217. * using a now() function.
  218. */
  219. OSSL_TIME time;
  220. /* The QRX which was used to receive the packet. */
  221. OSSL_QRX *qrx;
  222. /*
  223. * The key epoch the packet was received with. Always 0 for non-1-RTT
  224. * packets.
  225. */
  226. uint64_t key_epoch;
  227. } OSSL_QRX_PKT;
  228. /*
  229. * Tries to read a new decrypted packet from the QRX.
  230. *
  231. * On success, *pkt points to a OSSL_QRX_PKT structure. The structure should be
  232. * freed when no longer needed by calling ossl_qrx_pkt_release(). The structure
  233. * is refcounted; to gain extra references, call ossl_qrx_pkt_up_ref(). This
  234. * will cause a corresponding number of calls to ossl_qrx_pkt_release() to be
  235. * ignored.
  236. *
  237. * The resources referenced by (*pkt)->hdr, (*pkt)->hdr->data and (*pkt)->peer
  238. * have the same lifetime as *pkt.
  239. *
  240. * Returns 1 on success and 0 on failure.
  241. */
  242. int ossl_qrx_read_pkt(OSSL_QRX *qrx, OSSL_QRX_PKT **pkt);
  243. /*
  244. * Decrement the reference count for the given packet and frees it if the
  245. * reference count drops to zero. No-op if pkt is NULL.
  246. */
  247. void ossl_qrx_pkt_release(OSSL_QRX_PKT *pkt);
  248. /* Increments the reference count for the given packet. */
  249. void ossl_qrx_pkt_up_ref(OSSL_QRX_PKT *pkt);
  250. /*
  251. * Returns 1 if there are any already processed (i.e. decrypted) packets waiting
  252. * to be read from the QRX.
  253. */
  254. int ossl_qrx_processed_read_pending(OSSL_QRX *qrx);
  255. /*
  256. * Returns 1 if there are any unprocessed (i.e. not yet decrypted) packets
  257. * waiting to be processed by the QRX. These may or may not result in
  258. * successfully decrypted packets once processed. This indicates whether
  259. * unprocessed data is buffered by the QRX, not whether any data is available in
  260. * a kernel socket buffer.
  261. */
  262. int ossl_qrx_unprocessed_read_pending(OSSL_QRX *qrx);
  263. /*
  264. * Returns the number of UDP payload bytes received from the network so far
  265. * since the last time this counter was cleared. If clear is 1, clears the
  266. * counter and returns the old value.
  267. *
  268. * The intended use of this is to allow callers to determine how much credit to
  269. * add to their anti-amplification budgets. This is reported separately instead
  270. * of in the OSSL_QRX_PKT structure so that a caller can apply
  271. * anti-amplification credit as soon as a datagram is received, before it has
  272. * necessarily read all processed packets contained within that datagram from
  273. * the QRX.
  274. */
  275. uint64_t ossl_qrx_get_bytes_received(OSSL_QRX *qrx, int clear);
  276. /*
  277. * Sets a callback which is called when a packet is received and being validated
  278. * before being queued in the read queue. This is called after packet body
  279. * decryption and authentication to prevent exposing side channels. pn_space is
  280. * a QUIC_PN_SPACE_* value denoting which PN space the PN belongs to.
  281. *
  282. * If this callback returns 1, processing continues normally.
  283. * If this callback returns 0, the packet is discarded.
  284. *
  285. * Other packets in the same datagram will still be processed where possible.
  286. *
  287. * The callback is optional and can be unset by passing NULL for cb.
  288. * cb_arg is an opaque value passed to cb.
  289. */
  290. typedef int (ossl_qrx_late_validation_cb)(QUIC_PN pn, int pn_space,
  291. void *arg);
  292. int ossl_qrx_set_late_validation_cb(OSSL_QRX *qrx,
  293. ossl_qrx_late_validation_cb *cb,
  294. void *cb_arg);
  295. /*
  296. * Forcibly injects a URXE which has been issued by the DEMUX into the QRX for
  297. * processing. This can be used to pass a received datagram to the QRX if it
  298. * would not be correctly routed to the QRX via standard DCID-based routing; for
  299. * example, when handling an incoming Initial packet which is attempting to
  300. * establish a new connection.
  301. */
  302. void ossl_qrx_inject_urxe(OSSL_QRX *qrx, QUIC_URXE *e);
  303. /*
  304. * Decryption of 1-RTT packets must be explicitly enabled by calling this
  305. * function. This is to comply with the requirement that we not process 1-RTT
  306. * packets until the handshake is complete, even if we already have 1-RTT
  307. * secrets. Even if a 1-RTT secret is provisioned for the QRX, incoming 1-RTT
  308. * packets will be handled as though no key is available until this function is
  309. * called. Calling this function will then requeue any such deferred packets for
  310. * processing.
  311. */
  312. void ossl_qrx_allow_1rtt_processing(OSSL_QRX *qrx);
  313. /*
  314. * Key Update (RX)
  315. * ===============
  316. *
  317. * Key update on the RX side is a largely but not entirely automatic process.
  318. *
  319. * Key update is initially triggered by receiving a 1-RTT packet with a
  320. * different Key Phase value. This could be caused by an attacker in the network
  321. * flipping random bits, therefore such a key update is tentative until the
  322. * packet payload is successfully decrypted and authenticated by the AEAD with
  323. * the 'next' keys. These 'next' keys then become the 'current' keys and the
  324. * 'current' keys then become the 'previous' keys. The 'previous' keys must be
  325. * kept around temporarily as some packets may still be in flight in the network
  326. * encrypted with the old keys. If the old Key Phase value is X and the new Key
  327. * Phase Value is Y (where obviously X != Y), this creates an ambiguity as any
  328. * new packet received with a KP of X could either be an attempt to initiate yet
  329. * another key update right after the last one, or an old packet encrypted
  330. * before the key update.
  331. *
  332. * RFC 9001 provides some guidance on handling this issue:
  333. *
  334. * Strategy 1:
  335. * Three keys, disambiguation using packet numbers
  336. *
  337. * "A recovered PN that is lower than any PN from the current KP uses the
  338. * previous packet protection keys; a recovered PN that is higher than any
  339. * PN from the current KP requires use of the next packet protection
  340. * keys."
  341. *
  342. * Strategy 2:
  343. * Two keys and a timer
  344. *
  345. * "Alternatively, endpoints can retain only two sets of packet protection
  346. * keys, swapping previous keys for next after enough time has passed to
  347. * allow for reordering in the network. In this case, the KP bit alone can
  348. * be used to select keys."
  349. *
  350. * Strategy 2 is more efficient (we can keep fewer cipher contexts around) and
  351. * should cover all actually possible network conditions. It also allows a delay
  352. * after we make the 'next' keys our 'current' keys before we generate new
  353. * 'next' keys, which allows us to mitigate against malicious peers who try to
  354. * initiate an excessive number of key updates.
  355. *
  356. * We therefore model the following state machine:
  357. *
  358. *
  359. * PROVISIONED
  360. * _______________________________
  361. * | |
  362. * UNPROVISIONED --|----> NORMAL <----------\ |------> DISCARDED
  363. * | | | |
  364. * | | | |
  365. * | v | |
  366. * | UPDATING | |
  367. * | | | |
  368. * | | | |
  369. * | v | |
  370. * | COOLDOWN | |
  371. * | | | |
  372. * | | | |
  373. * | \---------------| |
  374. * |_______________________________|
  375. *
  376. *
  377. * The RX starts (once a secret has been provisioned) in the NORMAL state. In
  378. * the NORMAL state, the current expected value of the Key Phase bit is
  379. * recorded. When a flipped Key Phase bit is detected, the RX attempts to
  380. * decrypt and authenticate the received packet with the 'next' keys rather than
  381. * the 'current' keys. If (and only if) this authentication is successful, we
  382. * move to the UPDATING state. (An attacker in the network could flip
  383. * the Key Phase bit randomly, so it is essential we do nothing until AEAD
  384. * authentication is complete.)
  385. *
  386. * In the UPDATING state, we know a key update is occurring and record
  387. * the new Key Phase bit value as the newly current value, but we still keep the
  388. * old keys around so that we can still process any packets which were still in
  389. * flight when the key update was initiated. In the UPDATING state, a
  390. * Key Phase bit value different to the current expected value is treated not as
  391. * the initiation of another key update, but a reference to our old keys.
  392. *
  393. * Eventually we will be reasonably sure we are not going to receive any more
  394. * packets with the old keys. At this point, we can transition to the COOLDOWN
  395. * state. This transition occurs automatically after a certain amount of time;
  396. * RFC 9001 recommends it be the PTO interval, which relates to our RTT to the
  397. * peer. The duration also SHOULD NOT exceed three times the PTO to assist with
  398. * maintaining PFS.
  399. *
  400. * In the COOLDOWN phase, the old keys have been securely erased and only one
  401. * set of keys can be used: the current keys. If a packet is received with a Key
  402. * Phase bit value different to the current Key Phase Bit value, this is treated
  403. * as a request for a Key Update, but this request is ignored and the packet is
  404. * treated as malformed. We do this to allow mitigation against malicious peers
  405. * trying to initiate an excessive number of Key Updates. The timeout for the
  406. * transition from UPDATING to COOLDOWN is recommended as adequate for
  407. * this purpose in itself by the RFC, so the normal additional timeout value for
  408. * the transition from COOLDOWN to normal is zero (immediate transition).
  409. *
  410. * A summary of each state:
  411. *
  412. * Epoch Exp KP Uses Keys KS0 KS1 If Non-Expected KP Bit
  413. * ----- ------ --------- ------ ----- ----------------------
  414. * NORMAL 0 0 Keyset 0 Gen 0 Gen 1 → UPDATING
  415. * UPDATING 1 1 Keyset 1 Gen 0 Gen 1 Use Keyset 0
  416. * COOLDOWN 1 1 Keyset 1 Erased Gen 1 Ignore Packet (*)
  417. *
  418. * NORMAL 1 1 Keyset 1 Gen 2 Gen 1 → UPDATING
  419. * UPDATING 2 0 Keyset 0 Gen 2 Gen 1 Use Keyset 1
  420. * COOLDOWN 2 0 Keyset 0 Gen 2 Erased Ignore Packet (*)
  421. *
  422. * (*) Actually implemented by attempting to decrypt the packet with the
  423. * wrong keys (which ultimately has the same outcome), as recommended
  424. * by RFC 9001 to avoid creating timing channels.
  425. *
  426. * Note that the key material for the next key generation ("key epoch") is
  427. * always kept in the NORMAL state (necessary to avoid side-channel attacks).
  428. * This material is derived during the transition from COOLDOWN to NORMAL.
  429. *
  430. * Note that when a peer initiates a Key Update, we MUST also initiate a Key
  431. * Update as per the RFC. The caller is responsible for detecting this condition
  432. * and making the necessary calls to the TX side by detecting changes to the
  433. * return value of ossl_qrx_get_key_epoch().
  434. *
  435. * The above states (NORMAL, UPDATING, COOLDOWN) can themselves be
  436. * considered substates of the PROVISIONED state. Providing a secret to the QRX
  437. * for an EL transitions from UNPROVISIONED, the initial state, to PROVISIONED
  438. * (NORMAL). Dropping key material for an EL transitions from whatever the
  439. * current substate of the PROVISIONED state is to the DISCARDED state, which is
  440. * the terminal state.
  441. *
  442. * Note that non-1RTT ELs cannot undergo key update, therefore a non-1RTT EL is
  443. * always in the NORMAL substate if it is in the PROVISIONED state.
  444. */
  445. /*
  446. * Return the current RX key epoch for the 1-RTT encryption level. This is
  447. * initially zero and is incremented by one for every Key Update successfully
  448. * signalled by the peer. If the 1-RTT EL has not yet been provisioned or has
  449. * been discarded, returns UINT64_MAX.
  450. *
  451. * A necessary implication of this API is that the least significant bit of the
  452. * returned value corresponds to the currently expected Key Phase bit, though
  453. * callers are not anticipated to have any need of this information.
  454. *
  455. * It is not possible for the returned value to overflow, as a QUIC connection
  456. * cannot support more than 2**62 packet numbers, and a connection must be
  457. * terminated if this limit is reached.
  458. *
  459. * The caller should use this function to detect when the key epoch has changed
  460. * and use it to initiate a key update on the TX side.
  461. *
  462. * The value returned by this function increments specifically at the transition
  463. * from the NORMAL to the UPDATING state discussed above.
  464. */
  465. uint64_t ossl_qrx_get_key_epoch(OSSL_QRX *qrx);
  466. /*
  467. * Sets an optional callback which will be called when the key epoch changes.
  468. *
  469. * The callback is optional and can be unset by passing NULL for cb.
  470. * cb_arg is an opaque value passed to cb. pn is the PN of the packet.
  471. * Since key update is only supported for 1-RTT packets, the PN is always
  472. * in the Application Data PN space.
  473. */
  474. typedef void (ossl_qrx_key_update_cb)(QUIC_PN pn, void *arg);
  475. int ossl_qrx_set_key_update_cb(OSSL_QRX *qrx,
  476. ossl_qrx_key_update_cb *cb, void *cb_arg);
  477. /*
  478. * Relates to the 1-RTT encryption level. The caller should call this after the
  479. * UPDATING state is reached, after a timeout to be determined by the caller.
  480. *
  481. * This transitions from the UPDATING state to the COOLDOWN state (if
  482. * still in the UPDATING state). If normal is 1, then transitions from
  483. * the COOLDOWN state to the NORMAL state. Both transitions can be performed at
  484. * once if desired.
  485. *
  486. * If in the normal state, or if in the COOLDOWN state and normal is 0, this is
  487. * a no-op and returns 1. Returns 0 if the 1-RTT EL has not been provisioned or
  488. * has been dropped.
  489. *
  490. * It is essential that the caller call this within a few PTO intervals of a key
  491. * update occurring (as detected by the caller in a call to
  492. * ossl_qrx_key_get_key_epoch()), as otherwise the peer will not be able to
  493. * perform a Key Update ever again.
  494. */
  495. int ossl_qrx_key_update_timeout(OSSL_QRX *qrx, int normal);
  496. /*
  497. * Key Expiration
  498. * ==============
  499. */
  500. /*
  501. * Returns the number of seemingly forged packets which have been received by
  502. * the QRX. If this value reaches the value returned by
  503. * ossl_qrx_get_max_epoch_forged_pkt_count() for a given EL, all further
  504. * received encrypted packets for that EL will be discarded without processing.
  505. *
  506. * Note that the forged packet limit is for the connection lifetime, thus it is
  507. * not reset by a key update. It is suggested that the caller terminate the
  508. * connection a reasonable margin before the limit is reached. However, the
  509. * exact limit imposed does vary by EL due to the possibility that different ELs
  510. * use different AEADs.
  511. */
  512. uint64_t ossl_qrx_get_cur_forged_pkt_count(OSSL_QRX *qrx);
  513. /*
  514. * Returns the maximum number of forged packets which the record layer will
  515. * permit to be verified using this QRX instance.
  516. */
  517. uint64_t ossl_qrx_get_max_forged_pkt_count(OSSL_QRX *qrx,
  518. uint32_t enc_level);
  519. # endif
  520. #endif