OpenCoverage

t1_lib.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/ssl/t1_lib.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 <stdio.h>-
11#include <stdlib.h>-
12#include <openssl/objects.h>-
13#include <openssl/evp.h>-
14#include <openssl/hmac.h>-
15#include <openssl/ocsp.h>-
16#include <openssl/conf.h>-
17#include <openssl/x509v3.h>-
18#include <openssl/dh.h>-
19#include <openssl/bn.h>-
20#include "internal/nelem.h"-
21#include "ssl_locl.h"-
22#include <openssl/ct.h>-
23-
24SSL3_ENC_METHOD const TLSv1_enc_data = {-
25 tls1_enc,-
26 tls1_mac,-
27 tls1_setup_key_block,-
28 tls1_generate_master_secret,-
29 tls1_change_cipher_state,-
30 tls1_final_finish_mac,-
31 TLS_MD_CLIENT_FINISH_CONST, TLS_MD_CLIENT_FINISH_CONST_SIZE,-
32 TLS_MD_SERVER_FINISH_CONST, TLS_MD_SERVER_FINISH_CONST_SIZE,-
33 tls1_alert_code,-
34 tls1_export_keying_material,-
35 0,-
36 ssl3_set_handshake_header,-
37 tls_close_construct_packet,-
38 ssl3_handshake_write-
39};-
40-
41SSL3_ENC_METHOD const TLSv1_1_enc_data = {-
42 tls1_enc,-
43 tls1_mac,-
44 tls1_setup_key_block,-
45 tls1_generate_master_secret,-
46 tls1_change_cipher_state,-
47 tls1_final_finish_mac,-
48 TLS_MD_CLIENT_FINISH_CONST, TLS_MD_CLIENT_FINISH_CONST_SIZE,-
49 TLS_MD_SERVER_FINISH_CONST, TLS_MD_SERVER_FINISH_CONST_SIZE,-
50 tls1_alert_code,-
51 tls1_export_keying_material,-
52 SSL_ENC_FLAG_EXPLICIT_IV,-
53 ssl3_set_handshake_header,-
54 tls_close_construct_packet,-
55 ssl3_handshake_write-
56};-
57-
58SSL3_ENC_METHOD const TLSv1_2_enc_data = {-
59 tls1_enc,-
60 tls1_mac,-
61 tls1_setup_key_block,-
62 tls1_generate_master_secret,-
63 tls1_change_cipher_state,-
64 tls1_final_finish_mac,-
65 TLS_MD_CLIENT_FINISH_CONST, TLS_MD_CLIENT_FINISH_CONST_SIZE,-
66 TLS_MD_SERVER_FINISH_CONST, TLS_MD_SERVER_FINISH_CONST_SIZE,-
67 tls1_alert_code,-
68 tls1_export_keying_material,-
69 SSL_ENC_FLAG_EXPLICIT_IV | SSL_ENC_FLAG_SIGALGS | SSL_ENC_FLAG_SHA256_PRF-
70 | SSL_ENC_FLAG_TLS1_2_CIPHERS,-
71 ssl3_set_handshake_header,-
72 tls_close_construct_packet,-
73 ssl3_handshake_write-
74};-
75-
76SSL3_ENC_METHOD const TLSv1_3_enc_data = {-
77 tls13_enc,-
78 tls1_mac,-
79 tls13_setup_key_block,-
80 tls13_generate_master_secret,-
81 tls13_change_cipher_state,-
82 tls13_final_finish_mac,-
83 TLS_MD_CLIENT_FINISH_CONST, TLS_MD_CLIENT_FINISH_CONST_SIZE,-
84 TLS_MD_SERVER_FINISH_CONST, TLS_MD_SERVER_FINISH_CONST_SIZE,-
85 tls13_alert_code,-
86 tls13_export_keying_material,-
87 SSL_ENC_FLAG_SIGALGS | SSL_ENC_FLAG_SHA256_PRF,-
88 ssl3_set_handshake_header,-
89 tls_close_construct_packet,-
90 ssl3_handshake_write-
91};-
92-
93long tls1_default_timeout(void)-
94{-
95 /*-
96 * 2 hours, the 24 hours mentioned in the TLSv1 spec is way too long for-
97 * http, the cache would over fill-
98 */-
99 return (60 * 60 * 2);
executed 7712 times by 2 tests: return (60 * 60 * 2);
Executed by:
  • libssl.so.1.1
  • tls13encryptiontest
7712
100}-
101-
102int tls1_new(SSL *s)-
103{-
104 if (!ssl3_new(s))
!ssl3_new(s)Description
TRUEnever evaluated
FALSEevaluated 7949 times by 2 tests
Evaluated by:
  • libssl.so.1.1
  • tls13encryptiontest
0-7949
105 return 0;
never executed: return 0;
0
106 if (!s->method->ssl_clear(s))
!s->method->ssl_clear(s)Description
TRUEnever evaluated
FALSEevaluated 7949 times by 2 tests
Evaluated by:
  • libssl.so.1.1
  • tls13encryptiontest
0-7949
107 return 0;
never executed: return 0;
0
108-
109 return 1;
executed 7949 times by 2 tests: return 1;
Executed by:
  • libssl.so.1.1
  • tls13encryptiontest
7949
110}-
111-
112void tls1_free(SSL *s)-
113{-
114 OPENSSL_free(s->ext.session_ticket);-
115 ssl3_free(s);-
116}
executed 7949 times by 2 tests: end of block
Executed by:
  • libssl.so.1.1
  • tls13encryptiontest
7949
117-
118int tls1_clear(SSL *s)-
119{-
120 if (!ssl3_clear(s))
!ssl3_clear(s)Description
TRUEnever evaluated
FALSEevaluated 31388 times by 2 tests
Evaluated by:
  • libssl.so.1.1
  • tls13encryptiontest
0-31388
121 return 0;
never executed: return 0;
0
122-
123 if (s->method->version == TLS_ANY_VERSION)
s->method->version == 0x10000Description
TRUEevaluated 31388 times by 2 tests
Evaluated by:
  • libssl.so.1.1
  • tls13encryptiontest
FALSEnever evaluated
0-31388
124 s->version = TLS_MAX_VERSION;
executed 31388 times by 2 tests: s->version = 0x0304;
Executed by:
  • libssl.so.1.1
  • tls13encryptiontest
31388
125 else-
126 s->version = s->method->version;
never executed: s->version = s->method->version;
0
127-
128 return 1;
executed 31388 times by 2 tests: return 1;
Executed by:
  • libssl.so.1.1
  • tls13encryptiontest
31388
129}-
130-
131#ifndef OPENSSL_NO_EC-
132-
133/*-
134 * Table of curve information.-
135 * Do not delete entries or reorder this array! It is used as a lookup-
136 * table: the index of each entry is one less than the TLS curve id.-
137 */-
138static const TLS_GROUP_INFO nid_list[] = {-
139 {NID_sect163k1, 80, TLS_CURVE_CHAR2}, /* sect163k1 (1) */-
140 {NID_sect163r1, 80, TLS_CURVE_CHAR2}, /* sect163r1 (2) */-
141 {NID_sect163r2, 80, TLS_CURVE_CHAR2}, /* sect163r2 (3) */-
142 {NID_sect193r1, 80, TLS_CURVE_CHAR2}, /* sect193r1 (4) */-
143 {NID_sect193r2, 80, TLS_CURVE_CHAR2}, /* sect193r2 (5) */-
144 {NID_sect233k1, 112, TLS_CURVE_CHAR2}, /* sect233k1 (6) */-
145 {NID_sect233r1, 112, TLS_CURVE_CHAR2}, /* sect233r1 (7) */-
146 {NID_sect239k1, 112, TLS_CURVE_CHAR2}, /* sect239k1 (8) */-
147 {NID_sect283k1, 128, TLS_CURVE_CHAR2}, /* sect283k1 (9) */-
148 {NID_sect283r1, 128, TLS_CURVE_CHAR2}, /* sect283r1 (10) */-
149 {NID_sect409k1, 192, TLS_CURVE_CHAR2}, /* sect409k1 (11) */-
150 {NID_sect409r1, 192, TLS_CURVE_CHAR2}, /* sect409r1 (12) */-
151 {NID_sect571k1, 256, TLS_CURVE_CHAR2}, /* sect571k1 (13) */-
152 {NID_sect571r1, 256, TLS_CURVE_CHAR2}, /* sect571r1 (14) */-
153 {NID_secp160k1, 80, TLS_CURVE_PRIME}, /* secp160k1 (15) */-
154 {NID_secp160r1, 80, TLS_CURVE_PRIME}, /* secp160r1 (16) */-
155 {NID_secp160r2, 80, TLS_CURVE_PRIME}, /* secp160r2 (17) */-
156 {NID_secp192k1, 80, TLS_CURVE_PRIME}, /* secp192k1 (18) */-
157 {NID_X9_62_prime192v1, 80, TLS_CURVE_PRIME}, /* secp192r1 (19) */-
158 {NID_secp224k1, 112, TLS_CURVE_PRIME}, /* secp224k1 (20) */-
159 {NID_secp224r1, 112, TLS_CURVE_PRIME}, /* secp224r1 (21) */-
160 {NID_secp256k1, 128, TLS_CURVE_PRIME}, /* secp256k1 (22) */-
161 {NID_X9_62_prime256v1, 128, TLS_CURVE_PRIME}, /* secp256r1 (23) */-
162 {NID_secp384r1, 192, TLS_CURVE_PRIME}, /* secp384r1 (24) */-
163 {NID_secp521r1, 256, TLS_CURVE_PRIME}, /* secp521r1 (25) */-
164 {NID_brainpoolP256r1, 128, TLS_CURVE_PRIME}, /* brainpoolP256r1 (26) */-
165 {NID_brainpoolP384r1, 192, TLS_CURVE_PRIME}, /* brainpoolP384r1 (27) */-
166 {NID_brainpoolP512r1, 256, TLS_CURVE_PRIME}, /* brainpool512r1 (28) */-
167 {EVP_PKEY_X25519, 128, TLS_CURVE_CUSTOM}, /* X25519 (29) */-
168 {EVP_PKEY_X448, 224, TLS_CURVE_CUSTOM}, /* X448 (30) */-
169};-
170-
171static const unsigned char ecformats_default[] = {-
172 TLSEXT_ECPOINTFORMAT_uncompressed,-
173 TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime,-
174 TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2-
175};-
176-
177/* The default curves */-
178static const uint16_t eccurves_default[] = {-
179 29, /* X25519 (29) */-
180 23, /* secp256r1 (23) */-
181 30, /* X448 (30) */-
182 25, /* secp521r1 (25) */-
183 24, /* secp384r1 (24) */-
184};-
185-
186static const uint16_t suiteb_curves[] = {-
187 TLSEXT_curve_P_256,-
188 TLSEXT_curve_P_384-
189};-
190-
191const TLS_GROUP_INFO *tls1_group_id_lookup(uint16_t group_id)-
192{-
193 /* ECC curves from RFC 4492 and RFC 7027 */-
194 if (group_id < 1 || group_id > OSSL_NELEM(nid_list))
group_id < 1Description
TRUEnever evaluated
FALSEevaluated 42060 times by 1 test
Evaluated by:
  • libssl.so.1.1
group_id > (si...nid_list)[0]))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 42056 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-42060
195 return NULL;
executed 4 times by 1 test: return ((void *)0) ;
Executed by:
  • libssl.so.1.1
4
196 return &nid_list[group_id - 1];
executed 42056 times by 1 test: return &nid_list[group_id - 1];
Executed by:
  • libssl.so.1.1
42056
197}-
198-
199static uint16_t tls1_nid2group_id(int nid)-
200{-
201 size_t i;-
202 for (i = 0; i < OSSL_NELEM(nid_list); i++) {
i < (sizeof(ni...nid_list)[0]))Description
TRUEevaluated 21158 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
1-21158
203 if (nid_list[i].nid == nid)
nid_list[i].nid == nidDescription
TRUEevaluated 929 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 20229 times by 1 test
Evaluated by:
  • libssl.so.1.1
929-20229
204 return (uint16_t)(i + 1);
executed 929 times by 1 test: return (uint16_t)(i + 1);
Executed by:
  • libssl.so.1.1
929
205 }
executed 20229 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
20229
206 return 0;
executed 1 time by 1 test: return 0;
Executed by:
  • libssl.so.1.1
1
207}-
208-
209/*-
210 * Set *pgroups to the supported groups list and *pgroupslen to-
211 * the number of groups supported.-
212 */-
213void tls1_get_supported_groups(SSL *s, const uint16_t **pgroups,-
214 size_t *pgroupslen)-
215{-
216-
217 /* For Suite B mode only include P-256, P-384 */-
218 switch (tls1_suiteb(s)) {-
219 case SSL_CERT_FLAG_SUITEB_128_LOS:
executed 2 times by 1 test: case 0x30000:
Executed by:
  • libssl.so.1.1
2
220 *pgroups = suiteb_curves;-
221 *pgroupslen = OSSL_NELEM(suiteb_curves);-
222 break;
executed 2 times by 1 test: break;
Executed by:
  • libssl.so.1.1
2
223-
224 case SSL_CERT_FLAG_SUITEB_128_LOS_ONLY:
never executed: case 0x10000:
0
225 *pgroups = suiteb_curves;-
226 *pgroupslen = 1;-
227 break;
never executed: break;
0
228-
229 case SSL_CERT_FLAG_SUITEB_192_LOS:
never executed: case 0x20000:
0
230 *pgroups = suiteb_curves + 1;-
231 *pgroupslen = 1;-
232 break;
never executed: break;
0
233-
234 default:
executed 19557 times by 1 test: default:
Executed by:
  • libssl.so.1.1
19557
235 if (s->ext.supportedgroups == NULL) {
s->ext.support...== ((void *)0)Description
TRUEevaluated 19278 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 279 times by 1 test
Evaluated by:
  • libssl.so.1.1
279-19278
236 *pgroups = eccurves_default;-
237 *pgroupslen = OSSL_NELEM(eccurves_default);-
238 } else {
executed 19278 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
19278
239 *pgroups = s->ext.supportedgroups;-
240 *pgroupslen = s->ext.supportedgroups_len;-
241 }
executed 279 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
279
242 break;
executed 19557 times by 1 test: break;
Executed by:
  • libssl.so.1.1
19557
243 }-
244}-
245-
246/* See if curve is allowed by security callback */-
247int tls_curve_allowed(SSL *s, uint16_t curve, int op)-
248{-
249 const TLS_GROUP_INFO *cinfo = tls1_group_id_lookup(curve);-
250 unsigned char ctmp[2];-
251-
252 if (cinfo == NULL)
cinfo == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 34756 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-34756
253 return 0;
never executed: return 0;
0
254# ifdef OPENSSL_NO_EC2M-
255 if (cinfo->flags & TLS_CURVE_CHAR2)-
256 return 0;-
257# endif-
258 ctmp[0] = curve >> 8;-
259 ctmp[1] = curve & 0xff;-
260 return ssl_security(s, op, cinfo->secbits, cinfo->nid, (void *)ctmp);
executed 34756 times by 1 test: return ssl_security(s, op, cinfo->secbits, cinfo->nid, (void *)ctmp);
Executed by:
  • libssl.so.1.1
34756
261}-
262-
263/* Return 1 if "id" is in "list" */-
264static int tls1_in_list(uint16_t id, const uint16_t *list, size_t listlen)-
265{-
266 size_t i;-
267 for (i = 0; i < listlen; i++)
i < listlenDescription
TRUEevaluated 14185 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1730 times by 1 test
Evaluated by:
  • libssl.so.1.1
1730-14185
268 if (list[i] == id)
list[i] == idDescription
TRUEevaluated 4136 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 10049 times by 1 test
Evaluated by:
  • libssl.so.1.1
4136-10049
269 return 1;
executed 4136 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
4136
270 return 0;
executed 1730 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
1730
271}-
272-
273/*--
274 * For nmatch >= 0, return the id of the |nmatch|th shared group or 0-
275 * if there is no match.-
276 * For nmatch == -1, return number of matches-
277 * For nmatch == -2, return the id of the group to use for-
278 * a tmp key, or 0 if there is no match.-
279 */-
280uint16_t tls1_shared_group(SSL *s, int nmatch)-
281{-
282 const uint16_t *pref, *supp;-
283 size_t num_pref, num_supp, i;-
284 int k;-
285-
286 /* Can't do anything on client side */-
287 if (s->server == 0)
s->server == 0Description
TRUEnever evaluated
FALSEevaluated 7034 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-7034
288 return 0;
never executed: return 0;
0
289 if (nmatch == -2) {
nmatch == -2Description
TRUEevaluated 1085 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5949 times by 1 test
Evaluated by:
  • libssl.so.1.1
1085-5949
290 if (tls1_suiteb(s)) {
(s->cert->cert...ags & 0x30000)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1083 times by 1 test
Evaluated by:
  • libssl.so.1.1
2-1083
291 /*-
292 * For Suite B ciphersuite determines curve: we already know-
293 * these are acceptable due to previous checks.-
294 */-
295 unsigned long cid = s->s3->tmp.new_cipher->id;-
296-
297 if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256)
cid == 0x0300C02BDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2
298 return TLSEXT_curve_P_256;
executed 2 times by 1 test: return 23;
Executed by:
  • libssl.so.1.1
2
299 if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384)
cid == 0x0300C02CDescription
TRUEnever evaluated
FALSEnever evaluated
0
300 return TLSEXT_curve_P_384;
never executed: return 24;
0
301 /* Should never happen */-
302 return 0;
never executed: return 0;
0
303 }-
304 /* If not Suite B just return first preference shared curve */-
305 nmatch = 0;-
306 }
executed 1083 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
1083
307 /*-
308 * If server preference set, our groups are the preference order-
309 * otherwise peer decides.-
310 */-
311 if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE) {
s->options & 0x00400000UDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 7019 times by 1 test
Evaluated by:
  • libssl.so.1.1
13-7019
312 tls1_get_supported_groups(s, &pref, &num_pref);-
313 tls1_get_peer_groups(s, &supp, &num_supp);-
314 } else {
executed 13 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
13
315 tls1_get_peer_groups(s, &pref, &num_pref);-
316 tls1_get_supported_groups(s, &supp, &num_supp);-
317 }
executed 7019 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
7019
318-
319 for (k = 0, i = 0; i < num_pref; i++) {
i < num_prefDescription
TRUEevaluated 4289 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4352 times by 1 test
Evaluated by:
  • libssl.so.1.1
4289-4352
320 uint16_t id = pref[i];-
321-
322 if (!tls1_in_list(id, supp, num_supp)
!tls1_in_list(...upp, num_supp)Description
TRUEevaluated 1609 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2680 times by 1 test
Evaluated by:
  • libssl.so.1.1
1609-2680
323 || !tls_curve_allowed(s, id, SSL_SECOP_CURVE_SHARED))
!tls_curve_all... | (2 << 16)))Description
TRUEnever evaluated
FALSEevaluated 2680 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2680
324 continue;
executed 1609 times by 1 test: continue;
Executed by:
  • libssl.so.1.1
1609
325 if (nmatch == k)
nmatch == kDescription
TRUEevaluated 2680 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2680
326 return id;
executed 2680 times by 1 test: return id;
Executed by:
  • libssl.so.1.1
2680
327 k++;-
328 }
never executed: end of block
0
329 if (nmatch == -1)
nmatch == -1Description
TRUEnever evaluated
FALSEevaluated 4352 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4352
330 return k;
never executed: return k;
0
331 /* Out of range (nmatch > k). */-
332 return 0;
executed 4352 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
4352
333}-
334-
335int tls1_set_groups(uint16_t **pext, size_t *pextlen,-
336 int *groups, size_t ngroups)-
337{-
338 uint16_t *glist;-
339 size_t i;-
340 /*-
341 * Bitmap of groups included to detect duplicates: only works while group-
342 * ids < 32-
343 */-
344 unsigned long dup_list = 0;-
345-
346 if ((glist = OPENSSL_malloc(ngroups * sizeof(*glist))) == NULL) {
(glist = CRYPT...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 111 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-111
347 SSLerr(SSL_F_TLS1_SET_GROUPS, ERR_R_MALLOC_FAILURE);-
348 return 0;
never executed: return 0;
0
349 }-
350 for (i = 0; i < ngroups; i++) {
i < ngroupsDescription
TRUEevaluated 116 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 111 times by 1 test
Evaluated by:
  • libssl.so.1.1
111-116
351 unsigned long idmask;-
352 uint16_t id;-
353 /* TODO(TLS1.3): Convert for DH groups */-
354 id = tls1_nid2group_id(groups[i]);-
355 idmask = 1L << id;-
356 if (!id || (dup_list & idmask)) {
!idDescription
TRUEnever evaluated
FALSEevaluated 116 times by 1 test
Evaluated by:
  • libssl.so.1.1
(dup_list & idmask)Description
TRUEnever evaluated
FALSEevaluated 116 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-116
357 OPENSSL_free(glist);-
358 return 0;
never executed: return 0;
0
359 }-
360 dup_list |= idmask;-
361 glist[i] = id;-
362 }
executed 116 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
116
363 OPENSSL_free(*pext);-
364 *pext = glist;-
365 *pextlen = ngroups;-
366 return 1;
executed 111 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
111
367}-
368-
369# define MAX_CURVELIST OSSL_NELEM(nid_list)-
370-
371typedef struct {-
372 size_t nidcnt;-
373 int nid_arr[MAX_CURVELIST];-
374} nid_cb_st;-
375-
376static int nid_cb(const char *elem, int len, void *arg)-
377{-
378 nid_cb_st *narg = arg;-
379 size_t i;-
380 int nid;-
381 char etmp[20];-
382 if (elem == NULL)
elem == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 116 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-116
383 return 0;
never executed: return 0;
0
384 if (narg->nidcnt == MAX_CURVELIST)
narg->nidcnt =...nid_list)[0]))Description
TRUEnever evaluated
FALSEevaluated 116 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-116
385 return 0;
never executed: return 0;
0
386 if (len > (int)(sizeof(etmp) - 1))
len > (int)(sizeof(etmp) - 1)Description
TRUEnever evaluated
FALSEevaluated 116 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-116
387 return 0;
never executed: return 0;
0
388 memcpy(etmp, elem, len);-
389 etmp[len] = 0;-
390 nid = EC_curve_nist2nid(etmp);-
391 if (nid == NID_undef)
nid == 0Description
TRUEevaluated 70 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 46 times by 1 test
Evaluated by:
  • libssl.so.1.1
46-70
392 nid = OBJ_sn2nid(etmp);
executed 70 times by 1 test: nid = OBJ_sn2nid(etmp);
Executed by:
  • libssl.so.1.1
70
393 if (nid == NID_undef)
nid == 0Description
TRUEnever evaluated
FALSEevaluated 116 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-116
394 nid = OBJ_ln2nid(etmp);
never executed: nid = OBJ_ln2nid(etmp);
0
395 if (nid == NID_undef)
nid == 0Description
TRUEnever evaluated
FALSEevaluated 116 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-116
396 return 0;
never executed: return 0;
0
397 for (i = 0; i < narg->nidcnt; i++)
i < narg->nidcntDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 116 times by 1 test
Evaluated by:
  • libssl.so.1.1
5-116
398 if (narg->nid_arr[i] == nid)
narg->nid_arr[i] == nidDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-5
399 return 0;
never executed: return 0;
0
400 narg->nid_arr[narg->nidcnt++] = nid;-
401 return 1;
executed 116 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
116
402}-
403-
404/* Set groups based on a colon separate list */-
405int tls1_set_groups_list(uint16_t **pext, size_t *pextlen, const char *str)-
406{-
407 nid_cb_st ncb;-
408 ncb.nidcnt = 0;-
409 if (!CONF_parse_list(str, ':', 1, nid_cb, &ncb))
!CONF_parse_li... nid_cb, &ncb)Description
TRUEnever evaluated
FALSEevaluated 111 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-111
410 return 0;
never executed: return 0;
0
411 if (pext == NULL)
pext == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 111 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-111
412 return 1;
never executed: return 1;
0
413 return tls1_set_groups(pext, pextlen, ncb.nid_arr, ncb.nidcnt);
executed 111 times by 1 test: return tls1_set_groups(pext, pextlen, ncb.nid_arr, ncb.nidcnt);
Executed by:
  • libssl.so.1.1
111
414}-
415/* Return group id of a key */-
416static uint16_t tls1_get_group_id(EVP_PKEY *pkey)-
417{-
418 EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey);-
419 const EC_GROUP *grp;-
420-
421 if (ec == NULL)
ec == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 814 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-814
422 return 0;
never executed: return 0;
0
423 grp = EC_KEY_get0_group(ec);-
424 return tls1_nid2group_id(EC_GROUP_get_curve_name(grp));
executed 814 times by 1 test: return tls1_nid2group_id(EC_GROUP_get_curve_name(grp));
Executed by:
  • libssl.so.1.1
