OpenCoverage

rec_layer_d1.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/ssl/record/rec_layer_d1.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2005-2018 The OpenSSL Project Authors. All Rights Reserved.-
3 *-
4 * Licensed under the OpenSSL license (the "License"). You may not use-
5 * this file except in compliance with the License. You can obtain a copy-
6 * in the file LICENSE in the source distribution or at-
7 * https://www.openssl.org/source/license.html-
8 */-
9-
10#include <stdio.h>-
11#include <errno.h>-
12#include "../ssl_locl.h"-
13#include <openssl/evp.h>-
14#include <openssl/buffer.h>-
15#include "record_locl.h"-
16#include "../packet_locl.h"-
17#include "internal/cryptlib.h"-
18-
19int DTLS_RECORD_LAYER_new(RECORD_LAYER *rl)-
20{-
21 DTLS_RECORD_LAYER *d;-
22-
23 if ((d = OPENSSL_malloc(sizeof(*d))) == NULL) {
(d = CRYPTO_ma...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 373 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-373
24 SSLerr(SSL_F_DTLS_RECORD_LAYER_NEW, ERR_R_MALLOC_FAILURE);-
25 return 0;
never executed: return 0;
0
26 }-
27-
28 rl->d = d;-
29-
30 d->unprocessed_rcds.q = pqueue_new();-
31 d->processed_rcds.q = pqueue_new();-
32 d->buffered_app_data.q = pqueue_new();-
33-
34 if (d->unprocessed_rcds.q == NULL || d->processed_rcds.q == NULL
d->unprocessed...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 373 times by 1 test
Evaluated by:
  • libssl.so.1.1
d->processed_r...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 373 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-373
35 || d->buffered_app_data.q == NULL) {
d->buffered_ap...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 373 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-373
36 pqueue_free(d->unprocessed_rcds.q);-
37 pqueue_free(d->processed_rcds.q);-
38 pqueue_free(d->buffered_app_data.q);-
39 OPENSSL_free(d);-
40 rl->d = NULL;-
41 return 0;
never executed: return 0;
0
42 }-
43-
44 return 1;
executed 373 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
373
45}-
46-
47void DTLS_RECORD_LAYER_free(RECORD_LAYER *rl)-
48{-
49 DTLS_RECORD_LAYER_clear(rl);-
50 pqueue_free(rl->d->unprocessed_rcds.q);-
51 pqueue_free(rl->d->processed_rcds.q);-
52 pqueue_free(rl->d->buffered_app_data.q);-
53 OPENSSL_free(rl->d);-
54 rl->d = NULL;-
55}
executed 373 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
373
56-
57void DTLS_RECORD_LAYER_clear(RECORD_LAYER *rl)-
58{-
59 DTLS_RECORD_LAYER *d;-
60 pitem *item = NULL;-
61 DTLS1_RECORD_DATA *rdata;-
62 pqueue *unprocessed_rcds;-
63 pqueue *processed_rcds;-
64 pqueue *buffered_app_data;-
65-
66 d = rl->d;-
67-
68 while ((item = pqueue_pop(d->unprocessed_rcds.q)) != NULL) {
(item = pqueue...!= ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2608 times by 1 test
Evaluated by:
  • libssl.so.1.1
2-2608
69 rdata = (DTLS1_RECORD_DATA *)item->data;-
70 OPENSSL_free(rdata->rbuf.buf);-
71 OPENSSL_free(item->data);-
72 pitem_free(item);-
73 }
executed 2 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2
74-
75 while ((item = pqueue_pop(d->processed_rcds.q)) != NULL) {
(item = pqueue...!= ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2608 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2608
76 rdata = (DTLS1_RECORD_DATA *)item->data;-
77 OPENSSL_free(rdata->rbuf.buf);-
78 OPENSSL_free(item->data);-
79 pitem_free(item);-
80 }
never executed: end of block
0
81-
82 while ((item = pqueue_pop(d->buffered_app_data.q)) != NULL) {
(item = pqueue...!= ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2608 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2608
83 rdata = (DTLS1_RECORD_DATA *)item->data;-
84 OPENSSL_free(rdata->rbuf.buf);-
85 OPENSSL_free(item->data);-
86 pitem_free(item);-
87 }
never executed: end of block
0
88-
89 unprocessed_rcds = d->unprocessed_rcds.q;-
90 processed_rcds = d->processed_rcds.q;-
91 buffered_app_data = d->buffered_app_data.q;-
92 memset(d, 0, sizeof(*d));-
93 d->unprocessed_rcds.q = unprocessed_rcds;-
94 d->processed_rcds.q = processed_rcds;-
95 d->buffered_app_data.q = buffered_app_data;-
96}
executed 2608 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2608
97-
98void DTLS_RECORD_LAYER_set_saved_w_epoch(RECORD_LAYER *rl, unsigned short e)-
99{-
100 if (e == rl->d->w_epoch - 1) {
e == rl->d->w_epoch - 1Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 210 times by 1 test
Evaluated by:
  • libssl.so.1.1
34-210
101 memcpy(rl->d->curr_write_sequence,-
102 rl->write_sequence, sizeof(rl->write_sequence));-
103 memcpy(rl->write_sequence,-
104 rl->d->last_write_sequence, sizeof(rl->write_sequence));-
105 } else if (e == rl->d->w_epoch + 1) {
executed 34 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
e == rl->d->w_epoch + 1Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 176 times by 1 test
Evaluated by:
  • libssl.so.1.1
34-176
106 memcpy(rl->d->last_write_sequence,-
107 rl->write_sequence, sizeof(unsigned char[8]));-
108 memcpy(rl->write_sequence,-
109 rl->d->curr_write_sequence, sizeof(rl->write_sequence));-
110 }
executed 34 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
34
111 rl->d->w_epoch = e;-
112}
executed 244 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
244
113-
114void DTLS_RECORD_LAYER_set_write_sequence(RECORD_LAYER *rl, unsigned char *seq)-
115{-
116 memcpy(rl->write_sequence, seq, SEQ_NUM_SIZE);-
117}
executed 2 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2
118-
119/* copy buffered record into SSL structure */-
120static int dtls1_copy_record(SSL *s, pitem *item)-
121{-
122 DTLS1_RECORD_DATA *rdata;-
123-
124 rdata = (DTLS1_RECORD_DATA *)item->data;-
125-
126 SSL3_BUFFER_release(&s->rlayer.rbuf);-
127-
128 s->rlayer.packet = rdata->packet;-
129 s->rlayer.packet_length = rdata->packet_length;-
130 memcpy(&s->rlayer.rbuf, &(rdata->rbuf), sizeof(SSL3_BUFFER));-
131 memcpy(&s->rlayer.rrec, &(rdata->rrec), sizeof(SSL3_RECORD));-
132-
133 /* Set proper sequence number for mac calculation */-
134 memcpy(&(s->rlayer.read_sequence[2]), &(rdata->packet[5]), 6);-
135-
136 return 1;
executed 14 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
14
137}-
138-
139int dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority)-
140{-
141 DTLS1_RECORD_DATA *rdata;-
142 pitem *item;-
143-
144 /* Limit the size of the queue to prevent DOS attacks */-
145 if (pqueue_size(queue->q) >= 100)
pqueue_size(queue->q) >= 100Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-16
146 return 0;
never executed: return 0;
0
147-
148 rdata = OPENSSL_malloc(sizeof(*rdata));-
149 item = pitem_new(priority, rdata);-
150 if (rdata == NULL || item == NULL) {
rdata == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libssl.so.1.1
item == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-16
151 OPENSSL_free(rdata);-
152 pitem_free(item);-
153 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_DTLS1_BUFFER_RECORD,-
154 ERR_R_INTERNAL_ERROR);-
155 return -1;
never executed: return -1;
0
156 }-
157-
158 rdata->packet = s->rlayer.packet;-
159 rdata->packet_length = s->rlayer.packet_length;-
160 memcpy(&(rdata->rbuf), &s->rlayer.rbuf, sizeof(SSL3_BUFFER));-
161 memcpy(&(rdata->rrec), &s->rlayer.rrec, sizeof(SSL3_RECORD));-
162-
163 item->data = rdata;-
164-
165#ifndef OPENSSL_NO_SCTP-
166 /* Store bio_dgram_sctp_rcvinfo struct */-
167 if (BIO_dgram_is_sctp(SSL_get_rbio(s)) &&-
168 (SSL_get_state(s) == TLS_ST_SR_FINISHED-
169 || SSL_get_state(s) == TLS_ST_CR_FINISHED)) {-
170 BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SCTP_GET_RCVINFO,-
171 sizeof(rdata->recordinfo), &rdata->recordinfo);-
172 }-
173#endif-
174-
175 s->rlayer.packet = NULL;-
176 s->rlayer.packet_length = 0;-
177 memset(&s->rlayer.rbuf, 0, sizeof(s->rlayer.rbuf));-
178 memset(&s->rlayer.rrec, 0, sizeof(s->rlayer.rrec));-
179-
180 if (!ssl3_setup_buffers(s)) {
!ssl3_setup_buffers(s)Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-16
181 /* SSLfatal() already called */-
182 OPENSSL_free(rdata->rbuf.buf);-
183 OPENSSL_free(rdata);-
184 pitem_free(item);-
185 return -1;
never executed: return -1;
0
186 }-
187-
188 /* insert should not fail, since duplicates are dropped */-
189 if (pqueue_insert(queue->q, item) == NULL) {
pqueue_insert(...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-16
190 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_DTLS1_BUFFER_RECORD,-
191 ERR_R_INTERNAL_ERROR);-
192 OPENSSL_free(rdata->rbuf.buf);-
193 OPENSSL_free(rdata);-
194 pitem_free(item);-
195 return -1;
never executed: return -1;
0
196 }-
197-
198 return 1;
executed 16 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
16
199}-
200-
201int dtls1_retrieve_buffered_record(SSL *s, record_pqueue *queue)-
202{-
203 pitem *item;-
204-
205 item = pqueue_pop(queue->q);-
206 if (item) {
itemDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4698 times by 1 test
Evaluated by:
  • libssl.so.1.1
14-4698
207 dtls1_copy_record(s, item);-
208-
209 OPENSSL_free(item->data);-
210 pitem_free(item);-
211-
212 return 1;
executed 14 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
14
213 }-
214-
215 return 0;
executed 4698 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
4698
216}-
217-
218/*-
219 * retrieve a buffered record that belongs to the new epoch, i.e., not-
220 * processed yet-
221 */-
222#define dtls1_get_unprocessed_record(s) \-
223 dtls1_retrieve_buffered_record((s), \-
224 &((s)->rlayer.d->unprocessed_rcds))-
225-
226int dtls1_process_buffered_records(SSL *s)-
227{-
228 pitem *item;-
229 SSL3_BUFFER *rb;-
230 SSL3_RECORD *rr;-
231 DTLS1_BITMAP *bitmap;-
232 unsigned int is_next_epoch;-
233 int replayok = 1;-
234-
235 item = pqueue_peek(s->rlayer.d->unprocessed_rcds.q);-
236 if (item) {
itemDescription
TRUEevaluated 93 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4612 times by 1 test
Evaluated by:
  • libssl.so.1.1
93-4612
237 /* Check if epoch is current. */-
238 if (s->rlayer.d->unprocessed_rcds.epoch != s->rlayer.d->r_epoch)
s->rlayer.d->u...yer.d->r_epochDescription
TRUEevaluated 84 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libssl.so.1.1
9-84
239 return 1; /* Nothing to do. */
executed 84 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
84
240-
241 rr = RECORD_LAYER_get_rrec(&s->rlayer);-
242-
243 rb = RECORD_LAYER_get_rbuf(&s->rlayer);-
244-
245 if (SSL3_BUFFER_get_left(rb) > 0) {
((rb)->left) > 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
2-7
246 /*-
247 * We've still got data from the current packet to read. There could-
248 * be a record from the new epoch in it - so don't overwrite it-
249 * with the unprocessed records yet (we'll do it when we've-
250 * finished reading the current packet).-
251 */-
252 return 1;
executed 2 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
2
253 }-
254-
255 /* Process all the records. */-
256 while (pqueue_peek(s->rlayer.d->unprocessed_rcds.q)) {
pqueue_peek(s-...cessed_rcds.q)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
7
257 dtls1_get_unprocessed_record(s);-
258 bitmap = dtls1_get_bitmap(s, rr, &is_next_epoch);-
259 if (bitmap == NULL) {
bitmap == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-7
260 /*-
261 * Should not happen. This will only ever be NULL when the-
262 * current record is from a different epoch. But that cannot-
263 * be the case because we already checked the epoch above-
264 */-
265 SSLfatal(s, SSL_AD_INTERNAL_ERROR,-
266 SSL_F_DTLS1_PROCESS_BUFFERED_RECORDS,-
267 ERR_R_INTERNAL_ERROR);-
268 return 0;
never executed: return 0;
0
269 }-
270#ifndef OPENSSL_NO_SCTP-
271 /* Only do replay check if no SCTP bio */-
272 if (!BIO_dgram_is_sctp(SSL_get_rbio(s)))-
273#endif-
274 {-
275 /*-
276 * Check whether this is a repeat, or aged record. We did this-
277 * check once already when we first received the record - but-
278 * we might have updated the window since then due to-
279 * records we subsequently processed.-
280 */-
281 replayok = dtls1_record_replay_check(s, bitmap);-
282 }-
283-
284 if (!replayok || !dtls1_process_record(s, bitmap)) {
!replayokDescription
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
!dtls1_process...ord(s, bitmap)Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-7
285 if (ossl_statem_in_error(s)) {
ossl_statem_in_error(s)Description
TRUEnever evaluated
FALSEnever evaluated
0
286 /* dtls1_process_record called SSLfatal() */-
287 return -1;
never executed: return -1;
0
288 }-
289 /* dump this record */-
290 rr->length = 0;-
291 RECORD_LAYER_reset_packet_length(&s->rlayer);-
292 continue;
never executed: continue;
0
293 }-
294-
295 if (dtls1_buffer_record(s, &(s->rlayer.d->processed_rcds),
dtls1_buffer_r...>seq_num)) < 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-7
296 SSL3_RECORD_get_seq_num(s->rlayer.rrec)) < 0) {
dtls1_buffer_r...>seq_num)) < 0Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-7
297 /* SSLfatal() already called */-
298 return 0;
never executed: return 0;
0
299 }-
300 }
executed 7 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
7
301 }
executed 7 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
7
302-
303 /*-
304 * sync epoch numbers once all the unprocessed records have been-
305 * processed-
306 */-
307 s->rlayer.d->processed_rcds.epoch = s->rlayer.d->r_epoch;-
308 s->rlayer.d->unprocessed_rcds.epoch = s->rlayer.d->r_epoch + 1;-
309-
310 return 1;
executed 4619 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
4619
311}-
312-
313/*--
314 * Return up to 'len' payload bytes received in 'type' records.-
315 * 'type' is one of the following:-
316 *-
317 * - SSL3_RT_HANDSHAKE (when ssl3_get_message calls us)-
318 * - SSL3_RT_APPLICATION_DATA (when ssl3_read calls us)-
319 * - 0 (during a shutdown, no data has to be returned)-
320 *-
321 * If we don't have stored data to work from, read a SSL/TLS record first-
322 * (possibly multiple records if we still don't have anything to return).-
323 *-
324 * This function must handle any surprises the peer may have for us, such as-
325 * Alert records (e.g. close_notify) or renegotiation requests. ChangeCipherSpec-
326 * messages are treated as if they were handshake messages *if* the |recd_type|-
327 * argument is non NULL.-
328 * Also if record payloads contain fragments too small to process, we store-
329 * them until there is enough for the respective protocol (the record protocol-
330 * may use arbitrary fragmentation and even interleaving):-
331 * Change cipher spec protocol-
332 * just 1 byte needed, no need for keeping anything stored-
333 * Alert protocol-
334 * 2 bytes needed (AlertLevel, AlertDescription)-
335 * Handshake protocol-
336 * 4 bytes needed (HandshakeType, uint24 length) -- we just have-
337 * to detect unexpected Client Hello and Hello Request messages-
338 * here, anything else is handled by higher layers-
339 * Application data protocol-
340 * none of our business-
341 */-
342int dtls1_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf,-
343 size_t len, int peek, size_t *readbytes)-
344{-
345 int i, j, iret;-
346 size_t n;-
347 SSL3_RECORD *rr;-
348 void (*cb) (const SSL *ssl, int type2, int val) = NULL;-
349-
350 if (!SSL3_BUFFER_is_initialised(&s->rlayer.rbuf)) {
!((&s->rlayer.... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 6999 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-6999
351 /* Not initialized yet */-
352 if (!ssl3_setup_buffers(s)) {
!ssl3_setup_buffers(s)Description
TRUEnever evaluated
FALSEnever evaluated
0
353 /* SSLfatal() already called */-
354 return -1;
never executed: return -1;
0
355 }-
356 }
never executed: end of block
0
357-
358 if ((type && (type != SSL3_RT_APPLICATION_DATA) &&
typeDescription
TRUEevaluated 6787 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 212 times by 1 test
Evaluated by:
  • libssl.so.1.1
(type != 23)Description
TRUEevaluated 6274 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 513 times by 1 test
Evaluated by:
  • libssl.so.1.1
212-6787
359 (type != SSL3_RT_HANDSHAKE)) ||
(type != 22)Description
TRUEnever evaluated
FALSEevaluated 6274 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-6274
360 (peek && (type != SSL3_RT_APPLICATION_DATA))) {
peekDescription
TRUEnever evaluated
FALSEevaluated 6999 times by 1 test
Evaluated by:
  • libssl.so.1.1
(type != 23)Description
TRUEnever evaluated
FALSEnever evaluated
0-6999
361 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_DTLS1_READ_BYTES,-
362 ERR_R_INTERNAL_ERROR);-
363 return -1;
never executed: return -1;
0
364 }-
365-
366 if (!ossl_statem_get_in_handshake(s) && SSL_in_init(s)) {
!ossl_statem_g...n_handshake(s)Description
TRUEevaluated 725 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 6274 times by 1 test
Evaluated by:
  • libssl.so.1.1
SSL_in_init(s)Description
TRUEnever evaluated
FALSEevaluated 725 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-6274
367 /* type == SSL3_RT_APPLICATION_DATA */-
368 i = s->handshake_func(s);-
369 /* SSLfatal() already called if appropriate */-
370 if (i < 0)
i < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
371 return i;
never executed: return i;
0
372 if (i == 0)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
373 return -1;
never executed: return -1;
0
374 }
never executed: end of block
0
375-
376 start:
code before this statement executed 6999 times by 1 test: start:
Executed by:
  • libssl.so.1.1
6999
377 s->rwstate = SSL_NOTHING;-
378-
379 /*--
380 * s->s3->rrec.type - is the type of record-
381 * s->s3->rrec.data, - data-
382 * s->s3->rrec.off, - offset into 'data' for next read-
383 * s->s3->rrec.length, - number of bytes.-
384 */-
385 rr = s->rlayer.rrec;-
386-
387 /*-
388 * We are not handshaking and have no data yet, so process data buffered-
389 * during the last handshake in advance, if any.-
390 */-
391 if (SSL_is_init_finished(s) && SSL3_RECORD_get_length(rr) == 0) {
SSL_is_init_finished(s)Description
TRUEevaluated 731 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 6314 times by 1 test
Evaluated by:
  • libssl.so.1.1
((rr)->length) == 0Description
TRUEevaluated 731 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-6314
392 pitem *item;-
393 item = pqueue_pop(s->rlayer.d->buffered_app_data.q);-
394 if (item) {
itemDescription
TRUEnever evaluated
FALSEevaluated 731 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-731
395#ifndef OPENSSL_NO_SCTP-
396 /* Restore bio_dgram_sctp_rcvinfo struct */-
397 if (BIO_dgram_is_sctp(SSL_get_rbio(s))) {-
398 DTLS1_RECORD_DATA *rdata = (DTLS1_RECORD_DATA *)item->data;-
399 BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SCTP_SET_RCVINFO,-
400 sizeof(rdata->recordinfo), &rdata->recordinfo);-
401 }-
402#endif-
403-
404 dtls1_copy_record(s, item);-
405-
406 OPENSSL_free(item->data);-
407 pitem_free(item);-
408 }
never executed: end of block
0
409 }
executed 731 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
731
410-
411 /* Check for timeout */-
412 if (dtls1_handle_timeout(s) > 0) {
dtls1_handle_timeout(s) > 0Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 7005 times by 1 test
Evaluated by:
  • libssl.so.1.1
40-7005
413 goto start;
executed 40 times by 1 test: goto start;
Executed by:
  • libssl.so.1.1
40
414 } else if (ossl_statem_in_error(s)) {
ossl_statem_in_error(s)Description
TRUEnever evaluated
FALSEevaluated 7005 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-7005
415 /* dtls1_handle_timeout() has failed with a fatal error */-
416 return -1;
never executed: return -1;
0
417 }-
418-
419 /* get new packet if necessary */-
420 if ((SSL3_RECORD_get_length(rr) == 0)
(((rr)->length) == 0)Description
TRUEevaluated 4613 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2392 times by 1 test
Evaluated by:
  • libssl.so.1.1
2392-4613
421 || (s->rlayer.rstate == SSL_ST_READ_BODY)) {
(s->rlayer.rstate == 0xF1)Description
TRUEnever evaluated
FALSEevaluated 2392 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2392
422 RECORD_LAYER_set_numrpipes(&s->rlayer, 0);-
423 iret = dtls1_get_record(s);-
424 if (iret <= 0) {
iret <= 0Description
TRUEevaluated 1204 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3409 times by 1 test
Evaluated by:
  • libssl.so.1.1
1204-3409
425 iret = dtls1_read_failed(s, iret);-
426 /*-
427 * Anything other than a timeout is an error. SSLfatal() already-
428 * called if appropriate.-
429 */-
430 if (iret <= 0)
iret <= 0Description
TRUEevaluated 1204 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-1204
431 return iret;
executed 1204 times by 1 test: return iret;
Executed by:
  • libssl.so.1.1
1204
432 else-
433 goto start;
never executed: goto start;
0
434 }-
435 RECORD_LAYER_set_numrpipes(&s->rlayer, 1);-
436 }
executed 3409 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
3409
437-
438 /*-
439 * Reset the count of consecutive warning alerts if we've got a non-empty-
440 * record that isn't an alert.-
441 */-
442 if (SSL3_RECORD_get_type(rr) != SSL3_RT_ALERT
((rr)->type) != 21Description
TRUEevaluated 5576 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 225 times by 1 test
Evaluated by:
  • libssl.so.1.1
225-5576
443 && SSL3_RECORD_get_length(rr) != 0)
((rr)->length) != 0Description
TRUEevaluated 5576 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-5576
444 s->rlayer.alert_count = 0;
executed 5576 times by 1 test: s->rlayer.alert_count = 0;
Executed by:
  • libssl.so.1.1
5576
445-
446 if (SSL3_RECORD_get_type(rr) != SSL3_RT_HANDSHAKE
((rr)->type) != 22Description
TRUEevaluated 842 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4959 times by 1 test
Evaluated by:
  • libssl.so.1.1
842-4959
447 && SSL3_RECORD_get_type(rr) != SSL3_RT_CHANGE_CIPHER_SPEC
((rr)->type) != 20Description
TRUEevaluated 484 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 358 times by 1 test
Evaluated by:
  • libssl.so.1.1
358-484
448 && !SSL_in_init(s)
!SSL_in_init(s)Description
TRUEevaluated 471 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libssl.so.1.1
13-471
449 && (s->d1->next_timeout.tv_sec != 0
s->d1->next_ti...ut.tv_sec != 0Description
TRUEevaluated 116 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 355 times by 1 test
Evaluated by:
  • libssl.so.1.1
116-355
450 || s->d1->next_timeout.tv_usec != 0)) {
s->d1->next_ti...t.tv_usec != 0Description
TRUEnever evaluated
FALSEevaluated 355 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-355
451 /*-
452 * The timer is still running but we've received something that isn't-
453 * handshake data - so the peer must have finished processing our-
454 * last handshake flight. Stop the timer.-
455 */-
456 dtls1_stop_timer(s);-
457 }
executed 116 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
116
458-
459 /* we now have a packet which can be read and processed */-
460-
461 if (s->s3->change_cipher_spec /* set when we receive ChangeCipherSpec,
s->s3->change_cipher_specDescription
TRUEevaluated 728 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5073 times by 1 test
Evaluated by:
  • libssl.so.1.1
728-5073
462 * reset by ssl3_get_finished */-
463 && (SSL3_RECORD_get_type(rr) != SSL3_RT_HANDSHAKE)) {
(((rr)->type) != 22)Description
TRUEnever evaluated
FALSEevaluated 728 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-728
464 /*-
465 * We now have application data between CCS and Finished. Most likely-
466 * the packets were reordered on their way, so buffer the application-
467 * data for later processing rather than dropping the connection.-
468 */-
469 if (dtls1_buffer_record(s, &(s->rlayer.d->buffered_app_data),
dtls1_buffer_r...>seq_num)) < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
470 SSL3_RECORD_get_seq_num(rr)) < 0) {
dtls1_buffer_r...>seq_num)) < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
471 /* SSLfatal() already called */-
472 return -1;
never executed: return -1;
0
473 }-
474 SSL3_RECORD_set_length(rr, 0);-
475 SSL3_RECORD_set_read(rr);-
476 goto start;
never executed: goto start;
0
477 }-
478-
479 /*-
480 * If the other end has shut down, throw anything we read away (even in-
481 * 'peek' mode)-
482 */-
483 if (s->shutdown & SSL_RECEIVED_SHUTDOWN) {
s->shutdown & 2Description
TRUEnever evaluated
FALSEevaluated 5801 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-5801
484 SSL3_RECORD_set_length(rr, 0);-
485 SSL3_RECORD_set_read(rr);-
486 s->rwstate = SSL_NOTHING;-
487 return 0;
never executed: return 0;
0
488 }-
489-
490 if (type == SSL3_RECORD_get_type(rr)
type == ((rr)->type)Description
TRUEevaluated 5200 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 601 times by 1 test
Evaluated by:
  • libssl.so.1.1
601-5200
491 || (SSL3_RECORD_get_type(rr) == SSL3_RT_CHANGE_CIPHER_SPEC
((rr)->type) == 20Description
TRUEevaluated 358 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 243 times by 1 test
Evaluated by:
  • libssl.so.1.1
243-358
492 && type == SSL3_RT_HANDSHAKE && recvd_type != NULL)) {
type == 22Description
TRUEevaluated 358 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
recvd_type != ((void *)0)Description
TRUEevaluated 358 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-358
493 /*-
494 * SSL3_RT_APPLICATION_DATA or-
495 * SSL3_RT_HANDSHAKE or-
496 * SSL3_RT_CHANGE_CIPHER_SPEC-
497 */-
498 /*-
499 * make sure that we are not getting application data when we are-
500 * doing a handshake for the first time-
501 */-
502 if (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) &&
SSL_in_init(s)Description
TRUEevaluated 5299 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 259 times by 1 test
Evaluated by:
  • libssl.so.1.1
(type == 23)Description
TRUEnever evaluated
FALSEevaluated 5299 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-5299
503 (s->enc_read_ctx == NULL)) {
(s->enc_read_c... ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
504 SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_F_DTLS1_READ_BYTES,-
505 SSL_R_APP_DATA_IN_HANDSHAKE);-
506 return -1;
never executed: return -1;
0
507 }-
508-
509 if (recvd_type != NULL)
recvd_type != ((void *)0)Description
TRUEevaluated 2919 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2639 times by 1 test
Evaluated by:
  • libssl.so.1.1
