Skip to content

Commit

Permalink
deps: update ngtcp2 to 1.9.0
Browse files Browse the repository at this point in the history
PR-URL: #55975
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
  • Loading branch information
nodejs-github-bot authored and aduh95 committed Nov 26, 2024
1 parent d180a8a commit 96e846d
Show file tree
Hide file tree
Showing 92 changed files with 4,936 additions and 4,334 deletions.
3 changes: 2 additions & 1 deletion deps/ngtcp2/ngtcp2.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
'ngtcp2/lib/ngtcp2_cid.c',
'ngtcp2/lib/ngtcp2_conn.c',
'ngtcp2/lib/ngtcp2_conv.c',
'ngtcp2/lib/ngtcp2_conversion.c',
'ngtcp2/lib/ngtcp2_crypto.c',
'ngtcp2/lib/ngtcp2_err.c',
'ngtcp2/lib/ngtcp2_frame_chain.c',
Expand All @@ -37,8 +36,10 @@
'ngtcp2/lib/ngtcp2_rob.c',
'ngtcp2/lib/ngtcp2_rst.c',
'ngtcp2/lib/ngtcp2_rtb.c',
'ngtcp2/lib/ngtcp2_settings.c',
'ngtcp2/lib/ngtcp2_str.c',
'ngtcp2/lib/ngtcp2_strm.c',
'ngtcp2/lib/ngtcp2_transport_params.c',
'ngtcp2/lib/ngtcp2_unreachable.c',
'ngtcp2/lib/ngtcp2_vec.c',
'ngtcp2/lib/ngtcp2_version.c',
Expand Down
41 changes: 20 additions & 21 deletions deps/ngtcp2/ngtcp2/crypto/boringssl/boringssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */
#endif /* defined(HAVE_CONFIG_H) */

#include <assert.h>
#include <string.h>
Expand Down Expand Up @@ -52,15 +52,15 @@ typedef struct ngtcp2_crypto_boringssl_cipher {
} ngtcp2_crypto_boringssl_cipher;

static ngtcp2_crypto_boringssl_cipher crypto_cipher_aes_128 = {
NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_128,
NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_128,
};

static ngtcp2_crypto_boringssl_cipher crypto_cipher_aes_256 = {
NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_256,
NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_AES_256,
};

static ngtcp2_crypto_boringssl_cipher crypto_cipher_chacha20 = {
NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20,
NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20,
};