814
425}-
426-
427/* Check a key is compatible with compression extension */-
428static int tls1_check_pkey_comp(SSL *s, EVP_PKEY *pkey)-
429{-
430 const EC_KEY *ec;-
431 const EC_GROUP *grp;-
432 unsigned char comp_id;-
433 size_t i;-
434-
435 /* If not an EC key nothing to check */-
436 if (EVP_PKEY_id(pkey) != EVP_PKEY_EC)
EVP_PKEY_id(pkey) != 408Description
TRUEnever evaluated
FALSEevaluated 869 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-869
437 return 1;
never executed: return 1;
0
438 ec = EVP_PKEY_get0_EC_KEY(pkey);-
439 grp = EC_KEY_get0_group(ec);-
440-
441 /* Get required compression id */-
442 if (EC_KEY_get_conv_form(ec) == POINT_CONVERSION_UNCOMPRESSED) {
EC_KEY_get_con...N_UNCOMPRESSEDDescription
TRUEevaluated 863 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
6-863
443 comp_id = TLSEXT_ECPOINTFORMAT_uncompressed;-
444 } else if (SSL_IS_TLS13(s)) {
executed 863 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
(s)->method->version >= 0x0304Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->v...ion != 0x10000Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-863
445 /*-
446 * ec_point_formats extension is not used in TLSv1.3 so we ignore-
447 * this check.-
448 */-
449 return 1;
executed 1 time by 1 test: return 1;
Executed by:
  • libssl.so.1.1
1
450 } else {-
451 int field_type = EC_METHOD_get_field_type(EC_GROUP_method_of(grp));-
452-
453 if (field_type == NID_X9_62_prime_field)
field_type == 406Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
1-4
454 comp_id = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime;
executed 4 times by 1 test: comp_id = 1;
Executed by:
  • libssl.so.1.1
4
455 else if (field_type == NID_X9_62_characteristic_two_field)
field_type == 407Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-1
456 comp_id = TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2;
executed 1 time by 1 test: comp_id = 2;
Executed by:
  • libssl.so.1.1
1
457 else-
458 return 0;
never executed: return 0;
0
459 }-
460 /*-
461 * If point formats extension present check it, otherwise everything is-
462 * supported (see RFC4492).-
463 */-
464 if (s->session->ext.ecpointformats == NULL)
s->session->ex...== ((void *)0)Description
TRUEevaluated 417 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 451 times by 1 test
Evaluated by:
  • libssl.so.1.1
417-451
465 return 1;
executed 417 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
417
466-
467 for (i = 0; i < s->session->ext.ecpointformats_len; i++) {
i < s->session...intformats_lenDescription
TRUEevaluated 796 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 46 times by 1 test
Evaluated by:
  • libssl.so.1.1
46-796
468 if (s->session->ext.ecpointformats[i] == comp_id)
s->session->ex...[i] == comp_idDescription
TRUEevaluated 405 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 391 times by 1 test
Evaluated by:
  • libssl.so.1.1
391-405
469 return 1;
executed 405 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
405
470 }
executed 391 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
391
471 return 0;
executed 46 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
46
472}-
473-
474/* Check a group id matches preferences */-
475int tls1_check_group_id(SSL *s, uint16_t group_id, int check_own_groups)-
476 {-
477 const uint16_t *groups;-
478 size_t groups_len;-
479-
480 if (group_id == 0)
group_id == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1805 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-1805
481 return 0;
executed 1 time by 1 test: return 0;
Executed by:
  • libssl.so.1.1
1
482-
483 /* Check for Suite B compliance */-
484 if (tls1_suiteb(s) && s->s3->tmp.new_cipher != NULL) {
(s->cert->cert...ags & 0x30000)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1801 times by 1 test
Evaluated by:
  • libssl.so.1.1
s->s3->tmp.new...!= ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1801
485 unsigned long cid = s->s3->tmp.new_cipher->id;-
486-
487 if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256) {
cid == 0x0300C02BDescription
TRUEnever evaluated
FALSEnever evaluated
0
488 if (group_id != TLSEXT_curve_P_256)
group_id != 23Description
TRUEnever evaluated
FALSEnever evaluated
0
489 return 0;
never executed: return 0;
0
490 } else if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384) {
never executed: end of block
cid == 0x0300C02CDescription
TRUEnever evaluated
FALSEnever evaluated
0
491 if (group_id != TLSEXT_curve_P_384)
group_id != 24Description
TRUEnever evaluated
FALSEnever evaluated
0
492 return 0;
never executed: return 0;
0
493 } else {
never executed: end of block
0
494 /* Should never happen */-
495 return 0;
never executed: return 0;
0
496 }-
497 }-
498-
499 if (check_own_groups) {
check_own_groupsDescription
TRUEevaluated 1162 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 643 times by 1 test
Evaluated by:
  • libssl.so.1.1
643-1162
500 /* Check group is one of our preferences */-
501 tls1_get_supported_groups(s, &groups, &groups_len);-
502 if (!tls1_in_list(group_id, groups, groups_len))
!tls1_in_list(...s, groups_len)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1159 times by 1 test
Evaluated by:
  • libssl.so.1.1
3-1159
503 return 0;
executed 3 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
3
504 }
executed 1159 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
1159
505-
506 if (!tls_curve_allowed(s, group_id, SSL_SECOP_CURVE_CHECK))
!tls_curve_all... | (2 << 16)))Description
TRUEnever evaluated
FALSEevaluated 1802 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1802
507 return 0;
never executed: return 0;
0
508-
509 /* For clients, nothing more to check */-
510 if (!s->server)
!s->serverDescription
TRUEevaluated 1157 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 645 times by 1 test
Evaluated by:
  • libssl.so.1.1
645-1157
511 return 1;
executed 1157 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
1157
512-
513 /* Check group is one of peers preferences */-
514 tls1_get_peer_groups(s, &groups, &groups_len);-
515-
516 /*-
517 * RFC 4492 does not require the supported elliptic curves extension-
518 * so if it is not sent we can just choose any curve.-
519 * It is invalid to send an empty list in the supported groups-
520 * extension, so groups_len == 0 always means no extension.-
521 */-
522 if (groups_len == 0)
groups_len == 0Description
TRUEevaluated 230 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 415 times by 1 test
Evaluated by:
  • libssl.so.1.1
230-415
523 return 1;
executed 230 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
230
524 return tls1_in_list(group_id, groups, groups_len);
executed 415 times by 1 test: return tls1_in_list(group_id, groups, groups_len);
Executed by:
  • libssl.so.1.1
415
525}-
526-
527void tls1_get_formatlist(SSL *s, const unsigned char **pformats,-
528 size_t *num_formats)-
529{-
530 /*-
531 * If we have a custom point format list use it otherwise use default-
532 */-
533 if (s->ext.ecpointformats) {
s->ext.ecpointformatsDescription
TRUEnever evaluated
FALSEevaluated 5858 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-5858
534 *pformats = s->ext.ecpointformats;-
535 *num_formats = s->ext.ecpointformats_len;-
536 } else {
never executed: end of block
0
537 *pformats = ecformats_default;-
538 /* For Suite B we don't support char2 fields */-
539 if (tls1_suiteb(s))
(s->cert->cert...ags & 0x30000)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5856 times by 1 test
Evaluated by:
  • libssl.so.1.1
2-5856
540 *num_formats = sizeof(ecformats_default) - 1;
executed 2 times by 1 test: *num_formats = sizeof(ecformats_default) - 1;
Executed by:
  • libssl.so.1.1
2
541 else-
542 *num_formats = sizeof(ecformats_default);
executed 5856 times by 1 test: *num_formats = sizeof(ecformats_default);
Executed by:
  • libssl.so.1.1
5856
543 }-
544}-
545-
546/*-
547 * Check cert parameters compatible with extensions: currently just checks EC-
548 * certificates have compatible curves and compression.-
549 */-
550static int tls1_check_cert_param(SSL *s, X509 *x, int check_ee_md)-
551{-
552 uint16_t group_id;-
553 EVP_PKEY *pkey;-
554 pkey = X509_get0_pubkey(x);-
555 if (pkey == NULL)
pkey == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2982 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2982
556 return 0;
never executed: return 0;
0
557 /* If not EC nothing to do */-
558 if (EVP_PKEY_id(pkey) != EVP_PKEY_EC)
EVP_PKEY_id(pkey) != 408Description
TRUEevaluated 2294 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 688 times by 1 test
Evaluated by:
  • libssl.so.1.1
688-2294
559 return 1;
executed 2294 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
2294
560 /* Check compression */-
561 if (!tls1_check_pkey_comp(s, pkey))
!tls1_check_pkey_comp(s, pkey)Description
TRUEevaluated 45 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 643 times by 1 test
Evaluated by:
  • libssl.so.1.1
45-643
562 return 0;
executed 45 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
45
563 group_id = tls1_get_group_id(pkey);-
564 /*-
565 * For a server we allow the certificate to not be in our list of supported-
566 * groups.-
567 */-
568 if (!tls1_check_group_id(s, group_id, !s->server))
!tls1_check_gr...d, !s->server)Description
TRUEevaluated 118 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 525 times by 1 test
Evaluated by:
  • libssl.so.1.1
118-525
569 return 0;
executed 118 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
118
570 /*-
571 * Special case for suite B. We *MUST* sign using SHA256+P-256 or-
572 * SHA384+P-384.-
573 */-
574 if (check_ee_md && tls1_suiteb(s)) {
check_ee_mdDescription
TRUEevaluated 525 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
(s->cert->cert...ags & 0x30000)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 523 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-525
575 int check_md;-
576 size_t i;-
577 CERT *c = s->cert;-
578-
579 /* Check to see we have necessary signing algorithm */-
580 if (group_id == TLSEXT_curve_P_256)
group_id == 23Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
1
581 check_md = NID_ecdsa_with_SHA256;
executed 1 time by 1 test: check_md = 794;
Executed by:
  • libssl.so.1.1
1
582 else if (group_id == TLSEXT_curve_P_384)
group_id == 24Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-1
583 check_md = NID_ecdsa_with_SHA384;
executed 1 time by 1 test: check_md = 795;
Executed by:
  • libssl.so.1.1
1
584 else-
585 return 0; /* Should never happen */
never executed: return 0;
0
586 for (i = 0; i < c->shared_sigalgslen; i++) {
i < c->shared_sigalgslenDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-3
587 if (check_md == c->shared_sigalgs[i]->sigandhash)
check_md == c-...i]->sigandhashDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
1-2
588 return 1;;
executed 2 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
2
589 }
executed 1 time by 1 test: end of block
Executed by:
  • libssl.so.1.1
1
590 return 0;
never executed: return 0;
0
591 }-
592 return 1;
executed 523 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
523
593}-
594-
595/*-
596 * tls1_check_ec_tmp_key - Check EC temporary key compatibility-
597 * @s: SSL connection-
598 * @cid: Cipher ID we're considering using-
599 *-
600 * Checks that the kECDHE cipher suite we're considering using-
601 * is compatible with the client extensions.-
602 *-
603 * Returns 0 when the cipher can't be used or 1 when it can.-
604 */-
605int tls1_check_ec_tmp_key(SSL *s, unsigned long cid)-
606{-
607 /* If not Suite B just need a shared group */-
608 if (!tls1_suiteb(s))
!(s->cert->cer...ags & 0x30000)Description
TRUEevaluated 5949 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
2-5949
609 return tls1_shared_group(s, 0) != 0;
executed 5949 times by 1 test: return tls1_shared_group(s, 0) != 0;
Executed by:
  • libssl.so.1.1
5949
610 /*-
611 * If Suite B, AES128 MUST use P-256 and AES256 MUST use P-384, no other-
612 * curves permitted.-
613 */-
614 if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256)
cid == 0x0300C02BDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2
615 return tls1_check_group_id(s, TLSEXT_curve_P_256, 1);
executed 2 times by 1 test: return tls1_check_group_id(s, 23, 1);
Executed by:
  • libssl.so.1.1
2
616 if (cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384)
cid == 0x0300C02CDescription
TRUEnever evaluated
FALSEnever evaluated
0
617 return tls1_check_group_id(s, TLSEXT_curve_P_384, 1);
never executed: return tls1_check_group_id(s, 24, 1);
0
618-
619 return 0;
never executed: return 0;
0
620}-
621-
622#else-
623-
624static int tls1_check_cert_param(SSL *s, X509 *x, int set_ee_md)-
625{-
626 return 1;-
627}-
628-
629#endif /* OPENSSL_NO_EC */-
630-
631/* Default sigalg schemes */-
632static const uint16_t tls12_sigalgs[] = {-
633#ifndef OPENSSL_NO_EC-
634 TLSEXT_SIGALG_ecdsa_secp256r1_sha256,-
635 TLSEXT_SIGALG_ecdsa_secp384r1_sha384,-
636 TLSEXT_SIGALG_ecdsa_secp521r1_sha512,-
637 TLSEXT_SIGALG_ed25519,-
638 TLSEXT_SIGALG_ed448,-
639#endif-
640-
641 TLSEXT_SIGALG_rsa_pss_pss_sha256,-
642 TLSEXT_SIGALG_rsa_pss_pss_sha384,-
643 TLSEXT_SIGALG_rsa_pss_pss_sha512,-
644 TLSEXT_SIGALG_rsa_pss_rsae_sha256,-
645 TLSEXT_SIGALG_rsa_pss_rsae_sha384,-
646 TLSEXT_SIGALG_rsa_pss_rsae_sha512,-
647-
648 TLSEXT_SIGALG_rsa_pkcs1_sha256,-
649 TLSEXT_SIGALG_rsa_pkcs1_sha384,-
650 TLSEXT_SIGALG_rsa_pkcs1_sha512,-
651-
652#ifndef OPENSSL_NO_EC-
653 TLSEXT_SIGALG_ecdsa_sha224,-
654 TLSEXT_SIGALG_ecdsa_sha1,-
655#endif-
656 TLSEXT_SIGALG_rsa_pkcs1_sha224,-
657 TLSEXT_SIGALG_rsa_pkcs1_sha1,-
658#ifndef OPENSSL_NO_DSA-
659 TLSEXT_SIGALG_dsa_sha224,-
660 TLSEXT_SIGALG_dsa_sha1,-
661-
662 TLSEXT_SIGALG_dsa_sha256,-
663 TLSEXT_SIGALG_dsa_sha384,-
664 TLSEXT_SIGALG_dsa_sha512,-
665#endif-
666#ifndef OPENSSL_NO_GOST-
667 TLSEXT_SIGALG_gostr34102012_256_gostr34112012_256,-
668 TLSEXT_SIGALG_gostr34102012_512_gostr34112012_512,-
669 TLSEXT_SIGALG_gostr34102001_gostr3411,-
670#endif-
671};-
672-
673#ifndef OPENSSL_NO_EC-
674static const uint16_t suiteb_sigalgs[] = {-
675 TLSEXT_SIGALG_ecdsa_secp256r1_sha256,-
676 TLSEXT_SIGALG_ecdsa_secp384r1_sha384-
677};-
678#endif-
679-
680static const SIGALG_LOOKUP sigalg_lookup_tbl[] = {-
681#ifndef OPENSSL_NO_EC-
682 {"ecdsa_secp256r1_sha256", TLSEXT_SIGALG_ecdsa_secp256r1_sha256,-
683 NID_sha256, SSL_MD_SHA256_IDX, EVP_PKEY_EC, SSL_PKEY_ECC,-
684 NID_ecdsa_with_SHA256, NID_X9_62_prime256v1},-
685 {"ecdsa_secp384r1_sha384", TLSEXT_SIGALG_ecdsa_secp384r1_sha384,-
686 NID_sha384, SSL_MD_SHA384_IDX, EVP_PKEY_EC, SSL_PKEY_ECC,-
687 NID_ecdsa_with_SHA384, NID_secp384r1},-
688 {"ecdsa_secp521r1_sha512", TLSEXT_SIGALG_ecdsa_secp521r1_sha512,-
689 NID_sha512, SSL_MD_SHA512_IDX, EVP_PKEY_EC, SSL_PKEY_ECC,-
690 NID_ecdsa_with_SHA512, NID_secp521r1},-
691 {"ed25519", TLSEXT_SIGALG_ed25519,-
692 NID_undef, -1, EVP_PKEY_ED25519, SSL_PKEY_ED25519,-
693 NID_undef, NID_undef},-
694 {"ed448", TLSEXT_SIGALG_ed448,-
695 NID_undef, -1, EVP_PKEY_ED448, SSL_PKEY_ED448,-
696 NID_undef, NID_undef},-
697 {NULL, TLSEXT_SIGALG_ecdsa_sha224,-
698 NID_sha224, SSL_MD_SHA224_IDX, EVP_PKEY_EC, SSL_PKEY_ECC,-
699 NID_ecdsa_with_SHA224, NID_undef},-
700 {NULL, TLSEXT_SIGALG_ecdsa_sha1,-
701 NID_sha1, SSL_MD_SHA1_IDX, EVP_PKEY_EC, SSL_PKEY_ECC,-
702 NID_ecdsa_with_SHA1, NID_undef},-
703#endif-
704 {"rsa_pss_rsae_sha256", TLSEXT_SIGALG_rsa_pss_rsae_sha256,-
705 NID_sha256, SSL_MD_SHA256_IDX, EVP_PKEY_RSA_PSS, SSL_PKEY_RSA,-
706 NID_undef, NID_undef},-
707 {"rsa_pss_rsae_sha384", TLSEXT_SIGALG_rsa_pss_rsae_sha384,-
708 NID_sha384, SSL_MD_SHA384_IDX, EVP_PKEY_RSA_PSS, SSL_PKEY_RSA,-
709 NID_undef, NID_undef},-
710 {"rsa_pss_rsae_sha512", TLSEXT_SIGALG_rsa_pss_rsae_sha512,-
711 NID_sha512, SSL_MD_SHA512_IDX, EVP_PKEY_RSA_PSS, SSL_PKEY_RSA,-
712 NID_undef, NID_undef},-
713 {"rsa_pss_pss_sha256", TLSEXT_SIGALG_rsa_pss_pss_sha256,-
714 NID_sha256, SSL_MD_SHA256_IDX, EVP_PKEY_RSA_PSS, SSL_PKEY_RSA_PSS_SIGN,-
715 NID_undef, NID_undef},-
716 {"rsa_pss_pss_sha384", TLSEXT_SIGALG_rsa_pss_pss_sha384,-
717 NID_sha384, SSL_MD_SHA384_IDX, EVP_PKEY_RSA_PSS, SSL_PKEY_RSA_PSS_SIGN,-
718 NID_undef, NID_undef},-
719 {"rsa_pss_pss_sha512", TLSEXT_SIGALG_rsa_pss_pss_sha512,-
720 NID_sha512, SSL_MD_SHA512_IDX, EVP_PKEY_RSA_PSS, SSL_PKEY_RSA_PSS_SIGN,-
721 NID_undef, NID_undef},-
722 {"rsa_pkcs1_sha256", TLSEXT_SIGALG_rsa_pkcs1_sha256,-
723 NID_sha256, SSL_MD_SHA256_IDX, EVP_PKEY_RSA, SSL_PKEY_RSA,-
724 NID_sha256WithRSAEncryption, NID_undef},-
725 {"rsa_pkcs1_sha384", TLSEXT_SIGALG_rsa_pkcs1_sha384,-
726 NID_sha384, SSL_MD_SHA384_IDX, EVP_PKEY_RSA, SSL_PKEY_RSA,-
727 NID_sha384WithRSAEncryption, NID_undef},-
728 {"rsa_pkcs1_sha512", TLSEXT_SIGALG_rsa_pkcs1_sha512,-
729 NID_sha512, SSL_MD_SHA512_IDX, EVP_PKEY_RSA, SSL_PKEY_RSA,-
730 NID_sha512WithRSAEncryption, NID_undef},-
731 {"rsa_pkcs1_sha224", TLSEXT_SIGALG_rsa_pkcs1_sha224,-
732 NID_sha224, SSL_MD_SHA224_IDX, EVP_PKEY_RSA, SSL_PKEY_RSA,-
733 NID_sha224WithRSAEncryption, NID_undef},-
734 {"rsa_pkcs1_sha1", TLSEXT_SIGALG_rsa_pkcs1_sha1,-
735 NID_sha1, SSL_MD_SHA1_IDX, EVP_PKEY_RSA, SSL_PKEY_RSA,-
736 NID_sha1WithRSAEncryption, NID_undef},-
737#ifndef OPENSSL_NO_DSA-
738 {NULL, TLSEXT_SIGALG_dsa_sha256,-
739 NID_sha256, SSL_MD_SHA256_IDX, EVP_PKEY_DSA, SSL_PKEY_DSA_SIGN,-
740 NID_dsa_with_SHA256, NID_undef},-
741 {NULL, TLSEXT_SIGALG_dsa_sha384,-
742 NID_sha384, SSL_MD_SHA384_IDX, EVP_PKEY_DSA, SSL_PKEY_DSA_SIGN,-
743 NID_undef, NID_undef},-
744 {NULL, TLSEXT_SIGALG_dsa_sha512,-
745 NID_sha512, SSL_MD_SHA512_IDX, EVP_PKEY_DSA, SSL_PKEY_DSA_SIGN,-
746 NID_undef, NID_undef},-
747 {NULL, TLSEXT_SIGALG_dsa_sha224,-
748 NID_sha224, SSL_MD_SHA224_IDX, EVP_PKEY_DSA, SSL_PKEY_DSA_SIGN,-
749 NID_undef, NID_undef},-
750 {NULL, TLSEXT_SIGALG_dsa_sha1,-
751 NID_sha1, SSL_MD_SHA1_IDX, EVP_PKEY_DSA, SSL_PKEY_DSA_SIGN,-
752 NID_dsaWithSHA1, NID_undef},-
753#endif-
754#ifndef OPENSSL_NO_GOST-
755 {NULL, TLSEXT_SIGALG_gostr34102012_256_gostr34112012_256,-
756 NID_id_GostR3411_2012_256, SSL_MD_GOST12_256_IDX,-
757 NID_id_GostR3410_2012_256, SSL_PKEY_GOST12_256,-
758 NID_undef, NID_undef},-
759 {NULL, TLSEXT_SIGALG_gostr34102012_512_gostr34112012_512,-
760 NID_id_GostR3411_2012_512, SSL_MD_GOST12_512_IDX,-
761 NID_id_GostR3410_2012_512, SSL_PKEY_GOST12_512,-
762 NID_undef, NID_undef},-
763 {NULL, TLSEXT_SIGALG_gostr34102001_gostr3411,-
764 NID_id_GostR3411_94, SSL_MD_GOST94_IDX,-
765 NID_id_GostR3410_2001, SSL_PKEY_GOST01,-
766 NID_undef, NID_undef}-
767#endif-
768};-
769/* Legacy sigalgs for TLS < 1.2 RSA TLS signatures */-
770static const SIGALG_LOOKUP legacy_rsa_sigalg = {-
771 "rsa_pkcs1_md5_sha1", 0,-
772 NID_md5_sha1, SSL_MD_MD5_SHA1_IDX,-
773 EVP_PKEY_RSA, SSL_PKEY_RSA,-
774 NID_undef, NID_undef-
775};-
776-
777/*-
778 * Default signature algorithm values used if signature algorithms not present.-
779 * From RFC5246. Note: order must match certificate index order.-
780 */-
781static const uint16_t tls_default_sigalg[] = {-
782 TLSEXT_SIGALG_rsa_pkcs1_sha1, /* SSL_PKEY_RSA */-
783 0, /* SSL_PKEY_RSA_PSS_SIGN */-
784 TLSEXT_SIGALG_dsa_sha1, /* SSL_PKEY_DSA_SIGN */-
785 TLSEXT_SIGALG_ecdsa_sha1, /* SSL_PKEY_ECC */-
786 TLSEXT_SIGALG_gostr34102001_gostr3411, /* SSL_PKEY_GOST01 */-
787 TLSEXT_SIGALG_gostr34102012_256_gostr34112012_256, /* SSL_PKEY_GOST12_256 */-
788 TLSEXT_SIGALG_gostr34102012_512_gostr34112012_512, /* SSL_PKEY_GOST12_512 */-
789 0, /* SSL_PKEY_ED25519 */-
790 0, /* SSL_PKEY_ED448 */-
791};-
792-
793/* Lookup TLS signature algorithm */-
794static const SIGALG_LOOKUP *tls1_lookup_sigalg(uint16_t sigalg)-
795{-
796 size_t i;-
797 const SIGALG_LOOKUP *s;-
798-
799 for (i = 0, s = sigalg_lookup_tbl; i < OSSL_NELEM(sigalg_lookup_tbl);
i < (sizeof(si...okup_tbl)[0]))Description
TRUEevaluated 5135349 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 26938 times by 1 test
Evaluated by:
  • libssl.so.1.1
26938-5135349
800 i++, s++) {-
801 if (s->sigalg == sigalg)
s->sigalg == sigalgDescription
TRUEevaluated 328869 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4806480 times by 1 test
Evaluated by:
  • libssl.so.1.1
328869-4806480
802 return s;
executed 328869 times by 1 test: return s;
Executed by:
  • libssl.so.1.1
328869
803 }
executed 4806480 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
4806480
804 return NULL;
executed 26938 times by 1 test: return ((void *)0) ;
Executed by:
  • libssl.so.1.1
