OpenCoverage

s3_msg.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/ssl/s3_msg.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 1995-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 "ssl_locl.h"-
11-
12int ssl3_do_change_cipher_spec(SSL *s)-
13{-
14 int i;-
15-
16 if (s->server)
s->serverDescription
TRUEevaluated 1217 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1252 times by 1 test
Evaluated by:
  • libssl.so.1.1
1217-1252
17 i = SSL3_CHANGE_CIPHER_SERVER_READ;
executed 1217 times by 1 test: i = (0x020|0x001);
Executed by:
  • libssl.so.1.1
1217
18 else-
19 i = SSL3_CHANGE_CIPHER_CLIENT_READ;
executed 1252 times by 1 test: i = (0x010|0x001);
Executed by:
  • libssl.so.1.1
1252
20-
21 if (s->s3->tmp.key_block == NULL) {
s->s3->tmp.key...== ((void *)0)Description
TRUEevaluated 1210 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1259 times by 1 test
Evaluated by:
  • libssl.so.1.1
1210-1259
22 if (s->session == NULL || s->session->master_key_length == 0) {
s->session == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1210 times by 1 test
Evaluated by:
  • libssl.so.1.1
s->session->ma...ey_length == 0Description
TRUEnever evaluated
FALSEevaluated 1210 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1210
23 /* might happen if dtls1_read_bytes() calls this */-
24 SSLerr(SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC, SSL_R_CCS_RECEIVED_EARLY);-
25 return 0;
never executed: return 0;
0
26 }-
27-
28 s->session->cipher = s->s3->tmp.new_cipher;-
29 if (!s->method->ssl3_enc->setup_key_block(s))
!s->method->ss...p_key_block(s)Description
TRUEnever evaluated
FALSEevaluated 1210 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1210
30 return 0;
never executed: return 0;
0
31 }
executed 1210 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
1210
32-
33 if (!s->method->ssl3_enc->change_cipher_state(s, i))
!s->method->ss...er_state(s, i)Description
TRUEnever evaluated
FALSEevaluated 2469 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2469
34 return 0;
never executed: return 0;
0
35-
36 return 1;
executed 2469 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
2469
37}-
38-
39int ssl3_send_alert(SSL *s, int level, int desc)-
40{-
41 /* Map tls/ssl alert value to correct one */-
42 if (SSL_TREAT_AS_TLS13(s))
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 6138 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 239 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->version >= 0x0304Description
TRUEevaluated 2394 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3744 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->v...ion != 0x10000Description
TRUEevaluated 1249 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1145 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->early_dat...ATA_CONNECTINGDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5125 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->early_dat..._CONNECT_RETRYDescription
TRUEnever evaluated
FALSEevaluated 5125 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->early_dat...Y_DATA_WRITINGDescription
TRUEnever evaluated
FALSEevaluated 5125 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->early_dat...TA_WRITE_RETRYDescription
TRUEnever evaluated
FALSEevaluated 5125 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->hello_ret...SL_HRR_PENDINGDescription
TRUEevaluated 90 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5035 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-6138
43 desc = tls13_alert_code(desc);
executed 1342 times by 1 test: desc = tls13_alert_code(desc);
Executed by:
  • libssl.so.1.1
1342
44 else-
45 desc = s->method->ssl3_enc->alert_value(desc);
executed 5035 times by 1 test: desc = s->method->ssl3_enc->alert_value(desc);
Executed by:
  • libssl.so.1.1
5035
46 if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION)
s->version == 0x0300Description
TRUEevaluated 376 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 6001 times by 1 test
Evaluated by:
  • libssl.so.1.1
desc == 70Description
TRUEevaluated 375 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
1-6001
47 desc = SSL_AD_HANDSHAKE_FAILURE; /* SSL 3.0 does not have
executed 375 times by 1 test: desc = 40;
Executed by:
  • libssl.so.1.1
375
48 * protocol_version alerts */-
49 if (desc < 0)
desc < 0Description
TRUEnever evaluated
FALSEevaluated 6377 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-6377
50 return -1;
never executed: return -1;
0
51 /* If a fatal one, remove from cache */-
52 if ((level == SSL3_AL_FATAL) && (s->session != NULL))
(level == 2)Description
TRUEevaluated 3787 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2590 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s->session != ((void *)0) )Description
TRUEevaluated 3044 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 743 times by 1 test
Evaluated by:
  • libssl.so.1.1
