summaryrefslogtreecommitdiff
path: root/src/lib/libssl
diff options
context:
space:
mode:
authorjsing <>2026-06-06 15:22:25 +0000
committerjsing <>2026-06-06 15:22:25 +0000
commitea2a1c165f2ed603b827d3bc22b989c30325f200 (patch)
tree12c0bfba49e96fa8237ea6a14943c6be2807405a /src/lib/libssl
parent8191edd9cf4fcae6a4e5e054326fdf2e620b353b (diff)
downloadopenbsd-ea2a1c165f2ed603b827d3bc22b989c30325f200.tar.gz
openbsd-ea2a1c165f2ed603b827d3bc22b989c30325f200.tar.bz2
openbsd-ea2a1c165f2ed603b827d3bc22b989c30325f200.zip
Move DTLS handshake message handling to its own function.
When a TLSv1.2 handshake message has been built, call a separate function that can handle the DTLS specific processing rather than including this in the TLS code. ok kenjiro@ tb@
Diffstat (limited to 'src/lib/libssl')
-rw-r--r--src/lib/libssl/d1_both.c27
-rw-r--r--src/lib/libssl/dtls_local.h3
-rw-r--r--src/lib/libssl/s3_lib.c14
3 files changed, 30 insertions, 14 deletions
diff --git a/src/lib/libssl/d1_both.c b/src/lib/libssl/d1_both.c
index 2af307f594..0a0a80dad9 100644
--- a/src/lib/libssl/d1_both.c
+++ b/src/lib/libssl/d1_both.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: d1_both.c,v 1.94 2026/05/16 08:20:41 jsing Exp $ */ 1/* $OpenBSD: d1_both.c,v 1.95 2026/06/06 15:22:25 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.
@@ -1162,3 +1162,28 @@ dtls1_get_message_header(CBS *header, struct hm_header_st *msg_hdr)
1162 1162
1163 return 1; 1163 return 1;
1164} 1164}
1165
1166int
1167dtls12_handshake_msg_built(SSL *s)
1168{
1169 unsigned long len;
1170 uint8_t msg_type;
1171 CBS cbs;
1172
1173 CBS_init(&cbs, s->init_buf->data, s->init_num);
1174 if (!CBS_get_u8(&cbs, &msg_type))
1175 return 0;
1176
1177 if (s->init_off != 0)
1178 return 0;
1179 if (s->init_num < DTLS1_HM_HEADER_LENGTH)
1180 return 0;
1181
1182 len = s->init_num - DTLS1_HM_HEADER_LENGTH;
1183
1184 dtls1_set_message_header(s, msg_type, len, 0, len);
1185
1186 dtls1_buffer_message(s, 0);
1187
1188 return 1;
1189}
diff --git a/src/lib/libssl/dtls_local.h b/src/lib/libssl/dtls_local.h
index a3d7f88615..9da48d1739 100644
--- a/src/lib/libssl/dtls_local.h
+++ b/src/lib/libssl/dtls_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: dtls_local.h,v 1.6 2026/05/25 13:34:58 jsg Exp $ */ 1/* $OpenBSD: dtls_local.h,v 1.7 2026/06/06 15:22:25 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.
@@ -222,6 +222,7 @@ long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg);
222int dtls1_get_message(SSL *s, int st1, int stn, int mt, long max); 222int dtls1_get_message(SSL *s, int st1, int stn, int mt, long max);
223int dtls1_get_record(SSL *s); 223int dtls1_get_record(SSL *s);
224 224
225int dtls12_handshake_msg_built(SSL *s);
225__END_HIDDEN_DECLS 226__END_HIDDEN_DECLS
226 227
227#endif /* !HEADER_DTLS_LOCL_H */ 228#endif /* !HEADER_DTLS_LOCL_H */
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index ee9a695ecd..df45df47fc 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.259 2026/06/06 15:08:15 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.260 2026/06/06 15:22:25 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 *
@@ -1209,18 +1209,8 @@ ssl3_handshake_msg_finish(SSL *s, CBB *handshake)
1209 s->init_off = 0; 1209 s->init_off = 0;
1210 1210
1211 if (SSL_is_dtls(s)) { 1211 if (SSL_is_dtls(s)) {
1212 unsigned long len; 1212 if (!dtls12_handshake_msg_built(s))
1213 uint8_t msg_type;
1214 CBS cbs;
1215
1216 CBS_init(&cbs, data, outlen);
1217 if (!CBS_get_u8(&cbs, &msg_type))
1218 goto err; 1213 goto err;
1219
1220 len = outlen - DTLS1_HM_HEADER_LENGTH;
1221
1222 dtls1_set_message_header(s, msg_type, len, 0, len);
1223 dtls1_buffer_message(s, 0);
1224 } 1214 }
1225 1215
1226 ret = 1; 1216 ret = 1;