ngtcp2_crypto_aead *ngtcp2_crypto_aead_aes_128_gcm(ngtcp2_crypto_aead *aead) {
Expand Down Expand Up @@ -175,7 +175,7 @@ static ngtcp2_crypto_ctx *crypto_ctx_cipher_id(ngtcp2_crypto_ctx *ctx,
ctx->hp.native_handle = (void *)crypto_cipher_id_get_hp(cipher_id);
ctx->max_encryption = crypto_cipher_id_get_aead_max_encryption(cipher_id);
ctx->max_decryption_failure =
crypto_cipher_id_get_aead_max_decryption_failure(cipher_id);
crypto_cipher_id_get_aead_max_decryption_failure(cipher_id);

return ctx;
}
Expand Down Expand Up @@ -413,12 +413,12 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
AES_ecb_encrypt(sample, dest, &ctx->aes_key, 1);
return 0;
case NGTCP2_CRYPTO_BORINGSSL_CIPHER_TYPE_CHACHA20:
#if defined(WORDS_BIGENDIAN)
#ifdef WORDS_BIGENDIAN
counter = (uint32_t)sample[0] + (uint32_t)(sample[1] << 8) +
(uint32_t)(sample[2] << 16) + (uint32_t)(sample[3] << 24);
#else /* !WORDS_BIGENDIAN */
#else /* !defined(WORDS_BIGENDIAN) */
memcpy(&counter, sample, sizeof(counter));
#endif /* !WORDS_BIGENDIAN */
#endif /* !defined(WORDS_BIGENDIAN) */
CRYPTO_chacha_20(dest, PLAINTEXT, sizeof(PLAINTEXT) - 1, ctx->key,
sample + sizeof(counter), counter);
return 0;
Expand All @@ -429,17 +429,16 @@ int ngtcp2_crypto_hp_mask(uint8_t *dest, const ngtcp2_crypto_cipher *hp,
}

int ngtcp2_crypto_read_write_crypto_data(
ngtcp2_conn *conn, ngtcp2_encryption_level encryption_level,
const uint8_t *data, size_t datalen) {
ngtcp2_conn *conn, ngtcp2_encryption_level encryption_level,
const uint8_t *data, size_t datalen) {
SSL *ssl = ngtcp2_conn_get_tls_native_handle(conn);
int rv;
int err;

if (SSL_provide_quic_data(
ssl,
ngtcp2_crypto_boringssl_from_ngtcp2_encryption_level(
encryption_level),
data, datalen) != 1) {
ssl,
ngtcp2_crypto_boringssl_from_ngtcp2_encryption_level(encryption_level),
data, datalen) != 1) {
return -1;
}

Expand Down Expand Up @@ -522,7 +521,7 @@ int ngtcp2_crypto_set_local_transport_params(void *tls, const uint8_t *buf,
}

ngtcp2_encryption_level ngtcp2_crypto_boringssl_from_ssl_encryption_level(
enum ssl_encryption_level_t ssl_level) {
enum ssl_encryption_level_t ssl_level) {
switch (ssl_level) {
case ssl_encryption_initial:
return NGTCP2_ENCRYPTION_LEVEL_INITIAL;
Expand All @@ -540,7 +539,7 @@ ngtcp2_encryption_level ngtcp2_crypto_boringssl_from_ssl_encryption_level(

enum ssl_encryption_level_t
ngtcp2_crypto_boringssl_from_ngtcp2_encryption_level(
ngtcp2_encryption_level encryption_level) {
ngtcp2_encryption_level encryption_level) {
switch (encryption_level) {
case NGTCP2_ENCRYPTION_LEVEL_INITIAL:
return ssl_encryption_initial;
Expand Down Expand Up @@ -582,7 +581,7 @@ static int set_read_secret(SSL *ssl, enum ssl_encryption_level_t bssl_level,
ngtcp2_crypto_conn_ref *conn_ref = SSL_get_app_data(ssl);
ngtcp2_conn *conn = conn_ref->get_conn(conn_ref);
ngtcp2_encryption_level level =
ngtcp2_crypto_boringssl_from_ssl_encryption_level(bssl_level);
ngtcp2_crypto_boringssl_from_ssl_encryption_level(bssl_level);
(void)cipher;

if (ngtcp2_crypto_derive_and_install_rx_key(conn, NULL, NULL, NULL, level,
Expand All @@ -599,7 +598,7 @@ static int set_write_secret(SSL *ssl, enum ssl_encryption_level_t bssl_level,
ngtcp2_crypto_conn_ref *conn_ref = SSL_get_app_data(ssl);
ngtcp2_conn *conn = conn_ref->get_conn(conn_ref);
ngtcp2_encryption_level level =
ngtcp2_crypto_boringssl_from_ssl_encryption_level(bssl_level);
ngtcp2_crypto_boringssl_from_ssl_encryption_level(bssl_level);
(void)cipher;

if (ngtcp2_crypto_derive_and_install_tx_key(conn, NULL, NULL, NULL, level,
Expand All @@ -615,7 +614,7 @@ static int add_handshake_data(SSL *ssl, enum ssl_encryption_level_t bssl_level,
ngtcp2_crypto_conn_ref *conn_ref = SSL_get_app_data(ssl);
ngtcp2_conn *conn = conn_ref->get_conn(conn_ref);
ngtcp2_encryption_level level =
ngtcp2_crypto_boringssl_from_ssl_encryption_level(bssl_level);
ngtcp2_crypto_boringssl_from_ssl_encryption_level(bssl_level);
int rv;

rv = ngtcp2_conn_submit_crypto_data(conn, level, data, datalen);
Expand Down Expand Up @@ -644,8 +643,8 @@ static int send_alert(SSL *ssl, enum ssl_encryption_level_t bssl_level,
}

static SSL_QUIC_METHOD quic_method = {
set_read_secret, set_write_secret, add_handshake_data,
flush_flight, send_alert,
set_read_secret, set_write_secret, add_handshake_data,
flush_flight, send_alert,
};

static void crypto_boringssl_configure_context(SSL_CTX *ssl_ctx) {
Expand Down
Loading

0 comments on commit 96e846d

Please sign in to comment.