-/* $OpenBSD: s3_lib.c,v 1.237 2022/08/17 18:51:47 tb Exp $ */
+/* $OpenBSD: s3_lib.c,v 1.238 2022/08/21 19:39:44 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
freezero(s->s3->hs.tls13.cookie, s->s3->hs.tls13.cookie_len);
tls13_clienthello_hash_clear(&s->s3->hs.tls13);
+ tls_buffer_free(s->s3->hs.tls13.quic_read_buffer);
+
sk_X509_NAME_pop_free(s->s3->hs.tls12.ca_names, X509_NAME_free);
sk_X509_pop_free(s->internal->verified_chain, X509_free);
s->s3->hs.tls13.cookie_len = 0;
tls13_clienthello_hash_clear(&s->s3->hs.tls13);
+ tls_buffer_free(s->s3->hs.tls13.quic_read_buffer);
+ s->s3->hs.tls13.quic_read_buffer = NULL;
+ s->s3->hs.tls13.quic_read_level = ssl_encryption_initial;
+ s->s3->hs.tls13.quic_write_level = ssl_encryption_initial;
+
s->s3->hs.extensions_seen = 0;
rp = s->s3->rbuf.buf;
-/* $OpenBSD: tls13_quic.c,v 1.3 2022/08/21 19:18:57 jsing Exp $ */
+/* $OpenBSD: tls13_quic.c,v 1.4 2022/08/21 19:39:44 jsing Exp $ */
/*
* Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
*
struct tls13_ctx *ctx = arg;
SSL *ssl = ctx->ssl;
- /* XXX - call flush_flight. */
- SSLerror(ssl, ERR_R_INTERNAL_ERROR);
- return TLS13_IO_FAILURE;
+ if (!ssl->quic_method->flush_flight(ssl)) {
+ SSLerror(ssl, SSL_R_QUIC_INTERNAL_ERROR);
+ return TLS13_IO_FAILURE;
+ }
+
+ return TLS13_IO_SUCCESS;
}
static ssize_t
tls13_quic_handshake_read_cb(void *buf, size_t n, void *arg)
{
- /* XXX - read handshake data. */
- return TLS13_IO_FAILURE;
+ struct tls13_ctx *ctx = arg;
+
+ return tls_buffer_read(ctx->hs->tls13.quic_read_buffer, buf, n);
}
static ssize_t
struct tls13_ctx *ctx = arg;
SSL *ssl = ctx->ssl;
- /* XXX - call add_handshake_data. */
- SSLerror(ssl, ERR_R_INTERNAL_ERROR);
- return TLS13_IO_FAILURE;
+ if (!ssl->quic_method->add_handshake_data(ssl,
+ ctx->hs->tls13.quic_write_level, buf, n)) {
+ SSLerror(ssl, SSL_R_QUIC_INTERNAL_ERROR);
+ return TLS13_IO_FAILURE;
+ }
+
+ return n;
}
static int
ctx->hs->tls13.quic_read_level = read_level;
- /* XXX - call set_read_secret. */
- SSLerror(ssl, ERR_R_INTERNAL_ERROR);
+ /* Handle both the new (BoringSSL) and old (quictls) APIs. */
+
+ if (ssl->quic_method->set_read_secret != NULL)
+ return ssl->quic_method->set_read_secret(ssl,
+ ctx->hs->tls13.quic_read_level, ctx->hs->cipher,
+ read_key->data, read_key->len);
+
+ if (ssl->quic_method->set_encryption_secrets != NULL)
+ return ssl->quic_method->set_encryption_secrets(ssl,
+ ctx->hs->tls13.quic_read_level, read_key->data, NULL,
+ read_key->len);
+
return 0;
}
ctx->hs->tls13.quic_write_level = write_level;
- /* XXX - call set_write_secret. */
- SSLerror(ssl, ERR_R_INTERNAL_ERROR);
+ /* Handle both the new (BoringSSL) and old (quictls) APIs. */
+
+ if (ssl->quic_method->set_write_secret != NULL)
+ return ssl->quic_method->set_write_secret(ssl,
+ ctx->hs->tls13.quic_write_level, ctx->hs->cipher,
+ write_key->data, write_key->len);
+
+ if (ssl->quic_method->set_encryption_secrets != NULL)
+ return ssl->quic_method->set_encryption_secrets(ssl,
+ ctx->hs->tls13.quic_write_level, NULL, write_key->data,
+ write_key->len);
+
return 0;
}
struct tls13_ctx *ctx = arg;
SSL *ssl = ctx->ssl;
- /* XXX - call send_alert. */
- SSLerror(ssl, ERR_R_INTERNAL_ERROR);
- return TLS13_IO_FAILURE;
+ if (!ssl->quic_method->send_alert(ssl, ctx->hs->tls13.quic_write_level,
+ alert_desc)) {
+ SSLerror(ssl, SSL_R_QUIC_INTERNAL_ERROR);
+ return TLS13_IO_FAILURE;
+ }
+
+ return TLS13_IO_SUCCESS;
}
static const struct tls13_record_layer_callbacks quic_rl_callbacks = {