OpenCoverage

v3_tlsf.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/x509v3/v3_tlsf.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2015-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 "e_os.h"-
11#include "internal/cryptlib.h"-
12#include <stdio.h>-
13#include "internal/o_str.h"-
14#include <openssl/asn1t.h>-
15#include <openssl/conf.h>-
16#include <openssl/x509v3.h>-
17#include "ext_dat.h"-
18-
19static STACK_OF(CONF_VALUE) *i2v_TLS_FEATURE(const X509V3_EXT_METHOD *method,-
20 TLS_FEATURE *tls_feature,-
21 STACK_OF(CONF_VALUE) *ext_list);-
22static TLS_FEATURE *v2i_TLS_FEATURE(const X509V3_EXT_METHOD *method,-
23 X509V3_CTX *ctx,-
24 STACK_OF(CONF_VALUE) *nval);-
25-
26ASN1_ITEM_TEMPLATE(TLS_FEATURE) =-
27 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, TLS_FEATURE, ASN1_INTEGER)-
28static_ASN1_ITEM_TEMPLATE_END(TLS_FEATURE)-
29-
30IMPLEMENT_ASN1_ALLOC_FUNCTIONS(TLS_FEATURE)
never executed: end of block
never executed: return (TLS_FEATURE *)ASN1_item_new((&(TLS_FEATURE_it)));
0
31-
32const X509V3_EXT_METHOD v3_tls_feature = {-
33 NID_tlsfeature, 0,-
34 ASN1_ITEM_ref(TLS_FEATURE),-
35 0, 0, 0, 0,-
36 0, 0,-
37 (X509V3_EXT_I2V)i2v_TLS_FEATURE,-
38 (X509V3_EXT_V2I)v2i_TLS_FEATURE,-
39 0, 0,-
40 NULL-
41};-
42-
43-
44typedef struct {-
45 long num;-
46 const char *name;-
47} TLS_FEATURE_NAME;-
48-
49static TLS_FEATURE_NAME tls_feature_tbl[] = {-
50 { 5, "status_request" },-
51 { 17, "status_request_v2" }-
52};-
53-
54/*-
55 * i2v_TLS_FEATURE converts the TLS_FEATURE structure tls_feature into the-
56 * STACK_OF(CONF_VALUE) structure ext_list. STACK_OF(CONF_VALUE) is the format-
57 * used by the CONF library to represent a multi-valued extension. ext_list is-
58 * returned.-
59 */-
60static STACK_OF(CONF_VALUE) *i2v_TLS_FEATURE(const X509V3_EXT_METHOD *method,-
61 TLS_FEATURE *tls_feature,-
62 STACK_OF(CONF_VALUE) *ext_list)-
63{-
64 int i;-
65 size_t j;-
66 ASN1_INTEGER *ai;-
67 long tlsextid;-
68 for (i = 0; i < sk_ASN1_INTEGER_num(tls_feature); i++) {
i < sk_ASN1_IN...m(tls_feature)Description
TRUEevaluated 110 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 28 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
28-110
69 ai = sk_ASN1_INTEGER_value(tls_feature, i);-
70 tlsextid = ASN1_INTEGER_get(ai);-
71 for (j = 0; j < OSSL_NELEM(tls_feature_tbl); j++)
j < (sizeof(tl...ture_tbl)[0]))Description
TRUEevaluated 213 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 84 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
84-213
72 if (tlsextid == tls_feature_tbl[j].num)
tlsextid == tl...ure_tbl[j].numDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 187 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
26-187
73 break;
executed 26 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
26
74 if (j < OSSL_NELEM(tls_feature_tbl))
j < (sizeof(tl...ture_tbl)[0]))Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 84 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
26-84
75 X509V3_add_value(NULL, tls_feature_tbl[j].name, &ext_list);
executed 26 times by 1 test: X509V3_add_value( ((void *)0) , tls_feature_tbl[j].name, &ext_list);
Executed by:
  • libcrypto.so.1.1
26
76 else-
77 X509V3_add_value_int(NULL, ai, &ext_list);
executed 84 times by 1 test: X509V3_add_value_int( ((void *)0) , ai, &ext_list);
Executed by:
  • libcrypto.so.1.1
