diff options
Diffstat (limited to 'src/lib/libssl/tls13_record_layer.c')
-rw-r--r-- | src/lib/libssl/tls13_record_layer.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/lib/libssl/tls13_record_layer.c b/src/lib/libssl/tls13_record_layer.c index c92fd8d193..ac5b83bd34 100644 --- a/src/lib/libssl/tls13_record_layer.c +++ b/src/lib/libssl/tls13_record_layer.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls13_record_layer.c,v 1.69 2022/07/24 14:16:29 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_record_layer.c,v 1.70 2022/07/24 14:28:16 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -146,8 +146,8 @@ tls13_record_layer_new(const struct tls13_record_layer_callbacks *callbacks, | |||
146 | goto err; | 146 | goto err; |
147 | 147 | ||
148 | rl->legacy_version = TLS1_2_VERSION; | 148 | rl->legacy_version = TLS1_2_VERSION; |
149 | rl->cb = *callbacks; | 149 | |
150 | rl->cb_arg = cb_arg; | 150 | tls13_record_layer_set_callbacks(rl, callbacks, cb_arg); |
151 | 151 | ||
152 | return rl; | 152 | return rl; |
153 | 153 | ||
@@ -178,6 +178,14 @@ tls13_record_layer_free(struct tls13_record_layer *rl) | |||
178 | } | 178 | } |
179 | 179 | ||
180 | void | 180 | void |
181 | tls13_record_layer_set_callbacks(struct tls13_record_layer *rl, | ||
182 | const struct tls13_record_layer_callbacks *callbacks, void *cb_arg) | ||
183 | { | ||
184 | rl->cb = *callbacks; | ||
185 | rl->cb_arg = cb_arg; | ||
186 | } | ||
187 | |||
188 | void | ||
181 | tls13_record_layer_rcontent(struct tls13_record_layer *rl, CBS *cbs) | 189 | tls13_record_layer_rcontent(struct tls13_record_layer *rl, CBS *cbs) |
182 | { | 190 | { |
183 | CBS_dup(tls_content_cbs(rl->rcontent), cbs); | 191 | CBS_dup(tls_content_cbs(rl->rcontent), cbs); |
@@ -489,6 +497,10 @@ int | |||
489 | tls13_record_layer_set_read_traffic_key(struct tls13_record_layer *rl, | 497 | tls13_record_layer_set_read_traffic_key(struct tls13_record_layer *rl, |
490 | struct tls13_secret *read_key, enum ssl_encryption_level_t read_level) | 498 | struct tls13_secret *read_key, enum ssl_encryption_level_t read_level) |
491 | { | 499 | { |
500 | if (rl->cb.set_read_traffic_key != NULL) | ||
501 | return rl->cb.set_read_traffic_key(read_key, read_level, | ||
502 | rl->cb_arg); | ||
503 | |||
492 | return tls13_record_layer_set_traffic_key(rl->aead, rl->hash, | 504 | return tls13_record_layer_set_traffic_key(rl->aead, rl->hash, |
493 | rl->read, read_key); | 505 | rl->read, read_key); |
494 | } | 506 | } |
@@ -497,6 +509,10 @@ int | |||
497 | tls13_record_layer_set_write_traffic_key(struct tls13_record_layer *rl, | 509 | tls13_record_layer_set_write_traffic_key(struct tls13_record_layer *rl, |
498 | struct tls13_secret *write_key, enum ssl_encryption_level_t write_level) | 510 | struct tls13_secret *write_key, enum ssl_encryption_level_t write_level) |
499 | { | 511 | { |
512 | if (rl->cb.set_write_traffic_key != NULL) | ||
513 | return rl->cb.set_write_traffic_key(write_key, write_level, | ||
514 | rl->cb_arg); | ||
515 | |||
500 | return tls13_record_layer_set_traffic_key(rl->aead, rl->hash, | 516 | return tls13_record_layer_set_traffic_key(rl->aead, rl->hash, |
501 | rl->write, write_key); | 517 | rl->write, write_key); |
502 | } | 518 | } |
@@ -1128,6 +1144,9 @@ tls13_send_dummy_ccs(struct tls13_record_layer *rl) | |||
1128 | ssize_t | 1144 | ssize_t |
1129 | tls13_read_handshake_data(struct tls13_record_layer *rl, uint8_t *buf, size_t n) | 1145 | tls13_read_handshake_data(struct tls13_record_layer *rl, uint8_t *buf, size_t n) |
1130 | { | 1146 | { |
1147 | if (rl->cb.handshake_read != NULL) | ||
1148 | return rl->cb.handshake_read(buf, n, rl->cb_arg); | ||
1149 | |||
1131 | return tls13_record_layer_read(rl, SSL3_RT_HANDSHAKE, buf, n); | 1150 | return tls13_record_layer_read(rl, SSL3_RT_HANDSHAKE, buf, n); |
1132 | } | 1151 | } |
1133 | 1152 | ||
@@ -1135,6 +1154,9 @@ ssize_t | |||
1135 | tls13_write_handshake_data(struct tls13_record_layer *rl, const uint8_t *buf, | 1154 | tls13_write_handshake_data(struct tls13_record_layer *rl, const uint8_t *buf, |
1136 | size_t n) | 1155 | size_t n) |
1137 | { | 1156 | { |
1157 | if (rl->cb.handshake_write != NULL) | ||
1158 | return rl->cb.handshake_write(buf, n, rl->cb_arg); | ||
1159 | |||
1138 | return tls13_record_layer_write(rl, SSL3_RT_HANDSHAKE, buf, n); | 1160 | return tls13_record_layer_write(rl, SSL3_RT_HANDSHAKE, buf, n); |
1139 | } | 1161 | } |
1140 | 1162 | ||
@@ -1181,6 +1203,9 @@ tls13_send_alert(struct tls13_record_layer *rl, uint8_t alert_desc) | |||
1181 | uint8_t alert_level = TLS13_ALERT_LEVEL_FATAL; | 1203 | uint8_t alert_level = TLS13_ALERT_LEVEL_FATAL; |
1182 | ssize_t ret; | 1204 | ssize_t ret; |
1183 | 1205 | ||
1206 | if (rl->cb.alert_send != NULL) | ||
1207 | return rl->cb.alert_send(alert_desc, rl->cb_arg); | ||
1208 | |||
1184 | if (alert_desc == TLS13_ALERT_CLOSE_NOTIFY || | 1209 | if (alert_desc == TLS13_ALERT_CLOSE_NOTIFY || |
1185 | alert_desc == TLS13_ALERT_USER_CANCELED) | 1210 | alert_desc == TLS13_ALERT_USER_CANCELED) |
1186 | alert_level = TLS13_ALERT_LEVEL_WARNING; | 1211 | alert_level = TLS13_ALERT_LEVEL_WARNING; |