diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/tls13_quic.c | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/src/lib/libssl/tls13_quic.c b/src/lib/libssl/tls13_quic.c new file mode 100644 index 0000000000..3f814188a7 --- /dev/null +++ b/src/lib/libssl/tls13_quic.c | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | /* $OpenBSD: tls13_quic.c,v 1.1 2022/07/24 14:28:16 jsing Exp $ */ | ||
| 2 | /* | ||
| 3 | * Copyright (c) 2022 Joel Sing <jsing@openbsd.org> | ||
| 4 | * | ||
| 5 | * Permission to use, copy, modify, and distribute this software for any | ||
| 6 | * purpose with or without fee is hereby granted, provided that the above | ||
| 7 | * copyright notice and this permission notice appear in all copies. | ||
| 8 | * | ||
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <ssl_locl.h> | ||
| 19 | |||
| 20 | #include "tls13_internal.h" | ||
| 21 | |||
| 22 | static ssize_t | ||
| 23 | tls13_quic_wire_read_cb(void *buf, size_t n, void *arg) | ||
| 24 | { | ||
| 25 | struct tls13_ctx *ctx = arg; | ||
| 26 | SSL *ssl = ctx->ssl; | ||
| 27 | |||
| 28 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); | ||
| 29 | return TLS13_IO_FAILURE; | ||
| 30 | } | ||
| 31 | |||
| 32 | static ssize_t | ||
| 33 | tls13_quic_wire_write_cb(const void *buf, size_t n, void *arg) | ||
| 34 | { | ||
| 35 | struct tls13_ctx *ctx = arg; | ||
| 36 | SSL *ssl = ctx->ssl; | ||
| 37 | |||
| 38 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); | ||
| 39 | return TLS13_IO_FAILURE; | ||
| 40 | } | ||
| 41 | |||
| 42 | static ssize_t | ||
| 43 | tls13_quic_wire_flush_cb(void *arg) | ||
| 44 | { | ||
| 45 | struct tls13_ctx *ctx = arg; | ||
| 46 | SSL *ssl = ctx->ssl; | ||
| 47 | |||
| 48 | /* XXX - call flush_flight. */ | ||
| 49 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); | ||
| 50 | return TLS13_IO_FAILURE; | ||
| 51 | } | ||
| 52 | |||
| 53 | static ssize_t | ||
| 54 | tls13_quic_handshake_read_cb(void *buf, size_t n, void *arg) | ||
| 55 | { | ||
| 56 | /* XXX - read handshake data. */ | ||
| 57 | return TLS13_IO_FAILURE; | ||
| 58 | } | ||
| 59 | |||
| 60 | static ssize_t | ||
| 61 | tls13_quic_handshake_write_cb(const void *buf, size_t n, void *arg) | ||
| 62 | { | ||
| 63 | struct tls13_ctx *ctx = arg; | ||
| 64 | SSL *ssl = ctx->ssl; | ||
| 65 | |||
| 66 | /* XXX - call add_handshake_data. */ | ||
| 67 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); | ||
| 68 | return TLS13_IO_FAILURE; | ||
| 69 | } | ||
| 70 | |||
| 71 | static int | ||
| 72 | tls13_quic_set_read_traffic_key(struct tls13_secret *read_key, | ||
| 73 | enum ssl_encryption_level_t read_level, void *arg) | ||
| 74 | { | ||
| 75 | struct tls13_ctx *ctx = arg; | ||
| 76 | SSL *ssl = ctx->ssl; | ||
| 77 | |||
| 78 | ctx->hs->tls13.quic_read_level = read_level; | ||
| 79 | |||
| 80 | /* XXX - call set_read_secret. */ | ||
| 81 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); | ||
| 82 | return 0; | ||
| 83 | } | ||
| 84 | |||
| 85 | static int | ||
| 86 | tls13_quic_set_write_traffic_key(struct tls13_secret *write_key, | ||
| 87 | enum ssl_encryption_level_t write_level, void *arg) | ||
| 88 | { | ||
| 89 | struct tls13_ctx *ctx = arg; | ||
| 90 | SSL *ssl = ctx->ssl; | ||
| 91 | |||
| 92 | ctx->hs->tls13.quic_write_level = write_level; | ||
| 93 | |||
| 94 | /* XXX - call set_write_secret. */ | ||
| 95 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); | ||
| 96 | return 0; | ||
| 97 | } | ||
| 98 | |||
| 99 | static int | ||
| 100 | tls13_quic_alert_send_cb(int alert_desc, void *arg) | ||
| 101 | { | ||
| 102 | struct tls13_ctx *ctx = arg; | ||
| 103 | SSL *ssl = ctx->ssl; | ||
| 104 | |||
| 105 | /* XXX - call send_alert. */ | ||
| 106 | SSLerror(ssl, ERR_R_INTERNAL_ERROR); | ||
| 107 | return TLS13_IO_FAILURE; | ||
| 108 | } | ||
| 109 | |||
| 110 | static const struct tls13_record_layer_callbacks quic_rl_callbacks = { | ||
| 111 | .wire_read = tls13_quic_wire_read_cb, | ||
| 112 | .wire_write = tls13_quic_wire_write_cb, | ||
| 113 | .wire_flush = tls13_quic_wire_flush_cb, | ||
| 114 | |||
| 115 | .handshake_read = tls13_quic_handshake_read_cb, | ||
| 116 | .handshake_write = tls13_quic_handshake_write_cb, | ||
| 117 | .set_read_traffic_key = tls13_quic_set_read_traffic_key, | ||
| 118 | .set_write_traffic_key = tls13_quic_set_write_traffic_key, | ||
| 119 | .alert_send = tls13_quic_alert_send_cb, | ||
| 120 | |||
| 121 | .alert_recv = tls13_alert_received_cb, | ||
| 122 | .alert_sent = tls13_alert_sent_cb, | ||
| 123 | .phh_recv = tls13_phh_received_cb, | ||
| 124 | .phh_sent = tls13_phh_done_cb, | ||
| 125 | }; | ||
| 126 | |||
| 127 | int | ||
| 128 | tls13_quic_init(struct tls13_ctx *ctx) | ||
| 129 | { | ||
| 130 | tls13_record_layer_set_callbacks(ctx->rl, &quic_rl_callbacks, ctx); | ||
| 131 | |||
| 132 | ctx->middlebox_compat = 0; | ||
| 133 | |||
| 134 | return 1; | ||
| 135 | } | ||
