Merge pull request #454 from h2o/kazuho/fusion-aligned-free
[fusion][windows] Use `_aligned_free`
diff --git a/include/picotls.h b/include/picotls.h
index e2a4366..9762dad 100644
--- a/include/picotls.h
+++ b/include/picotls.h
@@ -135,7 +135,7 @@
/* negotiated_groups */
#define PTLS_GROUP_SECP256R1 23
-#define PTLS_GROUP_NAME_SECP256R1 "scep256r1"
+#define PTLS_GROUP_NAME_SECP256R1 "secp256r1"
#define PTLS_GROUP_SECP384R1 24
#define PTLS_GROUP_NAME_SECP384R1 "secp384r1"
#define PTLS_GROUP_SECP521R1 25
@@ -1472,7 +1472,7 @@
/**
* return if a ECH handshake was performed, as well as optionally the kem and cipher-suite being used
*/
-int ptls_is_ech_handshake(ptls_t *tls, ptls_hpke_kem_t **kem, ptls_hpke_cipher_suite_t **cipher);
+int ptls_is_ech_handshake(ptls_t *tls, uint8_t *config_id, ptls_hpke_kem_t **kem, ptls_hpke_cipher_suite_t **cipher);
/**
* returns a pointer to user data pointer (client is reponsible for freeing the associated data prior to calling ptls_free)
*/
diff --git a/lib/picotls.c b/lib/picotls.c
index a712c85..e8b7ac0 100644
--- a/lib/picotls.c
+++ b/lib/picotls.c
@@ -2905,7 +2905,7 @@
break;
case PTLS_EXTENSION_TYPE_ENCRYPTED_CLIENT_HELLO: {
/* accept retry_configs only if we offered ECH but rejected */
- if (!((tls->ech.offered || tls->ech.offered_grease) && !ptls_is_ech_handshake(tls, NULL, NULL))) {
+ if (!((tls->ech.offered || tls->ech.offered_grease) && !ptls_is_ech_handshake(tls, NULL, NULL, NULL))) {
ret = PTLS_ALERT_UNSUPPORTED_EXTENSION;
goto Exit;
}
@@ -3184,7 +3184,7 @@
if (tls->ctx->verify_certificate != NULL) {
const char *server_name = NULL;
if (!ptls_is_server(tls)) {
- if (tls->ech.offered && !ptls_is_ech_handshake(tls, NULL, NULL)) {
+ if (tls->ech.offered && !ptls_is_ech_handshake(tls, NULL, NULL, NULL)) {
server_name = tls->ech.client.public_name;
} else {
server_name = tls->server_name;
@@ -3355,7 +3355,7 @@
static int client_handle_finished(ptls_t *tls, ptls_message_emitter_t *emitter, ptls_iovec_t message)
{
uint8_t send_secret[PTLS_MAX_DIGEST_SIZE];
- int alert_ech_required = tls->ech.offered && !ptls_is_ech_handshake(tls, NULL, NULL), ret;
+ int alert_ech_required = tls->ech.offered && !ptls_is_ech_handshake(tls, NULL, NULL, NULL), ret;
if ((ret = verify_finished(tls, message)) != 0)
goto Exit;
@@ -4422,7 +4422,7 @@
/* Either send a stateless retry (w. cookies) or a stateful one. When sending the latter, run the state machine. At the
* moment, stateless retry is disabled when ECH is used (do we need to support it?). */
int retry_uses_cookie =
- properties != NULL && properties->server.retry_uses_cookie && !ptls_is_ech_handshake(tls, NULL, NULL);
+ properties != NULL && properties->server.retry_uses_cookie && !ptls_is_ech_handshake(tls, NULL, NULL, NULL);
if (!retry_uses_cookie) {
key_schedule_transform_post_ch1hash(tls->key_schedule);
key_schedule_extract(tls->key_schedule, ptls_iovec_init(NULL, 0));
@@ -4432,7 +4432,7 @@
tls->key_schedule, key_share.algorithm != NULL ? NULL : negotiated_group,
{
ptls_buffer_t *sendbuf = emitter->buf;
- if (ptls_is_ech_handshake(tls, NULL, NULL)) {
+ if (ptls_is_ech_handshake(tls, NULL, NULL, NULL)) {
buffer_push_extension(sendbuf, PTLS_EXTENSION_TYPE_ENCRYPTED_CLIENT_HELLO, {
if ((ret = ptls_buffer_reserve(sendbuf, PTLS_ECH_CONFIRM_LENGTH)) != 0)
goto Exit;
@@ -4572,7 +4572,7 @@
{
tls->ctx->random_bytes(emitter->buf->base + emitter->buf->off, PTLS_HELLO_RANDOM_SIZE);
/* when accepting CHInner, last 8 byte of SH.random is zero for the handshake transcript */
- if (ptls_is_ech_handshake(tls, NULL, NULL)) {
+ if (ptls_is_ech_handshake(tls, NULL, NULL, NULL)) {
ech_confirm_off = emitter->buf->off + PTLS_HELLO_RANDOM_SIZE - PTLS_ECH_CONFIRM_LENGTH;
memset(emitter->buf->base + ech_confirm_off, 0, PTLS_ECH_CONFIRM_LENGTH);
}
@@ -4649,7 +4649,7 @@
if (tls->pending_handshake_secret != NULL)
buffer_push_extension(sendbuf, PTLS_EXTENSION_TYPE_EARLY_DATA, {});
/* send ECH retry_configs, if ECH was offered by rejected, even though we (the server) could have accepted ECH */
- if (tls->ech.offered && !ptls_is_ech_handshake(tls, NULL, NULL) && tls->ctx->ech.server.create_opener != NULL &&
+ if (tls->ech.offered && !ptls_is_ech_handshake(tls, NULL, NULL, NULL) && tls->ctx->ech.server.create_opener != NULL &&
tls->ctx->ech.server.retry_configs.len != 0)
buffer_push_extension(sendbuf, PTLS_EXTENSION_TYPE_ENCRYPTED_CLIENT_HELLO, {
ptls_buffer_pushv(sendbuf, tls->ctx->ech.server.retry_configs.base, tls->ctx->ech.server.retry_configs.len);
@@ -5299,9 +5299,11 @@
return tls->is_psk_handshake;
}
-int ptls_is_ech_handshake(ptls_t *tls, ptls_hpke_kem_t **kem, ptls_hpke_cipher_suite_t **cipher)
+int ptls_is_ech_handshake(ptls_t *tls, uint8_t *config_id, ptls_hpke_kem_t **kem, ptls_hpke_cipher_suite_t **cipher)
{
if (tls->ech.accepted) {
+ if (config_id != NULL)
+ *config_id = tls->ech.config_id;
if (kem != NULL)
*kem = tls->ech.kem;
if (cipher != NULL)
diff --git a/t/picotls.c b/t/picotls.c
index bc68ab9..14fa849 100644
--- a/t/picotls.c
+++ b/t/picotls.c
@@ -1002,11 +1002,11 @@
}
if (can_ech(ctx_peer, 1) && can_ech(ctx, 0)) {
- ok(ptls_is_ech_handshake(client, NULL, NULL));
- ok(ptls_is_ech_handshake(server, NULL, NULL));
+ ok(ptls_is_ech_handshake(client, NULL, NULL, NULL));
+ ok(ptls_is_ech_handshake(server, NULL, NULL, NULL));
} else {
- ok(!ptls_is_ech_handshake(client, NULL, NULL));
- ok(!ptls_is_ech_handshake(server, NULL, NULL));
+ ok(!ptls_is_ech_handshake(client, NULL, NULL, NULL));
+ ok(!ptls_is_ech_handshake(server, NULL, NULL, NULL));
}
ptls_buffer_dispose(&cbuf);