26938
805}-
806/* Lookup hash: return 0 if invalid or not enabled */-
807int tls1_lookup_md(const SIGALG_LOOKUP *lu, const EVP_MD **pmd)-
808{-
809 const EVP_MD *md;-
810 if (lu == NULL)
lu == ((void *)0)Description
TRUEevaluated 24719 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 221615 times by 1 test
Evaluated by:
  • libssl.so.1.1
24719-221615
811 return 0;
executed 24719 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
24719
812 /* lu->hash == NID_undef means no associated digest */-
813 if (lu->hash == NID_undef) {
lu->hash == 0Description
TRUEevaluated 16291 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 205324 times by 1 test
Evaluated by:
  • libssl.so.1.1
16291-205324
814 md = NULL;-
815 } else {
executed 16291 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
16291
816 md = ssl_md(lu->hash_idx);-
817 if (md == NULL)
md == ((void *)0)Description
TRUEevaluated 18881 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 186443 times by 1 test
Evaluated by:
  • libssl.so.1.1
18881-186443
818 return 0;
executed 18881 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
18881
819 }
executed 186443 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
186443
820 if (pmd)
pmdDescription
TRUEevaluated 6264 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 196470 times by 1 test
Evaluated by:
  • libssl.so.1.1
6264-196470
821 *pmd = md;
executed 6264 times by 1 test: *pmd = md;
Executed by:
  • libssl.so.1.1
6264
822 return 1;
executed 202734 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
202734
823}-
824-
825/*-
826 * Check if key is large enough to generate RSA-PSS signature.-
827 *-
828 * The key must greater than or equal to 2 * hash length + 2.-
829 * SHA512 has a hash length of 64 bytes, which is incompatible-
830 * with a 128 byte (1024 bit) key.-
831 */-
832#define RSA_PSS_MINIMUM_KEY_SIZE(md) (2 * EVP_MD_size(md) + 2)-
833static int rsa_pss_check_min_key_size(const RSA *rsa, const SIGALG_LOOKUP *lu)-
834{-
835 const EVP_MD *md;-
836-
837 if (rsa == NULL)
rsa == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1249 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1249
838 return 0;
never executed: return 0;
0
839 if (!tls1_lookup_md(lu, &md) || md == NULL)
!tls1_lookup_md(lu, &md)Description
TRUEnever evaluated
FALSEevaluated 1249 times by 1 test
Evaluated by:
  • libssl.so.1.1
md == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1249 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1249
840 return 0;
never executed: return 0;
0
841 if (RSA_size(rsa) < RSA_PSS_MINIMUM_KEY_SIZE(md))
RSA_size(rsa) ..._size(md) + 2)Description
TRUEnever evaluated
FALSEevaluated 1249 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1249
842 return 0;
never executed: return 0;
0
843 return 1;
executed 1249 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
1249
844}-
845-
846/*-
847 * Return a signature algorithm for TLS < 1.2 where the signature type-
848 * is fixed by the certificate type.-
849 */-
850static const SIGALG_LOOKUP *tls1_get_legacy_sigalg(const SSL *s, int idx)-
851{-
852 if (idx == -1) {
idx == -1Description
TRUEevaluated 563 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 6566 times by 1 test
Evaluated by:
  • libssl.so.1.1
563-6566
853 if (s->server) {
s->serverDescription
TRUEevaluated 554 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libssl.so.1.1
9-554
854 size_t i;-
855-
856 /* Work out index corresponding to ciphersuite */-
857 for (i = 0; i < SSL_PKEY_NUM; i++) {
i < 9Description
TRUEevaluated 687 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-687
858 const SSL_CERT_LOOKUP *clu = ssl_cert_lookup_by_idx(i);-
859-
860 if (clu->amask & s->s3->tmp.new_cipher->algorithm_auth) {
clu->amask & s...algorithm_authDescription
TRUEevaluated 554 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 133 times by 1 test
Evaluated by:
  • libssl.so.1.1
133-554
861 idx = i;-
862 break;
executed 554 times by 1 test: break;
Executed by:
  • libssl.so.1.1
554
863 }-
864 }
executed 133 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
133
865-
866 /*-
867 * Some GOST ciphersuites allow more than one signature algorithms-
868 * */-
869 if (idx == SSL_PKEY_GOST01 && s->s3->tmp.new_cipher->algorithm_auth != SSL_aGOST01) {
idx == 4Description
TRUEnever evaluated
FALSEevaluated 554 times by 1 test
Evaluated by:
  • libssl.so.1.1
s->s3->tmp.new...!= 0x00000020UDescription
TRUEnever evaluated
FALSEnever evaluated
0-554
870 int real_idx;-
871-
872 for (real_idx = SSL_PKEY_GOST12_512; real_idx >= SSL_PKEY_GOST01;
real_idx >= 4Description
TRUEnever evaluated
FALSEnever evaluated
0
873 real_idx--) {-
874 if (s->cert->pkeys[real_idx].privatekey != NULL) {
s->cert->pkeys...!= ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
875 idx = real_idx;-
876 break;
never executed: break;
0
877 }-
878 }
never executed: end of block
0
879 }
never executed: end of block
0
880 } else {
executed 554 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
554
881 idx = s->cert->key - s->cert->pkeys;-
882 }
executed 9 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
9
883 }-
884 if (idx < 0 || idx >= (int)OSSL_NELEM(tls_default_sigalg))
idx < 0Description
TRUEnever evaluated
FALSEevaluated 7129 times by 1 test
Evaluated by:
  • libssl.so.1.1
idx >= (int)(s...t_sigalg)[0]))Description
TRUEnever evaluated
FALSEevaluated 7129 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-7129
885 return NULL;
never executed: return ((void *)0) ;
0
886 if (SSL_USE_SIGALGS(s) || idx != SSL_PKEY_RSA) {
(s->method->ss...c_flags & 0x2)Description
TRUEevaluated 1841 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5288 times by 1 test
Evaluated by:
  • libssl.so.1.1
idx != 0Description
TRUEevaluated 4019 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1269 times by 1 test
Evaluated by:
  • libssl.so.1.1
1269-5288
887 const SIGALG_LOOKUP *lu = tls1_lookup_sigalg(tls_default_sigalg[idx]);-
888-
889 if (!tls1_lookup_md(lu, NULL))
!tls1_lookup_m... ((void *)0) )Description
TRUEevaluated 4135 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1725 times by 1 test
Evaluated by:
  • libssl.so.1.1
1725-4135
890 return NULL;
executed 4135 times by 1 test: return ((void *)0) ;
Executed by:
  • libssl.so.1.1
4135
891 return lu;
executed 1725 times by 1 test: return lu;
Executed by:
  • libssl.so.1.1
1725
892 }-
893 return &legacy_rsa_sigalg;
executed 1269 times by 1 test: return &legacy_rsa_sigalg;
Executed by:
  • libssl.so.1.1
1269
894}-
895/* Set peer sigalg based key type */-
896int tls1_set_peer_legacy_sigalg(SSL *s, const EVP_PKEY *pkey)-
897{-
898 size_t idx;-
899 const SIGALG_LOOKUP *lu;-
900-
901 if (ssl_cert_lookup_by_pkey(pkey, &idx) == NULL)
ssl_cert_looku...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 365 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-365
902 return 0;
never executed: return 0;
0
903 lu = tls1_get_legacy_sigalg(s, idx);-
904 if (lu == NULL)
lu == ((void *)0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 364 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-364
905 return 0;
executed 1 time by 1 test: return 0;
Executed by:
  • libssl.so.1.1
1
906 s->s3->tmp.peer_sigalg = lu;-
907 return 1;
executed 364 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
364
908}-
909-
910size_t tls12_get_psigalgs(SSL *s, int sent, const uint16_t **psigs)-
911{-
912 /*-
913 * If Suite B mode use Suite B sigalgs only, ignore any other-
914 * preferences.-
915 */-
916#ifndef OPENSSL_NO_EC-
917 switch (tls1_suiteb(s)) {-
918 case SSL_CERT_FLAG_SUITEB_128_LOS:
executed 2 times by 1 test: case 0x30000:
Executed by:
  • libssl.so.1.1
2
919 *psigs = suiteb_sigalgs;-
920 return OSSL_NELEM(suiteb_sigalgs);
executed 2 times by 1 test: return (sizeof(suiteb_sigalgs)/sizeof((suiteb_sigalgs)[0]));
Executed by:
  • libssl.so.1.1
2
921-
922 case SSL_CERT_FLAG_SUITEB_128_LOS_ONLY:
never executed: case 0x10000:
0
923 *psigs = suiteb_sigalgs;-
924 return 1;
never executed: return 1;
0
925-
926 case SSL_CERT_FLAG_SUITEB_192_LOS:
never executed: case 0x20000:
0
927 *psigs = suiteb_sigalgs + 1;-
928 return 1;
never executed: return 1;
0
929 }-
930#endif-
931 /*-
932 * We use client_sigalgs (if not NULL) if we're a server-
933 * and sending a certificate request or if we're a client and-
934 * determining which shared algorithm to use.-
935 */-
936 if ((s->server == sent) && s->cert->client_sigalgs != NULL) {
(s->server == sent)Description
TRUEevaluated 1066 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 12720 times by 1 test
Evaluated by:
  • libssl.so.1.1
s->cert->clien...!= ((void *)0)Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1045 times by 1 test
Evaluated by:
  • libssl.so.1.1
21-12720
937 *psigs = s->cert->client_sigalgs;-
938 return s->cert->client_sigalgslen;
executed 21 times by 1 test: return s->cert->client_sigalgslen;
Executed by:
  • libssl.so.1.1
21
939 } else if (s->cert->conf_sigalgs) {
s->cert->conf_sigalgsDescription
TRUEevaluated 129 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 13636 times by 1 test
Evaluated by:
  • libssl.so.1.1
129-13636
940 *psigs = s->cert->conf_sigalgs;-
941 return s->cert->conf_sigalgslen;
executed 129 times by 1 test: return s->cert->conf_sigalgslen;
Executed by:
  • libssl.so.1.1
129
942 } else {-
943 *psigs = tls12_sigalgs;-
944 return OSSL_NELEM(tls12_sigalgs);
executed 13636 times by 1 test: return (sizeof(tls12_sigalgs)/sizeof((tls12_sigalgs)[0]));
Executed by:
  • libssl.so.1.1
13636
945 }-
946}-
947-
948/*-
949 * Check signature algorithm is consistent with sent supported signature-
950 * algorithms and if so set relevant digest and signature scheme in-
951 * s.-
952 */-
953int tls12_check_peer_sigalg(SSL *s, uint16_t sig, EVP_PKEY *pkey)-
954{-
955 const uint16_t *sent_sigs;-
956 const EVP_MD *md = NULL;-
957 char sigalgstr[2];-
958 size_t sent_sigslen, i, cidx;-
959 int pkeyid = EVP_PKEY_id(pkey);-
960 const SIGALG_LOOKUP *lu;-
961-
962 /* Should never happen */-
963 if (pkeyid == -1)
pkeyid == -1Description
TRUEnever evaluated
FALSEevaluated 1389 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1389
964 return -1;
never executed: return -1;
0
965 if (SSL_IS_TLS13(s)) {
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 1293 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 96 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->version >= 0x0304Description
TRUEevaluated 489 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 804 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->v...ion != 0x10000Description
TRUEevaluated 489 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-1293
966 /* Disallow DSA for TLS 1.3 */-
967 if (pkeyid == EVP_PKEY_DSA) {
pkeyid == 116Description
TRUEnever evaluated
FALSEevaluated 489 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-489
968 SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_TLS12_CHECK_PEER_SIGALG,-
969 SSL_R_WRONG_SIGNATURE_TYPE);-
970 return 0;
never executed: return 0;
0
971 }-
972 /* Only allow PSS for TLS 1.3 */-
973 if (pkeyid == EVP_PKEY_RSA)
pkeyid == 6Description
TRUEevaluated 475 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 14 times by 1 test
Evaluated by:
  • libssl.so.1.1
14-475
974 pkeyid = EVP_PKEY_RSA_PSS;
executed 475 times by 1 test: pkeyid = 912;
Executed by:
  • libssl.so.1.1
475
975 }
executed 489 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
489
976 lu = tls1_lookup_sigalg(sig);-
977 /*-
978 * Check sigalgs is known. Disallow SHA1/SHA224 with TLS 1.3. Check key type-
979 * is consistent with signature: RSA keys can be used for RSA-PSS-
980 */-
981 if (lu == NULL
lu == ((void *)0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1388 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-1388
982 || (SSL_IS_TLS13(s) && (lu->hash == NID_sha1 || lu->hash == NID_sha224))
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 1292 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 96 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->version >= 0x0304Description
TRUEevaluated 489 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 803 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->v...ion != 0x10000Description
TRUEevaluated 489 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
lu->hash == 64Description
TRUEnever evaluated
FALSEevaluated 489 times by 1 test
Evaluated by:
  • libssl.so.1.1
lu->hash == 675Description
TRUEnever evaluated
FALSEevaluated 489 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1292
983 || (pkeyid != lu->sig
pkeyid != lu->sigDescription
TRUEevaluated 461 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 927 times by 1 test
Evaluated by:
  • libssl.so.1.1
461-927
984 && (lu->sig != EVP_PKEY_RSA_PSS || pkeyid != EVP_PKEY_RSA))) {
lu->sig != 912Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 459 times by 1 test
Evaluated by:
  • libssl.so.1.1
pkeyid != 6Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 458 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-459
985 SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_TLS12_CHECK_PEER_SIGALG,-
986 SSL_R_WRONG_SIGNATURE_TYPE);-
987 return 0;
executed 4 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
4
988 }-
989 /* Check the sigalg is consistent with the key OID */-
990 if (!ssl_cert_lookup_by_nid(EVP_PKEY_id(pkey), &cidx)
!ssl_cert_look...(pkey), &cidx)Description
TRUEnever evaluated
FALSEevaluated 1385 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1385
991 || lu->sig_idx != (int)cidx) {
lu->sig_idx != (int)cidxDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1382 times by 1 test
Evaluated by:
  • libssl.so.1.1
3-1382
992 SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER, SSL_F_TLS12_CHECK_PEER_SIGALG,-
993 SSL_R_WRONG_SIGNATURE_TYPE);-
994 return 0;
executed 3 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
3
995 }-
996-
997#ifndef OPENSSL_NO_EC-
998 if (pkeyid == EVP_PKEY_EC) {
pkeyid == 408Description
TRUEevaluated 181 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1201 times by 1 test
Evaluated by:
  • libssl.so.1.1
181-1201
999-
1000 /* Check point compression is permitted */-
1001 if (!tls1_check_pkey_comp(s, pkey)) {
!tls1_check_pkey_comp(s, pkey)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 180 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-180
1002 SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER,-
1003 SSL_F_TLS12_CHECK_PEER_SIGALG,-
1004 SSL_R_ILLEGAL_POINT_COMPRESSION);-
1005 return 0;
executed 1 time by 1 test: return 0;
Executed by:
  • libssl.so.1.1
1
1006 }-
1007-
1008 /* For TLS 1.3 or Suite B check curve matches signature algorithm */-
1009 if (SSL_IS_TLS13(s) || tls1_suiteb(s)) {
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 180 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
(s)->method->version >= 0x0304Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 171 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->v...ion != 0x10000Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
(s->cert->cert...ags & 0x30000)Description
TRUEnever evaluated
FALSEevaluated 171 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-180
1010 EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey);-
1011 int curve = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));-
1012-
1013 if (lu->curve != NID_undef && curve != lu->curve) {
lu->curve != 0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
curve != lu->curveDescription
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-9
1014 SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER,-
1015 SSL_F_TLS12_CHECK_PEER_SIGALG, SSL_R_WRONG_CURVE);-
1016 return 0;
never executed: return 0;
0
1017 }-
1018 }
executed 9 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
9
1019 if (!SSL_IS_TLS13(s)) {
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 180 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
(s)->method->version >= 0x0304Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 171 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->v...ion != 0x10000Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-180
1020 /* Check curve matches extensions */-
1021 if (!tls1_check_group_id(s, tls1_get_group_id(pkey), 1)) {
!tls1_check_gr...p_id(pkey), 1)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 168 times by 1 test
Evaluated by:
  • libssl.so.1.1
3-168
1022 SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER,-
1023 SSL_F_TLS12_CHECK_PEER_SIGALG, SSL_R_WRONG_CURVE);-
1024 return 0;
executed 3 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
3
1025 }-
1026 if (tls1_suiteb(s)) {
(s->cert->cert...ags & 0x30000)Description
TRUEnever evaluated
FALSEevaluated 168 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-168
1027 /* Check sigalg matches a permissible Suite B value */-
1028 if (sig != TLSEXT_SIGALG_ecdsa_secp256r1_sha256
sig != 0x0403Description
TRUEnever evaluated
FALSEnever evaluated
0
1029 && sig != TLSEXT_SIGALG_ecdsa_secp384r1_sha384) {
sig != 0x0503Description
TRUEnever evaluated
FALSEnever evaluated
0
1030 SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE,-
1031 SSL_F_TLS12_CHECK_PEER_SIGALG,-
1032 SSL_R_WRONG_SIGNATURE_TYPE);-
1033 return 0;
never executed: return 0;
0
1034 }-
1035 }
never executed: end of block
0
1036 }
executed 168 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
168
1037 } else if (tls1_suiteb(s)) {
executed 177 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
(s->cert->cert...ags & 0x30000)Description
TRUEnever evaluated
FALSEevaluated 1201 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1201
1038 SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS12_CHECK_PEER_SIGALG,-
1039 SSL_R_WRONG_SIGNATURE_TYPE);-
1040 return 0;
never executed: return 0;
0
1041 }-
1042#endif-
1043-
1044 /* Check signature matches a type we sent */-
1045 sent_sigslen = tls12_get_psigalgs(s, 1, &sent_sigs);-
1046 for (i = 0; i < sent_sigslen; i++, sent_sigs++) {
i < sent_sigslenDescription
TRUEevaluated 14288 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
1-14288
1047 if (sig == *sent_sigs)
sig == *sent_sigsDescription
TRUEevaluated 1377 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 12911 times by 1 test
Evaluated by:
  • libssl.so.1.1
1377-12911
1048 break;
executed 1377 times by 1 test: break;
Executed by:
  • libssl.so.1.1
1377
1049 }
executed 12911 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
12911
1050 /* Allow fallback to SHA1 if not strict mode */-
1051 if (i == sent_sigslen && (lu->hash != NID_sha1
i == sent_sigslenDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1377 times by 1 test
Evaluated by:
  • libssl.so.1.1
lu->hash != 64Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-1377
1052 || s->cert->cert_flags & SSL_CERT_FLAGS_CHECK_TLS_STRICT)) {
s->cert->cert_...0|0x00000001U)Description
TRUEnever evaluated
FALSEnever evaluated
0
1053 SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS12_CHECK_PEER_SIGALG,-
1054 SSL_R_WRONG_SIGNATURE_TYPE);-
1055 return 0;
executed 1 time by 1 test: return 0;
Executed by:
  • libssl.so.1.1
1
1056 }-
1057 if (!tls1_lookup_md(lu, &md)) {
!tls1_lookup_md(lu, &md)Description
TRUEnever evaluated
FALSEevaluated 1377 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1377
1058 SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS12_CHECK_PEER_SIGALG,-
1059 SSL_R_UNKNOWN_DIGEST);-
1060 return 0;
never executed: return 0;
0
1061 }-
1062 if (md != NULL) {
md != ((void *)0)Description
TRUEevaluated 1367 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 10 times by 1 test
Evaluated by:
  • libssl.so.1.1
10-1367
1063 /*-
1064 * Make sure security callback allows algorithm. For historical-
1065 * reasons we have to pass the sigalg as a two byte char array.-
1066 */-
1067 sigalgstr[0] = (sig >> 8) & 0xff;-
1068 sigalgstr[1] = sig & 0xff;-
1069 if (!ssl_security(s, SSL_SECOP_SIGALG_CHECK,
!ssl_security(...d *)sigalgstr)Description
TRUEnever evaluated
FALSEevaluated 1367 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1367
1070 EVP_MD_size(md) * 4, EVP_MD_type(md),
!ssl_security(...d *)sigalgstr)Description
TRUEnever evaluated
FALSEevaluated 1367 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1367
1071 (void *)sigalgstr)) {
!ssl_security(...d *)sigalgstr)Description
TRUEnever evaluated
FALSEevaluated 1367 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1367
1072 SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS12_CHECK_PEER_SIGALG,-
1073 SSL_R_WRONG_SIGNATURE_TYPE);-
1074 return 0;
never executed: return 0;
0
1075 }-
1076 }
executed 1367 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
1367
1077 /* Store the sigalg the peer uses */-
1078 s->s3->tmp.peer_sigalg = lu;-
1079 return 1;
executed 1377 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
1377
1080}-
1081-
1082int SSL_get_peer_signature_type_nid(const SSL *s, int *pnid)-
1083{-
1084 if (s->s3->tmp.peer_sigalg == NULL)
s->s3->tmp.pee...== ((void *)0)Description
TRUEevaluated 1635 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 978 times by 1 test
Evaluated by:
  • libssl.so.1.1
978-1635
1085 return 0;
executed 1635 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
1635
1086 *pnid = s->s3->tmp.peer_sigalg->sig;-
1087 return 1;
executed 978 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
978
1088}-
1089-
1090/*-
1091 * Set a mask of disabled algorithms: an algorithm is disabled if it isn't-
1092 * supported, doesn't appear in supported signature algorithms, isn't supported-
1093 * by the enabled protocol versions or by the security level.-
1094 *-
1095 * This function should only be used for checking which ciphers are supported-
1096 * by the client.-
1097 *-
1098 * Call ssl_cipher_disabled() to check that it's enabled or not.-
1099 */-
1100int ssl_set_client_disabled(SSL *s)-
1101{-
1102 s->s3->tmp.mask_a = 0;-
1103 s->s3->tmp.mask_k = 0;-
1104 ssl_set_sig_mask(&s->s3->tmp.mask_a, s, SSL_SECOP_SIGALG_MASK);-
1105 if (ssl_get_min_max_version(s, &s->s3->tmp.min_ver,
ssl_get_min_ma...id *)0) ) != 0Description
TRUEnever evaluated
FALSEevaluated 4948 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4948
1106 &s->s3->tmp.max_ver, NULL) != 0)
ssl_get_min_ma...id *)0) ) != 0Description
TRUEnever evaluated
FALSEevaluated 4948 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4948
1107 return 0;
never executed: return 0;
0
1108#ifndef OPENSSL_NO_PSK-
1109 /* with PSK there must be client callback set */-
1110 if (!s->psk_client_callback) {
!s->psk_client_callbackDescription
TRUEevaluated 4906 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 42 times by 1 test
Evaluated by:
  • libssl.so.1.1
42-4906
1111 s->s3->tmp.mask_a |= SSL_aPSK;-
1112 s->s3->tmp.mask_k |= SSL_PSK;-
1113 }
executed 4906 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
4906
1114#endif /* OPENSSL_NO_PSK */-
1115#ifndef OPENSSL_NO_SRP-
1116 if (!(s->srp_ctx.srp_Mask & SSL_kSRP)) {
!(s->srp_ctx.s...& 0x00000020U)Description
TRUEevaluated 4937 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libssl.so.1.1
11-4937
1117 s->s3->tmp.mask_a |= SSL_aSRP;-
1118 s->s3->tmp.mask_k |= SSL_kSRP;-
1119 }
executed 4937 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
4937
1120#endif-
1121 return 1;
executed 4948 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
4948
1122}-
1123-
1124/*-
1125 * ssl_cipher_disabled - check that a cipher is disabled or not-
1126 * @s: SSL connection that you want to use the cipher on-
1127 * @c: cipher to check-
1128 * @op: Security check that you want to do-
1129 * @ecdhe: If set to 1 then TLSv1 ECDHE ciphers are also allowed in SSLv3-
1130 *-
1131 * Returns 1 when it's disabled, 0 when enabled.-
1132 */-
1133int ssl_cipher_disabled(SSL *s, const SSL_CIPHER *c, int op, int ecdhe)-
1134{-
1135 if (c->algorithm_mkey & s->s3->tmp.mask_k
c->algorithm_m...s3->tmp.mask_kDescription
TRUEevaluated 246524 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 345518 times by 1 test
Evaluated by:
  • libssl.so.1.1
246524-345518
1136 || c->algorithm_auth & s->s3->tmp.mask_a)
c->algorithm_a...s3->tmp.mask_aDescription
TRUEevaluated 620 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 344898 times by 1 test
Evaluated by:
  • libssl.so.1.1
620-344898
1137 return 1;
executed 247144 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
247144
1138 if (s->s3->tmp.max_ver == 0)
s->s3->tmp.max_ver == 0Description
TRUEnever evaluated
FALSEevaluated 344898 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-344898
1139 return 1;
never executed: return 1;
0
1140 if (!SSL_IS_DTLS(s)) {
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 339969 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4929 times by 1 test
Evaluated by:
  • libssl.so.1.1
4929-339969
1141 int min_tls = c->min_tls;-
1142-
1143 /*-
1144 * For historical reasons we will allow ECHDE to be selected by a server-
1145 * in SSLv3 if we are a client-
1146 */-
1147 if (min_tls == TLS1_VERSION && ecdhe
min_tls == 0x0301Description
TRUEevaluated 33674 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 306295 times by 1 test
Evaluated by:
  • libssl.so.1.1
ecdheDescription
TRUEevaluated 434 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 33240 times by 1 test
Evaluated by:
  • libssl.so.1.1
434-306295
1148 && (c->algorithm_mkey & (SSL_kECDHE | SSL_kECDHEPSK)) != 0)
(c->algorithm_...000080U)) != 0Description
TRUEevaluated 433 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
1-433
1149 min_tls = SSL3_VERSION;
executed 433 times by 1 test: min_tls = 0x0300;
Executed by:
  • libssl.so.1.1
433
1150-
1151 if ((min_tls > s->s3->tmp.max_ver) || (c->max_tls < s->s3->tmp.min_ver))
(min_tls > s->s3->tmp.max_ver)Description
TRUEevaluated 7244 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 332725 times by 1 test
Evaluated by:
  • libssl.so.1.1
(c->max_tls < ...->tmp.min_ver)Description
TRUEevaluated 2925 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 329800 times by 1 test
Evaluated by:
  • libssl.so.1.1
2925-332725
1152 return 1;
executed 10169 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
10169
1153 }
executed 329800 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
329800
1154 if (SSL_IS_DTLS(s) && (DTLS_VERSION_GT(c->min_dtls, s->s3->tmp.max_ver)
((c->min_dtls) == 0x0100)Description
TRUEevaluated 1317 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3612 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s->method->ss...c_flags & 0x8)Description
TRUEevaluated 4929 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 329800 times by 1 test
Evaluated by:
  • libssl.so.1.1
((((c->min_dtl...tmp.max_ver)))Description
TRUEevaluated 1146 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3783 times by 1 test
Evaluated by:
  • libssl.so.1.1
1146-329800
1155 || DTLS_VERSION_LT(c->max_dtls, s->s3->tmp.min_ver)))
((c->max_dtls) == 0x0100)Description
TRUEnever evaluated
FALSEevaluated 3783 times by 1 test
Evaluated by:
  • libssl.so.1.1