2639-2919
510 *recvd_type = SSL3_RECORD_get_type(rr);
executed 2919 times by 1 test: *recvd_type = ((rr)->type);
Executed by:
  • libssl.so.1.1
2919
511-
512 if (len == 0) {
len == 0Description
TRUEnever evaluated
FALSEevaluated 5558 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-5558
513 /*-
514 * Mark a zero length record as read. This ensures multiple calls to-
515 * SSL_read() with a zero length buffer will eventually cause-
516 * SSL_pending() to report data as being available.-
517 */-
518 if (SSL3_RECORD_get_length(rr) == 0)
((rr)->length) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
519 SSL3_RECORD_set_read(rr);
never executed: ((rr)->read = 1);
0
520 return 0;
never executed: return 0;
0
521 }-
522-
523 if (len > SSL3_RECORD_get_length(rr))
len > ((rr)->length)Description
TRUEevaluated 616 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4942 times by 1 test
Evaluated by:
  • libssl.so.1.1
616-4942
524 n = SSL3_RECORD_get_length(rr);
executed 616 times by 1 test: n = ((rr)->length);
Executed by:
  • libssl.so.1.1
616
525 else-
526 n = len;
executed 4942 times by 1 test: n = len;
Executed by:
  • libssl.so.1.1
4942
527-
528 memcpy(buf, &(SSL3_RECORD_get_data(rr)[SSL3_RECORD_get_off(rr)]), n);-
529 if (peek) {
peekDescription
TRUEnever evaluated
FALSEevaluated 5558 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-5558
530 if (SSL3_RECORD_get_length(rr) == 0)
((rr)->length) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
531 SSL3_RECORD_set_read(rr);
never executed: ((rr)->read = 1);
0
532 } else {
never executed: end of block
0
533 SSL3_RECORD_sub_length(rr, n);-
534 SSL3_RECORD_add_off(rr, n);-
535 if (SSL3_RECORD_get_length(rr) == 0) {
((rr)->length) == 0Description
TRUEevaluated 3177 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2381 times by 1 test
Evaluated by:
  • libssl.so.1.1
2381-3177
536 s->rlayer.rstate = SSL_ST_READ_HEADER;-
537 SSL3_RECORD_set_off(rr, 0);-
538 SSL3_RECORD_set_read(rr);-
539 }
executed 3177 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
3177
540 }
executed 5558 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
5558
541#ifndef OPENSSL_NO_SCTP-
542 /*-
543 * We might had to delay a close_notify alert because of reordered-
544 * app data. If there was an alert and there is no message to read-
545 * anymore, finally set shutdown.-
546 */-
547 if (BIO_dgram_is_sctp(SSL_get_rbio(s)) &&-
548 s->d1->shutdown_received-
549 && !BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s))) {-
550 s->shutdown |= SSL_RECEIVED_SHUTDOWN;-
551 return 0;-
552 }-
553#endif-
554 *readbytes = n;-
555 return 1;
executed 5558 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
5558
556 }-
557-
558 /*-
559 * If we get here, then type != rr->type; if we have a handshake message,-
560 * then it was unexpected (Hello Request or Client Hello).-
561 */-
562-
563 if (SSL3_RECORD_get_type(rr) == SSL3_RT_ALERT) {
((rr)->type) == 21Description
TRUEevaluated 225 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 18 times by 1 test
Evaluated by:
  • libssl.so.1.1
18-225
564 unsigned int alert_level, alert_descr;-
565 unsigned char *alert_bytes = SSL3_RECORD_get_data(rr)-
566 + SSL3_RECORD_get_off(rr);-
567 PACKET alert;-
568-
569 if (!PACKET_buf_init(&alert, alert_bytes, SSL3_RECORD_get_length(rr))
!PACKET_buf_in...(rr)->length))Description
TRUEnever evaluated
FALSEevaluated 225 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-225
570 || !PACKET_get_1(&alert, &alert_level)
!PACKET_get_1(... &alert_level)Description
TRUEnever evaluated
FALSEevaluated 225 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-225
571 || !PACKET_get_1(&alert, &alert_descr)
!PACKET_get_1(... &alert_descr)Description
TRUEnever evaluated
FALSEevaluated 225 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-225
572 || PACKET_remaining(&alert) != 0) {
PACKET_remaining(&alert) != 0Description
TRUEnever evaluated
FALSEevaluated 225 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-225
573 SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_F_DTLS1_READ_BYTES,-
574 SSL_R_INVALID_ALERT);-
575 return -1;
never executed: return -1;
0
576 }-
577-
578 if (s->msg_callback)
s->msg_callbackDescription
TRUEnever evaluated
FALSEevaluated 225 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-225
579 s->msg_callback(0, s->version, SSL3_RT_ALERT, alert_bytes, 2, s,
never executed: s->msg_callback(0, s->version, 21, alert_bytes, 2, s, s->msg_callback_arg);
0
580 s->msg_callback_arg);
never executed: s->msg_callback(0, s->version, 21, alert_bytes, 2, s, s->msg_callback_arg);
0
581-
582 if (s->info_callback != NULL)
s->info_callba...!= ((void *)0)Description
TRUEevaluated 225 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-225
583 cb = s->info_callback;
executed 225 times by 1 test: cb = s->info_callback;
Executed by:
  • libssl.so.1.1
