Skip to content

Commit c788be2

Browse files
committed
deps: update ngtcp2
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #34752 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent bc8a4df commit c788be2

37 files changed

+3439
-1245
lines changed

deps/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto.h

+94-23
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ NGTCP2_EXTERN int ngtcp2_crypto_derive_packet_protection_key(
210210
*/
211211
NGTCP2_EXTERN int ngtcp2_crypto_encrypt(uint8_t *dest,
212212
const ngtcp2_crypto_aead *aead,
213+
const ngtcp2_crypto_aead_ctx *aead_ctx,
213214
const uint8_t *plaintext,
214-
size_t plaintextlen, const uint8_t *key,
215+
size_t plaintextlen,
215216
const uint8_t *nonce, size_t noncelen,
216217
const uint8_t *ad, size_t adlen);
217218

@@ -227,9 +228,10 @@ NGTCP2_EXTERN int ngtcp2_crypto_encrypt(uint8_t *dest,
227228
*/
228229
NGTCP2_EXTERN int
229230
ngtcp2_crypto_encrypt_cb(uint8_t *dest, const ngtcp2_crypto_aead *aead,
231+
const ngtcp2_crypto_aead_ctx *aead_ctx,
230232
const uint8_t *plaintext, size_t plaintextlen,
231-
const uint8_t *key, const uint8_t *nonce,
232-
size_t noncelen, const uint8_t *ad, size_t adlen);
233+
const uint8_t *nonce, size_t noncelen,
234+
const uint8_t *ad, size_t adlen);
233235

234236
/**
235237
* @function
@@ -243,11 +245,13 @@ ngtcp2_crypto_encrypt_cb(uint8_t *dest, const ngtcp2_crypto_aead *aead,
243245
*
244246
* This function returns 0 if it succeeds, or -1.
245247
*/
246-
NGTCP2_EXTERN int
247-
ngtcp2_crypto_decrypt(uint8_t *dest, const ngtcp2_crypto_aead *aead,
248-
const uint8_t *ciphertext, size_t ciphertextlen,
249-
const uint8_t *key, const uint8_t *nonce, size_t noncelen,
250-
const uint8_t *ad, size_t adlen);
248+
NGTCP2_EXTERN int ngtcp2_crypto_decrypt(uint8_t *dest,
249+
const ngtcp2_crypto_aead *aead,
250+
const ngtcp2_crypto_aead_ctx *aead_ctx,
251+
const uint8_t *ciphertext,
252+
size_t ciphertextlen,
253+
const uint8_t *nonce, size_t noncelen,
254+
const uint8_t *ad, size_t adlen);
251255

252256
/**
253257
* @function
@@ -261,9 +265,10 @@ ngtcp2_crypto_decrypt(uint8_t *dest, const ngtcp2_crypto_aead *aead,
261265
*/
262266
NGTCP2_EXTERN int
263267
ngtcp2_crypto_decrypt_cb(uint8_t *dest, const ngtcp2_crypto_aead *aead,
268+
const ngtcp2_crypto_aead_ctx *aead_ctx,
264269
const uint8_t *ciphertext, size_t ciphertextlen,
265-
const uint8_t *key, const uint8_t *nonce,
266-
size_t noncelen, const uint8_t *ad, size_t adlen);
270+
const uint8_t *nonce, size_t noncelen,
271+
const uint8_t *ad, size_t adlen);
267272

268273
/**
269274
* @function
@@ -277,7 +282,7 @@ ngtcp2_crypto_decrypt_cb(uint8_t *dest, const ngtcp2_crypto_aead *aead,
277282
*/
278283
NGTCP2_EXTERN int ngtcp2_crypto_hp_mask(uint8_t *dest,
279284
const ngtcp2_crypto_cipher *hp,
280-
const uint8_t *key,
285+
const ngtcp2_crypto_cipher_ctx *hp_ctx,
281286
const uint8_t *sample);
282287

283288
/**
@@ -290,10 +295,10 @@ NGTCP2_EXTERN int ngtcp2_crypto_hp_mask(uint8_t *dest,
290295
* This function returns 0 if it succeeds, or
291296
* :enum:`NGTCP2_ERR_CALLBACK_FAILURE`.
292297
*/
293-
NGTCP2_EXTERN int ngtcp2_crypto_hp_mask_cb(uint8_t *dest,
294-
const ngtcp2_crypto_cipher *hp,
295-
const uint8_t *key,
296-
const uint8_t *sample);
298+
NGTCP2_EXTERN int
299+
ngtcp2_crypto_hp_mask_cb(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
300+
const ngtcp2_crypto_cipher_ctx *hp_ctx,
301+
const uint8_t *sample);
297302