((((c->max_dtl...tmp.min_ver)))Description
TRUEnever evaluated
FALSEevaluated 3783 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-3783
1156 return 1;
executed 1146 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
1146
1157-
1158 return !ssl_security(s, op, c->strength_bits, 0, (void *)c);
executed 333583 times by 1 test: return !ssl_security(s, op, c->strength_bits, 0, (void *)c);
Executed by:
  • libssl.so.1.1
333583
1159}-
1160-
1161int tls_use_ticket(SSL *s)-
1162{-
1163 if ((s->options & SSL_OP_NO_TICKET))
(s->options & 0x00004000U)Description
TRUEevaluated 93 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 9514 times by 1 test
Evaluated by:
  • libssl.so.1.1
93-9514
1164 return 0;
executed 93 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
93
1165 return ssl_security(s, SSL_SECOP_TICKET, 0, 0, NULL);
executed 9514 times by 1 test: return ssl_security(s, (10 | 0), 0, 0, ((void *)0) );
Executed by:
  • libssl.so.1.1
9514
1166}-
1167-
1168int tls1_set_server_sigalgs(SSL *s)-
1169{-
1170 size_t i;-
1171-
1172 /* Clear any shared signature algorithms */-
1173 OPENSSL_free(s->cert->shared_sigalgs);-
1174 s->cert->shared_sigalgs = NULL;-
1175 s->cert->shared_sigalgslen = 0;-
1176 /* Clear certificate validity flags */-
1177 for (i = 0; i < SSL_PKEY_NUM; i++)
i < 9Description
TRUEevaluated 22527 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2503 times by 1 test
Evaluated by:
  • libssl.so.1.1
2503-22527
1178 s->s3->tmp.valid_flags[i] = 0;
executed 22527 times by 1 test: s->s3->tmp.valid_flags[i] = 0;
Executed by:
  • libssl.so.1.1
22527
1179 /*-
1180 * If peer sent no signature algorithms check to see if we support-
1181 * the default algorithm for each certificate type-
1182 */-
1183 if (s->s3->tmp.peer_cert_sigalgs == NULL
s->s3->tmp.pee...== ((void *)0)Description
TRUEevaluated 2451 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 52 times by 1 test
Evaluated by:
  • libssl.so.1.1
52-2451
1184 && s->s3->tmp.peer_sigalgs == NULL) {
s->s3->tmp.pee...== ((void *)0)Description
TRUEevaluated 689 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1762 times by 1 test
Evaluated by:
  • libssl.so.1.1
689-1762
1185 const uint16_t *sent_sigs;-
1186 size_t sent_sigslen = tls12_get_psigalgs(s, 1, &sent_sigs);-
1187-
1188 for (i = 0; i < SSL_PKEY_NUM; i++) {
i < 9Description
TRUEevaluated 6201 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 689 times by 1 test
Evaluated by:
  • libssl.so.1.1
689-6201
1189 const SIGALG_LOOKUP *lu = tls1_get_legacy_sigalg(s, i);-
1190 size_t j;-
1191-
1192 if (lu == NULL)
lu == ((void *)0)Description
TRUEevaluated 4134 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2067 times by 1 test
Evaluated by:
  • libssl.so.1.1
2067-4134
1193 continue;
executed 4134 times by 1 test: continue;
Executed by:
  • libssl.so.1.1
4134
1194 /* Check default matches a type we sent */-
1195 for (j = 0; j < sent_sigslen; j++) {
j < sent_sigslenDescription
TRUEevaluated 41190 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 498 times by 1 test
Evaluated by:
  • libssl.so.1.1
498-41190
1196 if (lu->sigalg == sent_sigs[j]) {
lu->sigalg == sent_sigs[j]Description
TRUEevaluated 1569 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 39621 times by 1 test
Evaluated by:
  • libssl.so.1.1
1569-39621
1197 s->s3->tmp.valid_flags[i] = CERT_PKEY_SIGN;-
1198 break;
executed 1569 times by 1 test: break;
Executed by:
  • libssl.so.1.1
1569
1199 }-
1200 }
executed 39621 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
39621
1201 }
executed 2067 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2067
1202 return 1;
executed 689 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
689
1203 }-
1204-
1205 if (!tls1_process_sigalgs(s)) {
!tls1_process_sigalgs(s)Description
TRUEnever evaluated
FALSEevaluated 1814 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1814
1206 SSLfatal(s, SSL_AD_INTERNAL_ERROR,-
1207 SSL_F_TLS1_SET_SERVER_SIGALGS, ERR_R_INTERNAL_ERROR);-
1208 return 0;
never executed: return 0;
0
1209 }-
1210 if (s->cert->shared_sigalgs != NULL)
s->cert->share...!= ((void *)0)Description
TRUEevaluated 1795 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 19 times by 1 test
Evaluated by:
  • libssl.so.1.1
19-1795
1211 return 1;
executed 1795 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
1795
1212-
1213 /* Fatal error if no shared signature algorithms */-
1214 SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS1_SET_SERVER_SIGALGS,-
1215 SSL_R_NO_SHARED_SIGNATURE_ALGORITHMS);-
1216 return 0;
executed 19 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
19
1217}-
1218-
1219/*--
1220 * Gets the ticket information supplied by the client if any.-
1221 *-
1222 * hello: The parsed ClientHello data-
1223 * ret: (output) on return, if a ticket was decrypted, then this is set to-
1224 * point to the resulting session.-
1225 */-
1226SSL_TICKET_STATUS tls_get_ticket_from_client(SSL *s, CLIENTHELLO_MSG *hello,-
1227 SSL_SESSION **ret)-
1228{-
1229 size_t size;-
1230 RAW_EXTENSION *ticketext;-
1231-
1232 *ret = NULL;-
1233 s->ext.ticket_expected = 0;-
1234-
1235 /*-
1236 * If tickets disabled or not supported by the protocol version-
1237 * (e.g. TLSv1.3) behave as if no ticket present to permit stateful-
1238 * resumption.-
1239 */-
1240 if (s->version <= SSL3_VERSION || !tls_use_ticket(s))
s->version <= 0x0300Description
TRUEnever evaluated
FALSEevaluated 1922 times by 1 test
Evaluated by:
  • libssl.so.1.1
!tls_use_ticket(s)Description
TRUEevaluated 81 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1841 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1922
1241 return SSL_TICKET_NONE;
executed 81 times by 1 test: return 2;
Executed by:
  • libssl.so.1.1
81
1242-
1243 ticketext = &hello->pre_proc_exts[TLSEXT_IDX_session_ticket];-
1244 if (!ticketext->present)
!ticketext->presentDescription
TRUEevaluated 517 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1324 times by 1 test
Evaluated by:
  • libssl.so.1.1
517-1324
1245 return SSL_TICKET_NONE;
executed 517 times by 1 test: return 2;
Executed by:
  • libssl.so.1.1
517
1246-
1247 size = PACKET_remaining(&ticketext->data);-
1248-
1249 return tls_decrypt_ticket(s, PACKET_data(&ticketext->data), size,
executed 1324 times by 1 test: return tls_decrypt_ticket(s, PACKET_data(&ticketext->data), size, hello->session_id, hello->session_id_len, ret);
Executed by:
  • libssl.so.1.1
1324
1250 hello->session_id, hello->session_id_len, ret);
executed 1324 times by 1 test: return tls_decrypt_ticket(s, PACKET_data(&ticketext->data), size, hello->session_id, hello->session_id_len, ret);
Executed by:
  • libssl.so.1.1
1324
1251}-
1252-
1253/*--
1254 * tls_decrypt_ticket attempts to decrypt a session ticket.-
1255 *-
1256 * If s->tls_session_secret_cb is set and we're not doing TLSv1.3 then we are-
1257 * expecting a pre-shared key ciphersuite, in which case we have no use for-
1258 * session tickets and one will never be decrypted, nor will-
1259 * s->ext.ticket_expected be set to 1.-
1260 *-
1261 * Side effects:-
1262 * Sets s->ext.ticket_expected to 1 if the server will have to issue-
1263 * a new session ticket to the client because the client indicated support-
1264 * (and s->tls_session_secret_cb is NULL) but the client either doesn't have-
1265 * a session ticket or we couldn't use the one it gave us, or if-
1266 * s->ctx->ext.ticket_key_cb asked to renew the client's ticket.-
1267 * Otherwise, s->ext.ticket_expected is set to 0.-
1268 *-
1269 * etick: points to the body of the session ticket extension.-
1270 * eticklen: the length of the session tickets extension.-
1271 * sess_id: points at the session ID.-
1272 * sesslen: the length of the session ID.-
1273 * psess: (output) on return, if a ticket was decrypted, then this is set to-
1274 * point to the resulting session.-
1275 */-
1276SSL_TICKET_STATUS tls_decrypt_ticket(SSL *s, const unsigned char *etick,-
1277 size_t eticklen, const unsigned char *sess_id,-
1278 size_t sesslen, SSL_SESSION **psess)-
1279{-
1280 SSL_SESSION *sess = NULL;-
1281 unsigned char *sdec;-
1282 const unsigned char *p;-
1283 int slen, renew_ticket = 0, declen;-
1284 SSL_TICKET_STATUS ret = SSL_TICKET_FATAL_ERR_OTHER;-
1285 size_t mlen;-
1286 unsigned char tick_hmac[EVP_MAX_MD_SIZE];-
1287 HMAC_CTX *hctx = NULL;-
1288 EVP_CIPHER_CTX *ctx = NULL;-
1289 SSL_CTX *tctx = s->session_ctx;-
1290-
1291 if (eticklen == 0) {
eticklen == 0Description
TRUEevaluated 1140 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 284 times by 1 test
Evaluated by:
  • libssl.so.1.1
284-1140
1292 /*-
1293 * The client will accept a ticket but doesn't currently have-
1294 * one (TLSv1.2 and below), or treated as a fatal error in TLSv1.3-
1295 */-
1296 ret = SSL_TICKET_EMPTY;-
1297 goto end;
executed 1140 times by 1 test: goto end;
Executed by:
  • libssl.so.1.1
1140
1298 }-
1299 if (!SSL_IS_TLS13(s) && s->ext.session_secret_cb) {
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 269 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 15 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->version >= 0x0304Description
TRUEevaluated 98 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 171 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->v...ion != 0x10000Description
TRUEevaluated 98 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
s->ext.session_secret_cbDescription
TRUEnever evaluated
FALSEevaluated 186 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-269
1300 /*-
1301 * Indicate that the ticket couldn't be decrypted rather than-
1302 * generating the session from ticket now, trigger-
1303 * abbreviated handshake based on external mechanism to-
1304 * calculate the master secret later.-
1305 */-
1306 ret = SSL_TICKET_NO_DECRYPT;-
1307 goto end;
never executed: goto end;
0
1308 }-
1309-
1310 /* Need at least keyname + iv */-
1311 if (eticklen < TLSEXT_KEYNAME_LENGTH + EVP_MAX_IV_LENGTH) {
eticklen < 16 + 16Description
TRUEevaluated 51 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 233 times by 1 test
Evaluated by:
  • libssl.so.1.1
51-233
1312 ret = SSL_TICKET_NO_DECRYPT;-
1313 goto end;
executed 51 times by 1 test: goto end;
Executed by:
  • libssl.so.1.1
51
1314 }-
1315-
1316 /* Initialize session ticket encryption and HMAC contexts */-
1317 hctx = HMAC_CTX_new();-
1318 if (hctx == NULL) {
hctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 233 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-233
1319 ret = SSL_TICKET_FATAL_ERR_MALLOC;-
1320 goto end;
never executed: goto end;
0
1321 }-
1322 ctx = EVP_CIPHER_CTX_new();-
1323 if (ctx == NULL) {
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 233 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-233
1324 ret = SSL_TICKET_FATAL_ERR_MALLOC;-
1325 goto end;
never executed: goto end;
0
1326 }-
1327 if (tctx->ext.ticket_key_cb) {
tctx->ext.ticket_key_cbDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 229 times by 1 test
Evaluated by:
  • libssl.so.1.1
4-229
1328 unsigned char *nctick = (unsigned char *)etick;-
1329 int rv = tctx->ext.ticket_key_cb(s, nctick,-
1330 nctick + TLSEXT_KEYNAME_LENGTH,-
1331 ctx, hctx, 0);-
1332 if (rv < 0) {
rv < 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4
1333 ret = SSL_TICKET_FATAL_ERR_OTHER;-
1334 goto end;
never executed: goto end;
0
1335 }-
1336 if (rv == 0) {
rv == 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4
1337 ret = SSL_TICKET_NO_DECRYPT;-
1338 goto end;
never executed: goto end;
0
1339 }-
1340 if (rv == 2)
rv == 2Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
2
1341 renew_ticket = 1;
executed 2 times by 1 test: renew_ticket = 1;
Executed by:
  • libssl.so.1.1
2
1342 } else {
executed 4 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
4
1343 /* Check key name matches */-
1344 if (memcmp(etick, tctx->ext.tick_key_name,
memcmp(etick, ...name, 16) != 0Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 217 times by 1 test
Evaluated by:
  • libssl.so.1.1
12-217
1345 TLSEXT_KEYNAME_LENGTH) != 0) {
memcmp(etick, ...name, 16) != 0Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 217 times by 1 test
Evaluated by:
  • libssl.so.1.1
12-217
1346 ret = SSL_TICKET_NO_DECRYPT;-
1347 goto end;
executed 12 times by 1 test: goto end;
Executed by:
  • libssl.so.1.1
12
1348 }-
1349 if (HMAC_Init_ex(hctx, tctx->ext.secure->tick_hmac_key,
HMAC_Init_ex(h...id *)0) ) <= 0Description
TRUEnever evaluated
FALSEevaluated 217 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-217
1350 sizeof(tctx->ext.secure->tick_hmac_key),
HMAC_Init_ex(h...id *)0) ) <= 0Description
TRUEnever evaluated
FALSEevaluated 217 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-217
1351 EVP_sha256(), NULL) <= 0
HMAC_Init_ex(h...id *)0) ) <= 0Description
TRUEnever evaluated
FALSEevaluated 217 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-217
1352 || EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL,
EVP_DecryptIni...ick + 16) <= 0Description
TRUEnever evaluated
FALSEevaluated 217 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-217
1353 tctx->ext.secure->tick_aes_key,
EVP_DecryptIni...ick + 16) <= 0Description
TRUEnever evaluated
FALSEevaluated 217 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-217
1354 etick + TLSEXT_KEYNAME_LENGTH) <= 0) {
EVP_DecryptIni...ick + 16) <= 0Description
TRUEnever evaluated
FALSEevaluated 217 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-217
1355 ret = SSL_TICKET_FATAL_ERR_OTHER;-
1356 goto end;
never executed: goto end;
0
1357 }-
1358 if (SSL_IS_TLS13(s))
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 202 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 15 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->version >= 0x0304Description
TRUEevaluated 85 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 117 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->v...ion != 0x10000Description
TRUEevaluated 85 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-202
1359 renew_ticket = 1;
executed 85 times by 1 test: renew_ticket = 1;
Executed by:
  • libssl.so.1.1
85
1360 }
executed 217 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
217
1361 /*-
1362 * Attempt to process session ticket, first conduct sanity and integrity-
1363 * checks on ticket.-
1364 */-
1365 mlen = HMAC_size(hctx);-
1366 if (mlen == 0) {
mlen == 0Description
TRUEnever evaluated
FALSEevaluated 221 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-221
1367 ret = SSL_TICKET_FATAL_ERR_OTHER;-
1368 goto end;
never executed: goto end;
0
1369 }-
1370-
1371 /* Sanity check ticket length: must exceed keyname + IV + HMAC */-
1372 if (eticklen <=
eticklen <= 16...th(ctx) + mlenDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 220 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-220
1373 TLSEXT_KEYNAME_LENGTH + EVP_CIPHER_CTX_iv_length(ctx) + mlen) {
eticklen <= 16...th(ctx) + mlenDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 220 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-220
1374 ret = SSL_TICKET_NO_DECRYPT;-
1375 goto end;
executed 1 time by 1 test: goto end;
Executed by:
  • libssl.so.1.1
1
1376 }-
1377 eticklen -= mlen;-
1378 /* Check HMAC of encrypted ticket */-
1379 if (HMAC_Update(hctx, etick, eticklen) <= 0
HMAC_Update(hc...eticklen) <= 0Description
TRUEnever evaluated
FALSEevaluated 220 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-220
1380 || HMAC_Final(hctx, tick_hmac, NULL) <= 0) {
HMAC_Final(hct...id *)0) ) <= 0Description
TRUEnever evaluated
FALSEevaluated 220 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-220
1381 ret = SSL_TICKET_FATAL_ERR_OTHER;-
1382 goto end;
never executed: goto end;
0
1383 }-
1384-
1385 if (CRYPTO_memcmp(tick_hmac, etick + eticklen, mlen)) {
CRYPTO_memcmp(...ticklen, mlen)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 213 times by 1 test
Evaluated by:
  • libssl.so.1.1
7-213
1386 ret = SSL_TICKET_NO_DECRYPT;-
1387 goto end;
executed 7 times by 1 test: goto end;
Executed by:
  • libssl.so.1.1
7
1388 }-
1389 /* Attempt to decrypt session data */-
1390 /* Move p after IV to start of encrypted ticket, update length */-
1391 p = etick + TLSEXT_KEYNAME_LENGTH + EVP_CIPHER_CTX_iv_length(ctx);-
1392 eticklen -= TLSEXT_KEYNAME_LENGTH + EVP_CIPHER_CTX_iv_length(ctx);-
1393 sdec = OPENSSL_malloc(eticklen);-
1394 if (sdec == NULL || EVP_DecryptUpdate(ctx, sdec, &slen, p,
sdec == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 213 times by 1 test
Evaluated by:
  • libssl.so.1.1
EVP_DecryptUpd...eticklen) <= 0Description
TRUEnever evaluated
FALSEevaluated 213 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-213
1395 (int)eticklen) <= 0) {
EVP_DecryptUpd...eticklen) <= 0Description
TRUEnever evaluated
FALSEevaluated 213 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-213
1396 OPENSSL_free(sdec);-
1397 ret = SSL_TICKET_FATAL_ERR_OTHER;-
1398 goto end;
never executed: goto end;
0
1399 }-
1400 if (EVP_DecryptFinal(ctx, sdec + slen, &declen) <= 0) {
EVP_DecryptFin... &declen) <= 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 205 times by 1 test
Evaluated by:
  • libssl.so.1.1
8-205
1401 OPENSSL_free(sdec);-
1402 ret = SSL_TICKET_NO_DECRYPT;-
1403 goto end;
executed 8 times by 1 test: goto end;
Executed by:
  • libssl.so.1.1
8
1404 }-
1405 slen += declen;-
1406 p = sdec;-
1407-
1408 sess = d2i_SSL_SESSION(NULL, &p, slen);-
1409 slen -= p - sdec;-
1410 OPENSSL_free(sdec);-
1411 if (sess) {
sessDescription
TRUEevaluated 183 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 22 times by 1 test
Evaluated by:
  • libssl.so.1.1
22-183
1412 /* Some additional consistency checks */-
1413 if (slen != 0) {
slen != 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 181 times by 1 test
Evaluated by:
  • libssl.so.1.1
2-181
1414 SSL_SESSION_free(sess);-
1415 sess = NULL;-
1416 ret = SSL_TICKET_NO_DECRYPT;-
1417 goto end;
executed 2 times by 1 test: goto end;
Executed by:
  • libssl.so.1.1
2
1418 }-
1419 /*-
1420 * The session ID, if non-empty, is used by some clients to detect-
1421 * that the ticket has been accepted. So we copy it to the session-
1422 * structure. If it is empty set length to zero as required by-
1423 * standard.-
1424 */-
1425 if (sesslen) {
sesslenDescription
TRUEevaluated 98 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 83 times by 1 test
Evaluated by:
  • libssl.so.1.1
83-98
1426 memcpy(sess->session_id, sess_id, sesslen);-
1427 sess->session_id_length = sesslen;-
1428 }
executed 98 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
98
1429 if (renew_ticket)
renew_ticketDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 101 times by 1 test
Evaluated by:
  • libssl.so.1.1
80-101
1430 ret = SSL_TICKET_SUCCESS_RENEW;
executed 80 times by 1 test: ret = 6;
Executed by:
  • libssl.so.1.1
80
1431 else-
1432 ret = SSL_TICKET_SUCCESS;
executed 101 times by 1 test: ret = 5;
Executed by:
  • libssl.so.1.1
101
1433 goto end;
executed 181 times by 1 test: goto end;
Executed by:
  • libssl.so.1.1
181
1434 }-
1435 ERR_clear_error();-
1436 /*-
1437 * For session parse failure, indicate that we need to send a new ticket.-
1438 */-
1439 ret = SSL_TICKET_NO_DECRYPT;-
1440-
1441 end:
code before this statement executed 22 times by 1 test: end:
Executed by:
  • libssl.so.1.1