225
584 else if (s->ctx->info_callback != NULL)
s->ctx->info_c...!= ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
585 cb = s->ctx->info_callback;
never executed: cb = s->ctx->info_callback;
0
586-
587 if (cb != NULL) {
cb != ((void *)0)Description
TRUEevaluated 225 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-225
588 j = (alert_level << 8) | alert_descr;-
589 cb(s, SSL_CB_READ_ALERT, j);-
590 }
executed 225 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
225
591-
592 if (alert_level == SSL3_AL_WARNING) {
alert_level == 1Description
TRUEevaluated 212 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 13 times by 1 test
Evaluated by:
  • libssl.so.1.1
13-212
593 s->s3->warn_alert = alert_descr;-
594 SSL3_RECORD_set_read(rr);-
595-
596 s->rlayer.alert_count++;-
597 if (s->rlayer.alert_count == MAX_WARN_ALERT_COUNT) {
s->rlayer.alert_count == 5Description
TRUEnever evaluated
FALSEevaluated 212 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-212
598 SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_F_DTLS1_READ_BYTES,-
599 SSL_R_TOO_MANY_WARN_ALERTS);-
600 return -1;
never executed: return -1;
0
601 }-
602-
603 if (alert_descr == SSL_AD_CLOSE_NOTIFY) {
alert_descr == 0Description
TRUEevaluated 212 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-212
604#ifndef OPENSSL_NO_SCTP-
605 /*-
606 * With SCTP and streams the socket may deliver app data-
607 * after a close_notify alert. We have to check this first so-
608 * that nothing gets discarded.-
609 */-
610 if (BIO_dgram_is_sctp(SSL_get_rbio(s)) &&-
611 BIO_dgram_sctp_msg_waiting(SSL_get_rbio(s))) {-
612 s->d1->shutdown_received = 1;-
613 s->rwstate = SSL_READING;-
614 BIO_clear_retry_flags(SSL_get_rbio(s));-
615 BIO_set_retry_read(SSL_get_rbio(s));-
616 return -1;-
617 }-
618#endif-
619 s->shutdown |= SSL_RECEIVED_SHUTDOWN;-
620 return 0;
executed 212 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
212
621 }-
622 } else if (alert_level == SSL3_AL_FATAL) {
never executed: end of block
alert_level == 2Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-13
623 char tmp[16];-
624-
625 s->rwstate = SSL_NOTHING;-
626 s->s3->fatal_alert = alert_descr;-
627 SSLfatal(s, SSL_AD_NO_ALERT, SSL_F_DTLS1_READ_BYTES,-
628 SSL_AD_REASON_OFFSET + alert_descr);-
629 BIO_snprintf(tmp, sizeof tmp, "%d", alert_descr);-
630 ERR_add_error_data(2, "SSL alert number ", tmp);-
631 s->shutdown |= SSL_RECEIVED_SHUTDOWN;-
632 SSL3_RECORD_set_read(rr);-
633 SSL_CTX_remove_session(s->session_ctx, s->session);-
634 return 0;
executed 13 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
13
635 } else {-
636 SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_DTLS1_READ_BYTES,-
637 SSL_R_UNKNOWN_ALERT_TYPE);-
638 return -1;
never executed: return -1;
0
639 }-
640-
641 goto start;
never executed: goto start;
0
642 }-
643-
644 if (s->shutdown & SSL_SENT_SHUTDOWN) { /* but we have not received a
s->shutdown & 1Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-18
645 * shutdown */-
646 s->rwstate = SSL_NOTHING;-
647 SSL3_RECORD_set_length(rr, 0);-
648 SSL3_RECORD_set_read(rr);-
649 return 0;
never executed: return 0;
0
650 }-
651-
652 if (SSL3_RECORD_get_type(rr) == SSL3_RT_CHANGE_CIPHER_SPEC) {
((rr)->type) == 20Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-18
653 /*-
654 * We can't process a CCS now, because previous handshake messages-
655 * are still missing, so just drop it.-
656 */-
657 SSL3_RECORD_set_length(rr, 0);-
658 SSL3_RECORD_set_read(rr);-
659 goto start;
never executed: goto start;
0
660 }-
661-
662 /*-
663 * Unexpected handshake message (Client Hello, or protocol violation)-
664 */-
665 if ((SSL3_RECORD_get_type(rr) == SSL3_RT_HANDSHAKE) &&
(((rr)->type) == 22)Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-18
666 !ossl_statem_get_in_handshake(s)) {
!ossl_statem_g...n_handshake(s)Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-18
667 struct hm_header_st msg_hdr;-
668-
669 /*-
670 * This may just be a stale retransmit. Also sanity check that we have-
671 * at least enough record bytes for a message header-
672 */-
673 if (SSL3_RECORD_get_epoch(rr) != s->rlayer.d->r_epoch
((rr)->epoch) ...yer.d->r_epochDescription
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-18
674 || SSL3_RECORD_get_length(rr) < DTLS1_HM_HEADER_LENGTH) {
((rr)->length) < 12Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-18
675 SSL3_RECORD_set_length(rr, 0);-
676 SSL3_RECORD_set_read(rr);-
677 goto start;
never executed: goto start;
0
678 }-
679-
680 dtls1_get_message_header(rr->data, &msg_hdr);-
681-
682 /*-
683 * If we are server, we may have a repeated FINISHED of the client-
684 * here, then retransmit our CCS and FINISHED.-
685 */-
686 if (msg_hdr.type == SSL3_MT_FINISHED) {
msg_hdr.type == 20Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libssl.so.1.1
6-12
687 if (dtls1_check_timeout_num(s) < 0) {
dtls1_check_timeout_num(s) < 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-6
688 /* SSLfatal) already called */-
689 return -1;
never executed: return -1;
0
690 }-
691-
692 if (dtls1_retransmit_buffered_messages(s) <= 0) {
dtls1_retransm...ssages(s) <= 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-6
693 /* Fail if we encountered a fatal error */-
694 if (ossl_statem_in_error(s))
ossl_statem_in_error(s)Description
TRUEnever evaluated
FALSEnever evaluated
0
695 return -1;
never executed: return -1;
0
696 }
never executed: end of block
0
697 SSL3_RECORD_set_length(rr, 0);-
698 SSL3_RECORD_set_read(rr);-
699 if (!(s->mode & SSL_MODE_AUTO_RETRY)) {
!(s->mode & 0x00000004U)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-6
700 if (SSL3_BUFFER_get_left(&s->rlayer.rbuf) == 0) {
((&s->rlayer.rbuf)->left) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
701 /* no read-ahead left? */-
702 BIO *bio;-
703-
704 s->rwstate = SSL_READING;-
705 bio = SSL_get_rbio(s);-
706 BIO_clear_retry_flags(bio);-
707 BIO_set_retry_read(bio);-
708 return -1;
never executed: return -1;
0
709 }-
710 }
never executed: end of block
0
711 goto start;
executed 6 times by 1 test: goto start;
Executed by:
  • libssl.so.1.1
6
712 }-
713-
714 /*-
715 * To get here we must be trying to read app data but found handshake-
716 * data. But if we're trying to read app data, and we're not in init-
717 * (which is tested for at the top of this function) then init must be-
718 * finished-
719 */-
720 if (!ossl_assert(SSL_is_init_finished(s))) {
!((SSL_is_init...shed(s)) != 0)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-12
721 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_DTLS1_READ_BYTES,-
722 ERR_R_INTERNAL_ERROR);-
723 return -1;
never executed: return -1;
0
724 }-
725-
726 /* We found handshake data, so we're going back into init */-
727 ossl_statem_set_in_init(s, 1);-
728-
729 i = s->handshake_func(s);-
730 /* SSLfatal() called if appropriate */-
731 if (i < 0)
i < 0Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-12
732 return i;
executed 12 times by 1 test: return i;
Executed by:
  • libssl.so.1.1
