Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ngtcp2: Support the latest update key callback type #4735

Merged
merged 1 commit into from Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 1 addition & 30 deletions lib/vquic/ngtcp2.c
Expand Up @@ -177,15 +177,6 @@ static int quic_set_encryption_secrets(SSL *ssl,
if(level == NGTCP2_CRYPTO_LEVEL_APP) {
if(init_ngh3_conn(qs) != CURLE_OK)
return 0;

/* malloc an area big enough for both secrets */
qs->rx_secret = malloc(secretlen * 2);
if(!qs->rx_secret)
return 0;
memcpy(qs->rx_secret, rx_secret, secretlen);
memcpy(&qs->rx_secret[secretlen], tx_secret, secretlen);
qs->tx_secret = &qs->rx_secret[secretlen];
qs->rx_secretlen = secretlen;
}

return 1;
Expand Down Expand Up @@ -516,25 +507,6 @@ static int cb_get_new_connection_id(ngtcp2_conn *tconn, ngtcp2_cid *cid,
return 0;
}

static int cb_update_key(ngtcp2_conn *tconn, uint8_t *rx_key,
uint8_t *rx_iv, uint8_t *tx_key,
uint8_t *tx_iv, void *user_data)
{
struct quicsocket *qs = (struct quicsocket *)user_data;
uint8_t rx_secret[64];
uint8_t tx_secret[64];

if(ngtcp2_crypto_update_key(tconn, rx_secret, tx_secret,
rx_key, rx_iv, tx_key, tx_iv, qs->rx_secret,
qs->tx_secret, qs->rx_secretlen) != 0)
return NGTCP2_ERR_CALLBACK_FAILURE;

/* store the updated secrets */
memcpy(qs->rx_secret, rx_secret, qs->rx_secretlen);
memcpy(qs->tx_secret, tx_secret, qs->rx_secretlen);
return 0;
}

static ngtcp2_conn_callbacks ng_callbacks = {
cb_initial,
NULL, /* recv_client_initial */
Expand All @@ -556,7 +528,7 @@ static ngtcp2_conn_callbacks ng_callbacks = {
NULL, /* rand */
cb_get_new_connection_id,
NULL, /* remove_connection_id */
cb_update_key, /* update_key */
ngtcp2_crypto_update_key_cb, /* update_key */
NULL, /* path_validation */
NULL, /* select_preferred_addr */
cb_stream_reset,
Expand Down Expand Up @@ -701,7 +673,6 @@ static CURLcode ng_disconnect(struct connectdata *conn,
int i;
struct quicsocket *qs = &conn->hequic[0];
(void)dead_connection;
free(qs->rx_secret);
if(qs->ssl)
SSL_free(qs->ssl);
for(i = 0; i < 3; i++)
Expand Down
3 changes: 0 additions & 3 deletions lib/vquic/ngtcp2.h
Expand Up @@ -46,9 +46,6 @@ struct quicsocket {
ngtcp2_settings settings;
SSL_CTX *sslctx;
SSL *ssl;
uint8_t *rx_secret; /* malloced */
uint8_t *tx_secret; /* points into the above buffer */
size_t rx_secretlen;
struct quic_handshake crypto_data[3];
/* the last TLS alert description generated by the local endpoint */
uint8_t tls_alert;
Expand Down