summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_pkt.c
diff options
context:
space:
mode:
authorjsing <>2021-07-26 03:17:38 +0000
committerjsing <>2021-07-26 03:17:38 +0000
commitd07f7fde139d15ba9e55fcf7ecb45bbfc82d6564 (patch)
treed5c4303283f0e876353ed068b657a28628fa0880 /src/lib/libssl/ssl_pkt.c
parent33ebe6f37b9fdb4bc9eb04dfa95da59ed59d9427 (diff)
downloadopenbsd-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@
Diffstat (limited to 'src/lib/libssl/ssl_pkt.c')
-rw-r--r--src/lib/libssl/ssl_pkt.c20
1 files changed, 16 insertions, 4 deletions
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
121static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, 122static 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
1192static int
1193ssl3_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
1191int 1203int
1192ssl3_send_alert(SSL *s, int level, int desc) 1204ssl3_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 {