12
733 if (i == 0)
i == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
734 return -1;
never executed: return -1;
0
735-
736 if (!(s->mode & SSL_MODE_AUTO_RETRY)) {
!(s->mode & 0x00000004U)Description
TRUEnever evaluated
FALSEnever evaluated
0
737 if (SSL3_BUFFER_get_left(&s->rlayer.rbuf) == 0) {
((&s->rlayer.rbuf)->left) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
738 /* no read-ahead left? */-
739 BIO *bio;-
740 /*-
741 * In the case where we try to read application data, but we-
742 * trigger an SSL handshake, we return -1 with the retry-
743 * option set. Otherwise renegotiation may cause nasty-
744 * problems in the blocking world-
745 */-
746 s->rwstate = SSL_READING;-
747 bio = SSL_get_rbio(s);-
748 BIO_clear_retry_flags(bio);-
749 BIO_set_retry_read(bio);-
750 return -1;
never executed: return -1;
0
751 }-
752 }
never executed: end of block
0
753 goto start;
never executed: goto start;
0
754 }-
755-
756 switch (SSL3_RECORD_get_type(rr)) {-
757 default:
never executed: default:
0
758 SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_F_DTLS1_READ_BYTES,-
759 SSL_R_UNEXPECTED_RECORD);-
760 return -1;
never executed: return -1;
0
761 case SSL3_RT_CHANGE_CIPHER_SPEC:
never executed: case 20:
0
762 case SSL3_RT_ALERT:
never executed: case 21:
0
763 case SSL3_RT_HANDSHAKE:
never executed: case 22:
0
764 /*-
765 * we already handled all of these, with the possible exception of-
766 * SSL3_RT_HANDSHAKE when ossl_statem_get_in_handshake(s) is true, but-
767 * that should not happen when type != rr->type-
768 */-
769 SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_F_DTLS1_READ_BYTES,-
770 ERR_R_INTERNAL_ERROR);-
771 return -1;
never executed: return -1;
0
772 case SSL3_RT_APPLICATION_DATA:
never executed: case 23:
0
773 /*-
774 * At this point, we were expecting handshake data, but have-
775 * application data. If the library was running inside ssl3_read()-
776 * (i.e. in_read_app_data is set) and it makes sense to read-
777 * application data at this point (session renegotiation not yet-
778 * started), we will indulge it.-
779 */-
780 if (s->s3->in_read_app_data &&
s->s3->in_read_app_dataDescription
TRUEnever evaluated
FALSEnever evaluated
0
781 (s->s3->total_renegotiations != 0) &&
(s->s3->total_...tiations != 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
782 ossl_statem_app_data_allowed(s)) {
ossl_statem_ap...ata_allowed(s)Description
TRUEnever evaluated
FALSEnever evaluated
0
783 s->s3->in_read_app_data = 2;-
784 return -1;
never executed: return -1;
0
785 } else {-
786 SSLfatal(s, SSL_AD_UNEXPECTED_MESSAGE, SSL_F_DTLS1_READ_BYTES,-
787 SSL_R_UNEXPECTED_RECORD);-
788 return -1;
never executed: return -1;
0
789 }-
790 }-
791 /* not reached */-
792}-
793-
794/*-
795 * Call this to write data in records of type 'type' It will return <= 0 if-
796 * not all data has been sent or non-blocking IO.-
797 */-
798int dtls1_write_bytes(SSL *s, int type, const void *buf, size_t len,-
799 size_t *written)-
800{-
801 int i;-
802-
803 if (!ossl_assert(len <= SSL3_RT_MAX_PLAIN_LENGTH)) {
!((len <= 16384) != 0)Description
TRUEnever evaluated
FALSEevaluated 4107 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4107
804 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_DTLS1_WRITE_BYTES,-
805 ERR_R_INTERNAL_ERROR);-
806 return -1;
never executed: return -1;
0
807 }-
808 s->rwstate = SSL_NOTHING;-
809 i = do_dtls1_write(s, type, buf, len, 0, written);-
810 return i;
executed 4107 times by 1 test: return i;
Executed by:
  • libssl.so.1.1
