summaryrefslogtreecommitdiff
path: root/src/lib/libssl/d1_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/d1_lib.c')
-rw-r--r--src/lib/libssl/d1_lib.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/src/lib/libssl/d1_lib.c b/src/lib/libssl/d1_lib.c
index 3bc1b42583..697cb434f7 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.35 2017/01/22 03:50:45 jsing Exp $ */ 1/* $OpenBSD: d1_lib.c,v 1.36 2017/01/22 07:16:38 beck 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.
@@ -117,24 +117,24 @@ dtls1_new(SSL *s)
117 117
118 /* d1->handshake_epoch=0; */ 118 /* d1->handshake_epoch=0; */
119 119
120 d1->unprocessed_rcds.q = pqueue_new(); 120 d1->internal->unprocessed_rcds.q = pqueue_new();
121 d1->processed_rcds.q = pqueue_new(); 121 d1->internal->processed_rcds.q = pqueue_new();
122 d1->buffered_messages = pqueue_new(); 122 d1->internal->buffered_messages = pqueue_new();
123 d1->sent_messages = pqueue_new(); 123 d1->sent_messages = pqueue_new();
124 d1->buffered_app_data.q = pqueue_new(); 124 d1->internal->buffered_app_data.q = pqueue_new();
125 125
126 if (s->server) { 126 if (s->server) {
127 d1->cookie_len = sizeof(s->d1->cookie); 127 d1->internal->cookie_len = sizeof(D1I(s)->cookie);
128 } 128 }
129 129
130 if (!d1->unprocessed_rcds.q || !d1->processed_rcds.q || 130 if (!d1->internal->unprocessed_rcds.q || !d1->internal->processed_rcds.q ||
131 !d1->buffered_messages || !d1->sent_messages || 131 !d1->internal->buffered_messages || !d1->sent_messages ||
132 !d1->buffered_app_data.q) { 132 !d1->internal->buffered_app_data.q) {
133 pqueue_free(d1->unprocessed_rcds.q); 133 pqueue_free(d1->internal->unprocessed_rcds.q);
134 pqueue_free(d1->processed_rcds.q); 134 pqueue_free(d1->internal->processed_rcds.q);
135 pqueue_free(d1->buffered_messages); 135 pqueue_free(d1->internal->buffered_messages);
136 pqueue_free(d1->sent_messages); 136 pqueue_free(d1->sent_messages);
137 pqueue_free(d1->buffered_app_data.q); 137 pqueue_free(d1->internal->buffered_app_data.q);
138 free(d1); 138 free(d1);
139 ssl3_free(s); 139 ssl3_free(s);
140 return (0); 140 return (0);
@@ -152,21 +152,21 @@ dtls1_clear_queues(SSL *s)
152 hm_fragment *frag = NULL; 152 hm_fragment *frag = NULL;
153 DTLS1_RECORD_DATA *rdata; 153 DTLS1_RECORD_DATA *rdata;
154 154
155 while ((item = pqueue_pop(s->d1->unprocessed_rcds.q)) != NULL) { 155 while ((item = pqueue_pop(D1I(s)->unprocessed_rcds.q)) != NULL) {
156 rdata = (DTLS1_RECORD_DATA *) item->data; 156 rdata = (DTLS1_RECORD_DATA *) item->data;
157 free(rdata->rbuf.buf); 157 free(rdata->rbuf.buf);
158 free(item->data); 158 free(item->data);
159 pitem_free(item); 159 pitem_free(item);
160 } 160 }
161 161
162 while ((item = pqueue_pop(s->d1->processed_rcds.q)) != NULL) { 162 while ((item = pqueue_pop(D1I(s)->processed_rcds.q)) != NULL) {
163 rdata = (DTLS1_RECORD_DATA *) item->data; 163 rdata = (DTLS1_RECORD_DATA *) item->data;
164 free(rdata->rbuf.buf); 164 free(rdata->rbuf.buf);
165 free(item->data); 165 free(item->data);
166 pitem_free(item); 166 pitem_free(item);
167 } 167 }
168 168
169 while ((item = pqueue_pop(s->d1->buffered_messages)) != NULL) { 169 while ((item = pqueue_pop(D1I(s)->buffered_messages)) != NULL) {
170 frag = (hm_fragment *)item->data; 170 frag = (hm_fragment *)item->data;
171 free(frag->fragment); 171 free(frag->fragment);
172 free(frag); 172 free(frag);
@@ -180,7 +180,7 @@ dtls1_clear_queues(SSL *s)
180 pitem_free(item); 180 pitem_free(item);
181 } 181 }
182 182
183 while ((item = pqueue_pop(s->d1->buffered_app_data.q)) != NULL) { 183 while ((item = pqueue_pop(D1I(s)->buffered_app_data.q)) != NULL) {
184 rdata = (DTLS1_RECORD_DATA *) item->data; 184 rdata = (DTLS1_RECORD_DATA *) item->data;
185 free(rdata->rbuf.buf); 185 free(rdata->rbuf.buf);
186 free(item->data); 186 free(item->data);
@@ -198,11 +198,11 @@ dtls1_free(SSL *s)
198 198
199 dtls1_clear_queues(s); 199 dtls1_clear_queues(s);
200 200
201 pqueue_free(s->d1->unprocessed_rcds.q); 201 pqueue_free(D1I(s)->unprocessed_rcds.q);
202 pqueue_free(s->d1->processed_rcds.q); 202 pqueue_free(D1I(s)->processed_rcds.q);
203 pqueue_free(s->d1->buffered_messages); 203 pqueue_free(D1I(s)->buffered_messages);
204 pqueue_free(s->d1->sent_messages); 204 pqueue_free(s->d1->sent_messages);
205 pqueue_free(s->d1->buffered_app_data.q); 205 pqueue_free(D1I(s)->buffered_app_data.q);
206 206
207 explicit_bzero(s->d1->internal, sizeof(*s->d1->internal)); 207 explicit_bzero(s->d1->internal, sizeof(*s->d1->internal));
208 free(s->d1->internal); 208 free(s->d1->internal);
@@ -225,12 +225,12 @@ dtls1_clear(SSL *s)
225 unsigned int mtu; 225 unsigned int mtu;
226 226
227 if (s->d1) { 227 if (s->d1) {
228 unprocessed_rcds = s->d1->unprocessed_rcds.q; 228 unprocessed_rcds = D1I(s)->unprocessed_rcds.q;
229 processed_rcds = s->d1->processed_rcds.q; 229 processed_rcds = D1I(s)->processed_rcds.q;
230 buffered_messages = s->d1->buffered_messages; 230 buffered_messages = D1I(s)->buffered_messages;
231 sent_messages = s->d1->sent_messages; 231 sent_messages = s->d1->sent_messages;
232 buffered_app_data = s->d1->buffered_app_data.q; 232 buffered_app_data = D1I(s)->buffered_app_data.q;
233 mtu = s->d1->mtu; 233 mtu = D1I(s)->mtu;
234 234
235 dtls1_clear_queues(s); 235 dtls1_clear_queues(s);
236 236
@@ -240,18 +240,18 @@ dtls1_clear(SSL *s)
240 s->d1->internal = internal; 240 s->d1->internal = internal;
241 241
242 if (s->server) { 242 if (s->server) {
243 s->d1->cookie_len = sizeof(s->d1->cookie); 243 D1I(s)->cookie_len = sizeof(D1I(s)->cookie);
244 } 244 }
245 245
246 if (SSL_get_options(s) & SSL_OP_NO_QUERY_MTU) { 246 if (SSL_get_options(s) & SSL_OP_NO_QUERY_MTU) {
247 s->d1->mtu = mtu; 247 D1I(s)->mtu = mtu;
248 } 248 }
249 249
250 s->d1->unprocessed_rcds.q = unprocessed_rcds; 250 D1I(s)->unprocessed_rcds.q = unprocessed_rcds;
251 s->d1->processed_rcds.q = processed_rcds; 251 D1I(s)->processed_rcds.q = processed_rcds;
252 s->d1->buffered_messages = buffered_messages; 252 D1I(s)->buffered_messages = buffered_messages;
253 s->d1->sent_messages = sent_messages; 253 s->d1->sent_messages = sent_messages;
254 s->d1->buffered_app_data.q = buffered_app_data; 254 D1I(s)->buffered_app_data.q = buffered_app_data;
255 } 255 }
256 256
257 ssl3_clear(s); 257 ssl3_clear(s);
@@ -319,7 +319,7 @@ dtls1_start_timer(SSL *s)
319 /* Add duration to current time */ 319 /* Add duration to current time */
320 s->d1->next_timeout.tv_sec += s->d1->timeout_duration; 320 s->d1->next_timeout.tv_sec += s->d1->timeout_duration;
321 BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0, 321 BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0,
322 &(s->d1->next_timeout)); 322 &s->d1->next_timeout);
323} 323}
324 324
325struct timeval* 325struct timeval*
@@ -396,7 +396,7 @@ void
396dtls1_stop_timer(SSL *s) 396dtls1_stop_timer(SSL *s)
397{ 397{
398 /* Reset everything */ 398 /* Reset everything */
399 memset(&(s->d1->timeout), 0, sizeof(struct dtls1_timeout_st)); 399 memset(&(D1I(s)->timeout), 0, sizeof(struct dtls1_timeout_st));
400 memset(&(s->d1->next_timeout), 0, sizeof(struct timeval)); 400 memset(&(s->d1->next_timeout), 0, sizeof(struct timeval));
401 s->d1->timeout_duration = 1; 401 s->d1->timeout_duration = 1;
402 BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0, 402 BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0,
@@ -408,16 +408,16 @@ dtls1_stop_timer(SSL *s)
408int 408int
409dtls1_check_timeout_num(SSL *s) 409dtls1_check_timeout_num(SSL *s)
410{ 410{
411 s->d1->timeout.num_alerts++; 411 D1I(s)->timeout.num_alerts++;
412 412
413 /* Reduce MTU after 2 unsuccessful retransmissions */ 413 /* Reduce MTU after 2 unsuccessful retransmissions */
414 if (s->d1->timeout.num_alerts > 2) { 414 if (D1I(s)->timeout.num_alerts > 2) {
415 s->d1->mtu = BIO_ctrl(SSL_get_wbio(s), 415 D1I(s)->mtu = BIO_ctrl(SSL_get_wbio(s),
416 BIO_CTRL_DGRAM_GET_FALLBACK_MTU, 0, NULL); 416 BIO_CTRL_DGRAM_GET_FALLBACK_MTU, 0, NULL);
417 417
418 } 418 }
419 419
420 if (s->d1->timeout.num_alerts > DTLS1_TMO_ALERT_COUNT) { 420 if (D1I(s)->timeout.num_alerts > DTLS1_TMO_ALERT_COUNT) {
421 /* fail the connection, enough alerts have been sent */ 421 /* fail the connection, enough alerts have been sent */
422 SSLerr(SSL_F_DTLS1_CHECK_TIMEOUT_NUM, SSL_R_READ_TIMEOUT_EXPIRED); 422 SSLerr(SSL_F_DTLS1_CHECK_TIMEOUT_NUM, SSL_R_READ_TIMEOUT_EXPIRED);
423 return -1; 423 return -1;
@@ -439,9 +439,9 @@ dtls1_handle_timeout(SSL *s)
439 if (dtls1_check_timeout_num(s) < 0) 439 if (dtls1_check_timeout_num(s) < 0)
440 return -1; 440 return -1;
441 441
442 s->d1->timeout.read_timeouts++; 442 D1I(s)->timeout.read_timeouts++;
443 if (s->d1->timeout.read_timeouts > DTLS1_TMO_READ_COUNT) { 443 if (D1I(s)->timeout.read_timeouts > DTLS1_TMO_READ_COUNT) {
444 s->d1->timeout.read_timeouts = 1; 444 D1I(s)->timeout.read_timeouts = 1;
445 } 445 }
446 446
447 dtls1_start_timer(s); 447 dtls1_start_timer(s);
@@ -457,7 +457,7 @@ dtls1_listen(SSL *s, struct sockaddr *client)
457 SSL_clear(s); 457 SSL_clear(s);
458 458
459 SSL_set_options(s, SSL_OP_COOKIE_EXCHANGE); 459 SSL_set_options(s, SSL_OP_COOKIE_EXCHANGE);
460 s->d1->listen = 1; 460 D1I(s)->listen = 1;
461 461
462 ret = SSL_accept(s); 462 ret = SSL_accept(s);
463 if (ret <= 0) 463 if (ret <= 0)