22
1442 EVP_CIPHER_CTX_free(ctx);-
1443 HMAC_CTX_free(hctx);-
1444-
1445 /*-
1446 * If set, the decrypt_ticket_cb() is called unless a fatal error was-
1447 * detected above. The callback is responsible for checking |ret| before it-
1448 * performs any action-
1449 */-
1450 if (s->session_ctx->decrypt_ticket_cb != NULL
s->session_ctx...!= ((void *)0)Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1403 times by 1 test
Evaluated by:
  • libssl.so.1.1
21-1403
1451 && (ret == SSL_TICKET_EMPTY
ret == 3Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 14 times by 1 test
Evaluated by:
  • libssl.so.1.1
7-14
1452 || ret == SSL_TICKET_NO_DECRYPT
ret == 4Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-14
1453 || ret == SSL_TICKET_SUCCESS
ret == 5Description
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
1454 || ret == SSL_TICKET_SUCCESS_RENEW)) {
ret == 6Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-7
1455 size_t keyname_len = eticklen;-
1456 int retcb;-
1457-
1458 if (keyname_len > TLSEXT_KEYNAME_LENGTH)
keyname_len > 16Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
7-14
1459 keyname_len = TLSEXT_KEYNAME_LENGTH;
executed 14 times by 1 test: keyname_len = 16;
Executed by:
  • libssl.so.1.1
14
1460 retcb = s->session_ctx->decrypt_ticket_cb(s, sess, etick, keyname_len,-
1461 ret,-
1462 s->session_ctx->ticket_cb_data);-
1463 switch (retcb) {-
1464 case SSL_TICKET_RETURN_ABORT:
never executed: case 0:
0
1465 ret = SSL_TICKET_FATAL_ERR_OTHER;-
1466 break;
never executed: break;
0
1467-
1468 case SSL_TICKET_RETURN_IGNORE:
executed 2 times by 1 test: case 1:
Executed by:
  • libssl.so.1.1
2
1469 ret = SSL_TICKET_NONE;-
1470 SSL_SESSION_free(sess);-
1471 sess = NULL;-
1472 break;
executed 2 times by 1 test: break;
Executed by:
  • libssl.so.1.1
2
1473-
1474 case SSL_TICKET_RETURN_IGNORE_RENEW:
executed 9 times by 1 test: case 2:
Executed by:
  • libssl.so.1.1
9
1475 if (ret != SSL_TICKET_EMPTY && ret != SSL_TICKET_NO_DECRYPT)
ret != 3Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
ret != 4Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-7
1476 ret = SSL_TICKET_NO_DECRYPT;
executed 2 times by 1 test: ret = 4;
Executed by:
  • libssl.so.1.1
2
1477 /* else the value of |ret| will already do the right thing */-
1478 SSL_SESSION_free(sess);-
1479 sess = NULL;-
1480 break;
executed 9 times by 1 test: break;
Executed by:
  • libssl.so.1.1
9
1481-
1482 case SSL_TICKET_RETURN_USE:
executed 5 times by 1 test: case 3:
Executed by:
  • libssl.so.1.1
5
1483 case SSL_TICKET_RETURN_USE_RENEW:
executed 5 times by 1 test: case 4:
Executed by:
  • libssl.so.1.1
5
1484 if (ret != SSL_TICKET_SUCCESS
ret != 5Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
5
1485 && ret != SSL_TICKET_SUCCESS_RENEW)
ret != 6Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-5
1486 ret = SSL_TICKET_FATAL_ERR_OTHER;
never executed: ret = 1;
0
1487 else if (retcb == SSL_TICKET_RETURN_USE)
retcb == 3Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
5
1488 ret = SSL_TICKET_SUCCESS;
executed 5 times by 1 test: ret = 5;
Executed by:
  • libssl.so.1.1
5
1489 else-
1490 ret = SSL_TICKET_SUCCESS_RENEW;
executed 5 times by 1 test: ret = 6;
Executed by:
  • libssl.so.1.1
5
1491 break;
executed 10 times by 1 test: break;
Executed by:
  • libssl.so.1.1
10
1492-
1493 default:
never executed: default:
0
1494 ret = SSL_TICKET_FATAL_ERR_OTHER;-
1495 }
never executed: end of block
0
1496 }-
1497-
1498 if (s->ext.session_secret_cb == NULL || SSL_IS_TLS13(s)) {
s->ext.session...== ((void *)0)Description
TRUEevaluated 1424 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
!(s->method->s...c_flags & 0x8)Description
TRUEnever evaluated
FALSEnever evaluated
(s)->method->version >= 0x0304Description
TRUEnever evaluated
FALSEnever evaluated
(s)->method->v...ion != 0x10000Description
TRUEnever evaluated
FALSEnever evaluated
0-1424
1499 switch (ret) {-
1500 case SSL_TICKET_NO_DECRYPT:
executed 105 times by 1 test: case 4:
Executed by:
  • libssl.so.1.1
105
1501 case SSL_TICKET_SUCCESS_RENEW:
executed 78 times by 1 test: case 6:
Executed by:
  • libssl.so.1.1
78
1502 case SSL_TICKET_EMPTY:
executed 1140 times by 1 test: case 3:
Executed by:
  • libssl.so.1.1
1140
1503 s->ext.ticket_expected = 1;-
1504 }
executed 1323 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
1323
1505 }
executed 1424 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
1424
1506-
1507 *psess = sess;-
1508-
1509 return ret;
executed 1424 times by 1 test: return ret;
Executed by:
  • libssl.so.1.1
1424
1510}-
1511-
1512/* Check to see if a signature algorithm is allowed */-
1513static int tls12_sigalg_allowed(SSL *s, int op, const SIGALG_LOOKUP *lu)-
1514{-
1515 unsigned char sigalgstr[2];-
1516 int secbits;-
1517-
1518 /* See if sigalgs is recognised and if hash is enabled */-
1519 if (!tls1_lookup_md(lu, NULL))
!tls1_lookup_m... ((void *)0) )Description
TRUEevaluated 39465 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 189541 times by 1 test
Evaluated by:
  • libssl.so.1.1
39465-189541
1520 return 0;
executed 39465 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
39465
1521 /* DSA is not allowed in TLS 1.3 */-
1522 if (SSL_IS_TLS13(s) && lu->sig == EVP_PKEY_DSA)
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 178806 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 10735 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->version >= 0x0304Description
TRUEevaluated 142358 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 36448 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->v...ion != 0x10000Description
TRUEevaluated 27071 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 115287 times by 1 test
Evaluated by:
  • libssl.so.1.1
lu->sig == 116Description
TRUEevaluated 5462 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 21609 times by 1 test
Evaluated by:
  • libssl.so.1.1
5462-178806
1523 return 0;
executed 5462 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
5462
1524 /* TODO(OpenSSL1.2) fully axe DSA/etc. in ClientHello per TLS 1.3 spec */-
1525 if (!s->server && !SSL_IS_DTLS(s) && s->s3->tmp.min_ver >= TLS1_3_VERSION
!s->serverDescription
TRUEevaluated 127645 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 56434 times by 1 test
Evaluated by:
  • libssl.so.1.1
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 123021 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4624 times by 1 test
Evaluated by:
  • libssl.so.1.1
s->s3->tmp.min_ver >= 0x0304Description
TRUEevaluated 3293 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 119728 times by 1 test
Evaluated by:
  • libssl.so.1.1
3293-127645
1526 && (lu->sig == EVP_PKEY_DSA || lu->hash_idx == SSL_MD_SHA1_IDX
lu->sig == 116Description
TRUEevaluated 525 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2768 times by 1 test
Evaluated by:
  • libssl.so.1.1
lu->hash_idx == 1Description
TRUEevaluated 306 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2462 times by 1 test
Evaluated by:
  • libssl.so.1.1
306-2768
1527 || lu->hash_idx == SSL_MD_MD5_IDX
lu->hash_idx == 0Description
TRUEnever evaluated
FALSEevaluated 2462 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2462
1528 || lu->hash_idx == SSL_MD_SHA224_IDX))
lu->hash_idx == 10Description
TRUEevaluated 306 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2156 times by 1 test
Evaluated by:
  • libssl.so.1.1
306-2156
1529 return 0;
executed 1137 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
1137
1530-
1531 /* See if public key algorithm allowed */-
1532 if (ssl_cert_is_disabled(lu->sig_idx))
ssl_cert_is_di...d(lu->sig_idx)Description
TRUEnever evaluated
FALSEevaluated 182942 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-182942
1533 return 0;
never executed: return 0;
0
1534-
1535 if (lu->sig == NID_id_GostR3410_2012_256
lu->sig == 979Description
TRUEnever evaluated
FALSEevaluated 182942 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-182942
1536 || lu->sig == NID_id_GostR3410_2012_512
lu->sig == 980Description
TRUEnever evaluated
FALSEevaluated 182942 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-182942
1537 || lu->sig == NID_id_GostR3410_2001) {
lu->sig == 811Description
TRUEnever evaluated
FALSEevaluated 182942 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-182942
1538 /* We never allow GOST sig algs on the server with TLSv1.3 */-
1539 if (s->server && SSL_IS_TLS13(s))
s->serverDescription
TRUEnever evaluated
FALSEnever evaluated
!(s->method->s...c_flags & 0x8)Description
TRUEnever evaluated
FALSEnever evaluated
(s)->method->version >= 0x0304Description
TRUEnever evaluated
FALSEnever evaluated
(s)->method->v...ion != 0x10000Description
TRUEnever evaluated
FALSEnever evaluated
0
1540 return 0;
never executed: return 0;
0
1541 if (!s->server
!s->serverDescription
TRUEnever evaluated
FALSEnever evaluated
0
1542 && s->method->version == TLS_ANY_VERSION
s->method->version == 0x10000Description
TRUEnever evaluated
FALSEnever evaluated
0
1543 && s->s3->tmp.max_ver >= TLS1_3_VERSION) {
s->s3->tmp.max_ver >= 0x0304Description
TRUEnever evaluated
FALSEnever evaluated
0
1544 int i, num;-
1545 STACK_OF(SSL_CIPHER) *sk;-
1546-
1547 /*-
1548 * We're a client that could negotiate TLSv1.3. We only allow GOST-
1549 * sig algs if we could negotiate TLSv1.2 or below and we have GOST-
1550 * ciphersuites enabled.-
1551 */-
1552-
1553 if (s->s3->tmp.min_ver >= TLS1_3_VERSION)
s->s3->tmp.min_ver >= 0x0304Description
TRUEnever evaluated
FALSEnever evaluated
0
1554 return 0;
never executed: return 0;
0
1555-
1556 sk = SSL_get_ciphers(s);-
1557 num = sk != NULL ? sk_SSL_CIPHER_num(sk) : 0;
sk != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1558 for (i = 0; i < num; i++) {
i < numDescription
TRUEnever evaluated
FALSEnever evaluated
0
1559 const SSL_CIPHER *c;-
1560-
1561 c = sk_SSL_CIPHER_value(sk, i);-
1562 /* Skip disabled ciphers */-
1563 if (ssl_cipher_disabled(s, c, SSL_SECOP_CIPHER_SUPPORTED, 0))
ssl_cipher_dis...(1 << 16)), 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1564 continue;
never executed: continue;
0
1565-
1566 if ((c->algorithm_mkey & SSL_kGOST) != 0)
(c->algorithm_...0000010U) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1567 break;
never executed: break;
0
1568 }
never executed: end of block
0
1569 if (i == num)
i == numDescription
TRUEnever evaluated
FALSEnever evaluated
0
1570 return 0;
never executed: return 0;
0
1571 }
never executed: end of block
0
1572 }
never executed: end of block
0
1573-
1574 if (lu->hash == NID_undef)
lu->hash == 0Description
TRUEevaluated 15187 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 167755 times by 1 test
Evaluated by:
  • libssl.so.1.1
15187-167755
1575 return 1;
executed 15187 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
15187
1576 /* Security bits: half digest bits */-
1577 secbits = EVP_MD_size(ssl_md(lu->hash_idx)) * 4;-
1578 /* Finally see if security callback allows it */-
1579 sigalgstr[0] = (lu->sigalg >> 8) & 0xff;-
1580 sigalgstr[1] = lu->sigalg & 0xff;-
1581 return ssl_security(s, op, secbits, lu->hash, (void *)sigalgstr);
executed 167755 times by 1 test: return ssl_security(s, op, secbits, lu->hash, (void *)sigalgstr);
Executed by:
  • libssl.so.1.1
167755
1582}-
1583-
1584/*-
1585 * Get a mask of disabled public key algorithms based on supported signature-
1586 * algorithms. For example if no signature algorithm supports RSA then RSA is-
1587 * disabled.-
1588 */-
1589-
1590void ssl_set_sig_mask(uint32_t *pmask_a, SSL *s, int op)-
1591{-
1592 const uint16_t *sigalgs;-
1593 size_t i, sigalgslen;-
1594 uint32_t disabled_mask = SSL_aRSA | SSL_aDSS | SSL_aECDSA;-
1595 /*-
1596 * Go through all signature algorithms seeing if we support any-
1597 * in disabled_mask.-
1598 */-
1599 sigalgslen = tls12_get_psigalgs(s, 1, &sigalgs);-
1600 for (i = 0; i < sigalgslen; i++, sigalgs++) {
i < sigalgslenDescription
TRUEevaluated 128352 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4983 times by 1 test
Evaluated by:
  • libssl.so.1.1
4983-128352
1601 const SIGALG_LOOKUP *lu = tls1_lookup_sigalg(*sigalgs);-
1602 const SSL_CERT_LOOKUP *clu;-
1603-
1604 if (lu == NULL)
lu == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 128352 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-128352
1605 continue;
never executed: continue;
0
1606-
1607 clu = ssl_cert_lookup_by_idx(lu->sig_idx);-
1608 if (clu == NULL)
clu == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 128352 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-128352
1609 continue;
never executed: continue;
0
1610-
1611 /* If algorithm is disabled see if we can enable it */-
1612 if ((clu->amask & disabled_mask) != 0
(clu->amask & ...led_mask) != 0Description
TRUEevaluated 14858 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 113494 times by 1 test
Evaluated by:
  • libssl.so.1.1
14858-113494
1613 && tls12_sigalg_allowed(s, op, lu))
tls12_sigalg_a...wed(s, op, lu)Description
TRUEevaluated 14858 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-14858
1614 disabled_mask &= ~clu->amask;
executed 14858 times by 1 test: disabled_mask &= ~clu->amask;
Executed by:
  • libssl.so.1.1
14858
1615 }
executed 128352 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
128352
1616 *pmask_a |= disabled_mask;-
1617}
executed 4983 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
4983
1618-
1619int tls12_copy_sigalgs(SSL *s, WPACKET *pkt,-
1620 const uint16_t *psig, size_t psiglen)-
1621{-
1622 size_t i;-
1623 int rv = 0;-
1624-
1625 for (i = 0; i < psiglen; i++, psig++) {
i < psiglenDescription
TRUEevaluated 120354 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4683 times by 1 test
Evaluated by:
  • libssl.so.1.1
4683-120354
1626 const SIGALG_LOOKUP *lu = tls1_lookup_sigalg(*psig);-
1627-
1628 if (!tls12_sigalg_allowed(s, SSL_SECOP_SIGALG_SUPPORTED, lu))
!tls12_sigalg_...5 << 16)), lu)Description
TRUEevaluated 15014 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 105340 times by 1 test
Evaluated by:
  • libssl.so.1.1
15014-105340
1629 continue;
executed 15014 times by 1 test: continue;
Executed by:
  • libssl.so.1.1
15014
1630 if (!WPACKET_put_bytes_u16(pkt, *psig))
!WPACKET_put_b...), (*psig), 2)Description
TRUEnever evaluated
FALSEevaluated 105340 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-105340
1631 return 0;
never executed: return 0;
0
1632 /*-
1633 * If TLS 1.3 must have at least one valid TLS 1.3 message-
1634 * signing algorithm: i.e. neither RSA nor SHA1/SHA224-
1635 */-
1636 if (rv == 0 && (!SSL_IS_TLS13(s)
rv == 0Description
TRUEevaluated 4684 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 100656 times by 1 test
Evaluated by:
  • libssl.so.1.1
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 4516 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 168 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->version >= 0x0304Description
TRUEevaluated 4489 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 27 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->v...ion != 0x10000Description
TRUEevaluated 47 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4442 times by 1 test
Evaluated by:
  • libssl.so.1.1
27-100656
1637 || (lu->sig != EVP_PKEY_RSA
lu->sig != 6Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
1-46
1638 && lu->hash != NID_sha1
lu->hash != 64Description
TRUEevaluated 45 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
1-45
1639 && lu->hash != NID_sha224)))
lu->hash != 675Description
TRUEevaluated 45 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-45
1640 rv = 1;
executed 4682 times by 1 test: rv = 1;
Executed by:
  • libssl.so.1.1
4682
1641 }
executed 105340 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
105340
1642 if (rv == 0)
rv == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4682 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-4682
1643 SSLerr(SSL_F_TLS12_COPY_SIGALGS, SSL_R_NO_SUITABLE_SIGNATURE_ALGORITHM);
executed 1 time by 1 test: ERR_put_error(20,(533),(118),__FILE__,1643);
Executed by:
  • libssl.so.1.1
1
1644 return rv;
executed 4683 times by 1 test: return rv;
Executed by:
  • libssl.so.1.1
4683
1645}-
1646-
1647/* Given preference and allowed sigalgs set shared sigalgs */-
1648static size_t tls12_shared_sigalgs(SSL *s, const SIGALG_LOOKUP **shsig,-
1649 const uint16_t *pref, size_t preflen,-
1650 const uint16_t *allow, size_t allowlen)-
1651{-
1652 const uint16_t *ptmp, *atmp;-
1653 size_t i, j, nmatch = 0;-
1654 for (i = 0, ptmp = pref; i < preflen; i++, ptmp++) {
i < preflenDescription
TRUEevaluated 93794 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3818 times by 1 test
Evaluated by:
  • libssl.so.1.1
3818-93794
1655 const SIGALG_LOOKUP *lu = tls1_lookup_sigalg(*ptmp);-
1656-
1657 /* Skip disabled hashes or signature algorithms */-
1658 if (!tls12_sigalg_allowed(s, SSL_SECOP_SIGALG_SHARED, lu))
!tls12_sigalg_...5 << 16)), lu)Description
TRUEevaluated 31050 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 62744 times by 1 test
Evaluated by:
  • libssl.so.1.1
31050-62744
1659 continue;
executed 31050 times by 1 test: continue;
Executed by:
  • libssl.so.1.1
31050
1660 for (j = 0, atmp = allow; j < allowlen; j++, atmp++) {
j < allowlenDescription
TRUEevaluated 739174 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-739174
1661 if (*ptmp == *atmp) {
*ptmp == *atmpDescription
TRUEevaluated 62744 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 676430 times by 1 test
Evaluated by:
  • libssl.so.1.1
62744-676430
1662 nmatch++;-
1663 if (shsig)
shsigDescription
TRUEevaluated 31372 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 31372 times by 1 test
Evaluated by:
  • libssl.so.1.1
31372
1664 *shsig++ = lu;
executed 31372 times by 1 test: *shsig++ = lu;
Executed by:
  • libssl.so.1.1
31372
1665 break;
executed 62744 times by 1 test: break;
Executed by:
  • libssl.so.1.1
62744
1666 }-
1667 }
executed 676430 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
676430
1668 }
executed 62744 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
62744
1669 return nmatch;
executed 3818 times by 1 test: return nmatch;
Executed by:
  • libssl.so.1.1