4107
811}-
812-
813int do_dtls1_write(SSL *s, int type, const unsigned char *buf,-
814 size_t len, int create_empty_fragment, size_t *written)-
815{-
816 unsigned char *p, *pseq;-
817 int i, mac_size, clear = 0;-
818 size_t prefix_len = 0;-
819 int eivlen;-
820 SSL3_RECORD wr;-
821 SSL3_BUFFER *wb;-
822 SSL_SESSION *sess;-
823-
824 wb = &s->rlayer.wbuf[0];-
825-
826 /*-
827 * first check if there is a SSL3_BUFFER still being written out. This-
828 * will happen with non blocking IO-
829 */-
830 if (!ossl_assert(SSL3_BUFFER_get_left(wb) == 0)) {
!((((wb)->left) == 0) != 0)Description
TRUEnever evaluated
FALSEevaluated 4346 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4346
831 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_DO_DTLS1_WRITE,-
832 ERR_R_INTERNAL_ERROR);-
833 return 0;
never executed: return 0;
0
834 }-
835-
836 /* If we have an alert to send, lets send it */-
837 if (s->s3->alert_dispatch) {
s->s3->alert_dispatchDescription
TRUEnever evaluated
FALSEevaluated 4346 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4346
838 i = s->method->ssl_dispatch_alert(s);-
839 if (i <= 0)
i <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
840 return i;
never executed: return i;
0
841 /* if it went, fall through and send more stuff */-
842 }
never executed: end of block
0
843-
844 if (len == 0 && !create_empty_fragment)
len == 0Description
TRUEnever evaluated
FALSEevaluated 4346 times by 1 test
Evaluated by:
  • libssl.so.1.1