84
78 }-
79 return ext_list;
executed 28 times by 1 test: return ext_list;
Executed by:
  • libcrypto.so.1.1
28
80}-
81-
82/*-
83 * v2i_TLS_FEATURE converts the multi-valued extension nval into a TLS_FEATURE-
84 * structure, which is returned if the conversion is successful. In case of-
85 * error, NULL is returned.-
86 */-
87static TLS_FEATURE *v2i_TLS_FEATURE(const X509V3_EXT_METHOD *method,-
88 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)-
89{-
90 TLS_FEATURE *tlsf;-
91 char *extval, *endptr;-
92 ASN1_INTEGER *ai;-
93 CONF_VALUE *val;-
94 int i;-
95 size_t j;-
96 long tlsextid;-
97-
98 if ((tlsf = sk_ASN1_INTEGER_new_null()) == NULL) {
(tlsf = sk_ASN...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
99 X509V3err(X509V3_F_V2I_TLS_FEATURE, ERR_R_MALLOC_FAILURE);-
100 return NULL;
never executed: return ((void *)0) ;
0
101 }-
102-
103 for (i = 0; i < sk_CONF_VALUE_num(nval); i++) {
i < sk_CONF_VALUE_num(nval)Description
TRUEnever evaluated
FALSEnever evaluated
0
104 val = sk_CONF_VALUE_value(nval, i);-
105 if (val->value)
val->valueDescription
TRUEnever evaluated
FALSEnever evaluated
0
106 extval = val->value;
never executed: extval = val->value;
0
107 else-
108 extval = val->name;
never executed: extval = val->name;
0
109-
110 for (j = 0; j < OSSL_NELEM(tls_feature_tbl); j++)
j < (sizeof(tl...ture_tbl)[0]))Description
TRUEnever evaluated
FALSEnever evaluated
0
111 if (strcasecmp(extval, tls_feature_tbl[j].name) == 0)
strcasecmp(ext...[j].name) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
112 break;
never executed: break;
0
113 if (j < OSSL_NELEM(tls_feature_tbl))
j < (sizeof(tl...ture_tbl)[0]))Description
TRUEnever evaluated
FALSEnever evaluated
0
114 tlsextid = tls_feature_tbl[j].num;
never executed: tlsextid = tls_feature_tbl[j].num;
0
115 else {-
116 tlsextid = strtol(extval, &endptr, 10);-
117 if (((*endptr) != '\0') || (extval == endptr) || (tlsextid < 0) ||
((*endptr) != '\0')Description
TRUEnever evaluated
FALSEnever evaluated
(extval == endptr)Description
TRUEnever evaluated
FALSEnever evaluated
(tlsextid < 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
118 (tlsextid > 65535)) {
(tlsextid > 65535)Description
TRUEnever evaluated
FALSEnever evaluated
0
119 X509V3err(X509V3_F_V2I_TLS_FEATURE, X509V3_R_INVALID_SYNTAX);-
120 X509V3_conf_err(val);-
121 goto err;
never executed: goto err;
0
122 }-
123 }
never executed: end of block
0
124-
125 if ((ai = ASN1_INTEGER_new()) == NULL
(ai = ASN1_INT...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
126 || !ASN1_INTEGER_set(ai, tlsextid)
!ASN1_INTEGER_...(ai, tlsextid)Description
TRUEnever evaluated
FALSEnever evaluated
0
127 || sk_ASN1_INTEGER_push(tlsf, ai) <= 0) {
sk_ASN1_INTEGE...tlsf, ai) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
128 X509V3err(X509V3_F_V2I_TLS_FEATURE, ERR_R_MALLOC_FAILURE);-
129 goto err;
never executed: goto err;
0
130 }-
131 }
never executed: end of block
0
132 return tlsf;
never executed: return tlsf;
0
133-
134 err:-
135 sk_ASN1_INTEGER_pop_free(tlsf, ASN1_INTEGER_free);-
136 return NULL;
never executed: return ((void *)0) ;
0
137}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2