3818
1670}-
1671-
1672/* Set shared signature algorithms for SSL structures */-
1673static int tls1_set_shared_sigalgs(SSL *s)-
1674{-
1675 const uint16_t *pref, *allow, *conf;-
1676 size_t preflen, allowlen, conflen;-
1677 size_t nmatch;-
1678 const SIGALG_LOOKUP **salgs = NULL;-
1679 CERT *c = s->cert;-
1680 unsigned int is_suiteb = tls1_suiteb(s);-
1681-
1682 OPENSSL_free(c->shared_sigalgs);-
1683 c->shared_sigalgs = NULL;-
1684 c->shared_sigalgslen = 0;-
1685 /* If client use client signature algorithms if not NULL */-
1686 if (!s->server && c->client_sigalgs && !is_suiteb) {
!s->serverDescription
TRUEevaluated 119 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1814 times by 1 test
Evaluated by:
  • libssl.so.1.1
c->client_sigalgsDescription
TRUEnever evaluated
FALSEevaluated 119 times by 1 test
Evaluated by:
  • libssl.so.1.1
!is_suitebDescription
TRUEnever evaluated
FALSEnever evaluated
0-1814
1687 conf = c->client_sigalgs;-
1688 conflen = c->client_sigalgslen;-
1689 } else if (c->conf_sigalgs && !is_suiteb) {
never executed: end of block
c->conf_sigalgsDescription
TRUEnever evaluated
FALSEevaluated 1933 times by 1 test
Evaluated by:
  • libssl.so.1.1
!is_suitebDescription
TRUEnever evaluated
FALSEnever evaluated
0-1933
1690 conf = c->conf_sigalgs;-
1691 conflen = c->conf_sigalgslen;-
1692 } else
never executed: end of block
0
1693 conflen = tls12_get_psigalgs(s, 0, &conf);
executed 1933 times by 1 test: conflen = tls12_get_psigalgs(s, 0, &conf);
Executed by:
  • libssl.so.1.1
1933
1694 if (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE || is_suiteb) {
s->options & 0x00400000UDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1927 times by 1 test
Evaluated by:
  • libssl.so.1.1
is_suitebDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1925 times by 1 test
Evaluated by:
  • libssl.so.1.1
2-1927
1695 pref = conf;-
1696 preflen = conflen;-
1697 allow = s->s3->tmp.peer_sigalgs;-
1698 allowlen = s->s3->tmp.peer_sigalgslen;-
1699 } else {
executed 8 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
8
1700 allow = conf;-
1701 allowlen = conflen;-
1702 pref = s->s3->tmp.peer_sigalgs;-
1703 preflen = s->s3->tmp.peer_sigalgslen;-
1704 }
executed 1925 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
1925
1705 nmatch = tls12_shared_sigalgs(s, NULL, pref, preflen, allow, allowlen);-
1706 if (nmatch) {
nmatchDescription
TRUEevaluated 1885 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 48 times by 1 test
Evaluated by:
  • libssl.so.1.1
48-1885
1707 if ((salgs = OPENSSL_malloc(nmatch * sizeof(*salgs))) == NULL) {
(salgs = CRYPT...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1885 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1885
1708 SSLerr(SSL_F_TLS1_SET_SHARED_SIGALGS, ERR_R_MALLOC_FAILURE);-
1709 return 0;
never executed: return 0;
0
1710 }-
1711 nmatch = tls12_shared_sigalgs(s, salgs, pref, preflen, allow, allowlen);-
1712 } else {
executed 1885 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
1885
1713 salgs = NULL;-
1714 }
executed 48 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
48
1715 c->shared_sigalgs = salgs;-
1716 c->shared_sigalgslen = nmatch;-
1717 return 1;
executed 1933 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
1933
1718}-
1719-
1720int tls1_save_u16(PACKET *pkt, uint16_t **pdest, size_t *pdestlen)-
1721{-
1722 unsigned int stmp;-
1723 size_t size, i;-
1724 uint16_t *buf;-
1725-
1726 size = PACKET_remaining(pkt);-
1727-
1728 /* Invalid data length */-
1729 if (size == 0 || (size & 1) != 0)
size == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4501 times by 1 test
Evaluated by:
  • libssl.so.1.1
(size & 1) != 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4498 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-4501
1730 return 0;
executed 4 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
4
1731-
1732 size >>= 1;-
1733-
1734 if ((buf = OPENSSL_malloc(size * sizeof(*buf))) == NULL) {
(buf = CRYPTO_...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4498 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4498
1735 SSLerr(SSL_F_TLS1_SAVE_U16, ERR_R_MALLOC_FAILURE);-
1736 return 0;
never executed: return 0;
0
1737 }-
1738 for (i = 0; i < size && PACKET_get_net_2(pkt, &stmp); i++)
i < sizeDescription
TRUEevaluated 61735 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4498 times by 1 test
Evaluated by:
  • libssl.so.1.1
PACKET_get_net_2(pkt, &stmp)Description
TRUEevaluated 61735 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-61735
1739 buf[i] = stmp;
executed 61735 times by 1 test: buf[i] = stmp;
Executed by:
  • libssl.so.1.1
61735
1740-
1741 if (i != size) {
i != sizeDescription
TRUEnever evaluated
FALSEevaluated 4498 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4498
1742 OPENSSL_free(buf);-
1743 return 0;
never executed: return 0;
0
1744 }-
1745-
1746 OPENSSL_free(*pdest);-
1747 *pdest = buf;-
1748 *pdestlen = size;-
1749-
1750 return 1;
executed 4498 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
4498
1751}-
1752-
1753int tls1_save_sigalgs(SSL *s, PACKET *pkt, int cert)-
1754{-
1755 /* Extension ignored for inappropriate versions */-
1756 if (!SSL_USE_SIGALGS(s))
!(s->method->s...c_flags & 0x2)Description
TRUEevaluated 152 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2062 times by 1 test
Evaluated by:
  • libssl.so.1.1
152-2062
1757 return 1;
executed 152 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
152
1758 /* Should never happen */-
1759 if (s->cert == NULL)
s->cert == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2062 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2062
1760 return 0;
never executed: return 0;
0
1761-
1762 if (cert)
certDescription
TRUEevaluated 54 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2008 times by 1 test
Evaluated by:
  • libssl.so.1.1
54-2008
1763 return tls1_save_u16(pkt, &s->s3->tmp.peer_cert_sigalgs,
executed 54 times by 1 test: return tls1_save_u16(pkt, &s->s3->tmp.peer_cert_sigalgs, &s->s3->tmp.peer_cert_sigalgslen);
Executed by:
  • libssl.so.1.1
54
1764 &s->s3->tmp.peer_cert_sigalgslen);
executed 54 times by 1 test: return tls1_save_u16(pkt, &s->s3->tmp.peer_cert_sigalgs, &s->s3->tmp.peer_cert_sigalgslen);
Executed by:
  • libssl.so.1.1
54
1765 else-
1766 return tls1_save_u16(pkt, &s->s3->tmp.peer_sigalgs,
executed 2008 times by 1 test: return tls1_save_u16(pkt, &s->s3->tmp.peer_sigalgs, &s->s3->tmp.peer_sigalgslen);
Executed by:
  • libssl.so.1.1
2008
1767 &s->s3->tmp.peer_sigalgslen);
executed 2008 times by 1 test: return tls1_save_u16(pkt, &s->s3->tmp.peer_sigalgs, &s->s3->tmp.peer_sigalgslen);
Executed by:
  • libssl.so.1.1
2008
1768-
1769}-
1770-
1771/* Set preferred digest for each key type */-
1772-
1773int tls1_process_sigalgs(SSL *s)-
1774{-
1775 size_t i;-
1776 uint32_t *pvalid = s->s3->tmp.valid_flags;-
1777 CERT *c = s->cert;-
1778-
1779 if (!tls1_set_shared_sigalgs(s))
!tls1_set_shared_sigalgs(s)Description
TRUEnever evaluated
FALSEevaluated 1933 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1933
1780 return 0;
never executed: return 0;
0
1781-
1782 for (i = 0; i < SSL_PKEY_NUM; i++)
i < 9Description
TRUEevaluated 17397 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1933 times by 1 test
Evaluated by:
  • libssl.so.1.1
1933-17397
1783 pvalid[i] = 0;
executed 17397 times by 1 test: pvalid[i] = 0;
Executed by:
  • libssl.so.1.1
17397
1784-
1785 for (i = 0; i < c->shared_sigalgslen; i++) {
i < c->shared_sigalgslenDescription
TRUEevaluated 31372 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1933 times by 1 test
Evaluated by:
  • libssl.so.1.1
1933-31372
1786 const SIGALG_LOOKUP *sigptr = c->shared_sigalgs[i];-
1787 int idx = sigptr->sig_idx;-
1788-
1789 /* Ignore PKCS1 based sig algs in TLSv1.3 */-
1790 if (SSL_IS_TLS13(s) && sigptr->sig == EVP_PKEY_RSA)
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 28244 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3128 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->version >= 0x0304Description
TRUEevaluated 10362 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 17882 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->v...ion != 0x10000Description
TRUEevaluated 10362 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
sigptr->sig == 6Description
TRUEevaluated 2759 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 7603 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-28244
1791 continue;
executed 2759 times by 1 test: continue;
Executed by:
  • libssl.so.1.1
2759
1792 /* If not disabled indicate we can explicitly sign */-
1793 if (pvalid[idx] == 0 && !ssl_cert_is_disabled(idx))
pvalid[idx] == 0Description
TRUEevaluated 7794 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 20819 times by 1 test
Evaluated by:
  • libssl.so.1.1
!ssl_cert_is_disabled(idx)Description
TRUEevaluated 7794 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-20819
1794 pvalid[idx] = CERT_PKEY_EXPLICIT_SIGN | CERT_PKEY_SIGN;
executed 7794 times by 1 test: pvalid[idx] = 0x100 | 0x2;
Executed by:
  • libssl.so.1.1
7794
1795 }
executed 28613 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
28613
1796 return 1;
executed 1933 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
1933
1797}-
1798-
1799int SSL_get_sigalgs(SSL *s, int idx,-
1800 int *psign, int *phash, int *psignhash,-
1801 unsigned char *rsig, unsigned char *rhash)-
1802{-
1803 uint16_t *psig = s->s3->tmp.peer_sigalgs;-
1804 size_t numsigalgs = s->s3->tmp.peer_sigalgslen;-
1805 if (psig == NULL || numsigalgs > INT_MAX)
psig == ((void *)0)Description
TRUEevaluated 212 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2296 times by 1 test
Evaluated by:
  • libssl.so.1.1
numsigalgs > 0x7fffffffDescription
TRUEnever evaluated
FALSEevaluated 2296 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2296
1806 return 0;
executed 212 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
212
1807 if (idx >= 0) {
idx >= 0Description
TRUEevaluated 2197 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 99 times by 1 test
Evaluated by:
  • libssl.so.1.1
99-2197
1808 const SIGALG_LOOKUP *lu;-
1809-
1810 if (idx >= (int)numsigalgs)
idx >= (int)numsigalgsDescription
TRUEnever evaluated
FALSEevaluated 2197 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2197
1811 return 0;
never executed: return 0;
0
1812 psig += idx;-
1813 if (rhash != NULL)
rhash != ((void *)0)Description
TRUEevaluated 2197 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2197
1814 *rhash = (unsigned char)((*psig >> 8) & 0xff);
executed 2197 times by 1 test: *rhash = (unsigned char)((*psig >> 8) & 0xff);
Executed by:
  • libssl.so.1.1
2197
1815 if (rsig != NULL)
rsig != ((void *)0)Description
TRUEevaluated 2197 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2197
1816 *rsig = (unsigned char)(*psig & 0xff);
executed 2197 times by 1 test: *rsig = (unsigned char)(*psig & 0xff);
Executed by:
  • libssl.so.1.1
2197
1817 lu = tls1_lookup_sigalg(*psig);-
1818 if (psign != NULL)
psign != ((void *)0)Description
TRUEevaluated 2197 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2197
1819 *psign = lu != NULL ? lu->sig : NID_undef;
executed 2197 times by 1 test: *psign = lu != ((void *)0) ? lu->sig : 0;
Executed by:
  • libssl.so.1.1
lu != ((void *)0)Description
TRUEevaluated 2197 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2197
1820 if (phash != NULL)
phash != ((void *)0)Description
TRUEevaluated 2197 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2197
1821 *phash = lu != NULL ? lu->hash : NID_undef;
executed 2197 times by 1 test: *phash = lu != ((void *)0) ? lu->hash : 0;
Executed by:
  • libssl.so.1.1
lu != ((void *)0)Description
TRUEevaluated 2197 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2197
1822 if (psignhash != NULL)
psignhash != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2197 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2197
1823 *psignhash = lu != NULL ? lu->sigandhash : NID_undef;
never executed: *psignhash = lu != ((void *)0) ? lu->sigandhash : 0;
lu != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1824 }
executed 2197 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2197
1825 return (int)numsigalgs;
executed 2296 times by 1 test: return (int)numsigalgs;
Executed by:
  • libssl.so.1.1
2296
1826}-
1827-
1828int SSL_get_shared_sigalgs(SSL *s, int idx,-
1829 int *psign, int *phash, int *psignhash,-
1830 unsigned char *rsig, unsigned char *rhash)-
1831{-
1832 const SIGALG_LOOKUP *shsigalgs;-
1833 if (s->cert->shared_sigalgs == NULL
s->cert->share...== ((void *)0)Description
TRUEevaluated 188 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 63 times by 1 test
Evaluated by:
  • libssl.so.1.1
63-188
1834 || idx < 0
idx < 0Description
TRUEnever evaluated
FALSEevaluated 63 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-63
1835 || idx >= (int)s->cert->shared_sigalgslen
idx >= (int)s-...red_sigalgslenDescription
TRUEnever evaluated
FALSEevaluated 63 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-63
1836 || s->cert->shared_sigalgslen > INT_MAX)
s->cert->share...n > 0x7fffffffDescription
TRUEnever evaluated
FALSEevaluated 63 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-63
1837 return 0;
executed 188 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
188
1838 shsigalgs = s->cert->shared_sigalgs[idx];-
1839 if (phash != NULL)
phash != ((void *)0)Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libssl.so.1.1
3-60
1840 *phash = shsigalgs->hash;
executed 60 times by 1 test: *phash = shsigalgs->hash;
Executed by:
  • libssl.so.1.1
60
1841 if (psign != NULL)
psign != ((void *)0)Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libssl.so.1.1
3-60
1842 *psign = shsigalgs->sig;
executed 60 times by 1 test: *psign = shsigalgs->sig;
Executed by:
  • libssl.so.1.1
60
1843 if (psignhash != NULL)
psignhash != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 63 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-63
1844 *psignhash = shsigalgs->sigandhash;
never executed: *psignhash = shsigalgs->sigandhash;
0
1845 if (rsig != NULL)
rsig != ((void *)0)Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libssl.so.1.1
3-60
1846 *rsig = (unsigned char)(shsigalgs->sigalg & 0xff);
executed 60 times by 1 test: *rsig = (unsigned char)(shsigalgs->sigalg & 0xff);
Executed by:
  • libssl.so.1.1
60
1847 if (rhash != NULL)
rhash != ((void *)0)Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libssl.so.1.1
3-60
1848 *rhash = (unsigned char)((shsigalgs->sigalg >> 8) & 0xff);
executed 60 times by 1 test: *rhash = (unsigned char)((shsigalgs->sigalg >> 8) & 0xff);
Executed by:
  • libssl.so.1.1
60
1849 return (int)s->cert->shared_sigalgslen;
executed 63 times by 1 test: return (int)s->cert->shared_sigalgslen;
Executed by:
  • libssl.so.1.1
63
1850}-
1851-
1852/* Maximum possible number of unique entries in sigalgs array */-
1853#define TLS_MAX_SIGALGCNT (OSSL_NELEM(sigalg_lookup_tbl) * 2)-
1854-
1855typedef struct {-
1856 size_t sigalgcnt;-
1857 /* TLSEXT_SIGALG_XXX values */-
1858 uint16_t sigalgs[TLS_MAX_SIGALGCNT];-
1859} sig_cb_st;-
1860-
1861static void get_sigorhash(int *psig, int *phash, const char *str)-
1862{-
1863 if (strcmp(str, "RSA") == 0) {
never executed: __result = (((const unsigned char *) (const char *) ( str ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
executed 20 times by 1 test: __result = (((const unsigned char *) (const char *) ( "RSA" ))[3] - __s2[3]);
Executed by:
  • libssl.so.1.1
executed 20 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
executed 20 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
__extension__ ... )))); }) == 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 113 times by 1 test
Evaluated by:
  • libssl.so.1.1
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEevaluated 128 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
__result == 0Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 108 times by 1 test
Evaluated by:
  • libssl.so.1.1
__s2_len > 1Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
__result == 0Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
__s2_len > 2Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
__result == 0Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-128
1864 *psig = EVP_PKEY_RSA;-
1865 } else if (strcmp(str, "RSA-PSS") == 0 || strcmp(str, "PSS") == 0) {
executed 15 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
never executed: __result = (((const unsigned char *) (const char *) ( str ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "RSA-PSS" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( str ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
executed 8 times by 1 test: __result = (((const unsigned char *) (const char *) ( "PSS" ))[3] - __s2[3]);
Executed by:
  • libssl.so.1.1
executed 8 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
executed 8 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
__extension__ ... )))); }) == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 108 times by 1 test
Evaluated by:
  • libssl.so.1.1
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__extension__ ... )))); }) == 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 100 times by 1 test
Evaluated by:
  • libssl.so.1.1
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEevaluated 108 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
__result == 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 100 times by 1 test
Evaluated by:
  • libssl.so.1.1
__s2_len > 1Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
__result == 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
__s2_len > 2Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
__result == 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-108
1866 *psig = EVP_PKEY_RSA_PSS;-
1867 } else if (strcmp(str, "DSA") == 0) {
executed 13 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
never executed: __result = (((const unsigned char *) (const char *) ( str ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
executed 5 times by 1 test: __result = (((const unsigned char *) (const char *) ( "DSA" ))[3] - __s2[3]);
Executed by:
  • libssl.so.1.1
executed 5 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
executed 5 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
__extension__ ... )))); }) == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libssl.so.1.1
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEevaluated 100 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
__result == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 95 times by 1 test
Evaluated by:
  • libssl.so.1.1
__s2_len > 1Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
__result == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
__s2_len > 2Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
__result == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-100
1868 *psig = EVP_PKEY_DSA;-
1869 } else if (strcmp(str, "ECDSA") == 0) {
executed 5 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
never executed: __result = (((const unsigned char *) (const char *) ( str ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "ECDSA" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__extension__ ... )))); }) == 0Description
TRUEevaluated 31 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 64 times by 1 test
Evaluated by:
  • libssl.so.1.1
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-64
1870 *psig = EVP_PKEY_EC;-
1871 } else {
executed 31 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
31
1872 *phash = OBJ_sn2nid(str);-
1873 if (*phash == NID_undef)
*phash == 0Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-64
1874 *phash = OBJ_ln2nid(str);
never executed: *phash = OBJ_ln2nid(str);
0
1875 }
executed 64 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
64
1876}-
1877/* Maximum length of a signature algorithm string component */-
1878#define TLS_MAX_SIGSTRING_LEN 40-
1879-
1880static int sig_cb(const char *elem, int len, void *arg)-
1881{-
1882 sig_cb_st *sarg = arg;-
1883 size_t i;-
1884 const SIGALG_LOOKUP *s;-
1885 char etmp[TLS_MAX_SIGSTRING_LEN], *p;-
1886 int sig_alg = NID_undef, hash_alg = NID_undef;-
1887 if (elem == NULL)
elem == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 82 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-82
1888 return 0;
never executed: return 0;
0
1889 if (sarg->sigalgcnt == TLS_MAX_SIGALGCNT)
sarg->sigalgcn...tbl)[0])) * 2)Description
TRUEnever evaluated
FALSEevaluated 82 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-82
1890 return 0;
never executed: return 0;
0
1891 if (len > (int)(sizeof(etmp) - 1))
len > (int)(sizeof(etmp) - 1)Description
TRUEnever evaluated
FALSEevaluated 82 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-82
1892 return 0;
never executed: return 0;
0
1893 memcpy(etmp, elem, len);-
1894 etmp[len] = 0;-
1895 p = strchr(etmp, '+');
__builtin_constant_p ( '+' )Description
TRUEevaluated 82 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
!__builtin_constant_p ( etmp )Description
TRUEevaluated 82 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
( '+' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 82 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-82
1896 /*-
1897 * We only allow SignatureSchemes listed in the sigalg_lookup_tbl;-
1898 * if there's no '+' in the provided name, look for the new-style combined-
1899 * name. If not, match both sig+hash to find the needed SIGALG_LOOKUP.-
1900 * Just sig+hash is not unique since TLS 1.3 adds rsa_pss_pss_* and-
1901 * rsa_pss_rsae_* that differ only by public key OID; in such cases-
1902 * we will pick the _rsae_ variant, by virtue of them appearing earlier-
1903 * in the table.-
1904 */-
1905 if (p == NULL) {
p == ((void *)0)Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 64 times by 1 test
Evaluated by:
  • libssl.so.1.1
18-64
1906 for (i = 0, s = sigalg_lookup_tbl; i < OSSL_NELEM(sigalg_lookup_tbl);
i < (sizeof(si...okup_tbl)[0]))Description
TRUEevaluated 259 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
8-259
1907 i++, s++) {-
1908 if (s->name != NULL && strcmp(etmp, s->name) == 0) {
never executed: __result = (((const unsigned char *) (const char *) ( etmp ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( s->name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
s->name != ((void *)0)Description
TRUEevaluated 177 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 82 times by 1 test
Evaluated by:
  • libssl.so.1.1
__extension__ ... )))); }) == 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 167 times by 1 test
Evaluated by:
  • libssl.so.1.1
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-177
1909 sarg->sigalgs[sarg->sigalgcnt++] = s->sigalg;-
1910 break;
executed 10 times by 1 test: break;
Executed by:
  • libssl.so.1.1
10
1911 }-
1912 }
executed 249 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
249
1913 if (i == OSSL_NELEM(sigalg_lookup_tbl))
i == (sizeof(s...okup_tbl)[0]))Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 10 times by 1 test
Evaluated by:
  • libssl.so.1.1
8-10
1914 return 0;
executed 8 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
8
1915 } else {
executed 10 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
10
1916 *p = 0;-
1917 p++;-
1918 if (*p == 0)
*p == 0Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-64
1919 return 0;
never executed: return 0;
0
1920 get_sigorhash(&sig_alg, &hash_alg, etmp);-
1921 get_sigorhash(&sig_alg, &hash_alg, p);-
1922 if (sig_alg == NID_undef || hash_alg == NID_undef)
sig_alg == 0Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • libssl.so.1.1
hash_alg == 0Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-64
1923 return 0;
never executed: return 0;
0
1924 for (i = 0, s = sigalg_lookup_tbl; i < OSSL_NELEM(sigalg_lookup_tbl);
i < (sizeof(si...okup_tbl)[0]))Description
TRUEevaluated 483 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-483
1925 i++, s++) {-
1926 if (s->hash == hash_alg && s->sig == sig_alg) {
s->hash == hash_algDescription
TRUEevaluated 138 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 345 times by 1 test
Evaluated by:
  • libssl.so.1.1
s->sig == sig_algDescription
TRUEevaluated 64 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 74 times by 1 test
Evaluated by:
  • libssl.so.1.1
64-345
1927 sarg->sigalgs[sarg->sigalgcnt++] = s->sigalg;-
1928 break;
executed 64 times by 1 test: break;
Executed by:
  • libssl.so.1.1
64
1929 }-
1930 }
executed 419 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
419
1931 if (i == OSSL_NELEM(sigalg_lookup_tbl))
i == (sizeof(s...okup_tbl)[0]))Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-64
1932 return 0;
never executed: return 0;
0
1933 }
executed 64 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
64
1934-
1935 /* Reject duplicates */-
1936 for (i = 0; i < sarg->sigalgcnt - 1; i++) {
i < sarg->sigalgcnt - 1Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 74 times by 1 test
Evaluated by:
  • libssl.so.1.1
22-74
1937 if (sarg->sigalgs[i] == sarg->sigalgs[sarg->sigalgcnt - 1]) {
sarg->sigalgs[...sigalgcnt - 1]Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-22
1938 sarg->sigalgcnt--;-
1939 return 0;
never executed: return 0;
0
1940 }-
1941 }
executed 22 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
22
1942 return 1;
executed 74 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
74
1943}-
1944-
1945/*-
1946 * Set supported signature algorithms based on a colon separated list of the-
1947 * form sig+hash e.g. RSA+SHA512:DSA+SHA512-
1948 */-
1949int tls1_set_sigalgs_list(CERT *c, const char *str, int client)-
1950{-
1951 sig_cb_st sig;-
1952 sig.sigalgcnt = 0;-
1953 if (!CONF_parse_list(str, ':', 1, sig_cb, &sig))
!CONF_parse_li... sig_cb, &sig)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 52 times by 1 test
Evaluated by:
  • libssl.so.1.1
8-52
1954 return 0;
executed 8 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
8
1955 if (c == NULL)
c == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 52 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-52
1956 return 1;
never executed: return 1;
0
1957 return tls1_set_raw_sigalgs(c, sig.sigalgs, sig.sigalgcnt, client);
executed 52 times by 1 test: return tls1_set_raw_sigalgs(c, sig.sigalgs, sig.sigalgcnt, client);
Executed by:
  • libssl.so.1.1