!create_empty_fragmentDescription
TRUEnever evaluated
FALSEnever evaluated
0-4346
845 return 0;
never executed: return 0;
0
846-
847 if (len > ssl_get_max_send_fragment(s)) {
len > ssl_get_...nd_fragment(s)Description
TRUEnever evaluated
FALSEevaluated 4346 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4346
848 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_DO_DTLS1_WRITE,-
849 SSL_R_EXCEEDS_MAX_FRAGMENT_SIZE);-
850 return 0;
never executed: return 0;
0
851 }-
852-
853 sess = s->session;-
854-
855 if ((sess == NULL) ||
(sess == ((void *)0) )Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4342 times by 1 test
Evaluated by:
  • libssl.so.1.1
4-4342
856 (s->enc_write_ctx == NULL) || (EVP_MD_CTX_md(s->write_hash) == NULL))
(s->enc_write_... ((void *)0) )Description
TRUEevaluated 2521 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1821 times by 1 test
Evaluated by:
  • libssl.so.1.1
(EVP_MD_CTX_md... ((void *)0) )Description
TRUEevaluated 916 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 905 times by 1 test
Evaluated by:
  • libssl.so.1.1
905-2521
857 clear = 1;
executed 3441 times by 1 test: clear = 1;
Executed by:
  • libssl.so.1.1