743-3787
53 SSL_CTX_remove_session(s->session_ctx, s->session);
executed 3044 times by 1 test: SSL_CTX_remove_session(s->session_ctx, s->session);
Executed by:
  • libssl.so.1.1
3044
54-
55 s->s3->alert_dispatch = 1;-
56 s->s3->send_alert[0] = level;-
57 s->s3->send_alert[1] = desc;-
58 if (!RECORD_LAYER_write_pending(&s->rlayer)) {
!RECORD_LAYER_...ng(&s->rlayer)Description
TRUEevaluated 6377 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-6377
59 /* data still being written out? */-
60 return s->method->ssl_dispatch_alert(s);
executed 6377 times by 1 test: return s->method->ssl_dispatch_alert(s);
Executed by:
  • libssl.so.1.1
6377
61 }-
62 /*-
63 * else data is still being written out, we will get written some time in-
64 * the future-
65 */-
66 return -1;
never executed: return -1;
0
67}-
68-
69int ssl3_dispatch_alert(SSL *s)-
70{-
71 int i, j;-
72 size_t alertlen;-
73 void (*cb) (const SSL *ssl, int type, int val) = NULL;-
74 size_t written;-
75-
76 s->s3->alert_dispatch = 0;-
77 alertlen = 2;-
78 i = do_ssl3_write(s, SSL3_RT_ALERT, &s->s3->send_alert[0], &alertlen, 1, 0,-
79 &written);-
80 if (i <= 0) {
i <= 0Description
TRUEevaluated 88 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 6050 times by 1 test
Evaluated by:
  • libssl.so.1.1
88-6050
81 s->s3->alert_dispatch = 1;-
82 } else {
executed 88 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
88
83 /*-
84 * Alert sent to BIO - now flush. If the message does not get sent due-
85 * to non-blocking IO, we will not worry too much.-
86 */-
87 (void)BIO_flush(s->wbio);-
88-
89 if (s->msg_callback)
s->msg_callbackDescription
TRUEnever evaluated
FALSEevaluated 6050 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-6050
90 s->msg_callback(1, s->version, SSL3_RT_ALERT, s->s3->send_alert,
never executed: s->msg_callback(1, s->version, 21, s->s3->send_alert, 2, s, s->msg_callback_arg);
0
91 2, s, s->msg_callback_arg);
never executed: s->msg_callback(1, s->version, 21, s->s3->send_alert, 2, s, s->msg_callback_arg);
0
92-
93 if (s->info_callback != NULL)
s->info_callba...!= ((void *)0)Description
TRUEevaluated 1923 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4127 times by 1 test
Evaluated by:
  • libssl.so.1.1
1923-4127
94 cb = s->info_callback;
executed 1923 times by 1 test: cb = s->info_callback;
Executed by:
  • libssl.so.1.1
1923
95 else if (s->ctx->info_callback != NULL)
s->ctx->info_c...!= ((void *)0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4123 times by 1 test
Evaluated by:
  • libssl.so.1.1
4-4123
96 cb = s->ctx->info_callback;
executed 4 times by 1 test: cb = s->ctx->info_callback;
Executed by:
  • libssl.so.1.1
4
97-
98 if (cb != NULL) {
cb != ((void *)0)Description
TRUEevaluated 1927 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4123 times by 1 test
Evaluated by:
  • libssl.so.1.1
1927-4123
99 j = (s->s3->send_alert[0] << 8) | s->s3->send_alert[1];-
100 cb(s, SSL_CB_WRITE_ALERT, j);-
101 }
executed 1927 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
1927
102 }
executed 6050 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
6050
103 return i;
executed 6138 times by 1 test: return i;
Executed by:
  • libssl.so.1.1
6138
104}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2