diff options
author | jsing <> | 2021-07-26 03:17:38 +0000 |
---|---|---|
committer | jsing <> | 2021-07-26 03:17:38 +0000 |
commit | d07f7fde139d15ba9e55fcf7ecb45bbfc82d6564 (patch) | |
tree | d5c4303283f0e876353ed068b657a28628fa0880 | |
parent | 33ebe6f37b9fdb4bc9eb04dfa95da59ed59d9427 (diff) | |
download | openbsd-d07f7fde139d15ba9e55fcf7ecb45bbfc82d6564.tar.gz openbsd-d07f7fde139d15ba9e55fcf7ecb45bbfc82d6564.tar.bz2 openbsd-d07f7fde139d15ba9e55fcf7ecb45bbfc82d6564.zip |
Dedup dtls1_dispatch_alert()/ssl3_dispatch_alert().
The code for dtls1_dispatch_alert() and ssl3_dispatch_alert() is largely
identical - with a bit of reshuffling we can use ssl3_dispatch_alert() for
both protocols and remove the ssl_dispatch_alert function pointer.
ok inoguchi@ tb@
-rw-r--r-- | src/lib/libssl/d1_pkt.c | 40 | ||||
-rw-r--r-- | src/lib/libssl/dtls_locl.h | 6 | ||||
-rw-r--r-- | src/lib/libssl/s3_lib.c | 4 | ||||
-rw-r--r-- | src/lib/libssl/ssl_locl.h | 3 | ||||
-rw-r--r-- | src/lib/libssl/ssl_methods.c | 18 | ||||
-rw-r--r-- | src/lib/libssl/ssl_pkt.c | 20 |
6 files changed, 26 insertions, 65 deletions
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c index 0416ee9c59..acd66e622c 100644 --- a/src/lib/libssl/d1_pkt.c +++ b/src/lib/libssl/d1_pkt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_pkt.c,v 1.103 2021/07/21 08:42:14 jsing Exp $ */ | 1 | /* $OpenBSD: d1_pkt.c,v 1.104 2021/07/26 03:17:38 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
@@ -126,10 +126,6 @@ | |||
126 | #include "pqueue.h" | 126 | #include "pqueue.h" |
127 | #include "ssl_locl.h" | 127 | #include "ssl_locl.h" |
128 | 128 | ||
129 | static int do_dtls1_write(SSL *s, int type, const unsigned char *buf, | ||
130 | unsigned int len); | ||
131 | |||
132 | |||
133 | /* mod 128 saturating subtract of two 64-bit values in big-endian order */ | 129 | /* mod 128 saturating subtract of two 64-bit values in big-endian order */ |
134 | static int | 130 | static int |
135 | satsub64be(const unsigned char *v1, const unsigned char *v2) | 131 | satsub64be(const unsigned char *v1, const unsigned char *v2) |
@@ -1057,7 +1053,7 @@ do_dtls1_write(SSL *s, int type, const unsigned char *buf, unsigned int len) | |||
1057 | 1053 | ||
1058 | /* If we have an alert to send, let's send it */ | 1054 | /* If we have an alert to send, let's send it */ |
1059 | if (S3I(s)->alert_dispatch) { | 1055 | if (S3I(s)->alert_dispatch) { |
1060 | if ((ret = s->method->ssl_dispatch_alert(s)) <= 0) | 1056 | if ((ret = ssl3_dispatch_alert(s)) <= 0) |
1061 | return (ret); | 1057 | return (ret); |
1062 | /* If it went, fall through and send more stuff. */ | 1058 | /* If it went, fall through and send more stuff. */ |
1063 | } | 1059 | } |
@@ -1139,38 +1135,6 @@ dtls1_record_bitmap_update(SSL *s, DTLS1_BITMAP *bitmap, | |||
1139 | } | 1135 | } |
1140 | } | 1136 | } |
1141 | 1137 | ||
1142 | int | ||
1143 | dtls1_dispatch_alert(SSL *s) | ||
1144 | { | ||
1145 | int i, j; | ||
1146 | void (*cb)(const SSL *ssl, int type, int val) = NULL; | ||
1147 | |||
1148 | S3I(s)->alert_dispatch = 0; | ||
1149 | |||
1150 | i = do_dtls1_write(s, SSL3_RT_ALERT, &S3I(s)->send_alert[0], 2); | ||
1151 | if (i <= 0) { | ||
1152 | S3I(s)->alert_dispatch = 1; | ||
1153 | } else { | ||
1154 | if (S3I(s)->send_alert[0] == SSL3_AL_FATAL) | ||
1155 | (void)BIO_flush(s->wbio); | ||
1156 | |||
1157 | if (s->internal->msg_callback) | ||
1158 | s->internal->msg_callback(1, s->version, SSL3_RT_ALERT, | ||
1159 | S3I(s)->send_alert, 2, s, s->internal->msg_callback_arg); | ||
1160 | |||
1161 | if (s->internal->info_callback != NULL) | ||
1162 | cb = s->internal->info_callback; | ||
1163 | else if (s->ctx->internal->info_callback != NULL) | ||
1164 | cb = s->ctx->internal->info_callback; | ||
1165 | |||
1166 | if (cb != NULL) { | ||
1167 | j = (S3I(s)->send_alert[0]<<8)|S3I(s)->send_alert[1]; | ||
1168 | cb(s, SSL_CB_WRITE_ALERT, j); | ||
1169 | } | ||
1170 | } | ||
1171 | return (i); | ||
1172 | } | ||
1173 | |||
1174 | static DTLS1_BITMAP * | 1138 | static DTLS1_BITMAP * |
1175 | dtls1_get_bitmap(SSL *s, SSL3_RECORD_INTERNAL *rr, unsigned int *is_next_epoch) | 1139 | dtls1_get_bitmap(SSL *s, SSL3_RECORD_INTERNAL *rr, unsigned int *is_next_epoch) |
1176 | { | 1140 | { |
diff --git a/src/lib/libssl/dtls_locl.h b/src/lib/libssl/dtls_locl.h index bc28ce8559..97f05b26bd 100644 --- a/src/lib/libssl/dtls_locl.h +++ b/src/lib/libssl/dtls_locl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dtls_locl.h,v 1.3 2021/07/21 08:42:14 jsing Exp $ */ | 1 | /* $OpenBSD: dtls_locl.h,v 1.4 2021/07/26 03:17:38 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
@@ -207,6 +207,9 @@ void dtls1_set_message_header_int(SSL *s, unsigned char mt, | |||
207 | unsigned long len, unsigned short seq_num, unsigned long frag_off, | 207 | unsigned long len, unsigned short seq_num, unsigned long frag_off, |
208 | unsigned long frag_len); | 208 | unsigned long frag_len); |
209 | 209 | ||
210 | int do_dtls1_write(SSL *s, int type, const unsigned char *buf, | ||
211 | unsigned int len); | ||
212 | |||
210 | int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf, int len); | 213 | int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf, int len); |
211 | int dtls1_write_bytes(SSL *s, int type, const void *buf, int len); | 214 | int dtls1_write_bytes(SSL *s, int type, const void *buf, int len); |
212 | 215 | ||
@@ -237,7 +240,6 @@ long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg); | |||
237 | 240 | ||
238 | long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); | 241 | long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); |
239 | int dtls1_get_record(SSL *s); | 242 | int dtls1_get_record(SSL *s); |
240 | int dtls1_dispatch_alert(SSL *s); | ||
241 | 243 | ||
242 | __END_HIDDEN_DECLS | 244 | __END_HIDDEN_DECLS |
243 | 245 | ||
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c index b2d94629c2..6400454f1b 100644 --- a/src/lib/libssl/s3_lib.c +++ b/src/lib/libssl/s3_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_lib.c,v 1.213 2021/07/03 16:06:44 jsing Exp $ */ | 1 | /* $OpenBSD: s3_lib.c,v 1.214 2021/07/26 03:17:38 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -2631,7 +2631,7 @@ ssl3_shutdown(SSL *s) | |||
2631 | return(-1); /* return WANT_WRITE */ | 2631 | return(-1); /* return WANT_WRITE */ |
2632 | } else if (S3I(s)->alert_dispatch) { | 2632 | } else if (S3I(s)->alert_dispatch) { |
2633 | /* resend it if not sent */ | 2633 | /* resend it if not sent */ |
2634 | ret = s->method->ssl_dispatch_alert(s); | 2634 | ret = ssl3_dispatch_alert(s); |
2635 | if (ret == -1) { | 2635 | if (ret == -1) { |
2636 | /* | 2636 | /* |
2637 | * We only get to return -1 here the 2nd/Nth | 2637 | * We only get to return -1 here the 2nd/Nth |
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h index 677feca157..f3650f238e 100644 --- a/src/lib/libssl/ssl_locl.h +++ b/src/lib/libssl/ssl_locl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_locl.h,v 1.355 2021/07/03 16:06:45 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_locl.h,v 1.356 2021/07/26 03:17:38 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -402,7 +402,6 @@ struct ssl_method_st { | |||
402 | int peek); | 402 | int peek); |
403 | int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len); | 403 | int (*ssl_write_bytes)(SSL *s, int type, const void *buf_, int len); |
404 | 404 | ||
405 | int (*ssl_dispatch_alert)(SSL *s); | ||
406 | const SSL_CIPHER *(*get_cipher)(unsigned int ncipher); | 405 | const SSL_CIPHER *(*get_cipher)(unsigned int ncipher); |
407 | 406 | ||
408 | unsigned int enc_flags; /* SSL_ENC_FLAG_* */ | 407 | unsigned int enc_flags; /* SSL_ENC_FLAG_* */ |
diff --git a/src/lib/libssl/ssl_methods.c b/src/lib/libssl/ssl_methods.c index b9b8a95e56..d8ffbb7b51 100644 --- a/src/lib/libssl/ssl_methods.c +++ b/src/lib/libssl/ssl_methods.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_methods.c,v 1.27 2021/07/03 16:06:45 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_methods.c,v 1.28 2021/07/26 03:17:38 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -77,7 +77,6 @@ static const SSL_METHOD DTLS_method_data = { | |||
77 | .ssl_pending = ssl3_pending, | 77 | .ssl_pending = ssl3_pending, |
78 | .ssl_read_bytes = dtls1_read_bytes, | 78 | .ssl_read_bytes = dtls1_read_bytes, |
79 | .ssl_write_bytes = dtls1_write_app_data_bytes, | 79 | .ssl_write_bytes = dtls1_write_app_data_bytes, |
80 | .ssl_dispatch_alert = dtls1_dispatch_alert, | ||
81 | .get_cipher = dtls1_get_cipher, | 80 | .get_cipher = dtls1_get_cipher, |
82 | .enc_flags = TLSV1_2_ENC_FLAGS, | 81 | .enc_flags = TLSV1_2_ENC_FLAGS, |
83 | }; | 82 | }; |
@@ -99,7 +98,6 @@ static const SSL_METHOD DTLS_client_method_data = { | |||
99 | .ssl_pending = ssl3_pending, | 98 | .ssl_pending = ssl3_pending, |
100 | .ssl_read_bytes = dtls1_read_bytes, | 99 | .ssl_read_bytes = dtls1_read_bytes, |
101 | .ssl_write_bytes = dtls1_write_app_data_bytes, | 100 | .ssl_write_bytes = dtls1_write_app_data_bytes, |
102 | .ssl_dispatch_alert = dtls1_dispatch_alert, | ||
103 | .get_cipher = dtls1_get_cipher, | 101 | .get_cipher = dtls1_get_cipher, |
104 | .enc_flags = TLSV1_2_ENC_FLAGS, | 102 | .enc_flags = TLSV1_2_ENC_FLAGS, |
105 | }; | 103 | }; |
@@ -121,7 +119,6 @@ static const SSL_METHOD DTLSv1_method_data = { | |||
121 | .ssl_pending = ssl3_pending, | 119 | .ssl_pending = ssl3_pending, |
122 | .ssl_read_bytes = dtls1_read_bytes, | 120 | .ssl_read_bytes = dtls1_read_bytes, |
123 | .ssl_write_bytes = dtls1_write_app_data_bytes, | 121 | .ssl_write_bytes = dtls1_write_app_data_bytes, |
124 | .ssl_dispatch_alert = dtls1_dispatch_alert, | ||
125 | .get_cipher = dtls1_get_cipher, | 122 | .get_cipher = dtls1_get_cipher, |
126 | .enc_flags = TLSV1_1_ENC_FLAGS, | 123 | .enc_flags = TLSV1_1_ENC_FLAGS, |
127 | }; | 124 | }; |
@@ -143,7 +140,6 @@ static const SSL_METHOD DTLSv1_client_method_data = { | |||
143 | .ssl_pending = ssl3_pending, | 140 | .ssl_pending = ssl3_pending, |
144 | .ssl_read_bytes = dtls1_read_bytes, | 141 | .ssl_read_bytes = dtls1_read_bytes, |
145 | .ssl_write_bytes = dtls1_write_app_data_bytes, | 142 | .ssl_write_bytes = dtls1_write_app_data_bytes, |
146 | .ssl_dispatch_alert = dtls1_dispatch_alert, | ||
147 | .get_cipher = dtls1_get_cipher, | 143 | .get_cipher = dtls1_get_cipher, |
148 | .enc_flags = TLSV1_1_ENC_FLAGS, | 144 | .enc_flags = TLSV1_1_ENC_FLAGS, |
149 | }; | 145 | }; |
@@ -165,7 +161,6 @@ static const SSL_METHOD DTLSv1_2_method_data = { | |||
165 | .ssl_pending = ssl3_pending, | 161 | .ssl_pending = ssl3_pending, |
166 | .ssl_read_bytes = dtls1_read_bytes, | 162 | .ssl_read_bytes = dtls1_read_bytes, |
167 | .ssl_write_bytes = dtls1_write_app_data_bytes, | 163 | .ssl_write_bytes = dtls1_write_app_data_bytes, |
168 | .ssl_dispatch_alert = dtls1_dispatch_alert, | ||
169 | .get_cipher = dtls1_get_cipher, | 164 | .get_cipher = dtls1_get_cipher, |
170 | .enc_flags = TLSV1_2_ENC_FLAGS, | 165 | .enc_flags = TLSV1_2_ENC_FLAGS, |
171 | }; | 166 | }; |
@@ -187,7 +182,6 @@ static const SSL_METHOD DTLSv1_2_client_method_data = { | |||
187 | .ssl_pending = ssl3_pending, | 182 | .ssl_pending = ssl3_pending, |
188 | .ssl_read_bytes = dtls1_read_bytes, | 183 | .ssl_read_bytes = dtls1_read_bytes, |
189 | .ssl_write_bytes = dtls1_write_app_data_bytes, | 184 | .ssl_write_bytes = dtls1_write_app_data_bytes, |
190 | .ssl_dispatch_alert = dtls1_dispatch_alert, | ||
191 | .get_cipher = dtls1_get_cipher, | 185 | .get_cipher = dtls1_get_cipher, |
192 | .enc_flags = TLSV1_2_ENC_FLAGS, | 186 | .enc_flags = TLSV1_2_ENC_FLAGS, |
193 | }; | 187 | }; |
@@ -264,7 +258,6 @@ static const SSL_METHOD TLS_method_data = { | |||
264 | .ssl_pending = tls13_legacy_pending, | 258 | .ssl_pending = tls13_legacy_pending, |
265 | .ssl_read_bytes = tls13_legacy_read_bytes, | 259 | .ssl_read_bytes = tls13_legacy_read_bytes, |
266 | .ssl_write_bytes = tls13_legacy_write_bytes, | 260 | .ssl_write_bytes = tls13_legacy_write_bytes, |
267 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
268 | .get_cipher = ssl3_get_cipher, | 261 | .get_cipher = ssl3_get_cipher, |
269 | .enc_flags = TLSV1_3_ENC_FLAGS, | 262 | .enc_flags = TLSV1_3_ENC_FLAGS, |
270 | }; | 263 | }; |
@@ -287,7 +280,6 @@ static const SSL_METHOD TLS_legacy_method_data = { | |||
287 | .ssl_pending = ssl3_pending, | 280 | .ssl_pending = ssl3_pending, |
288 | .ssl_read_bytes = ssl3_read_bytes, | 281 | .ssl_read_bytes = ssl3_read_bytes, |
289 | .ssl_write_bytes = ssl3_write_bytes, | 282 | .ssl_write_bytes = ssl3_write_bytes, |
290 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
291 | .get_cipher = ssl3_get_cipher, | 283 | .get_cipher = ssl3_get_cipher, |
292 | .enc_flags = TLSV1_2_ENC_FLAGS, | 284 | .enc_flags = TLSV1_2_ENC_FLAGS, |
293 | }; | 285 | }; |
@@ -310,7 +302,6 @@ static const SSL_METHOD TLS_client_method_data = { | |||
310 | .ssl_pending = tls13_legacy_pending, | 302 | .ssl_pending = tls13_legacy_pending, |
311 | .ssl_read_bytes = tls13_legacy_read_bytes, | 303 | .ssl_read_bytes = tls13_legacy_read_bytes, |
312 | .ssl_write_bytes = tls13_legacy_write_bytes, | 304 | .ssl_write_bytes = tls13_legacy_write_bytes, |
313 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
314 | .get_cipher = ssl3_get_cipher, | 305 | .get_cipher = ssl3_get_cipher, |
315 | .enc_flags = TLSV1_3_ENC_FLAGS, | 306 | .enc_flags = TLSV1_3_ENC_FLAGS, |
316 | }; | 307 | }; |
@@ -334,7 +325,6 @@ static const SSL_METHOD TLS_legacy_client_method_data = { | |||
334 | .ssl_pending = ssl3_pending, | 325 | .ssl_pending = ssl3_pending, |
335 | .ssl_read_bytes = ssl3_read_bytes, | 326 | .ssl_read_bytes = ssl3_read_bytes, |
336 | .ssl_write_bytes = ssl3_write_bytes, | 327 | .ssl_write_bytes = ssl3_write_bytes, |
337 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
338 | .get_cipher = ssl3_get_cipher, | 328 | .get_cipher = ssl3_get_cipher, |
339 | .enc_flags = TLSV1_2_ENC_FLAGS, | 329 | .enc_flags = TLSV1_2_ENC_FLAGS, |
340 | }; | 330 | }; |
@@ -357,7 +347,6 @@ static const SSL_METHOD TLSv1_method_data = { | |||
357 | .ssl_pending = ssl3_pending, | 347 | .ssl_pending = ssl3_pending, |
358 | .ssl_read_bytes = ssl3_read_bytes, | 348 | .ssl_read_bytes = ssl3_read_bytes, |
359 | .ssl_write_bytes = ssl3_write_bytes, | 349 | .ssl_write_bytes = ssl3_write_bytes, |
360 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
361 | .get_cipher = ssl3_get_cipher, | 350 | .get_cipher = ssl3_get_cipher, |
362 | .enc_flags = TLSV1_ENC_FLAGS, | 351 | .enc_flags = TLSV1_ENC_FLAGS, |
363 | }; | 352 | }; |
@@ -379,7 +368,6 @@ static const SSL_METHOD TLSv1_client_method_data = { | |||
379 | .ssl_pending = ssl3_pending, | 368 | .ssl_pending = ssl3_pending, |
380 | .ssl_read_bytes = ssl3_read_bytes, | 369 | .ssl_read_bytes = ssl3_read_bytes, |
381 | .ssl_write_bytes = ssl3_write_bytes, | 370 | .ssl_write_bytes = ssl3_write_bytes, |
382 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
383 | .get_cipher = ssl3_get_cipher, | 371 | .get_cipher = ssl3_get_cipher, |
384 | .enc_flags = TLSV1_ENC_FLAGS, | 372 | .enc_flags = TLSV1_ENC_FLAGS, |
385 | }; | 373 | }; |
@@ -401,7 +389,6 @@ static const SSL_METHOD TLSv1_1_method_data = { | |||
401 | .ssl_pending = ssl3_pending, | 389 | .ssl_pending = ssl3_pending, |
402 | .ssl_read_bytes = ssl3_read_bytes, | 390 | .ssl_read_bytes = ssl3_read_bytes, |
403 | .ssl_write_bytes = ssl3_write_bytes, | 391 | .ssl_write_bytes = ssl3_write_bytes, |
404 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
405 | .get_cipher = ssl3_get_cipher, | 392 | .get_cipher = ssl3_get_cipher, |
406 | .enc_flags = TLSV1_1_ENC_FLAGS, | 393 | .enc_flags = TLSV1_1_ENC_FLAGS, |
407 | }; | 394 | }; |
@@ -423,7 +410,6 @@ static const SSL_METHOD TLSv1_1_client_method_data = { | |||
423 | .ssl_pending = ssl3_pending, | 410 | .ssl_pending = ssl3_pending, |
424 | .ssl_read_bytes = ssl3_read_bytes, | 411 | .ssl_read_bytes = ssl3_read_bytes, |
425 | .ssl_write_bytes = ssl3_write_bytes, | 412 | .ssl_write_bytes = ssl3_write_bytes, |
426 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
427 | .get_cipher = ssl3_get_cipher, | 413 | .get_cipher = ssl3_get_cipher, |
428 | .enc_flags = TLSV1_1_ENC_FLAGS, | 414 | .enc_flags = TLSV1_1_ENC_FLAGS, |
429 | }; | 415 | }; |
@@ -445,7 +431,6 @@ static const SSL_METHOD TLSv1_2_method_data = { | |||
445 | .ssl_pending = ssl3_pending, | 431 | .ssl_pending = ssl3_pending, |
446 | .ssl_read_bytes = ssl3_read_bytes, | 432 | .ssl_read_bytes = ssl3_read_bytes, |
447 | .ssl_write_bytes = ssl3_write_bytes, | 433 | .ssl_write_bytes = ssl3_write_bytes, |
448 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
449 | .get_cipher = ssl3_get_cipher, | 434 | .get_cipher = ssl3_get_cipher, |
450 | .enc_flags = TLSV1_2_ENC_FLAGS, | 435 | .enc_flags = TLSV1_2_ENC_FLAGS, |
451 | }; | 436 | }; |
@@ -467,7 +452,6 @@ static const SSL_METHOD TLSv1_2_client_method_data = { | |||
467 | .ssl_pending = ssl3_pending, | 452 | .ssl_pending = ssl3_pending, |
468 | .ssl_read_bytes = ssl3_read_bytes, | 453 | .ssl_read_bytes = ssl3_read_bytes, |
469 | .ssl_write_bytes = ssl3_write_bytes, | 454 | .ssl_write_bytes = ssl3_write_bytes, |
470 | .ssl_dispatch_alert = ssl3_dispatch_alert, | ||
471 | .get_cipher = ssl3_get_cipher, | 455 | .get_cipher = ssl3_get_cipher, |
472 | .enc_flags = TLSV1_2_ENC_FLAGS, | 456 | .enc_flags = TLSV1_2_ENC_FLAGS, |
473 | }; | 457 | }; |
diff --git a/src/lib/libssl/ssl_pkt.c b/src/lib/libssl/ssl_pkt.c index 7f655adfe6..c3fd4a7365 100644 --- a/src/lib/libssl/ssl_pkt.c +++ b/src/lib/libssl/ssl_pkt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_pkt.c,v 1.45 2021/06/29 18:43:49 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_pkt.c,v 1.46 2021/07/26 03:17:38 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -116,6 +116,7 @@ | |||
116 | #include <openssl/evp.h> | 116 | #include <openssl/evp.h> |
117 | 117 | ||
118 | #include "bytestring.h" | 118 | #include "bytestring.h" |
119 | #include "dtls_locl.h" | ||
119 | #include "ssl_locl.h" | 120 | #include "ssl_locl.h" |
120 | 121 | ||
121 | static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, | 122 | static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, |
@@ -552,7 +553,7 @@ do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len) | |||
552 | 553 | ||
553 | /* If we have an alert to send, let's send it. */ | 554 | /* If we have an alert to send, let's send it. */ |
554 | if (S3I(s)->alert_dispatch) { | 555 | if (S3I(s)->alert_dispatch) { |
555 | if ((ret = s->method->ssl_dispatch_alert(s)) <= 0) | 556 | if ((ret = ssl3_dispatch_alert(s)) <= 0) |
556 | return (ret); | 557 | return (ret); |
557 | /* If it went, fall through and send more stuff. */ | 558 | /* If it went, fall through and send more stuff. */ |
558 | 559 | ||
@@ -1188,6 +1189,17 @@ ssl3_do_change_cipher_spec(SSL *s) | |||
1188 | return (1); | 1189 | return (1); |
1189 | } | 1190 | } |
1190 | 1191 | ||
1192 | static int | ||
1193 | ssl3_write_alert(SSL *s) | ||
1194 | { | ||
1195 | if (SSL_is_dtls(s)) | ||
1196 | return do_dtls1_write(s, SSL3_RT_ALERT, S3I(s)->send_alert, | ||
1197 | sizeof(S3I(s)->send_alert)); | ||
1198 | |||
1199 | return do_ssl3_write(s, SSL3_RT_ALERT, S3I(s)->send_alert, | ||
1200 | sizeof(S3I(s)->send_alert)); | ||
1201 | } | ||
1202 | |||
1191 | int | 1203 | int |
1192 | ssl3_send_alert(SSL *s, int level, int desc) | 1204 | ssl3_send_alert(SSL *s, int level, int desc) |
1193 | { | 1205 | { |
@@ -1199,7 +1211,7 @@ ssl3_send_alert(SSL *s, int level, int desc) | |||
1199 | S3I(s)->send_alert[0] = level; | 1211 | S3I(s)->send_alert[0] = level; |
1200 | S3I(s)->send_alert[1] = desc; | 1212 | S3I(s)->send_alert[1] = desc; |
1201 | if (S3I(s)->wbuf.left == 0) /* data still being written out? */ | 1213 | if (S3I(s)->wbuf.left == 0) /* data still being written out? */ |
1202 | return s->method->ssl_dispatch_alert(s); | 1214 | return ssl3_dispatch_alert(s); |
1203 | 1215 | ||
1204 | /* else data is still being written out, we will get written | 1216 | /* else data is still being written out, we will get written |
1205 | * some time in the future */ | 1217 | * some time in the future */ |
@@ -1213,7 +1225,7 @@ ssl3_dispatch_alert(SSL *s) | |||
1213 | void (*cb)(const SSL *ssl, int type, int val) = NULL; | 1225 | void (*cb)(const SSL *ssl, int type, int val) = NULL; |
1214 | 1226 | ||
1215 | S3I(s)->alert_dispatch = 0; | 1227 | S3I(s)->alert_dispatch = 0; |
1216 | i = do_ssl3_write(s, SSL3_RT_ALERT, &S3I(s)->send_alert[0], 2); | 1228 | i = ssl3_write_alert(s); |
1217 | if (i <= 0) { | 1229 | if (i <= 0) { |
1218 | S3I(s)->alert_dispatch = 1; | 1230 | S3I(s)->alert_dispatch = 1; |
1219 | } else { | 1231 | } else { |