3441
858-
859 if (clear)
clearDescription
TRUEevaluated 3441 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 905 times by 1 test
Evaluated by:
  • libssl.so.1.1
905-3441
860 mac_size = 0;
executed 3441 times by 1 test: mac_size = 0;
Executed by:
  • libssl.so.1.1
3441
861 else {-
862 mac_size = EVP_MD_CTX_size(s->write_hash);-
863 if (mac_size < 0) {
mac_size < 0Description
TRUEnever evaluated
FALSEevaluated 905 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-905
864 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_DO_DTLS1_WRITE,-
865 SSL_R_EXCEEDS_MAX_FRAGMENT_SIZE);-
866 return -1;
never executed: return -1;
0
867 }-
868 }
executed 905 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
905
869-
870 p = SSL3_BUFFER_get_buf(wb) + prefix_len;-
871-
872 /* write the header */-
873-
874 *(p++) = type & 0xff;-
875 SSL3_RECORD_set_type(&wr, type);-
876 /*-
877 * Special case: for hello verify request, client version 1.0 and we-
878 * haven't decided which version to use yet send back using version 1.0-
879 * header: otherwise some clients will ignore it.-
880 */-
881 if (s->method->version == DTLS_ANY_VERSION &&
s->method->version == 0x1FFFFDescription
TRUEevaluated 213 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4133 times by 1 test
Evaluated by:
  • libssl.so.1.1
213-4133
882 s->max_proto_version != DTLS1_BAD_VER) {
s->max_proto_version != 0x0100Description
TRUEevaluated 211 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
2-211
883 *(p++) = DTLS1_VERSION >> 8;-
884 *(p++) = DTLS1_VERSION & 0xff;-
885 } else {
executed 211 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
211
886 *(p++) = s->version >> 8;-
887 *(p++) = s->version & 0xff;-
888 }
executed 4135 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
4135
889-
890 /* field where we are to write out packet epoch, seq num and len */-
891 pseq = p;-
892 p += 10;-
893-
894 /* Explicit IV length, block ciphers appropriate version flag */-
895 if (s->enc_write_ctx) {
s->enc_write_ctxDescription
TRUEevaluated 1821 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2525 times by 1 test
Evaluated by:
  • libssl.so.1.1
1821-2525
896 int mode = EVP_CIPHER_CTX_mode(s->enc_write_ctx);-
897 if (mode == EVP_CIPH_CBC_MODE) {
mode == 0x2Description
TRUEevaluated 713 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1108 times by 1 test
Evaluated by:
  • libssl.so.1.1
713-1108
898 eivlen = EVP_CIPHER_CTX_iv_length(s->enc_write_ctx);-
899 if (eivlen <= 1)
eivlen <= 1Description
TRUEnever evaluated
FALSEevaluated 713 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-713
900 eivlen = 0;
never executed: eivlen = 0;
0
901 }
executed 713 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
713
902 /* Need explicit part of IV for GCM mode */-
903 else if (mode == EVP_CIPH_GCM_MODE)
mode == 0x6Description
TRUEevaluated 751 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 357 times by 1 test
Evaluated by:
  • libssl.so.1.1
357-751
904 eivlen = EVP_GCM_TLS_EXPLICIT_IV_LEN;
executed 751 times by 1 test: eivlen = 8;
Executed by:
  • libssl.so.1.1
751
905 else if (mode == EVP_CIPH_CCM_MODE)
mode == 0x7Description
TRUEevaluated 132 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 225 times by 1 test
Evaluated by:
  • libssl.so.1.1
132-225
906 eivlen = EVP_CCM_TLS_EXPLICIT_IV_LEN;
executed 132 times by 1 test: eivlen = 8;
Executed by:
  • libssl.so.1.1
132
907 else-
908 eivlen = 0;
executed 225 times by 1 test: eivlen = 0;
Executed by:
  • libssl.so.1.1
225
909 } else-
910 eivlen = 0;
executed 2525 times by 1 test: eivlen = 0;
Executed by:
  • libssl.so.1.1
2525
911-
912 /* lets setup the record stuff. */-
913 SSL3_RECORD_set_data(&wr, p + eivlen); /* make room for IV in case of CBC */-
914 SSL3_RECORD_set_length(&wr, len);-
915 SSL3_RECORD_set_input(&wr, (unsigned char *)buf);-
916-
917 /*-
918 * we now 'read' from wr.input, wr.length bytes into wr.data-
919 */-
920-
921 /* first we compress */-
922 if (s->compress != NULL) {
s->compress != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4346 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4346
923 if (!ssl3_do_compress(s, &wr)) {
!ssl3_do_compress(s, &wr)Description
TRUEnever evaluated
FALSEnever evaluated
0
924 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_DO_DTLS1_WRITE,-
925 SSL_R_COMPRESSION_FAILURE);-
926 return -1;
never executed: return -1;
0
927 }-
928 } else {
never executed: end of block
0
929 memcpy(SSL3_RECORD_get_data(&wr), SSL3_RECORD_get_input(&wr),-
930 SSL3_RECORD_get_length(&wr));-
931 SSL3_RECORD_reset_input(&wr);-
932 }
executed 4346 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
4346
933-
934 /*-
935 * we should still have the output to wr.data and the input from-
936 * wr.input. Length should be wr.length. wr.data still points in the-
937 * wb->buf-
938 */-
939-
940 if (!SSL_WRITE_ETM(s) && mac_size != 0) {
!(s->s3->flags & 0x0400)Description
TRUEevaluated 3748 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 598 times by 1 test
Evaluated by:
  • libssl.so.1.1
mac_size != 0Description
TRUEevaluated 307 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3441 times by 1 test
Evaluated by:
  • libssl.so.1.1
307-3748
941 if (!s->method->ssl3_enc->mac(s, &wr,
!s->method->ss...+ eivlen]), 1)Description
TRUEnever evaluated
FALSEevaluated 307 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-307
942 &(p[SSL3_RECORD_get_length(&wr) + eivlen]),
!s->method->ss...+ eivlen]), 1)Description
TRUEnever evaluated
FALSEevaluated 307 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-307
943 1)) {
!s->method->ss...+ eivlen]), 1)Description
TRUEnever evaluated
FALSEevaluated 307 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-307
944 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_DO_DTLS1_WRITE,-
945 ERR_R_INTERNAL_ERROR);-
946 return -1;
never executed: return -1;
0
947 }-
948 SSL3_RECORD_add_length(&wr, mac_size);-
949 }
executed 307 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
307
950-
951 /* this is true regardless of mac size */-
952 SSL3_RECORD_set_data(&wr, p);-
953 SSL3_RECORD_reset_input(&wr);-
954-
955 if (eivlen)
eivlenDescription
TRUEevaluated 1596 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2750 times by 1 test
Evaluated by:
  • libssl.so.1.1
