diff options
author | jsing <> | 2021-05-16 13:56:31 +0000 |
---|---|---|
committer | jsing <> | 2021-05-16 13:56:31 +0000 |
commit | 6eb9f4e8d442a1181957027a462b0fd7230baeba (patch) | |
tree | e59ed0b0555e9f15cbdb2eec4de487cb9336b8c5 | |
parent | a2af7b496e0aa8d2dbb66a0218ead36ed0e52edc (diff) | |
download | openbsd-6eb9f4e8d442a1181957027a462b0fd7230baeba.tar.gz openbsd-6eb9f4e8d442a1181957027a462b0fd7230baeba.tar.bz2 openbsd-6eb9f4e8d442a1181957027a462b0fd7230baeba.zip |
Move DTLS structs/definitions/prototypes to dtls_locl.h.
Now that the DTLS structs are opaque, add a dtls_locl.h header and move
internal-only structs from dtls1.h, along with prototypes from ssl_locl.h.
Only pull this header in where DTLS code actually exists.
ok inoguchi@ tb@
-rw-r--r-- | src/lib/libssl/d1_both.c | 5 | ||||
-rw-r--r-- | src/lib/libssl/d1_lib.c | 3 | ||||
-rw-r--r-- | src/lib/libssl/d1_pkt.c | 8 | ||||
-rw-r--r-- | src/lib/libssl/d1_srtp.c | 6 | ||||
-rw-r--r-- | src/lib/libssl/dtls1.h | 86 | ||||
-rw-r--r-- | src/lib/libssl/dtls_locl.h | 251 | ||||
-rw-r--r-- | src/lib/libssl/s3_lib.c | 5 | ||||
-rw-r--r-- | src/lib/libssl/ssl_both.c | 6 | ||||
-rw-r--r-- | src/lib/libssl/ssl_clnt.c | 3 | ||||
-rw-r--r-- | src/lib/libssl/ssl_lib.c | 3 | ||||
-rw-r--r-- | src/lib/libssl/ssl_locl.h | 110 | ||||
-rw-r--r-- | src/lib/libssl/ssl_methods.c | 3 | ||||
-rw-r--r-- | src/lib/libssl/ssl_srvr.c | 3 | ||||
-rw-r--r-- | src/lib/libssl/t1_enc.c | 4 |
14 files changed, 282 insertions, 214 deletions
diff --git a/src/lib/libssl/d1_both.c b/src/lib/libssl/d1_both.c index 3b9880b600..22bd3cec2a 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.70 2021/05/05 19:52:00 jsing Exp $ */ | 1 | /* $OpenBSD: d1_both.c,v 1.71 2021/05/16 13:56:30 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. |
@@ -124,8 +124,9 @@ | |||
124 | #include <openssl/objects.h> | 124 | #include <openssl/objects.h> |
125 | #include <openssl/x509.h> | 125 | #include <openssl/x509.h> |
126 | 126 | ||
127 | #include "pqueue.h" | ||
128 | #include "bytestring.h" | 127 | #include "bytestring.h" |
128 | #include "dtls_locl.h" | ||
129 | #include "pqueue.h" | ||
129 | 130 | ||
130 | #define RSMBLY_BITMASK_SIZE(msg_len) (((msg_len) + 7) / 8) | 131 | #define RSMBLY_BITMASK_SIZE(msg_len) (((msg_len) + 7) / 8) |
131 | 132 | ||
diff --git a/src/lib/libssl/d1_lib.c b/src/lib/libssl/d1_lib.c index 4a45e66f34..dbc89e6f46 100644 --- a/src/lib/libssl/d1_lib.c +++ b/src/lib/libssl/d1_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_lib.c,v 1.53 2021/02/20 07:29:07 jsing Exp $ */ | 1 | /* $OpenBSD: d1_lib.c,v 1.54 2021/05/16 13:56:30 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. |
@@ -67,6 +67,7 @@ | |||
67 | 67 | ||
68 | #include <openssl/objects.h> | 68 | #include <openssl/objects.h> |
69 | 69 | ||
70 | #include "dtls_locl.h" | ||
70 | #include "pqueue.h" | 71 | #include "pqueue.h" |
71 | #include "ssl_locl.h" | 72 | #include "ssl_locl.h" |
72 | 73 | ||
diff --git a/src/lib/libssl/d1_pkt.c b/src/lib/libssl/d1_pkt.c index 31ee5a679a..3b3fd95f6f 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.95 2021/05/05 19:52:00 jsing Exp $ */ | 1 | /* $OpenBSD: d1_pkt.c,v 1.96 2021/05/16 13:56:30 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. |
@@ -118,13 +118,13 @@ | |||
118 | #include <errno.h> | 118 | #include <errno.h> |
119 | #include <stdio.h> | 119 | #include <stdio.h> |
120 | 120 | ||
121 | #include "ssl_locl.h" | ||
122 | |||
123 | #include <openssl/buffer.h> | 121 | #include <openssl/buffer.h> |
124 | #include <openssl/evp.h> | 122 | #include <openssl/evp.h> |
125 | 123 | ||
126 | #include "pqueue.h" | ||
127 | #include "bytestring.h" | 124 | #include "bytestring.h" |
125 | #include "dtls_locl.h" | ||
126 | #include "pqueue.h" | ||
127 | #include "ssl_locl.h" | ||
128 | 128 | ||
129 | static int do_dtls1_write(SSL *s, int type, const unsigned char *buf, | 129 | static int do_dtls1_write(SSL *s, int type, const unsigned char *buf, |
130 | unsigned int len); | 130 | unsigned int len); |
diff --git a/src/lib/libssl/d1_srtp.c b/src/lib/libssl/d1_srtp.c index 2236e94e63..cbdb4a6144 100644 --- a/src/lib/libssl/d1_srtp.c +++ b/src/lib/libssl/d1_srtp.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_srtp.c,v 1.27 2021/05/16 08:24:21 jsing Exp $ */ | 1 | /* $OpenBSD: d1_srtp.c,v 1.28 2021/05/16 13:56:30 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 | * |
@@ -120,11 +120,11 @@ | |||
120 | #include <openssl/objects.h> | 120 | #include <openssl/objects.h> |
121 | #include <openssl/opensslconf.h> | 121 | #include <openssl/opensslconf.h> |
122 | 122 | ||
123 | #include "ssl_locl.h" | ||
124 | |||
125 | #ifndef OPENSSL_NO_SRTP | 123 | #ifndef OPENSSL_NO_SRTP |
126 | 124 | ||
127 | #include "bytestring.h" | 125 | #include "bytestring.h" |
126 | #include "dtls_locl.h" | ||
127 | #include "ssl_locl.h" | ||
128 | #include "srtp.h" | 128 | #include "srtp.h" |
129 | 129 | ||
130 | static const SRTP_PROTECTION_PROFILE srtp_known_profiles[] = { | 130 | static const SRTP_PROTECTION_PROFILE srtp_known_profiles[] = { |
diff --git a/src/lib/libssl/dtls1.h b/src/lib/libssl/dtls1.h index 624df2479b..7428d8ec3c 100644 --- a/src/lib/libssl/dtls1.h +++ b/src/lib/libssl/dtls1.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dtls1.h,v 1.26 2021/05/10 17:10:57 tb Exp $ */ | 1 | /* $OpenBSD: dtls1.h,v 1.27 2021/05/16 13:56:30 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. |
@@ -91,90 +91,6 @@ extern "C" { | |||
91 | 91 | ||
92 | #define DTLS1_AL_HEADER_LENGTH 2 | 92 | #define DTLS1_AL_HEADER_LENGTH 2 |
93 | 93 | ||
94 | #ifdef LIBRESSL_INTERNAL | ||
95 | |||
96 | typedef struct dtls1_bitmap_st { | ||
97 | unsigned long map; /* track 32 packets on 32-bit systems | ||
98 | and 64 - on 64-bit systems */ | ||
99 | unsigned char max_seq_num[8]; /* max record number seen so far, | ||
100 | 64-bit value in big-endian | ||
101 | encoding */ | ||
102 | } DTLS1_BITMAP; | ||
103 | |||
104 | struct dtls1_retransmit_state { | ||
105 | EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ | ||
106 | EVP_MD_CTX *write_hash; /* used for mac generation */ | ||
107 | SSL_SESSION *session; | ||
108 | unsigned short epoch; | ||
109 | }; | ||
110 | |||
111 | struct hm_header_st { | ||
112 | unsigned char type; | ||
113 | unsigned long msg_len; | ||
114 | unsigned short seq; | ||
115 | unsigned long frag_off; | ||
116 | unsigned long frag_len; | ||
117 | unsigned int is_ccs; | ||
118 | struct dtls1_retransmit_state saved_retransmit_state; | ||
119 | }; | ||
120 | |||
121 | struct ccs_header_st { | ||
122 | unsigned char type; | ||
123 | unsigned short seq; | ||
124 | }; | ||
125 | |||
126 | struct dtls1_timeout_st { | ||
127 | /* Number of read timeouts so far */ | ||
128 | unsigned int read_timeouts; | ||
129 | |||
130 | /* Number of write timeouts so far */ | ||
131 | unsigned int write_timeouts; | ||
132 | |||
133 | /* Number of alerts received so far */ | ||
134 | unsigned int num_alerts; | ||
135 | }; | ||
136 | |||
137 | struct _pqueue; | ||
138 | |||
139 | typedef struct record_pqueue_st { | ||
140 | unsigned short epoch; | ||
141 | struct _pqueue *q; | ||
142 | } record_pqueue; | ||
143 | |||
144 | typedef struct hm_fragment_st { | ||
145 | struct hm_header_st msg_header; | ||
146 | unsigned char *fragment; | ||
147 | unsigned char *reassembly; | ||
148 | } hm_fragment; | ||
149 | |||
150 | struct dtls1_state_internal_st; | ||
151 | |||
152 | typedef struct dtls1_state_st { | ||
153 | /* Buffered (sent) handshake records */ | ||
154 | struct _pqueue *sent_messages; | ||
155 | |||
156 | /* Indicates when the last handshake msg or heartbeat sent will timeout */ | ||
157 | struct timeval next_timeout; | ||
158 | |||
159 | /* Timeout duration */ | ||
160 | unsigned short timeout_duration; | ||
161 | |||
162 | struct dtls1_state_internal_st *internal; | ||
163 | } DTLS1_STATE; | ||
164 | |||
165 | #ifndef LIBRESSL_INTERNAL | ||
166 | |||
167 | typedef struct dtls1_record_data_st { | ||
168 | unsigned char *packet; | ||
169 | unsigned int packet_length; | ||
170 | SSL3_BUFFER rbuf; | ||
171 | SSL3_RECORD rrec; | ||
172 | } DTLS1_RECORD_DATA; | ||
173 | |||
174 | #endif | ||
175 | |||
176 | #endif | ||
177 | |||
178 | /* Timeout multipliers (timeout slice is defined in apps/timeouts.h */ | 94 | /* Timeout multipliers (timeout slice is defined in apps/timeouts.h */ |
179 | #define DTLS1_TMO_READ_COUNT 2 | 95 | #define DTLS1_TMO_READ_COUNT 2 |
180 | #define DTLS1_TMO_WRITE_COUNT 2 | 96 | #define DTLS1_TMO_WRITE_COUNT 2 |
diff --git a/src/lib/libssl/dtls_locl.h b/src/lib/libssl/dtls_locl.h new file mode 100644 index 0000000000..9bf1fe6661 --- /dev/null +++ b/src/lib/libssl/dtls_locl.h | |||
@@ -0,0 +1,251 @@ | |||
1 | /* $OpenBSD: dtls_locl.h,v 1.1 2021/05/16 13:56:30 jsing Exp $ */ | ||
2 | /* | ||
3 | * DTLS implementation written by Nagendra Modadugu | ||
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | ||
5 | */ | ||
6 | /* ==================================================================== | ||
7 | * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * | ||
13 | * 1. Redistributions of source code must retain the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer. | ||
15 | * | ||
16 | * 2. Redistributions in binary form must reproduce the above copyright | ||
17 | * notice, this list of conditions and the following disclaimer in | ||
18 | * the documentation and/or other materials provided with the | ||
19 | * distribution. | ||
20 | * | ||
21 | * 3. All advertising materials mentioning features or use of this | ||
22 | * software must display the following acknowledgment: | ||
23 | * "This product includes software developed by the OpenSSL Project | ||
24 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
25 | * | ||
26 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
27 | * endorse or promote products derived from this software without | ||
28 | * prior written permission. For written permission, please contact | ||
29 | * openssl-core@OpenSSL.org. | ||
30 | * | ||
31 | * 5. Products derived from this software may not be called "OpenSSL" | ||
32 | * nor may "OpenSSL" appear in their names without prior written | ||
33 | * permission of the OpenSSL Project. | ||
34 | * | ||
35 | * 6. Redistributions of any form whatsoever must retain the following | ||
36 | * acknowledgment: | ||
37 | * "This product includes software developed by the OpenSSL Project | ||
38 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
39 | * | ||
40 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
41 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
42 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
43 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
44 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
45 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
46 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
47 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
49 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
50 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
51 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
52 | * ==================================================================== | ||
53 | * | ||
54 | * This product includes cryptographic software written by Eric Young | ||
55 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
56 | * Hudson (tjh@cryptsoft.com). | ||
57 | * | ||
58 | */ | ||
59 | |||
60 | #ifndef HEADER_DTLS_LOCL_H | ||
61 | #define HEADER_DTLS_LOCL_H | ||
62 | |||
63 | #include <sys/time.h> | ||
64 | |||
65 | #include <openssl/dtls1.h> | ||
66 | |||
67 | #include "ssl_locl.h" | ||
68 | |||
69 | __BEGIN_HIDDEN_DECLS | ||
70 | |||
71 | typedef struct dtls1_bitmap_st { | ||
72 | unsigned long map; /* track 32 packets on 32-bit systems | ||
73 | and 64 - on 64-bit systems */ | ||
74 | unsigned char max_seq_num[8]; /* max record number seen so far, | ||
75 | 64-bit value in big-endian | ||
76 | encoding */ | ||
77 | } DTLS1_BITMAP; | ||
78 | |||
79 | struct dtls1_retransmit_state { | ||
80 | EVP_CIPHER_CTX *enc_write_ctx; /* cryptographic state */ | ||
81 | EVP_MD_CTX *write_hash; /* used for mac generation */ | ||
82 | SSL_SESSION *session; | ||
83 | unsigned short epoch; | ||
84 | }; | ||
85 | |||
86 | struct hm_header_st { | ||
87 | unsigned char type; | ||
88 | unsigned long msg_len; | ||
89 | unsigned short seq; | ||
90 | unsigned long frag_off; | ||
91 | unsigned long frag_len; | ||
92 | unsigned int is_ccs; | ||
93 | struct dtls1_retransmit_state saved_retransmit_state; | ||
94 | }; | ||
95 | |||
96 | struct ccs_header_st { | ||
97 | unsigned char type; | ||
98 | unsigned short seq; | ||
99 | }; | ||
100 | |||
101 | struct dtls1_timeout_st { | ||
102 | /* Number of read timeouts so far */ | ||
103 | unsigned int read_timeouts; | ||
104 | |||
105 | /* Number of write timeouts so far */ | ||
106 | unsigned int write_timeouts; | ||
107 | |||
108 | /* Number of alerts received so far */ | ||
109 | unsigned int num_alerts; | ||
110 | }; | ||
111 | |||
112 | struct _pqueue; | ||
113 | |||
114 | typedef struct record_pqueue_st { | ||
115 | unsigned short epoch; | ||
116 | struct _pqueue *q; | ||
117 | } record_pqueue; | ||
118 | |||
119 | typedef struct hm_fragment_st { | ||
120 | struct hm_header_st msg_header; | ||
121 | unsigned char *fragment; | ||
122 | unsigned char *reassembly; | ||
123 | } hm_fragment; | ||
124 | |||
125 | typedef struct dtls1_record_data_internal_st { | ||
126 | unsigned char *packet; | ||
127 | unsigned int packet_length; | ||
128 | SSL3_BUFFER_INTERNAL rbuf; | ||
129 | SSL3_RECORD_INTERNAL rrec; | ||
130 | } DTLS1_RECORD_DATA_INTERNAL; | ||
131 | |||
132 | struct dtls1_state_internal_st; | ||
133 | |||
134 | typedef struct dtls1_state_internal_st { | ||
135 | unsigned int send_cookie; | ||
136 | unsigned char cookie[DTLS1_COOKIE_LENGTH]; | ||
137 | unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH]; | ||
138 | unsigned int cookie_len; | ||
139 | |||
140 | /* | ||
141 | * The current data and handshake epoch. This is initially | ||
142 | * undefined, and starts at zero once the initial handshake is | ||
143 | * completed | ||
144 | */ | ||
145 | unsigned short r_epoch; | ||
146 | |||
147 | /* records being received in the current epoch */ | ||
148 | DTLS1_BITMAP bitmap; | ||
149 | |||
150 | /* renegotiation starts a new set of sequence numbers */ | ||
151 | DTLS1_BITMAP next_bitmap; | ||
152 | |||
153 | /* handshake message numbers */ | ||
154 | unsigned short handshake_write_seq; | ||
155 | unsigned short next_handshake_write_seq; | ||
156 | |||
157 | unsigned short handshake_read_seq; | ||
158 | |||
159 | /* Received handshake records (processed and unprocessed) */ | ||
160 | record_pqueue unprocessed_rcds; | ||
161 | record_pqueue processed_rcds; | ||
162 | |||
163 | /* Buffered handshake messages */ | ||
164 | struct _pqueue *buffered_messages; | ||
165 | |||
166 | /* Buffered application records. | ||
167 | * Only for records between CCS and Finished | ||
168 | * to prevent either protocol violation or | ||
169 | * unnecessary message loss. | ||
170 | */ | ||
171 | record_pqueue buffered_app_data; | ||
172 | |||
173 | /* Is set when listening for new connections with dtls1_listen() */ | ||
174 | unsigned int listen; | ||
175 | |||
176 | unsigned int mtu; /* max DTLS packet size */ | ||
177 | |||
178 | struct hm_header_st w_msg_hdr; | ||
179 | struct hm_header_st r_msg_hdr; | ||
180 | |||
181 | struct dtls1_timeout_st timeout; | ||
182 | |||
183 | /* storage for Alert/Handshake protocol data received but not | ||
184 | * yet processed by ssl3_read_bytes: */ | ||
185 | unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH]; | ||
186 | unsigned int alert_fragment_len; | ||
187 | unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH]; | ||
188 | unsigned int handshake_fragment_len; | ||
189 | |||
190 | unsigned int retransmitting; | ||
191 | unsigned int change_cipher_spec_ok; | ||
192 | } DTLS1_STATE_INTERNAL; | ||
193 | #define D1I(s) (s->d1->internal) | ||
194 | |||
195 | typedef struct dtls1_state_st { | ||
196 | /* Buffered (sent) handshake records */ | ||
197 | struct _pqueue *sent_messages; | ||
198 | |||
199 | /* Indicates when the last handshake msg or heartbeat sent will timeout */ | ||
200 | struct timeval next_timeout; | ||
201 | |||
202 | /* Timeout duration */ | ||
203 | unsigned short timeout_duration; | ||
204 | |||
205 | struct dtls1_state_internal_st *internal; | ||
206 | } DTLS1_STATE; | ||
207 | |||
208 | int dtls1_do_write(SSL *s, int type); | ||
209 | int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek); | ||
210 | void dtls1_set_message_header(SSL *s, unsigned char mt, unsigned long len, | ||
211 | unsigned long frag_off, unsigned long frag_len); | ||
212 | void dtls1_set_message_header_int(SSL *s, unsigned char mt, | ||
213 | unsigned long len, unsigned short seq_num, unsigned long frag_off, | ||
214 | unsigned long frag_len); | ||
215 | |||
216 | int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf, int len); | ||
217 | int dtls1_write_bytes(SSL *s, int type, const void *buf, int len); | ||
218 | |||
219 | int dtls1_read_failed(SSL *s, int code); | ||
220 | int dtls1_buffer_message(SSL *s, int ccs); | ||
221 | int dtls1_retransmit_message(SSL *s, unsigned short seq, | ||
222 | unsigned long frag_off, int *found); | ||
223 | int dtls1_get_queue_priority(unsigned short seq, int is_ccs); | ||
224 | int dtls1_retransmit_buffered_messages(SSL *s); | ||
225 | void dtls1_clear_record_buffer(SSL *s); | ||
226 | int dtls1_get_message_header(unsigned char *data, | ||
227 | struct hm_header_st *msg_hdr); | ||
228 | void dtls1_get_ccs_header(unsigned char *data, struct ccs_header_st *ccs_hdr); | ||
229 | void dtls1_reset_read_seq_numbers(SSL *s); | ||
230 | struct timeval* dtls1_get_timeout(SSL *s, struct timeval* timeleft); | ||
231 | int dtls1_check_timeout_num(SSL *s); | ||
232 | int dtls1_handle_timeout(SSL *s); | ||
233 | const SSL_CIPHER *dtls1_get_cipher(unsigned int u); | ||
234 | void dtls1_start_timer(SSL *s); | ||
235 | void dtls1_stop_timer(SSL *s); | ||
236 | int dtls1_is_timer_expired(SSL *s); | ||
237 | void dtls1_double_timeout(SSL *s); | ||
238 | unsigned int dtls1_min_mtu(void); | ||
239 | |||
240 | int dtls1_new(SSL *s); | ||
241 | void dtls1_free(SSL *s); | ||
242 | void dtls1_clear(SSL *s); | ||
243 | long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg); | ||
244 | |||
245 | long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); | ||
246 | int dtls1_get_record(SSL *s); | ||
247 | int dtls1_dispatch_alert(SSL *s); | ||
248 | |||
249 | __END_HIDDEN_DECLS | ||
250 | |||
251 | #endif | ||
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c index 2867d32deb..f056c3bae4 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.209 2021/05/16 08:24:21 jsing Exp $ */ | 1 | /* $OpenBSD: s3_lib.c,v 1.210 2021/05/16 13:56:30 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 | * |
@@ -158,8 +158,9 @@ | |||
158 | #include <openssl/objects.h> | 158 | #include <openssl/objects.h> |
159 | #include <openssl/opensslconf.h> | 159 | #include <openssl/opensslconf.h> |
160 | 160 | ||
161 | #include "ssl_locl.h" | ||
162 | #include "bytestring.h" | 161 | #include "bytestring.h" |
162 | #include "dtls_locl.h" | ||
163 | #include "ssl_locl.h" | ||
163 | 164 | ||
164 | #define SSL3_NUM_CIPHERS (sizeof(ssl3_ciphers) / sizeof(SSL_CIPHER)) | 165 | #define SSL3_NUM_CIPHERS (sizeof(ssl3_ciphers) / sizeof(SSL_CIPHER)) |
165 | 166 | ||
diff --git a/src/lib/libssl/ssl_both.c b/src/lib/libssl/ssl_both.c index c133449a6d..40dddd0805 100644 --- a/src/lib/libssl/ssl_both.c +++ b/src/lib/libssl/ssl_both.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_both.c,v 1.30 2021/05/02 15:55:29 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_both.c,v 1.31 2021/05/16 13:56:30 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 | * |
@@ -118,14 +118,14 @@ | |||
118 | #include <stdio.h> | 118 | #include <stdio.h> |
119 | #include <string.h> | 119 | #include <string.h> |
120 | 120 | ||
121 | #include "ssl_locl.h" | ||
122 | |||
123 | #include <openssl/buffer.h> | 121 | #include <openssl/buffer.h> |
124 | #include <openssl/evp.h> | 122 | #include <openssl/evp.h> |
125 | #include <openssl/objects.h> | 123 | #include <openssl/objects.h> |
126 | #include <openssl/x509.h> | 124 | #include <openssl/x509.h> |
127 | 125 | ||
128 | #include "bytestring.h" | 126 | #include "bytestring.h" |
127 | #include "dtls_locl.h" | ||
128 | #include "ssl_locl.h" | ||
129 | 129 | ||
130 | /* | 130 | /* |
131 | * Send s->internal->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or | 131 | * Send s->internal->init_buf in records of type 'type' (SSL3_RT_HANDSHAKE or |
diff --git a/src/lib/libssl/ssl_clnt.c b/src/lib/libssl/ssl_clnt.c index 8520bb7c05..abfe5c7d60 100644 --- a/src/lib/libssl/ssl_clnt.c +++ b/src/lib/libssl/ssl_clnt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_clnt.c,v 1.97 2021/05/16 08:24:21 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_clnt.c,v 1.98 2021/05/16 13:56:30 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 | * |
@@ -171,6 +171,7 @@ | |||
171 | #endif | 171 | #endif |
172 | 172 | ||
173 | #include "bytestring.h" | 173 | #include "bytestring.h" |
174 | #include "dtls_locl.h" | ||
174 | #include "ssl_sigalgs.h" | 175 | #include "ssl_sigalgs.h" |
175 | #include "ssl_tlsext.h" | 176 | #include "ssl_tlsext.h" |
176 | 177 | ||
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index 3cb64cfb16..c6c499eb02 100644 --- a/src/lib/libssl/ssl_lib.c +++ b/src/lib/libssl/ssl_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_lib.c,v 1.257 2021/05/16 08:24:21 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.258 2021/05/16 13:56:31 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 | * |
@@ -161,6 +161,7 @@ | |||
161 | #endif | 161 | #endif |
162 | 162 | ||
163 | #include "bytestring.h" | 163 | #include "bytestring.h" |
164 | #include "dtls_locl.h" | ||
164 | #include "ssl_sigalgs.h" | 165 | #include "ssl_sigalgs.h" |
165 | 166 | ||
166 | const char *SSL_version_str = OPENSSL_VERSION_TEXT; | 167 | const char *SSL_version_str = OPENSSL_VERSION_TEXT; |
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h index 52daec611f..2e324e5d31 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.345 2021/05/16 10:55:17 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_locl.h,v 1.346 2021/05/16 13:56:31 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 | * |
@@ -979,74 +979,6 @@ typedef struct ssl3_state_internal_st { | |||
979 | } SSL3_STATE_INTERNAL; | 979 | } SSL3_STATE_INTERNAL; |
980 | #define S3I(s) (s->s3->internal) | 980 | #define S3I(s) (s->s3->internal) |
981 | 981 | ||
982 | typedef struct dtls1_record_data_internal_st { | ||
983 | unsigned char *packet; | ||
984 | unsigned int packet_length; | ||
985 | SSL3_BUFFER_INTERNAL rbuf; | ||
986 | SSL3_RECORD_INTERNAL rrec; | ||
987 | } DTLS1_RECORD_DATA_INTERNAL; | ||
988 | |||
989 | typedef struct dtls1_state_internal_st { | ||
990 | unsigned int send_cookie; | ||
991 | unsigned char cookie[DTLS1_COOKIE_LENGTH]; | ||
992 | unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH]; | ||
993 | unsigned int cookie_len; | ||
994 | |||
995 | /* | ||
996 | * The current data and handshake epoch. This is initially | ||
997 | * undefined, and starts at zero once the initial handshake is | ||
998 | * completed | ||
999 | */ | ||
1000 | unsigned short r_epoch; | ||
1001 | |||
1002 | /* records being received in the current epoch */ | ||
1003 | DTLS1_BITMAP bitmap; | ||
1004 | |||
1005 | /* renegotiation starts a new set of sequence numbers */ | ||
1006 | DTLS1_BITMAP next_bitmap; | ||
1007 | |||
1008 | /* handshake message numbers */ | ||
1009 | unsigned short handshake_write_seq; | ||
1010 | unsigned short next_handshake_write_seq; | ||
1011 | |||
1012 | unsigned short handshake_read_seq; | ||
1013 | |||
1014 | /* Received handshake records (processed and unprocessed) */ | ||
1015 | record_pqueue unprocessed_rcds; | ||
1016 | record_pqueue processed_rcds; | ||
1017 | |||
1018 | /* Buffered handshake messages */ | ||
1019 | struct _pqueue *buffered_messages; | ||
1020 | |||
1021 | /* Buffered application records. | ||
1022 | * Only for records between CCS and Finished | ||
1023 | * to prevent either protocol violation or | ||
1024 | * unnecessary message loss. | ||
1025 | */ | ||
1026 | record_pqueue buffered_app_data; | ||
1027 | |||
1028 | /* Is set when listening for new connections with dtls1_listen() */ | ||
1029 | unsigned int listen; | ||
1030 | |||
1031 | unsigned int mtu; /* max DTLS packet size */ | ||
1032 | |||
1033 | struct hm_header_st w_msg_hdr; | ||
1034 | struct hm_header_st r_msg_hdr; | ||
1035 | |||
1036 | struct dtls1_timeout_st timeout; | ||
1037 | |||
1038 | /* storage for Alert/Handshake protocol data received but not | ||
1039 | * yet processed by ssl3_read_bytes: */ | ||
1040 | unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH]; | ||
1041 | unsigned int alert_fragment_len; | ||
1042 | unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH]; | ||
1043 | unsigned int handshake_fragment_len; | ||
1044 | |||
1045 | unsigned int retransmitting; | ||
1046 | unsigned int change_cipher_spec_ok; | ||
1047 | } DTLS1_STATE_INTERNAL; | ||
1048 | #define D1I(s) (s->d1->internal) | ||
1049 | |||
1050 | typedef struct cert_st { | 982 | typedef struct cert_st { |
1051 | /* Current active set */ | 983 | /* Current active set */ |
1052 | CERT_PKEY *key; /* ALWAYS points to an element of the pkeys array | 984 | CERT_PKEY *key; /* ALWAYS points to an element of the pkeys array |
@@ -1270,42 +1202,11 @@ int ssl3_record_write(SSL *s, int type); | |||
1270 | 1202 | ||
1271 | int ssl3_do_change_cipher_spec(SSL *ssl); | 1203 | int ssl3_do_change_cipher_spec(SSL *ssl); |
1272 | 1204 | ||
1273 | int dtls1_do_write(SSL *s, int type); | ||
1274 | int ssl3_packet_read(SSL *s, int plen); | 1205 | int ssl3_packet_read(SSL *s, int plen); |
1275 | int ssl3_packet_extend(SSL *s, int plen); | 1206 | int ssl3_packet_extend(SSL *s, int plen); |
1276 | int ssl_server_legacy_first_packet(SSL *s); | 1207 | int ssl_server_legacy_first_packet(SSL *s); |
1277 | int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek); | ||
1278 | int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, | 1208 | int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, |
1279 | unsigned int len); | 1209 | unsigned int len); |
1280 | void dtls1_set_message_header(SSL *s, unsigned char mt, unsigned long len, | ||
1281 | unsigned long frag_off, unsigned long frag_len); | ||
1282 | void dtls1_set_message_header_int(SSL *s, unsigned char mt, | ||
1283 | unsigned long len, unsigned short seq_num, unsigned long frag_off, | ||
1284 | unsigned long frag_len); | ||
1285 | |||
1286 | int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf, int len); | ||
1287 | int dtls1_write_bytes(SSL *s, int type, const void *buf, int len); | ||
1288 | |||
1289 | int dtls1_read_failed(SSL *s, int code); | ||
1290 | int dtls1_buffer_message(SSL *s, int ccs); | ||
1291 | int dtls1_retransmit_message(SSL *s, unsigned short seq, | ||
1292 | unsigned long frag_off, int *found); | ||
1293 | int dtls1_get_queue_priority(unsigned short seq, int is_ccs); | ||
1294 | int dtls1_retransmit_buffered_messages(SSL *s); | ||
1295 | void dtls1_clear_record_buffer(SSL *s); | ||
1296 | int dtls1_get_message_header(unsigned char *data, | ||
1297 | struct hm_header_st *msg_hdr); | ||
1298 | void dtls1_get_ccs_header(unsigned char *data, struct ccs_header_st *ccs_hdr); | ||
1299 | void dtls1_reset_read_seq_numbers(SSL *s); | ||
1300 | struct timeval* dtls1_get_timeout(SSL *s, struct timeval* timeleft); | ||
1301 | int dtls1_check_timeout_num(SSL *s); | ||
1302 | int dtls1_handle_timeout(SSL *s); | ||
1303 | const SSL_CIPHER *dtls1_get_cipher(unsigned int u); | ||
1304 | void dtls1_start_timer(SSL *s); | ||
1305 | void dtls1_stop_timer(SSL *s); | ||
1306 | int dtls1_is_timer_expired(SSL *s); | ||
1307 | void dtls1_double_timeout(SSL *s); | ||
1308 | unsigned int dtls1_min_mtu(void); | ||
1309 | 1210 | ||
1310 | /* some client-only functions */ | 1211 | /* some client-only functions */ |
1311 | int ssl3_send_client_hello(SSL *s); | 1212 | int ssl3_send_client_hello(SSL *s); |
@@ -1347,15 +1248,6 @@ int tls1_new(SSL *s); | |||
1347 | void tls1_free(SSL *s); | 1248 | void tls1_free(SSL *s); |
1348 | void tls1_clear(SSL *s); | 1249 | void tls1_clear(SSL *s); |
1349 | 1250 | ||
1350 | int dtls1_new(SSL *s); | ||
1351 | void dtls1_free(SSL *s); | ||
1352 | void dtls1_clear(SSL *s); | ||
1353 | long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg); | ||
1354 | |||
1355 | long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok); | ||
1356 | int dtls1_get_record(SSL *s); | ||
1357 | int dtls1_dispatch_alert(SSL *s); | ||
1358 | |||
1359 | int ssl_init_wbio_buffer(SSL *s, int push); | 1251 | int ssl_init_wbio_buffer(SSL *s, int push); |
1360 | void ssl_free_wbio_buffer(SSL *s); | 1252 | void ssl_free_wbio_buffer(SSL *s); |
1361 | 1253 | ||
diff --git a/src/lib/libssl/ssl_methods.c b/src/lib/libssl/ssl_methods.c index a3e51ac0d0..f1a59cd738 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.24 2021/03/31 16:59:32 tb Exp $ */ | 1 | /* $OpenBSD: ssl_methods.c,v 1.25 2021/05/16 13:56:31 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 | * |
@@ -56,6 +56,7 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include "dtls_locl.h" | ||
59 | #include "ssl_locl.h" | 60 | #include "ssl_locl.h" |
60 | #include "tls13_internal.h" | 61 | #include "tls13_internal.h" |
61 | 62 | ||
diff --git a/src/lib/libssl/ssl_srvr.c b/src/lib/libssl/ssl_srvr.c index 5891424b26..1d63c21af1 100644 --- a/src/lib/libssl/ssl_srvr.c +++ b/src/lib/libssl/ssl_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_srvr.c,v 1.109 2021/05/16 08:24:21 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_srvr.c,v 1.110 2021/05/16 13:56:31 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 | * |
@@ -168,6 +168,7 @@ | |||
168 | #endif | 168 | #endif |
169 | 169 | ||
170 | #include "bytestring.h" | 170 | #include "bytestring.h" |
171 | #include "dtls_locl.h" | ||
171 | #include "ssl_sigalgs.h" | 172 | #include "ssl_sigalgs.h" |
172 | #include "ssl_tlsext.h" | 173 | #include "ssl_tlsext.h" |
173 | 174 | ||
diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c index 9cd0c331c1..9dc4a0bfb4 100644 --- a/src/lib/libssl/t1_enc.c +++ b/src/lib/libssl/t1_enc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: t1_enc.c,v 1.145 2021/05/16 08:24:21 jsing Exp $ */ | 1 | /* $OpenBSD: t1_enc.c,v 1.146 2021/05/16 13:56:31 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 | * |
@@ -145,6 +145,8 @@ | |||
145 | #include <openssl/md5.h> | 145 | #include <openssl/md5.h> |
146 | #include <openssl/opensslconf.h> | 146 | #include <openssl/opensslconf.h> |
147 | 147 | ||
148 | #include "dtls_locl.h" | ||
149 | |||
148 | void | 150 | void |
149 | tls1_cleanup_key_block(SSL *s) | 151 | tls1_cleanup_key_block(SSL *s) |
150 | { | 152 | { |