298303
/**
299304
* @function
@@ -381,10 +386,12 @@ NGTCP2_EXTERN int ngtcp2_crypto_derive_and_install_tx_key(
381386
* The derived packet protection key for decryption is written to the
382387
* buffer pointed by |rx_key|. The derived packet protection IV for
383388
* decryption is written to the buffer pointed by |rx_iv|.
389+
* |rx_aead_ctx| must be constructed with |rx_key|.
384390
*
385391
* The derived packet protection key for encryption is written to the
386392
* buffer pointed by |tx_key|. The derived packet protection IV for
387393
* encryption is written to the buffer pointed by |tx_iv|.
394+
* |tx_aead_ctx| must be constructed with |rx_key|.
388395
*
389396
* |current_rx_secret| and |current_tx_secret| are the current traffic
390397
* secrets for decryption and encryption. |secretlen| specifies the
@@ -397,12 +404,12 @@ NGTCP2_EXTERN int ngtcp2_crypto_derive_and_install_tx_key(
397404
*
398405
* This function returns 0 if it succeeds, or -1.
399406
*/
400-
NGTCP2_EXTERN int
401-
ngtcp2_crypto_update_key(ngtcp2_conn *conn, uint8_t *rx_secret,
402-
uint8_t *tx_secret, uint8_t *rx_key, uint8_t *rx_iv,
403-
uint8_t *tx_key, uint8_t *tx_iv,
404-
const uint8_t *current_rx_secret,
405-
const uint8_t *current_tx_secret, size_t secretlen);
407+
NGTCP2_EXTERN int ngtcp2_crypto_update_key(
408+
ngtcp2_conn *conn, uint8_t *rx_secret, uint8_t *tx_secret,
409+
ngtcp2_crypto_aead_ctx *rx_aead_ctx, uint8_t *rx_key, uint8_t *rx_iv,
410+
ngtcp2_crypto_aead_ctx *tx_aead_ctx, uint8_t *tx_key, uint8_t *tx_iv,
411+
const uint8_t *current_rx_secret, const uint8_t *current_tx_secret,
412+
size_t secretlen);
406413

407414
/**
408415
* @function
@@ -415,8 +422,9 @@ ngtcp2_crypto_update_key(ngtcp2_conn *conn, uint8_t *rx_secret,
415422
* :enum:`NGTCP2_ERR_CALLBACK_FAILURE`.
416423
*/
417424
NGTCP2_EXTERN int ngtcp2_crypto_update_key_cb(
418-
ngtcp2_conn *conn, uint8_t *rx_secret, uint8_t *tx_secret, uint8_t *rx_key,
419-
uint8_t *rx_iv, uint8_t *tx_key, uint8_t *tx_iv,
425+
ngtcp2_conn *conn, uint8_t *rx_secret, uint8_t *tx_secret,
426+
ngtcp2_crypto_aead_ctx *rx_aead_ctx, uint8_t *rx_iv,
427+
ngtcp2_crypto_aead_ctx *tx_aead_ctx, uint8_t *tx_iv,
420428
const uint8_t *current_rx_secret, const uint8_t *current_tx_secret,
421429
size_t secretlen, void *user_data);
422430

@@ -543,6 +551,69 @@ ngtcp2_crypto_write_retry(uint8_t *dest, size_t destlen, const ngtcp2_cid *dcid,
543551
const ngtcp2_cid *scid, const ngtcp2_cid *odcid,
544552
const uint8_t *token, size_t tokenlen);
545553

554+
/**
555+
* @function
556+
*
557+
* `ngtcp2_crypto_aead_ctx_encrypt_init` initializes |aead_ctx| with
558+
* new AEAD cipher context object for encryption which is constructed
559+
* to use |key| as encryption key. |aead| specifies AEAD cipher to
560+
* use. |noncelen| is the length of nonce.
561+
*
562+
* This function returns 0 if it succeeds, or -1.
563+
*/
564+
NGTCP2_EXTERN int
565+
ngtcp2_crypto_aead_ctx_encrypt_init(ngtcp2_crypto_aead_ctx *aead_ctx,
566+
const ngtcp2_crypto_aead *aead,
567+
const uint8_t *key, size_t noncelen);
568+
569+
/**
570+
* @function
571+
*
572+
* `ngtcp2_crypto_aead_ctx_decrypt_init` initializes |aead_ctx| with
573+
* new AEAD cipher context object for decryption which is constructed
574+
* to use |key| as encryption key. |aead| specifies AEAD cipher to
575+
* use. |noncelen| is the length of nonce.
576+
*
577+
* This function returns 0 if it succeeds, or -1.
578+
*/
579+
NGTCP2_EXTERN int
580+
ngtcp2_crypto_aead_ctx_decrypt_init(ngtcp2_crypto_aead_ctx *aead_ctx,
581+
const ngtcp2_crypto_aead *aead,
582+
const uint8_t *key, size_t noncelen);
583+
584+
/**
585+
* @function
586+
*
587+
* `ngtcp2_crypto_aead_ctx_free` frees up resources used by
588+
* |aead_ctx|. This function does not free the memory pointed by
589+
* |aead_ctx| itself.
590+
*/
591+
NGTCP2_EXTERN void
592+
ngtcp2_crypto_aead_ctx_free(ngtcp2_crypto_aead_ctx *aead_ctx);
593+
594+
/**
595+
* @function
596+
*
597+
* `ngtcp2_crypto_delete_crypto_aead_ctx_cb` deletes the given |aead_ctx|.
598+
*
599+
* This function can be directly passed to delete_crypto_aead_ctx
600+
* field in ngtcp2_callbacks.
601+
*/
602+
NGTCP2_EXTERN void ngtcp2_crypto_delete_crypto_aead_ctx_cb(
603+
ngtcp2_conn *conn, ngtcp2_crypto_aead_ctx *aead_ctx, void *user_data);
604+
605+
/**
606+
* @function
607+
*
608+
* `ngtcp2_crypto_delete_crypto_cipher_ctx_cb` deletes the given
609+
* |cipher_ctx|.
610+
*
611+
* This function can be directly passed to delete_crypto_cipher_ctx
612+
* field in ngtcp2_callbacks.
613+
*/
614+
NGTCP2_EXTERN void ngtcp2_crypto_delete_crypto_cipher_ctx_cb(
615+
ngtcp2_conn *conn, ngtcp2_crypto_cipher_ctx *cipher_ctx, void *user_data);
616+
546617
#ifdef __cplusplus
547618
}
548619
#endif

0 commit comments

Comments
 (0)