1596-2750
956 SSL3_RECORD_add_length(&wr, eivlen);
executed 1596 times by 1 test: ((&wr)->length += (eivlen));
Executed by:
  • libssl.so.1.1
1596
957-
958 if (s->method->ssl3_enc->enc(s, &wr, 1, 1) < 1) {
s->method->ssl...&wr, 1, 1) < 1Description
TRUEnever evaluated
FALSEevaluated 4346 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4346
959 if (!ossl_statem_in_error(s)) {
!ossl_statem_in_error(s)Description
TRUEnever evaluated
FALSEnever evaluated
0
960 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_DO_DTLS1_WRITE,-
961 ERR_R_INTERNAL_ERROR);-
962 }
never executed: end of block
0
963 return -1;
never executed: return -1;
0
964 }-
965-
966 if (SSL_WRITE_ETM(s) && mac_size != 0) {
(s->s3->flags & 0x0400)Description
TRUEevaluated 598 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3748 times by 1 test
Evaluated by:
  • libssl.so.1.1
mac_size != 0Description
TRUEevaluated 598 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-3748
967 if (!s->method->ssl3_enc->mac(s, &wr,
!s->method->ss...>length)]), 1)Description
TRUEnever evaluated
FALSEevaluated 598 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-598
968 &(p[SSL3_RECORD_get_length(&wr)]), 1)) {
!s->method->ss...>length)]), 1)Description
TRUEnever evaluated
FALSEevaluated 598 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-598
969 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_DO_DTLS1_WRITE,-
970 ERR_R_INTERNAL_ERROR);-
971 return -1;
never executed: return -1;
0
972 }-
973 SSL3_RECORD_add_length(&wr, mac_size);-
974 }
executed 598 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
598
975-
976 /* record length after mac and block padding */-
977-
978 /* there's only one epoch between handshake and app data */-
979-
980 s2n(s->rlayer.d->w_epoch, pseq);-
981-
982 memcpy(pseq, &(s->rlayer.write_sequence[2]), 6);-
983 pseq += 6;-
984 s2n(SSL3_RECORD_get_length(&wr), pseq);-
985-
986 if (s->msg_callback)
s->msg_callbackDescription
TRUEnever evaluated
FALSEevaluated 4346 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4346
987 s->msg_callback(1, 0, SSL3_RT_HEADER, pseq - DTLS1_RT_HEADER_LENGTH,
never executed: s->msg_callback(1, 0, 0x100, pseq - 13, 13, s, s->msg_callback_arg);
0
988 DTLS1_RT_HEADER_LENGTH, s, s->msg_callback_arg);
never executed: s->msg_callback(1, 0, 0x100, pseq - 13, 13, s, s->msg_callback_arg);
0
989-
990 /*-
991 * we should now have wr.data pointing to the encrypted data, which is-
992 * wr->length long-
993 */-
994 SSL3_RECORD_set_type(&wr, type); /* not needed but helps for debugging */-
995 SSL3_RECORD_add_length(&wr, DTLS1_RT_HEADER_LENGTH);-
996-
997 ssl3_record_sequence_update(&(s->rlayer.write_sequence[0]));-
998-
999 if (create_empty_fragment) {
create_empty_fragmentDescription
TRUEnever evaluated
FALSEevaluated 4346 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4346
1000 /*-
1001 * we are in a recursive call; just return the length, don't write-
1002 * out anything here-
1003 */-
1004 *written = wr.length;-
1005 return 1;
never executed: return 1;
0
1006 }-
1007-
1008 /* now let's set up wb */-
1009 SSL3_BUFFER_set_left(wb, prefix_len + SSL3_RECORD_get_length(&wr));-
1010 SSL3_BUFFER_set_offset(wb, 0);-
1011-
1012 /*-
1013 * memorize arguments so that ssl3_write_pending can detect bad write-
1014 * retries later-
1015 */-
1016 s->rlayer.wpend_tot = len;-
1017 s->rlayer.wpend_buf = buf;-
1018 s->rlayer.wpend_type = type;-
1019 s->rlayer.wpend_ret = len;-
1020-
1021 /* we now just need to write the buffer. Calls SSLfatal() as required. */-
1022 return ssl3_write_pending(s, type, buf, len, written);
executed 4346 times by 1 test: return ssl3_write_pending(s, type, buf, len, written);
Executed by:
  • libssl.so.1.1
4346
1023}-
1024-
1025DTLS1_BITMAP *dtls1_get_bitmap(SSL *s, SSL3_RECORD *rr,-
1026 unsigned int *is_next_epoch)-
1027{-
1028-
1029 *is_next_epoch = 0;-
1030-
1031 /* In current epoch, accept HM, CCS, DATA, & ALERT */-
1032 if (rr->epoch == s->rlayer.d->r_epoch)
rr->epoch == s...yer.d->r_epochDescription
TRUEevaluated 3416 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 20 times by 1 test
Evaluated by:
  • libssl.so.1.1
20-3416
1033 return &s->rlayer.d->bitmap;
executed 3416 times by 1 test: return &s->rlayer.d->bitmap;
Executed by:
  • libssl.so.1.1
3416
1034-
1035 /*-
1036 * Only HM and ALERT messages can be from the next epoch and only if we-
1037 * have already processed all of the unprocessed records from the last-
1038 * epoch-
1039 */-
1040 else if (rr->epoch == (unsigned long)(s->rlayer.d->r_epoch + 1) &&
rr->epoch == (...->r_epoch + 1)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libssl.so.1.1
9-11
1041 s->rlayer.d->unprocessed_rcds.epoch != s->rlayer.d->r_epoch &&
s->rlayer.d->u...yer.d->r_epochDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-9
1042 (rr->type == SSL3_RT_HANDSHAKE || rr->type == SSL3_RT_ALERT)) {
rr->type == 22Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
rr->type == 21Description
TRUEnever evaluated
FALSEnever evaluated
0-9
1043 *is_next_epoch = 1;-
1044 return &s->rlayer.d->next_bitmap;
executed 9 times by 1 test: return &s->rlayer.d->next_bitmap;
Executed by:
  • libssl.so.1.1
9
1045 }-
1046-
1047 return NULL;
executed 11 times by 1 test: return ((void *)0) ;
Executed by:
  • libssl.so.1.1
11
1048}-
1049-
1050void dtls1_reset_seq_numbers(SSL *s, int rw)-
1051{-
1052 unsigned char *seq;-
1053 unsigned int seq_bytes = sizeof(s->rlayer.read_sequence);-
1054-
1055 if (rw & SSL3_CC_READ) {
rw & 0x001Description
TRUEevaluated 355 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 359 times by 1 test
Evaluated by:
  • libssl.so.1.1
355-359
1056 seq = s->rlayer.read_sequence;-
1057 s->rlayer.d->r_epoch++;-
1058 memcpy(&s->rlayer.d->bitmap, &s->rlayer.d->next_bitmap,-
1059 sizeof(s->rlayer.d->bitmap));-
1060 memset(&s->rlayer.d->next_bitmap, 0, sizeof(s->rlayer.d->next_bitmap));-
1061-
1062 /*-
1063 * We must not use any buffered messages received from the previous-
1064 * epoch-
1065 */-
1066 dtls1_clear_received_buffer(s);-
1067 } else {
executed 355 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
355
1068 seq = s->rlayer.write_sequence;-
1069 memcpy(s->rlayer.d->last_write_sequence, seq,-
1070 sizeof(s->rlayer.write_sequence));-
1071 s->rlayer.d->w_epoch++;-
1072 }
executed 359 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
359
1073-
1074 memset(seq, 0, seq_bytes);-
1075}
executed 714 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
714
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2