52
1958}-
1959-
1960int tls1_set_raw_sigalgs(CERT *c, const uint16_t *psigs, size_t salglen,-
1961 int client)-
1962{-
1963 uint16_t *sigalgs;-
1964-
1965 if ((sigalgs = OPENSSL_malloc(salglen * sizeof(*sigalgs))) == NULL) {
(sigalgs = CRY...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 52 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-52
1966 SSLerr(SSL_F_TLS1_SET_RAW_SIGALGS, ERR_R_MALLOC_FAILURE);-
1967 return 0;
never executed: return 0;
0
1968 }-
1969 memcpy(sigalgs, psigs, salglen * sizeof(*sigalgs));-
1970-
1971 if (client) {
clientDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 41 times by 1 test
Evaluated by:
  • libssl.so.1.1
11-41
1972 OPENSSL_free(c->client_sigalgs);-
1973 c->client_sigalgs = sigalgs;-
1974 c->client_sigalgslen = salglen;-
1975 } else {
executed 11 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
11
1976 OPENSSL_free(c->conf_sigalgs);-
1977 c->conf_sigalgs = sigalgs;-
1978 c->conf_sigalgslen = salglen;-
1979 }
executed 41 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
41
1980-
1981 return 1;
executed 52 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
52
1982}-
1983-
1984int tls1_set_sigalgs(CERT *c, const int *psig_nids, size_t salglen, int client)-
1985{-
1986 uint16_t *sigalgs, *sptr;-
1987 size_t i;-
1988-
1989 if (salglen & 1)
salglen & 1Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 10 times by 1 test
Evaluated by:
  • libssl.so.1.1
4-10
1990 return 0;
executed 4 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
4
1991 if ((sigalgs = OPENSSL_malloc((salglen / 2) * sizeof(*sigalgs))) == NULL) {
(sigalgs = CRY...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-10
1992 SSLerr(SSL_F_TLS1_SET_SIGALGS, ERR_R_MALLOC_FAILURE);-
1993 return 0;
never executed: return 0;
0
1994 }-
1995 for (i = 0, sptr = sigalgs; i < salglen; i += 2) {
i < salglenDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
6-12
1996 size_t j;-
1997 const SIGALG_LOOKUP *curr;-
1998 int md_id = *psig_nids++;-
1999 int sig_id = *psig_nids++;-
2000-
2001 for (j = 0, curr = sigalg_lookup_tbl; j < OSSL_NELEM(sigalg_lookup_tbl);
j < (sizeof(si...okup_tbl)[0]))Description
TRUEevaluated 172 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
4-172
2002 j++, curr++) {-
2003 if (curr->hash == md_id && curr->sig == sig_id) {
curr->hash == md_idDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 138 times by 1 test
Evaluated by:
  • libssl.so.1.1
curr->sig == sig_idDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 26 times by 1 test
Evaluated by:
  • libssl.so.1.1
8-138
2004 *sptr++ = curr->sigalg;-
2005 break;
executed 8 times by 1 test: break;
Executed by:
  • libssl.so.1.1
8
2006 }-
2007 }
executed 164 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
164
2008-
2009 if (j == OSSL_NELEM(sigalg_lookup_tbl))
j == (sizeof(s...okup_tbl)[0]))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
4-8
2010 goto err;
executed 4 times by 1 test: goto err;
Executed by:
  • libssl.so.1.1
4
2011 }
executed 8 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
8
2012-
2013 if (client) {
clientDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-6
2014 OPENSSL_free(c->client_sigalgs);-
2015 c->client_sigalgs = sigalgs;-
2016 c->client_sigalgslen = salglen / 2;-
2017 } else {
never executed: end of block
0
2018 OPENSSL_free(c->conf_sigalgs);-
2019 c->conf_sigalgs = sigalgs;-
2020 c->conf_sigalgslen = salglen / 2;-
2021 }
executed 6 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
6
2022-
2023 return 1;
executed 6 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
6
2024-
2025 err:-
2026 OPENSSL_free(sigalgs);-
2027 return 0;
executed 4 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
4
2028}-
2029-
2030static int tls1_check_sig_alg(CERT *c, X509 *x, int default_nid)-
2031{-
2032 int sig_nid;-
2033 size_t i;-
2034 if (default_nid == -1)
default_nid == -1Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2
2035 return 1;
never executed: return 1;
0
2036 sig_nid = X509_get_signature_nid(x);-
2037 if (default_nid)
default_nidDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2
2038 return sig_nid == default_nid ? 1 : 0;
never executed: return sig_nid == default_nid ? 1 : 0;
sig_nid == default_nidDescription
TRUEnever evaluated
FALSEnever evaluated
0
2039 for (i = 0; i < c->shared_sigalgslen; i++)
i < c->shared_sigalgslenDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2
2040 if (sig_nid == c->shared_sigalgs[i]->sigandhash)
sig_nid == c->...i]->sigandhashDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2
2041 return 1;
executed 2 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
2
2042 return 0;
never executed: return 0;
0
2043}-
2044-
2045/* Check to see if a certificate issuer name matches list of CA names */-
2046static int ssl_check_ca_name(STACK_OF(X509_NAME) *names, X509 *x)-
2047{-
2048 X509_NAME *nm;-
2049 int i;-
2050 nm = X509_get_issuer_name(x);-
2051 for (i = 0; i < sk_X509_NAME_num(names); i++) {
i < sk_X509_NAME_num(names)Description
TRUEnever evaluated
FALSEnever evaluated
0
2052 if (!X509_NAME_cmp(nm, sk_X509_NAME_value(names, i)))
!X509_NAME_cmp...lue(names, i))Description
TRUEnever evaluated
FALSEnever evaluated
0
2053 return 1;
never executed: return 1;
0
2054 }
never executed: end of block
0
2055 return 0;
never executed: return 0;
0
2056}-
2057-
2058/*-
2059 * Check certificate chain is consistent with TLS extensions and is usable by-
2060 * server. This servers two purposes: it allows users to check chains before-
2061 * passing them to the server and it allows the server to check chains before-
2062 * attempting to use them.-
2063 */-
2064-
2065/* Flags which need to be set for a certificate when strict mode not set */-
2066-
2067#define CERT_PKEY_VALID_FLAGS \-
2068 (CERT_PKEY_EE_SIGNATURE|CERT_PKEY_EE_PARAM)-
2069/* Strict mode flags */-
2070#define CERT_PKEY_STRICT_FLAGS \-
2071 (CERT_PKEY_VALID_FLAGS|CERT_PKEY_CA_SIGNATURE|CERT_PKEY_CA_PARAM \-
2072 | CERT_PKEY_ISSUER_NAME|CERT_PKEY_CERT_TYPE)-
2073-
2074int tls1_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain,-
2075 int idx)-
2076{-
2077 int i;-
2078 int rv = 0;-
2079 int check_flags = 0, strict_mode;-
2080 CERT_PKEY *cpk = NULL;-
2081 CERT *c = s->cert;-
2082 uint32_t *pvalid;-
2083 unsigned int suiteb_flags = tls1_suiteb(s);-
2084 /* idx == -1 means checking server chains */-
2085 if (idx != -1) {
idx != -1Description
TRUEevaluated 14598 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-14598
2086 /* idx == -2 means checking client certificate chains */-
2087 if (idx == -2) {
idx == -2Description
TRUEnever evaluated
FALSEevaluated 14598 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-14598
2088 cpk = c->key;-
2089 idx = (int)(cpk - c->pkeys);-
2090 } else
never executed: end of block
0
2091 cpk = c->pkeys + idx;
executed 14598 times by 1 test: cpk = c->pkeys + idx;
Executed by:
  • libssl.so.1.1
14598
2092 pvalid = s->s3->tmp.valid_flags + idx;-
2093 x = cpk->x509;-
2094 pk = cpk->privatekey;-
2095 chain = cpk->chain;-
2096 strict_mode = c->cert_flags & SSL_CERT_FLAGS_CHECK_TLS_STRICT;-
2097 /* If no cert or key, forget it */-
2098 if (!x || !pk)
!xDescription
TRUEevaluated 11614 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2984 times by 1 test
Evaluated by:
  • libssl.so.1.1
!pkDescription
TRUEnever evaluated
FALSEevaluated 2984 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-11614
2099 goto end;
executed 11614 times by 1 test: goto end;
Executed by:
  • libssl.so.1.1
11614
2100 } else {
executed 2984 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2984
2101 size_t certidx;-
2102-
2103 if (!x || !pk)
!xDescription
TRUEnever evaluated
FALSEnever evaluated
!pkDescription
TRUEnever evaluated
FALSEnever evaluated
0
2104 return 0;
never executed: return 0;
0
2105-
2106 if (ssl_cert_lookup_by_pkey(pk, &certidx) == NULL)
ssl_cert_looku...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2107 return 0;
never executed: return 0;
0
2108 idx = certidx;-
2109 pvalid = s->s3->tmp.valid_flags + idx;-
2110-
2111 if (c->cert_flags & SSL_CERT_FLAGS_CHECK_TLS_STRICT)
c->cert_flags ...0|0x00000001U)Description
TRUEnever evaluated
FALSEnever evaluated
0
2112 check_flags = CERT_PKEY_STRICT_FLAGS;
never executed: check_flags = ((0x10|0x40)|0x20|0x80 | 0x200|0x400);
0
2113 else-
2114 check_flags = CERT_PKEY_VALID_FLAGS;
never executed: check_flags = (0x10|0x40);
0
2115 strict_mode = 1;-
2116 }
never executed: end of block
0
2117-
2118 if (suiteb_flags) {
suiteb_flagsDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2980 times by 1 test
Evaluated by:
  • libssl.so.1.1
4-2980
2119 int ok;-
2120 if (check_flags)
check_flagsDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-4
2121 check_flags |= CERT_PKEY_SUITEB;
never executed: check_flags |= 0x800;
0
2122 ok = X509_chain_check_suiteb(NULL, x, chain, suiteb_flags);-
2123 if (ok == X509_V_OK)
ok == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
2
2124 rv |= CERT_PKEY_SUITEB;
executed 2 times by 1 test: rv |= 0x800;
Executed by:
  • libssl.so.1.1
2
2125 else if (!check_flags)
!check_flagsDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2
2126 goto end;
executed 2 times by 1 test: goto end;
Executed by:
  • libssl.so.1.1
2
2127 }
executed 2 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2
2128-
2129 /*-
2130 * Check all signature algorithms are consistent with signature-
2131 * algorithms extension if TLS 1.2 or later and strict mode.-
2132 */-
2133 if (TLS1_get_version(s) >= TLS1_2_VERSION && strict_mode) {
(SSL_version(s) >> 8) == 0x03Description
TRUEevaluated 2839 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 143 times by 1 test
Evaluated by:
  • libssl.so.1.1
((SSL_version(...: 0) >= 0x0303Description
TRUEevaluated 2125 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 857 times by 1 test
Evaluated by:
  • libssl.so.1.1
strict_modeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2123 times by 1 test
Evaluated by:
  • libssl.so.1.1
2-2839
2134 int default_nid;-
2135 int rsign = 0;-
2136 if (s->s3->tmp.peer_cert_sigalgs != NULL
s->s3->tmp.pee...!= ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2
2137 || s->s3->tmp.peer_sigalgs != NULL) {
s->s3->tmp.pee...!= ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2
2138 default_nid = 0;-
2139 /* If no sigalgs extension use defaults from RFC5246 */-
2140 } else {
executed 2 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2
2141 switch (idx) {-
2142 case SSL_PKEY_RSA:
never executed: case 0:
0
2143 rsign = EVP_PKEY_RSA;-
2144 default_nid = NID_sha1WithRSAEncryption;-
2145 break;
never executed: break;
0
2146-
2147 case SSL_PKEY_DSA_SIGN:
never executed: case 2:
0
2148 rsign = EVP_PKEY_DSA;-
2149 default_nid = NID_dsaWithSHA1;-
2150 break;
never executed: break;
0
2151-
2152 case SSL_PKEY_ECC:
never executed: case 3:
0
2153 rsign = EVP_PKEY_EC;-
2154 default_nid = NID_ecdsa_with_SHA1;-
2155 break;
never executed: break;
0
2156-
2157 case SSL_PKEY_GOST01:
never executed: case 4:
0
2158 rsign = NID_id_GostR3410_2001;-
2159 default_nid = NID_id_GostR3411_94_with_GostR3410_2001;-
2160 break;
never executed: break;
0
2161-
2162 case SSL_PKEY_GOST12_256:
never executed: case 5:
0
2163 rsign = NID_id_GostR3410_2012_256;-
2164 default_nid = NID_id_tc26_signwithdigest_gost3410_2012_256;-
2165 break;
never executed: break;
0
2166-
2167 case SSL_PKEY_GOST12_512:
never executed: case 6:
0
2168 rsign = NID_id_GostR3410_2012_512;-
2169 default_nid = NID_id_tc26_signwithdigest_gost3410_2012_512;-
2170 break;
never executed: break;
0
2171-
2172 default:
never executed: default:
0
2173 default_nid = -1;-
2174 break;
never executed: break;
0
2175 }-
2176 }-
2177 /*-
2178 * If peer sent no signature algorithms extension and we have set-
2179 * preferred signature algorithms check we support sha1.-
2180 */-
2181 if (default_nid > 0 && c->conf_sigalgs) {
default_nid > 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
c->conf_sigalgsDescription
TRUEnever evaluated
FALSEnever evaluated
0-2
2182 size_t j;-
2183 const uint16_t *p = c->conf_sigalgs;-
2184 for (j = 0; j < c->conf_sigalgslen; j++, p++) {
j < c->conf_sigalgslenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2185 const SIGALG_LOOKUP *lu = tls1_lookup_sigalg(*p);-
2186-
2187 if (lu != NULL && lu->hash == NID_sha1 && lu->sig == rsign)
lu != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
lu->hash == 64Description
TRUEnever evaluated
FALSEnever evaluated
lu->sig == rsignDescription
TRUEnever evaluated
FALSEnever evaluated
0
2188 break;
never executed: break;
0
2189 }
never executed: end of block
0
2190 if (j == c->conf_sigalgslen) {
j == c->conf_sigalgslenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2191 if (check_flags)
check_flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2192 goto skip_sigs;
never executed: goto skip_sigs;
0
2193 else-
2194 goto end;
never executed: goto end;
0
2195 }-
2196 }
never executed: end of block
0
2197 /* Check signature algorithm of each cert in chain */-
2198 if (!tls1_check_sig_alg(c, x, default_nid)) {
!tls1_check_si..., default_nid)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2
2199 if (!check_flags)
!check_flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2200 goto end;
never executed: goto end;
0
2201 } else
never executed: end of block
0
2202 rv |= CERT_PKEY_EE_SIGNATURE;
executed 2 times by 1 test: rv |= 0x10;
Executed by:
  • libssl.so.1.1
2
2203 rv |= CERT_PKEY_CA_SIGNATURE;-
2204 for (i = 0; i < sk_X509_num(chain); i++) {
i < sk_X509_num(chain)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2
2205 if (!tls1_check_sig_alg(c, sk_X509_value(chain, i), default_nid)) {
!tls1_check_si..., default_nid)Description
TRUEnever evaluated
FALSEnever evaluated
0
2206 if (check_flags) {
check_flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2207 rv &= ~CERT_PKEY_CA_SIGNATURE;-
2208 break;
never executed: break;
0
2209 } else-
2210 goto end;
never executed: goto end;
0
2211 }-
2212 }
never executed: end of block
0
2213 }
executed 2 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2
2214 /* Else not TLS 1.2, so mark EE and CA signing algorithms OK */-
2215 else if (check_flags)
check_flagsDescription
TRUEnever evaluated
FALSEevaluated 2980 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2980
2216 rv |= CERT_PKEY_EE_SIGNATURE | CERT_PKEY_CA_SIGNATURE;
never executed: rv |= 0x10 | 0x20;
0
2217 skip_sigs:
code before this statement executed 2982 times by 1 test: skip_sigs:
Executed by:
  • libssl.so.1.1
2982
2218 /* Check cert parameters are consistent */-
2219 if (tls1_check_cert_param(s, x, 1))
tls1_check_cert_param(s, x, 1)Description
TRUEevaluated 2819 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 163 times by 1 test
Evaluated by:
  • libssl.so.1.1
163-2819
2220 rv |= CERT_PKEY_EE_PARAM;
executed 2819 times by 1 test: rv |= 0x40;
Executed by:
  • libssl.so.1.1
2819
2221 else if (!check_flags)
!check_flagsDescription
TRUEevaluated 163 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-163
2222 goto end;
executed 163 times by 1 test: goto end;
Executed by:
  • libssl.so.1.1
163
2223 if (!s->server)
!s->serverDescription
TRUEnever evaluated
FALSEevaluated 2819 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2819
2224 rv |= CERT_PKEY_CA_PARAM;
never executed: rv |= 0x80;
0
2225 /* In strict mode check rest of chain too */-
2226 else if (strict_mode) {
strict_modeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2817 times by 1 test
Evaluated by:
  • libssl.so.1.1
2-2817
2227 rv |= CERT_PKEY_CA_PARAM;-
2228 for (i = 0; i < sk_X509_num(chain); i++) {
i < sk_X509_num(chain)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2
2229 X509 *ca = sk_X509_value(chain, i);-
2230 if (!tls1_check_cert_param(s, ca, 0)) {
!tls1_check_ce...aram(s, ca, 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2231 if (check_flags) {
check_flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2232 rv &= ~CERT_PKEY_CA_PARAM;-
2233 break;
never executed: break;
0
2234 } else-
2235 goto end;
never executed: goto end;
0
2236 }-
2237 }
never executed: end of block
0
2238 }
executed 2 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2
2239 if (!s->server && strict_mode) {
!s->serverDescription
TRUEnever evaluated
FALSEevaluated 2819 times by 1 test
Evaluated by:
  • libssl.so.1.1
strict_modeDescription
TRUEnever evaluated
FALSEnever evaluated
0-2819
2240 STACK_OF(X509_NAME) *ca_dn;-
2241 int check_type = 0;-
2242 switch (EVP_PKEY_id(pk)) {-
2243 case EVP_PKEY_RSA:
never executed: case 6:
0
2244 check_type = TLS_CT_RSA_SIGN;-
2245 break;
never executed: break;
0
2246 case EVP_PKEY_DSA:
never executed: case 116:
0
2247 check_type = TLS_CT_DSS_SIGN;-
2248 break;
never executed: break;
0
2249 case EVP_PKEY_EC:
never executed: case 408:
0
2250 check_type = TLS_CT_ECDSA_SIGN;-
2251 break;
never executed: break;
0
2252 }-
2253 if (check_type) {
check_typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2254 const uint8_t *ctypes = s->s3->tmp.ctype;-
2255 size_t j;-
2256-
2257 for (j = 0; j < s->s3->tmp.ctype_len; j++, ctypes++) {
j < s->s3->tmp.ctype_lenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2258 if (*ctypes == check_type) {
*ctypes == check_typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2259 rv |= CERT_PKEY_CERT_TYPE;-
2260 break;
never executed: break;
0
2261 }-
2262 }
never executed: end of block
0
2263 if (!(rv & CERT_PKEY_CERT_TYPE) && !check_flags)
!(rv & 0x400)Description
TRUEnever evaluated
FALSEnever evaluated
!check_flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2264 goto end;
never executed: goto end;
0
2265 } else {
never executed: end of block
0
2266 rv |= CERT_PKEY_CERT_TYPE;-
2267 }
never executed: end of block
0
2268-
2269 ca_dn = s->s3->tmp.peer_ca_names;-
2270-
2271 if (!sk_X509_NAME_num(ca_dn))
!sk_X509_NAME_num(ca_dn)Description
TRUEnever evaluated
FALSEnever evaluated
0
2272 rv |= CERT_PKEY_ISSUER_NAME;
never executed: rv |= 0x200;
0
2273-
2274 if (!(rv & CERT_PKEY_ISSUER_NAME)) {
!(rv & 0x200)Description
TRUEnever evaluated
FALSEnever evaluated
0
2275 if (ssl_check_ca_name(ca_dn, x))
ssl_check_ca_name(ca_dn, x)Description
TRUEnever evaluated
FALSEnever evaluated
0
2276 rv |= CERT_PKEY_ISSUER_NAME;
never executed: rv |= 0x200;
0
2277 }
never executed: end of block
0
2278 if (!(rv & CERT_PKEY_ISSUER_NAME)) {
!(rv & 0x200)Description
TRUEnever evaluated
FALSEnever evaluated
0
2279 for (i = 0; i < sk_X509_num(chain); i++) {
i < sk_X509_num(chain)Description
TRUEnever evaluated
FALSEnever evaluated
0
2280 X509 *xtmp = sk_X509_value(chain, i);-
2281 if (ssl_check_ca_name(ca_dn, xtmp)) {
ssl_check_ca_name(ca_dn, xtmp)Description
TRUEnever evaluated
FALSEnever evaluated
0
2282 rv |= CERT_PKEY_ISSUER_NAME;-
2283 break;
never executed: break;
0
2284 }-
2285 }
never executed: end of block
0
2286 }
never executed: end of block
0
2287 if (!check_flags && !(rv & CERT_PKEY_ISSUER_NAME))
!check_flagsDescription
TRUEnever evaluated
FALSEnever evaluated
!(rv & 0x200)Description
TRUEnever evaluated
FALSEnever evaluated
0
2288 goto end;
never executed: goto end;
0
2289 } else
never executed: end of block
0
2290 rv |= CERT_PKEY_ISSUER_NAME | CERT_PKEY_CERT_TYPE;
executed 2819 times by 1 test: rv |= 0x200 | 0x400;
Executed by:
  • libssl.so.1.1
2819
2291-
2292 if (!check_flags || (rv & check_flags) == check_flags)
!check_flagsDescription
TRUEevaluated 2819 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
(rv & check_fl...== check_flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0-2819
2293 rv |= CERT_PKEY_VALID;
executed 2819 times by 1 test: rv |= 0x1;
Executed by:
  • libssl.so.1.1
2819
2294-
2295 end:
code before this statement executed 2819 times by 1 test: end:
Executed by:
  • libssl.so.1.1
2819
2296-
2297 if (TLS1_get_version(s) >= TLS1_2_VERSION)
((SSL_version(...: 0) >= 0x0303Description
TRUEevaluated 8964 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5634 times by 1 test
Evaluated by:
  • libssl.so.1.1
(SSL_version(s) >> 8) == 0x03Description
TRUEevaluated 13068 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1530 times by 1 test
Evaluated by:
  • libssl.so.1.1
1530-13068
2298 rv |= *pvalid & (CERT_PKEY_EXPLICIT_SIGN | CERT_PKEY_SIGN);
executed 8964 times by 1 test: rv |= *pvalid & (0x100 | 0x2);
Executed by:
  • libssl.so.1.1
8964
2299 else-
2300 rv |= CERT_PKEY_SIGN | CERT_PKEY_EXPLICIT_SIGN;
executed 5634 times by 1 test: rv |= 0x2 | 0x100;
Executed by:
  • libssl.so.1.1
5634
2301-
2302 /*-
2303 * When checking a CERT_PKEY structure all flags are irrelevant if the-
2304 * chain is invalid.-
2305 */-
2306 if (!check_flags) {
!check_flagsDescription
TRUEevaluated 14598 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-14598
2307 if (rv & CERT_PKEY_VALID) {
rv & 0x1Description
TRUEevaluated 2819 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 11779 times by 1 test
Evaluated by:
  • libssl.so.1.1
2819-11779
2308 *pvalid = rv;-
2309 } else {
executed 2819 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2819
2310 /* Preserve sign and explicit sign flag, clear rest */-
2311 *pvalid &= CERT_PKEY_EXPLICIT_SIGN | CERT_PKEY_SIGN;-
2312 return 0;
executed 11779 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
11779
2313 }-
2314 }-
2315 return rv;
executed 2819 times by 1 test: return rv;
Executed by:
  • libssl.so.1.1
2819
2316}-
2317-
2318/* Set validity of certificates in an SSL structure */-
2319void tls1_set_cert_validity(SSL *s)-
2320{-
2321 tls1_check_chain(s, NULL, NULL, NULL, SSL_PKEY_RSA);-
2322 tls1_check_chain(s, NULL, NULL, NULL, SSL_PKEY_RSA_PSS_SIGN);-
2323 tls1_check_chain(s, NULL, NULL, NULL, SSL_PKEY_DSA_SIGN);-
2324 tls1_check_chain(s, NULL, NULL, NULL, SSL_PKEY_ECC);-
2325 tls1_check_chain(s, NULL, NULL, NULL, SSL_PKEY_GOST01);-
2326 tls1_check_chain(s, NULL, NULL, NULL, SSL_PKEY_GOST12_256);-
2327 tls1_check_chain(s, NULL, NULL, NULL, SSL_PKEY_GOST12_512);-
2328 tls1_check_chain(s, NULL, NULL, NULL, SSL_PKEY_ED25519);-
2329 tls1_check_chain(s, NULL, NULL, NULL, SSL_PKEY_ED448);-
2330}
executed 1622 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
1622
2331-
2332/* User level utility function to check a chain is suitable */-
2333int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain)-
2334{-
2335 return tls1_check_chain(s, x, pk, chain, -1);
never executed: return tls1_check_chain(s, x, pk, chain, -1);
0
2336}-
2337-
2338#ifndef OPENSSL_NO_DH-
2339DH *ssl_get_auto_dh(SSL *s)-
2340{-
2341 int dh_secbits = 80;-
2342 if (s->cert->dh_tmp_auto == 2)
s->cert->dh_tmp_auto == 2Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-9
2343 return DH_get_1024_160();
never executed: return DH_get_1024_160();
0
2344 if (s->s3->tmp.new_cipher->algorithm_auth & (SSL_aNULL | SSL_aPSK)) {
s->s3->tmp.new...| 0x00000010U)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
1-8
2345 if (s->s3->tmp.new_cipher->strength_bits == 256)
s->s3->tmp.new...th_bits == 256Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
0-1
2346 dh_secbits = 128;
never executed: dh_secbits = 128;
0
2347 else-
2348 dh_secbits = 80;
executed 1 time by 1 test: dh_secbits = 80;
Executed by:
  • libssl.so.1.1
1
2349 } else {-
2350 if (s->s3->tmp.cert == NULL)
s->s3->tmp.cert == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-8
2351 return NULL;
never executed: return ((void *)0) ;
0
2352 dh_secbits = EVP_PKEY_security_bits(s->s3->tmp.cert->privatekey);-
2353 }
executed 8 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
8
2354-
2355 if (dh_secbits >= 128) {
dh_secbits >= 128Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-9
2356 DH *dhp = DH_new();-
2357 BIGNUM *p, *g;-
2358 if (dhp == NULL)
dhp == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2359 return NULL;
never executed: return ((void *)0) ;
0
2360 g = BN_new();-
2361 if (g == NULL || !BN_set_word(g, 2)) {
g == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
!BN_set_word(g, 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
2362 DH_free(dhp);-
2363 BN_free(g);-
2364 return NULL;
never executed: return ((void *)0) ;
0
2365 }-
2366 if (dh_secbits >= 192)
dh_secbits >= 192Description
TRUEnever evaluated
FALSEnever evaluated
0
2367 p = BN_get_rfc3526_prime_8192(NULL);
never executed: p = BN_get_rfc3526_prime_8192( ((void *)0) );
0
2368 else-
2369 p = BN_get_rfc3526_prime_3072(NULL);
never executed: p = BN_get_rfc3526_prime_3072( ((void *)0) );
0
2370 if (p == NULL || !DH_set0_pqg(dhp, p, NULL, g)) {
p == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
!DH_set0_pqg(d...void *)0) , g)Description
TRUEnever evaluated
FALSEnever evaluated
0
2371 DH_free(dhp);-
2372 BN_free(p);-
2373 BN_free(g);-
2374 return NULL;
never executed: return ((void *)0) ;
0
2375 }-
2376 return dhp;
never executed: return dhp;
0
2377 }-
2378 if (dh_secbits >= 112)
dh_secbits >= 112Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
1-8
2379 return DH_get_2048_224();
executed 8 times by 1 test: return DH_get_2048_224();
Executed by:
  • libssl.so.1.1
8
2380 return DH_get_1024_160();
executed 1 time by 1 test: return DH_get_1024_160();
Executed by:
  • libssl.so.1.1
1
2381}-
2382#endif-
2383-
2384static int ssl_security_cert_key(SSL *s, SSL_CTX *ctx, X509 *x, int op)-
2385{-
2386 int secbits = -1;-
2387 EVP_PKEY *pkey = X509_get0_pubkey(x);-
2388 if (pkey) {
pkeyDescription
TRUEevaluated 10371 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-10371
2389 /*-
2390 * If no parameters this will return -1 and fail using the default-
2391 * security callback for any non-zero security level. This will-
2392 * reject keys which omit parameters but this only affects DSA and-
2393 * omission of parameters is never (?) done in practice.-
2394 */-
2395 secbits = EVP_PKEY_security_bits(pkey);-
2396 }
executed 10371 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
10371
2397 if (s)
sDescription
TRUEevaluated 2306 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 8065 times by 1 test
Evaluated by:
  • libssl.so.1.1
2306-8065
2398 return ssl_security(s, op, secbits, 0, x);
executed 2306 times by 1 test: return ssl_security(s, op, secbits, 0, x);
Executed by:
  • libssl.so.1.1
2306
2399 else-
2400 return ssl_ctx_security(ctx, op, secbits, 0, x);
executed 8065 times by 1 test: return ssl_ctx_security(ctx, op, secbits, 0, x);
Executed by:
  • libssl.so.1.1
8065
2401}-
2402-
2403static int ssl_security_cert_sig(SSL *s, SSL_CTX *ctx, X509 *x, int op)-
2404{-
2405 /* Lookup signature algorithm digest */-
2406 int secbits, nid, pknid;-
2407 /* Don't check signature if self signed */-
2408 if ((X509_get_extension_flags(x) & EXFLAG_SS) != 0)
(X509_get_exte...& 0x2000) != 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 10364 times by 1 test
Evaluated by:
  • libssl.so.1.1
7-10364
2409 return 1;
executed 7 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
7
2410 if (!X509_get_signature_info(x, &nid, &pknid, &secbits, NULL))
!X509_get_sign... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 10364 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-10364
2411 secbits = -1;
never executed: secbits = -1;
0
2412 /* If digest NID not defined use signature NID */-
2413 if (nid == NID_undef)
nid == 0Description
TRUEnever evaluated
FALSEevaluated 10364 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-10364
2414 nid = pknid;
never executed: nid = pknid;
0
2415 if (s)
sDescription
TRUEevaluated 2299 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 8065 times by 1 test
Evaluated by:
  • libssl.so.1.1
2299-8065
2416 return ssl_security(s, op, secbits, nid, x);
executed 2299 times by 1 test: return ssl_security(s, op, secbits, nid, x);
Executed by:
  • libssl.so.1.1
2299
2417 else-
2418 return ssl_ctx_security(ctx, op, secbits, nid, x);
executed 8065 times by 1 test: return ssl_ctx_security(ctx, op, secbits, nid, x);
Executed by:
  • libssl.so.1.1
8065
2419}-
2420-
2421int ssl_security_cert(SSL *s, SSL_CTX *ctx, X509 *x, int vfy, int is_ee)-
2422{-
2423 if (vfy)
vfyDescription
TRUEnever evaluated
FALSEevaluated 10371 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-10371
2424 vfy = SSL_SECOP_PEER;
never executed: vfy = 0x1000;
0
2425 if (is_ee) {
is_eeDescription
TRUEevaluated 10173 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 198 times by 1 test
Evaluated by:
  • libssl.so.1.1
198-10173
2426 if (!ssl_security_cert_key(s, ctx, x, SSL_SECOP_EE_KEY | vfy))
!ssl_security_...<< 16)) | vfy)Description
TRUEnever evaluated
FALSEevaluated 10173 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-10173
2427 return SSL_R_EE_KEY_TOO_SMALL;
never executed: return 399;
0
2428 } else {
executed 10173 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
10173
2429 if (!ssl_security_cert_key(s, ctx, x, SSL_SECOP_CA_KEY | vfy))
!ssl_security_...<< 16)) | vfy)Description
TRUEnever evaluated
FALSEevaluated 198 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-198
2430 return SSL_R_CA_KEY_TOO_SMALL;
never executed: return 397;
0
2431 }
executed 198 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
198
2432 if (!ssl_security_cert_sig(s, ctx, x, SSL_SECOP_CA_MD | vfy))
!ssl_security_...<< 16)) | vfy)Description
TRUEnever evaluated
FALSEevaluated 10371 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-10371
2433 return SSL_R_CA_MD_TOO_WEAK;
never executed: return 398;
0
2434 return 1;
executed 10371 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
10371
2435}-
2436-
2437/*-
2438 * Check security of a chain, if |sk| includes the end entity certificate then-
2439 * |x| is NULL. If |vfy| is 1 then we are verifying a peer chain and not sending-
2440 * one to the peer. Return values: 1 if ok otherwise error code to use-
2441 */-
2442-
2443int ssl_security_cert_chain(SSL *s, STACK_OF(X509) *sk, X509 *x, int vfy)-
2444{-
2445 int rv, start_idx, i;-
2446 if (x == NULL) {
x == ((void *)0)Description
TRUEevaluated 2104 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 38 times by 1 test
Evaluated by:
  • libssl.so.1.1
38-2104
2447 x = sk_X509_value(sk, 0);-
2448 start_idx = 1;-
2449 } else
executed 2104 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2104
2450 start_idx = 0;
executed 38 times by 1 test: start_idx = 0;
Executed by:
  • libssl.so.1.1
38
2451-
2452 rv = ssl_security_cert(s, NULL, x, vfy, 1);-
2453 if (rv != 1)
rv != 1Description
TRUEnever evaluated
FALSEevaluated 2142 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-2142
2454 return rv;
never executed: return rv;
0
2455-
2456 for (i = start_idx; i < sk_X509_num(sk); i++) {
i < sk_X509_num(sk)Description
TRUEevaluated 162 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2142 times by 1 test
Evaluated by:
  • libssl.so.1.1
162-2142
2457 x = sk_X509_value(sk, i);-
2458 rv = ssl_security_cert(s, NULL, x, vfy, 0);-
2459 if (rv != 1)
rv != 1Description
TRUEnever evaluated
FALSEevaluated 162 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-162
2460 return rv;
never executed: return rv;
0
2461 }
executed 162 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
162
2462 return 1;
executed 2142 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
2142
2463}-
2464-
2465/*-
2466 * For TLS 1.2 servers check if we have a certificate which can be used-
2467 * with the signature algorithm "lu" and return index of certificate.-
2468 */-
2469-
2470static int tls12_get_cert_sigalg_idx(const SSL *s, const SIGALG_LOOKUP *lu)-
2471{-
2472 int sig_idx = lu->sig_idx;-
2473 const SSL_CERT_LOOKUP *clu = ssl_cert_lookup_by_idx(sig_idx);-
2474-
2475 /* If not recognised or not supported by cipher mask it is not suitable */-
2476 if (clu == NULL
clu == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 7359 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-7359
2477 || (clu->amask & s->s3->tmp.new_cipher->algorithm_auth) == 0
(clu->amask & ...thm_auth) == 0Description
TRUEevaluated 4598 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2761 times by 1 test
Evaluated by:
  • libssl.so.1.1
2761-4598
2478 || (clu->nid == EVP_PKEY_RSA_PSS
clu->nid == 912Description
TRUEevaluated 1737 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1024 times by 1 test
Evaluated by:
  • libssl.so.1.1
1024-1737
2479 && (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kRSA) != 0))
(s->s3->tmp.ne...0000001U) != 0Description
TRUEevaluated 409 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1328 times by 1 test
Evaluated by:
  • libssl.so.1.1
409-1328
2480 return -1;
executed 5007 times by 1 test: return -1;
Executed by:
  • libssl.so.1.1
5007
2481-
2482 return s->s3->tmp.valid_flags[sig_idx] & CERT_PKEY_VALID ? sig_idx : -1;
executed 2352 times by 1 test: return s->s3->tmp.valid_flags[sig_idx] & 0x1 ? sig_idx : -1;
Executed by:
  • libssl.so.1.1
s->s3->tmp.val...sig_idx] & 0x1Description
TRUEevaluated 1024 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1328 times by 1 test
Evaluated by:
  • libssl.so.1.1
