summaryrefslogtreecommitdiff
path: root/src/lib/libssl/dtls_locl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/dtls_locl.h')
-rw-r--r--src/lib/libssl/dtls_locl.h246
1 files changed, 0 insertions, 246 deletions
diff --git a/src/lib/libssl/dtls_locl.h b/src/lib/libssl/dtls_locl.h
deleted file mode 100644
index 97f05b26bd..0000000000
--- a/src/lib/libssl/dtls_locl.h
+++ /dev/null
@@ -1,246 +0,0 @@
1/* $OpenBSD: dtls_locl.h,v 1.4 2021/07/26 03:17:38 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
71typedef 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
79struct 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
86struct 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
96struct dtls1_timeout_st {
97 /* Number of read timeouts so far */
98 unsigned int read_timeouts;
99
100 /* Number of write timeouts so far */
101 unsigned int write_timeouts;
102
103 /* Number of alerts received so far */
104 unsigned int num_alerts;
105};
106
107struct _pqueue;
108
109typedef struct record_pqueue_st {
110 unsigned short epoch;
111 struct _pqueue *q;
112} record_pqueue;
113
114typedef struct hm_fragment_st {
115 struct hm_header_st msg_header;
116 unsigned char *fragment;
117 unsigned char *reassembly;
118} hm_fragment;
119
120typedef struct dtls1_record_data_internal_st {
121 unsigned char *packet;
122 unsigned int packet_length;
123 SSL3_BUFFER_INTERNAL rbuf;
124 SSL3_RECORD_INTERNAL rrec;
125} DTLS1_RECORD_DATA_INTERNAL;
126
127struct dtls1_state_internal_st;
128
129typedef struct dtls1_state_internal_st {
130 unsigned int send_cookie;
131 unsigned char cookie[DTLS1_COOKIE_LENGTH];
132 unsigned char rcvd_cookie[DTLS1_COOKIE_LENGTH];
133 unsigned int cookie_len;
134
135 /*
136 * The current data and handshake epoch. This is initially
137 * undefined, and starts at zero once the initial handshake is
138 * completed
139 */
140 unsigned short r_epoch;
141
142 /* records being received in the current epoch */
143 DTLS1_BITMAP bitmap;
144
145 /* renegotiation starts a new set of sequence numbers */
146 DTLS1_BITMAP next_bitmap;
147
148 /* handshake message numbers */
149 unsigned short handshake_write_seq;
150 unsigned short next_handshake_write_seq;
151
152 unsigned short handshake_read_seq;
153
154 /* Received handshake records (unprocessed) */
155 record_pqueue unprocessed_rcds;
156
157 /* Buffered handshake messages */
158 struct _pqueue *buffered_messages;
159
160 /* Buffered application records.
161 * Only for records between CCS and Finished
162 * to prevent either protocol violation or
163 * unnecessary message loss.
164 */
165 record_pqueue buffered_app_data;
166
167 /* Is set when listening for new connections with dtls1_listen() */
168 unsigned int listen;
169
170 unsigned int mtu; /* max DTLS packet size */
171
172 struct hm_header_st w_msg_hdr;
173 struct hm_header_st r_msg_hdr;
174
175 struct dtls1_timeout_st timeout;
176
177 /* storage for Alert/Handshake protocol data received but not
178 * yet processed by ssl3_read_bytes: */
179 unsigned char alert_fragment[DTLS1_AL_HEADER_LENGTH];
180 unsigned int alert_fragment_len;
181 unsigned char handshake_fragment[DTLS1_HM_HEADER_LENGTH];
182 unsigned int handshake_fragment_len;
183
184 unsigned int retransmitting;
185 unsigned int change_cipher_spec_ok;
186} DTLS1_STATE_INTERNAL;
187#define D1I(s) (s->d1->internal)
188
189typedef struct dtls1_state_st {
190 /* Buffered (sent) handshake records */
191 struct _pqueue *sent_messages;
192
193 /* Indicates when the last handshake msg or heartbeat sent will timeout */
194 struct timeval next_timeout;
195
196 /* Timeout duration */
197 unsigned short timeout_duration;
198
199 struct dtls1_state_internal_st *internal;
200} DTLS1_STATE;
201
202int dtls1_do_write(SSL *s, int type);
203int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek);
204void dtls1_set_message_header(SSL *s, unsigned char mt, unsigned long len,
205 unsigned long frag_off, unsigned long frag_len);
206void dtls1_set_message_header_int(SSL *s, unsigned char mt,
207 unsigned long len, unsigned short seq_num, unsigned long frag_off,
208 unsigned long frag_len);
209
210int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
211 unsigned int len);
212
213int dtls1_write_app_data_bytes(SSL *s, int type, const void *buf, int len);
214int dtls1_write_bytes(SSL *s, int type, const void *buf, int len);
215
216int dtls1_read_failed(SSL *s, int code);
217int dtls1_buffer_message(SSL *s, int ccs);
218int dtls1_retransmit_message(SSL *s, unsigned short seq,
219 unsigned long frag_off, int *found);
220int dtls1_get_queue_priority(unsigned short seq, int is_ccs);
221int dtls1_retransmit_buffered_messages(SSL *s);
222void dtls1_clear_record_buffer(SSL *s);
223int dtls1_get_message_header(unsigned char *data,
224 struct hm_header_st *msg_hdr);
225void dtls1_reset_read_seq_numbers(SSL *s);
226struct timeval* dtls1_get_timeout(SSL *s, struct timeval* timeleft);
227int dtls1_check_timeout_num(SSL *s);
228int dtls1_handle_timeout(SSL *s);
229const SSL_CIPHER *dtls1_get_cipher(unsigned int u);
230void dtls1_start_timer(SSL *s);
231void dtls1_stop_timer(SSL *s);
232int dtls1_is_timer_expired(SSL *s);
233void dtls1_double_timeout(SSL *s);
234unsigned int dtls1_min_mtu(void);
235
236int dtls1_new(SSL *s);
237void dtls1_free(SSL *s);
238void dtls1_clear(SSL *s);
239long dtls1_ctrl(SSL *s, int cmd, long larg, void *parg);
240
241long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok);
242int dtls1_get_record(SSL *s);
243
244__END_HIDDEN_DECLS
245
246#endif