OpenCoverage

ssl_txt.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/ssl/ssl_txt.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.-
3 * Copyright 2005 Nokia. All rights reserved.-
4 *-
5 * Licensed under the OpenSSL license (the "License"). You may not use-
6 * this file except in compliance with the License. You can obtain a copy-
7 * in the file LICENSE in the source distribution or at-
8 * https://www.openssl.org/source/license.html-
9 */-
10-
11#include <stdio.h>-
12#include <openssl/buffer.h>-
13#include "ssl_locl.h"-
14-
15#ifndef OPENSSL_NO_STDIO-
16int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *x)-
17{-
18 BIO *b;-
19 int ret;-
20-
21 if ((b = BIO_new(BIO_s_file())) == NULL) {
(b = BIO_new(B...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
22 SSLerr(SSL_F_SSL_SESSION_PRINT_FP, ERR_R_BUF_LIB);-
23 return 0;
never executed: return 0;
0
24 }-
25 BIO_set_fp(b, fp, BIO_NOCLOSE);-
26 ret = SSL_SESSION_print(b, x);-
27 BIO_free(b);-
28 return ret;
never executed: return ret;
0
29}-
30#endif-
31-
32int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x)-
33{-
34 size_t i;-
35 const char *s;-
36 int istls13;-
37-
38 if (x == NULL)
x == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 149 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-149
39 goto err;
never executed: goto err;
0
40 istls13 = (x->ssl_version == TLS1_3_VERSION);-
41 if (BIO_puts(bp, "SSL-Session:\n") <= 0)
BIO_puts(bp, "...sion:\n") <= 0Description
TRUEnever evaluated
FALSEevaluated 149 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-149
42 goto err;
never executed: goto err;
0
43 s = ssl_protocol_to_string(x->ssl_version);-
44 if (BIO_printf(bp, " Protocol : %s\n", s) <= 0)
BIO_printf(bp,...%s\n", s) <= 0Description
TRUEnever evaluated
FALSEevaluated 149 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-149
45 goto err;
never executed: goto err;
0
46-
47 if (x->cipher == NULL) {
x->cipher == ((void *)0)Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 133 times by 1 test
Evaluated by:
  • libssl.so.1.1
16-133
48 if (((x->cipher_id) & 0xff000000) == 0x02000000) {
((x->cipher_id... == 0x02000000Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-16
49 if (BIO_printf(bp, " Cipher : %06lX\n",
BIO_printf(bp,...0xffffff) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
50 x->cipher_id & 0xffffff) <= 0)
BIO_printf(bp,...0xffffff) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
51 goto err;
never executed: goto err;
0
52 } else {
never executed: end of block
0
53 if (BIO_printf(bp, " Cipher : %04lX\n",
BIO_printf(bp,...& 0xffff) <= 0Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-16
54 x->cipher_id & 0xffff) <= 0)
BIO_printf(bp,...& 0xffff) <= 0Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-16
55 goto err;
never executed: goto err;
0
56 }
executed 16 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
16
57 } else {-
58 if (BIO_printf(bp, " Cipher : %s\n",
BIO_printf(bp,...r->name)) <= 0Description
TRUEnever evaluated
FALSEevaluated 133 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-133
59 ((x->cipher->name == NULL) ? "unknown"
BIO_printf(bp,...r->name)) <= 0Description
TRUEnever evaluated
FALSEevaluated 133 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-133
60 : x->cipher->name)) <= 0)
BIO_printf(bp,...r->name)) <= 0Description
TRUEnever evaluated
FALSEevaluated 133 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-133
61 goto err;
never executed: goto err;
0
62 }
executed 133 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
133
63 if (BIO_puts(bp, " Session-ID: ") <= 0)
BIO_puts(bp, "...on-ID: ") <= 0Description
TRUEnever evaluated
FALSEevaluated 149 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-149
64 goto err;
never executed: goto err;
0
65 for (i = 0; i < x->session_id_length; i++) {
i < x->session_id_lengthDescription
TRUEevaluated 3483 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 149 times by 1 test
Evaluated by:
  • libssl.so.1.1
149-3483
66 if (BIO_printf(bp, "%02X", x->session_id[i]) <= 0)
BIO_printf(bp,...on_id[i]) <= 0Description
TRUEnever evaluated
FALSEevaluated 3483 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-3483
67 goto err;
never executed: goto err;
0
68 }
executed 3483 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
3483
69 if (BIO_puts(bp, "\n Session-ID-ctx: ") <= 0)
BIO_puts(bp, "...D-ctx: ") <= 0Description
TRUEnever evaluated
FALSEevaluated 149 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-149
70 goto err;
never executed: goto err;
0
71 for (i = 0; i < x->sid_ctx_length; i++) {
i < x->sid_ctx_lengthDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 149 times by 1 test
Evaluated by:
  • libssl.so.1.1
4-149
72 if (BIO_printf(bp, "%02X", x->sid_ctx[i]) <= 0)
BIO_printf(bp,...d_ctx[i]) <= 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4
73 goto err;
never executed: goto err;
0
74 }
executed 4 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
4
75 if (istls13) {
istls13Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 126 times by 1 test
Evaluated by:
  • libssl.so.1.1
23-126
76 if (BIO_puts(bp, "\n Resumption PSK: ") <= 0)
BIO_puts(bp, "...n PSK: ") <= 0Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-23
77 goto err;
never executed: goto err;
0
78 } else if (BIO_puts(bp, "\n Master-Key: ") <= 0)
executed 23 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
BIO_puts(bp, "...r-Key: ") <= 0Description
TRUEnever evaluated
FALSEevaluated 126 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-126
79 goto err;
never executed: goto err;
0
80 for (i = 0; i < x->master_key_length; i++) {
i < x->master_key_lengthDescription
TRUEevaluated 5022 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 149 times by 1 test
Evaluated by:
  • libssl.so.1.1
149-5022
81 if (BIO_printf(bp, "%02X", x->master_key[i]) <= 0)
BIO_printf(bp,...r_key[i]) <= 0Description
TRUEnever evaluated
FALSEevaluated 5022 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-5022
82 goto err;
never executed: goto err;
0
83 }
executed 5022 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
5022
84#ifndef OPENSSL_NO_PSK-
85 if (BIO_puts(bp, "\n PSK identity: ") <= 0)
BIO_puts(bp, "...ntity: ") <= 0Description
TRUEnever evaluated
FALSEevaluated 149 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-149
86 goto err;
never executed: goto err;
0
87 if (BIO_printf(bp, "%s", x->psk_identity ? x->psk_identity : "None") <= 0)
BIO_printf(bp,...: "None") <= 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 148 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-148
88 goto err;
executed 1 time by 1 test: goto err;
Executed by:
  • libssl.so.1.1
1
89 if (BIO_puts(bp, "\n PSK identity hint: ") <= 0)
BIO_puts(bp, "... hint: ") <= 0Description
TRUEnever evaluated
FALSEevaluated 148 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-148
90 goto err;
never executed: goto err;
0
91 if (BIO_printf
BIO_printf (bp...: "None") <= 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 147 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-147
92 (bp, "%s", x->psk_identity_hint ? x->psk_identity_hint : "None") <= 0)
BIO_printf (bp...: "None") <= 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 147 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-147
93 goto err;
executed 1 time by 1 test: goto err;
Executed by:
  • libssl.so.1.1
1
94#endif-
95#ifndef OPENSSL_NO_SRP-
96 if (BIO_puts(bp, "\n SRP username: ") <= 0)
BIO_puts(bp, "...rname: ") <= 0Description
TRUEnever evaluated
FALSEevaluated 147 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-147
97 goto err;
never executed: goto err;
0
98 if (BIO_printf(bp, "%s", x->srp_username ? x->srp_username : "None") <= 0)
BIO_printf(bp,...: "None") <= 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 146 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-146
99 goto err;
executed 1 time by 1 test: goto err;
Executed by:
  • libssl.so.1.1
1
100#endif-
101 if (x->ext.tick_lifetime_hint) {
x->ext.tick_lifetime_hintDescription
TRUEevaluated 85 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 61 times by 1 test
Evaluated by:
  • libssl.so.1.1
61-85
102 if (BIO_printf(bp,
BIO_printf(bp,...ime_hint) <= 0Description
TRUEnever evaluated
FALSEevaluated 85 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-85
103 "\n TLS session ticket lifetime hint: %ld (seconds)",
BIO_printf(bp,...ime_hint) <= 0Description
TRUEnever evaluated
FALSEevaluated 85 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-85
104 x->ext.tick_lifetime_hint) <= 0)
BIO_printf(bp,...ime_hint) <= 0Description
TRUEnever evaluated
FALSEevaluated 85 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-85
105 goto err;
never executed: goto err;
0
106 }
executed 85 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
85
107 if (x->ext.tick) {
x->ext.tickDescription
TRUEevaluated 86 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 60 times by 1 test
Evaluated by:
  • libssl.so.1.1
60-86
108 if (BIO_puts(bp, "\n TLS session ticket:\n") <= 0)
BIO_puts(bp, "...cket:\n") <= 0Description
TRUEnever evaluated
FALSEevaluated 86 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-86
109 goto err;
never executed: goto err;
0
110 /* TODO(size_t): Convert this call */-
111 if (BIO_dump_indent
BIO_dump_inden...cklen, 4) <= 0Description
TRUEnever evaluated
FALSEevaluated 86 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-86
112 (bp, (const char *)x->ext.tick, (int)x->ext.ticklen, 4)
BIO_dump_inden...cklen, 4) <= 0Description
TRUEnever evaluated
FALSEevaluated 86 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-86
113 <= 0)
BIO_dump_inden...cklen, 4) <= 0Description
TRUEnever evaluated
FALSEevaluated 86 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-86
114 goto err;
never executed: goto err;
0
115 }
executed 86 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
86
116#ifndef OPENSSL_NO_COMP-
117 if (x->compress_meth != 0) {
x->compress_meth != 0Description
TRUEnever evaluated
FALSEevaluated 146 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-146
118 SSL_COMP *comp = NULL;-
119-
120 if (!ssl_cipher_get_evp(x, NULL, NULL, NULL, NULL, &comp, 0))
!ssl_cipher_ge...0) , &comp, 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
121 goto err;
never executed: goto err;
0
122 if (comp == NULL) {
comp == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
123 if (BIO_printf(bp, "\n Compression: %d", x->compress_meth) <= 0)
BIO_printf(bp,...ess_meth) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
124 goto err;
never executed: goto err;
0
125 } else {
never executed: end of block
0
126 if (BIO_printf(bp, "\n Compression: %d (%s)", comp->id,
BIO_printf(bp,...mp->name) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
127 comp->name) <= 0)
BIO_printf(bp,...mp->name) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
128 goto err;
never executed: goto err;
0
129 }
never executed: end of block
0
130 }-
131#endif-
132 if (x->time != 0L) {
x->time != 0LDescription
TRUEevaluated 146 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-146
133 if (BIO_printf(bp, "\n Start Time: %ld", x->time) <= 0)
BIO_printf(bp,... x->time) <= 0Description
TRUEnever evaluated
FALSEevaluated 146 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-146
134 goto err;
never executed: goto err;
0
135 }
executed 146 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
146
136 if (x->timeout != 0L) {
x->timeout != 0LDescription
TRUEevaluated 146 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-146
137 if (BIO_printf(bp, "\n Timeout : %ld (sec)", x->timeout) <= 0)
BIO_printf(bp,...>timeout) <= 0Description
TRUEnever evaluated
FALSEevaluated 146 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-146
138 goto err;
never executed: goto err;
0
139 }
executed 146 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
146
140 if (BIO_puts(bp, "\n") <= 0)
BIO_puts(bp, "\n") <= 0Description
TRUEnever evaluated
FALSEevaluated 146 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-146
141 goto err;
never executed: goto err;
0
142-
143 if (BIO_puts(bp, " Verify return code: ") <= 0)
BIO_puts(bp, "... code: ") <= 0Description
TRUEnever evaluated
FALSEevaluated 146 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-146
144 goto err;
never executed: goto err;
0
145 if (BIO_printf(bp, "%ld (%s)\n", x->verify_result,
BIO_printf(bp,..._result)) <= 0Description
TRUEnever evaluated
FALSEevaluated 146 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-146
146 X509_verify_cert_error_string(x->verify_result)) <= 0)
BIO_printf(bp,..._result)) <= 0Description
TRUEnever evaluated
FALSEevaluated 146 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-146
147 goto err;
never executed: goto err;
0
148-
149 if (BIO_printf(bp, " Extended master secret: %s\n",
BIO_printf(bp,..." : "no") <= 0Description
TRUEnever evaluated
FALSEevaluated 146 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-146
150 x->flags & SSL_SESS_FLAG_EXTMS ? "yes" : "no") <= 0)
BIO_printf(bp,..." : "no") <= 0Description
TRUEnever evaluated
FALSEevaluated 146 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-146
151 goto err;
never executed: goto err;
0
152-
153 if (istls13) {
istls13Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 123 times by 1 test
Evaluated by:
  • libssl.so.1.1
23-123
154 if (BIO_printf(bp, " Max Early Data: %u\n",
BIO_printf(bp,...rly_data) <= 0Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-23
155 x->ext.max_early_data) <= 0)
BIO_printf(bp,...rly_data) <= 0Description
TRUEnever evaluated
FALSEevaluated 23 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-23
156 goto err;
never executed: goto err;
0
157 }
executed 23 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
23
158-
159 return 1;
executed 146 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
146
160 err:-
161 return 0;
executed 3 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
3
162}-
163-
164/*-
165 * print session id and master key in NSS keylog format (RSA-
166 * Session-ID:<session id> Master-Key:<master key>)-
167 */-
168int SSL_SESSION_print_keylog(BIO *bp, const SSL_SESSION *x)-
169{-
170 size_t i;-
171-
172 if (x == NULL)
x == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
173 goto err;
never executed: goto err;
0
174 if (x->session_id_length == 0 || x->master_key_length == 0)
x->session_id_length == 0Description
TRUEnever evaluated
FALSEnever evaluated
x->master_key_length == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
175 goto err;
never executed: goto err;
0
176-
177 /*-
178 * the RSA prefix is required by the format's definition although there's-
179 * nothing RSA-specific in the output, therefore, we don't have to check if-
180 * the cipher suite is based on RSA-
181 */-
182 if (BIO_puts(bp, "RSA ") <= 0)
BIO_puts(bp, "RSA ") <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
183 goto err;
never executed: goto err;
0
184-
185 if (BIO_puts(bp, "Session-ID:") <= 0)
BIO_puts(bp, "...ion-ID:") <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
186 goto err;
never executed: goto err;
0
187 for (i = 0; i < x->session_id_length; i++) {
i < x->session_id_lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
188 if (BIO_printf(bp, "%02X", x->session_id[i]) <= 0)
BIO_printf(bp,...on_id[i]) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
189 goto err;
never executed: goto err;
0
190 }
never executed: end of block
0
191 if (BIO_puts(bp, " Master-Key:") <= 0)
BIO_puts(bp, "...er-Key:") <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
192 goto err;
never executed: goto err;
0
193 for (i = 0; i < x->master_key_length; i++) {
i < x->master_key_lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
194 if (BIO_printf(bp, "%02X", x->master_key[i]) <= 0)
BIO_printf(bp,...r_key[i]) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
195 goto err;
never executed: goto err;
0
196 }
never executed: end of block
0
197 if (BIO_puts(bp, "\n") <= 0)
BIO_puts(bp, "\n") <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
198 goto err;
never executed: goto err;
0
199-
200 return 1;
never executed: return 1;
0
201 err:-
202 return 0;
never executed: return 0;
0
203}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2