1024-2352
2483}-
2484-
2485/*-
2486 * Returns true if |s| has a usable certificate configured for use-
2487 * with signature scheme |sig|.-
2488 * "Usable" includes a check for presence as well as applying-
2489 * the signature_algorithm_cert restrictions sent by the peer (if any).-
2490 * Returns false if no usable certificate is found.-
2491 */-
2492static int has_usable_cert(SSL *s, const SIGALG_LOOKUP *sig, int idx)-
2493{-
2494 const SIGALG_LOOKUP *lu;-
2495 int mdnid, pknid;-
2496 size_t i;-
2497-
2498 /* TLS 1.2 callers can override lu->sig_idx, but not TLS 1.3 callers. */-
2499 if (idx == -1)
idx == -1Description
TRUEevaluated 5204 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1162 times by 1 test
Evaluated by:
  • libssl.so.1.1
1162-5204
2500 idx = sig->sig_idx;
executed 5204 times by 1 test: idx = sig->sig_idx;
Executed by:
  • libssl.so.1.1
5204
2501 if (!ssl_has_cert(s, idx))
!ssl_has_cert(s, idx)Description
TRUEevaluated 4247 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2119 times by 1 test
Evaluated by:
  • libssl.so.1.1
2119-4247
2502 return 0;
executed 4247 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
4247
2503 if (s->s3->tmp.peer_cert_sigalgs != NULL) {
s->s3->tmp.pee...!= ((void *)0)Description
TRUEevaluated 229 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1890 times by 1 test
Evaluated by:
  • libssl.so.1.1
229-1890
2504 for (i = 0; i < s->s3->tmp.peer_cert_sigalgslen; i++) {
i < s->s3->tmp...ert_sigalgslenDescription
TRUEevaluated 3861 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 221 times by 1 test
Evaluated by:
  • libssl.so.1.1
221-3861
2505 lu = tls1_lookup_sigalg(s->s3->tmp.peer_cert_sigalgs[i]);-
2506 if (lu == NULL
lu == ((void *)0)Description
TRUEevaluated 2218 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1643 times by 1 test
Evaluated by:
  • libssl.so.1.1
1643-2218
2507 || !X509_get_signature_info(s->cert->pkeys[idx].x509, &mdnid,
!X509_get_sign... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 1643 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1643
2508 &pknid, NULL, NULL))
!X509_get_sign... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 1643 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-1643
2509 continue;
executed 2218 times by 1 test: continue;
Executed by:
  • libssl.so.1.1
2218
2510 /*-
2511 * TODO this does not differentiate between the-
2512 * rsa_pss_pss_* and rsa_pss_rsae_* schemes since we do not-
2513 * have a chain here that lets us look at the key OID in the-
2514 * signing certificate.-
2515 */-
2516 if (mdnid == lu->hash && pknid == lu->sig)
mdnid == lu->hashDescription
TRUEevaluated 298 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1345 times by 1 test
Evaluated by:
  • libssl.so.1.1
pknid == lu->sigDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 290 times by 1 test
Evaluated by:
  • libssl.so.1.1
8-1345
2517 return 1;
executed 8 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
8
2518 }
executed 1635 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
1635
2519 return 0;
executed 221 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
221
2520 }-
2521 return 1;
executed 1890 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
1890
2522}-
2523-
2524/*-
2525 * Choose an appropriate signature algorithm based on available certificates-
2526 * Sets chosen certificate and signature algorithm.-
2527 *-
2528 * For servers if we fail to find a required certificate it is a fatal error,-
2529 * an appropriate error code is set and a TLS alert is sent.-
2530 *-
2531 * For clients fatalerrs is set to 0. If a certificate is not suitable it is not-
2532 * a fatal error: we will either try another certificate or not present one-
2533 * to the server. In this case no error is set.-
2534 */-
2535int tls_choose_sigalg(SSL *s, int fatalerrs)-
2536{-
2537 const SIGALG_LOOKUP *lu = NULL;-
2538 int sig_idx = -1;-
2539-
2540 s->s3->tmp.cert = NULL;-
2541 s->s3->tmp.sigalg = NULL;-
2542-
2543 if (SSL_IS_TLS13(s)) {
!(s->method->s...c_flags & 0x8)Description
TRUEevaluated 2258 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 183 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->version >= 0x0304Description
TRUEevaluated 905 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1353 times by 1 test
Evaluated by:
  • libssl.so.1.1
(s)->method->v...ion != 0x10000Description
TRUEevaluated 905 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2258
2544 size_t i;-
2545#ifndef OPENSSL_NO_EC-
2546 int curve = -1;-
2547#endif-
2548-
2549 /* Look for a certificate matching shared sigalgs */-
2550 for (i = 0; i < s->cert->shared_sigalgslen; i++) {
i < s->cert->shared_sigalgslenDescription
TRUEevaluated 5672 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 47 times by 1 test
Evaluated by:
  • libssl.so.1.1
47-5672
2551 lu = s->cert->shared_sigalgs[i];-
2552 sig_idx = -1;-
2553-
2554 /* Skip SHA1, SHA224, DSA and RSA if not PSS */-
2555 if (lu->hash == NID_sha1
lu->hash == 64Description
TRUEevaluated 172 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5500 times by 1 test
Evaluated by:
  • libssl.so.1.1
172-5500
2556 || lu->hash == NID_sha224
lu->hash == 675Description
TRUEevaluated 49 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5451 times by 1 test
Evaluated by:
  • libssl.so.1.1
49-5451
2557 || lu->sig == EVP_PKEY_DSA
lu->sig == 116Description
TRUEnever evaluated
FALSEevaluated 5451 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-5451
2558 || lu->sig == EVP_PKEY_RSA)
lu->sig == 6Description
TRUEevaluated 247 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 5204 times by 1 test
Evaluated by:
  • libssl.so.1.1
247-5204
2559 continue;
executed 468 times by 1 test: continue;
Executed by:
  • libssl.so.1.1
468
2560 /* Check that we have a cert, and signature_algorithms_cert */-
2561 if (!tls1_lookup_md(lu, NULL) || !has_usable_cert(s, lu, -1))
!tls1_lookup_m... ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 5204 times by 1 test
Evaluated by:
  • libssl.so.1.1
!has_usable_cert(s, lu, -1)Description
TRUEevaluated 4250 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 954 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-5204
2562 continue;
executed 4250 times by 1 test: continue;
Executed by:
  • libssl.so.1.1
4250
2563 if (lu->sig == EVP_PKEY_EC) {
lu->sig == 408Description
TRUEevaluated 340 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 614 times by 1 test
Evaluated by:
  • libssl.so.1.1
340-614
2564#ifndef OPENSSL_NO_EC-
2565 if (curve == -1) {
curve == -1Description
TRUEevaluated 275 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 65 times by 1 test
Evaluated by:
  • libssl.so.1.1
65-275
2566 EC_KEY *ec = EVP_PKEY_get0_EC_KEY(s->cert->pkeys[SSL_PKEY_ECC].privatekey);-
2567-
2568 curve = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));-
2569 }
executed 275 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
275
2570 if (lu->curve != NID_undef && curve != lu->curve)
lu->curve != 0Description
TRUEevaluated 340 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
curve != lu->curveDescription
TRUEevaluated 96 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 244 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-340
2571 continue;
executed 96 times by 1 test: continue;
Executed by:
  • libssl.so.1.1
96
2572#else-
2573 continue;-
2574#endif-
2575 } else if (lu->sig == EVP_PKEY_RSA_PSS) {
executed 244 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
lu->sig == 912Description
TRUEevaluated 610 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 4 times by 1 test
Evaluated by:
  • libssl.so.1.1
4-610
2576 /* validate that key is large enough for the signature algorithm */-
2577 EVP_PKEY *pkey;-
2578-
2579 pkey = s->cert->pkeys[lu->sig_idx].privatekey;-
2580 if (!rsa_pss_check_min_key_size(EVP_PKEY_get0(pkey), lu))
!rsa_pss_check...et0(pkey), lu)Description
TRUEnever evaluated
FALSEevaluated 610 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-610
2581 continue;
never executed: continue;
0
2582 }
executed 610 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
610
2583 break;
executed 858 times by 1 test: break;
Executed by:
  • libssl.so.1.1
858
2584 }-
2585 if (i == s->cert->shared_sigalgslen) {
i == s->cert->...red_sigalgslenDescription
TRUEevaluated 47 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 858 times by 1 test
Evaluated by:
  • libssl.so.1.1
47-858
2586 if (!fatalerrs)
!fatalerrsDescription
TRUEevaluated 25 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 22 times by 1 test
Evaluated by:
  • libssl.so.1.1
22-25
2587 return 1;
executed 25 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
25
2588 SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS_CHOOSE_SIGALG,-
2589 SSL_R_NO_SUITABLE_SIGNATURE_ALGORITHM);-
2590 return 0;
executed 22 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
22
2591 }-
2592 } else {
executed 858 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
858
2593 /* If ciphersuite doesn't require a cert nothing to do */-
2594 if (!(s->s3->tmp.new_cipher->algorithm_auth & SSL_aCERT))
!(s->s3->tmp.n... 0x00000080U))Description
TRUEevaluated 69 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1467 times by 1 test
Evaluated by:
  • libssl.so.1.1
69-1467
2595 return 1;
executed 69 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
69
2596 if (!s->server && !ssl_has_cert(s, s->cert->key - s->cert->pkeys))
!s->serverDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1427 times by 1 test
Evaluated by:
  • libssl.so.1.1
!ssl_has_cert(...->cert->pkeys)Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 25 times by 1 test
Evaluated by:
  • libssl.so.1.1
15-1427
2597 return 1;
executed 15 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
15
2598-
2599 if (SSL_USE_SIGALGS(s)) {
(s->method->ss...c_flags & 0x2)Description
TRUEevaluated 1011 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 441 times by 1 test
Evaluated by:
  • libssl.so.1.1
441-1011
2600 size_t i;-
2601 if (s->s3->tmp.peer_sigalgs != NULL) {
s->s3->tmp.pee...!= ((void *)0)Description
TRUEevaluated 889 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 122 times by 1 test
Evaluated by:
  • libssl.so.1.1
122-889
2602#ifndef OPENSSL_NO_EC-
2603 int curve;-
2604-
2605 /* For Suite B need to match signature algorithm to curve */-
2606 if (tls1_suiteb(s)) {
(s->cert->cert...ags & 0x30000)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 887 times by 1 test
Evaluated by:
  • libssl.so.1.1
2-887
2607 EC_KEY *ec = EVP_PKEY_get0_EC_KEY(s->cert->pkeys[SSL_PKEY_ECC].privatekey);-
2608 curve = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));-
2609 } else {
executed 2 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2
2610 curve = -1;-
2611 }
executed 887 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
887
2612#endif-
2613-
2614 /*-
2615 * Find highest preference signature algorithm matching-
2616 * cert type-
2617 */-
2618 for (i = 0; i < s->cert->shared_sigalgslen; i++) {
i < s->cert->shared_sigalgslenDescription
TRUEevaluated 7478 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 68 times by 1 test
Evaluated by:
  • libssl.so.1.1
68-7478
2619 lu = s->cert->shared_sigalgs[i];-
2620-
2621 if (s->server) {
s->serverDescription
TRUEevaluated 7359 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 119 times by 1 test
Evaluated by:
  • libssl.so.1.1
119-7359
2622 if ((sig_idx = tls12_get_cert_sigalg_idx(s, lu)) == -1)
(sig_idx = tls...(s, lu)) == -1Description
TRUEevaluated 6335 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1024 times by 1 test
Evaluated by:
  • libssl.so.1.1
1024-6335
2623 continue;
executed 6335 times by 1 test: continue;
Executed by:
  • libssl.so.1.1
6335
2624 } else {
executed 1024 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
1024
2625 int cc_idx = s->cert->key - s->cert->pkeys;-
2626-
2627 sig_idx = lu->sig_idx;-
2628 if (cc_idx != sig_idx)
cc_idx != sig_idxDescription
TRUEevaluated 103 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libssl.so.1.1
16-103
2629 continue;
executed 103 times by 1 test: continue;
Executed by:
  • libssl.so.1.1
103
2630 }
executed 16 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
16
2631 /* Check that we have a cert, and sig_algs_cert */-
2632 if (!has_usable_cert(s, lu, sig_idx))
!has_usable_ce..., lu, sig_idx)Description
TRUEevaluated 218 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 822 times by 1 test
Evaluated by:
  • libssl.so.1.1
218-822
2633 continue;
executed 218 times by 1 test: continue;
Executed by:
  • libssl.so.1.1
218
2634 if (lu->sig == EVP_PKEY_RSA_PSS) {
lu->sig == 912Description
TRUEevaluated 639 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 183 times by 1 test
Evaluated by:
  • libssl.so.1.1
183-639
2635 /* validate that key is large enough for the signature algorithm */-
2636 EVP_PKEY *pkey = s->cert->pkeys[sig_idx].privatekey;-
2637-
2638 if (!rsa_pss_check_min_key_size(EVP_PKEY_get0(pkey), lu))
!rsa_pss_check...et0(pkey), lu)Description
TRUEnever evaluated
FALSEevaluated 639 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-639
2639 continue;
never executed: continue;
0
2640 }
executed 639 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
639
2641#ifndef OPENSSL_NO_EC-
2642 if (curve == -1 || lu->curve == curve)
curve == -1Description
TRUEevaluated 819 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libssl.so.1.1
lu->curve == curveDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libssl.so.1.1
1-819
2643#endif-
2644 break;
executed 821 times by 1 test: break;
Executed by:
  • libssl.so.1.1
821
2645 }
executed 1 time by 1 test: end of block
Executed by:
  • libssl.so.1.1
1
2646 if (i == s->cert->shared_sigalgslen) {
i == s->cert->...red_sigalgslenDescription
TRUEevaluated 68 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 821 times by 1 test
Evaluated by:
  • libssl.so.1.1
68-821
2647 if (!fatalerrs)
!fatalerrsDescription
TRUEnever evaluated
FALSEevaluated 68 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-68
2648 return 1;
never executed: return 1;
0
2649 SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE,-
2650 SSL_F_TLS_CHOOSE_SIGALG,-
2651 SSL_R_NO_SUITABLE_SIGNATURE_ALGORITHM);-
2652 return 0;
executed 68 times by 1 test: return 0;
Executed by:
  • libssl.so.1.1
68
2653 }-
2654 } else {
executed 821 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
821
2655 /*-
2656 * If we have no sigalg use defaults-
2657 */-
2658 const uint16_t *sent_sigs;-
2659 size_t sent_sigslen;-
2660-
2661 if ((lu = tls1_get_legacy_sigalg(s, -1)) == NULL) {
(lu = tls1_get...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 122 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-122
2662 if (!fatalerrs)
!fatalerrsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2663 return 1;
never executed: return 1;
0
2664 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CHOOSE_SIGALG,-
2665 ERR_R_INTERNAL_ERROR);-
2666 return 0;
never executed: return 0;
0
2667 }-
2668-
2669 /* Check signature matches a type we sent */-
2670 sent_sigslen = tls12_get_psigalgs(s, 1, &sent_sigs);-
2671 for (i = 0; i < sent_sigslen; i++, sent_sigs++) {
i < sent_sigslenDescription
TRUEevaluated 2138 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-2138
2672 if (lu->sigalg == *sent_sigs
lu->sigalg == *sent_sigsDescription
TRUEevaluated 122 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 2016 times by 1 test
Evaluated by:
  • libssl.so.1.1
122-2016
2673 && has_usable_cert(s, lu, lu->sig_idx))
has_usable_cer..., lu->sig_idx)Description
TRUEevaluated 122 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-122
2674 break;
executed 122 times by 1 test: break;
Executed by:
  • libssl.so.1.1
122
2675 }
executed 2016 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
2016
2676 if (i == sent_sigslen) {
i == sent_sigslenDescription
TRUEnever evaluated
FALSEevaluated 122 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-122
2677 if (!fatalerrs)
!fatalerrsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2678 return 1;
never executed: return 1;
0
2679 SSLfatal(s, SSL_AD_ILLEGAL_PARAMETER,-
2680 SSL_F_TLS_CHOOSE_SIGALG,-
2681 SSL_R_WRONG_SIGNATURE_TYPE);-
2682 return 0;
never executed: return 0;
0
2683 }-
2684 }
executed 122 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
122
2685 } else {-
2686 if ((lu = tls1_get_legacy_sigalg(s, -1)) == NULL) {
(lu = tls1_get...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 441 times by 1 test
Evaluated by:
  • libssl.so.1.1
0-441
2687 if (!fatalerrs)
!fatalerrsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2688 return 1;
never executed: return 1;
0
2689 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CHOOSE_SIGALG,-
2690 ERR_R_INTERNAL_ERROR);-
2691 return 0;
never executed: return 0;
0
2692 }-
2693 }
executed 441 times by 1 test: end of block
Executed by:
  • libssl.so.1.1
441
2694 }-
2695 if (sig_idx == -1)
sig_idx == -1Description
TRUEevaluated 1421 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 821 times by 1 test
Evaluated by:
  • libssl.so.1.1
821-1421
2696 sig_idx = lu->sig_idx;
executed 1421 times by 1 test: sig_idx = lu->sig_idx;
Executed by:
  • libssl.so.1.1
1421
2697 s->s3->tmp.cert = &s->cert->pkeys[sig_idx];-
2698 s->cert->key = s->s3->tmp.cert;-
2699 s->s3->tmp.sigalg = lu;-
2700 return 1;
executed 2242 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
2242
2701}-
2702-
2703int SSL_CTX_set_tlsext_max_fragment_length(SSL_CTX *ctx, uint8_t mode)-
2704{-
2705 if (mode != TLSEXT_max_fragment_length_DISABLED
mode != 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEevaluated 1204 times by 1 test
Evaluated by:
  • libssl.so.1.1
10-1204
2706 && !IS_MAX_FRAGMENT_LENGTH_EXT_VALID(mode)) {
((mode) >= 1)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
((mode) <= 4)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • libssl.so.1.1
FALSEnever evaluated
0-10
2707 SSLerr(SSL_F_SSL_CTX_SET_TLSEXT_MAX_FRAGMENT_LENGTH,-
2708 SSL_R_SSL3_EXT_INVALID_MAX_FRAGMENT_LENGTH);-
2709 return 0;
never executed: return 0;
0
2710 }-
2711-
2712 ctx->ext.max_fragment_len_mode = mode;-
2713 return 1;
executed 1214 times by 1 test: return 1;
Executed by:
  • libssl.so.1.1
1214
2714}-
2715-
2716int SSL_set_tlsext_max_fragment_length(SSL *ssl, uint8_t mode)-
2717{-
2718 if (mode != TLSEXT_max_fragment_length_DISABLED
mode != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2719 && !IS_MAX_FRAGMENT_LENGTH_EXT_VALID(mode)) {
((mode) >= 1)Description
TRUEnever evaluated
FALSEnever evaluated
((mode) <= 4)Description
TRUEnever evaluated
FALSEnever evaluated
0
2720 SSLerr(SSL_F_SSL_SET_TLSEXT_MAX_FRAGMENT_LENGTH,-
2721 SSL_R_SSL3_EXT_INVALID_MAX_FRAGMENT_LENGTH);-
2722 return 0;
never executed: return 0;
0
2723 }-
2724-
2725 ssl->ext.max_fragment_len_mode = mode;-
2726 return 1;
never executed: return 1;
0
2727}-
2728-
2729uint8_t SSL_SESSION_get_max_fragment_length(const SSL_SESSION *session)-
2730{-
2731 return session->ext.max_fragment_len_mode;
never executed: return session->ext.max_fragment_len_mode;
0
2732}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2