OpenCoverage

ts_rsp_print.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ts/ts_rsp_print.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2006-2016 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 "internal/cryptlib.h"-
12#include <openssl/objects.h>-
13#include <openssl/bn.h>-
14#include <openssl/x509v3.h>-
15#include <openssl/ts.h>-
16#include "ts_lcl.h"-
17-
18struct status_map_st {-
19 int bit;-
20 const char *text;-
21};-
22-
23static int ts_status_map_print(BIO *bio, const struct status_map_st *a,-
24 const ASN1_BIT_STRING *v);-
25static int ts_ACCURACY_print_bio(BIO *bio, const TS_ACCURACY *accuracy);-
26-
27-
28int TS_RESP_print_bio(BIO *bio, TS_RESP *a)-
29{-
30 BIO_printf(bio, "Status info:\n");-
31 TS_STATUS_INFO_print_bio(bio, a->status_info);-
32-
33 BIO_printf(bio, "\nTST info:\n");-
34 if (a->tst_info != NULL)
a->tst_info != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
35 TS_TST_INFO_print_bio(bio, a->tst_info);
never executed: TS_TST_INFO_print_bio(bio, a->tst_info);
0
36 else-
37 BIO_printf(bio, "Not included.\n");
executed 3 times by 1 test: BIO_printf(bio, "Not included.\n");
Executed by:
  • libcrypto.so.1.1
3
38-
39 return 1;
executed 3 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
3
40}-
41-
42int TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a)-
43{-
44 static const char *status_map[] = {-
45 "Granted.",-
46 "Granted with modifications.",-
47 "Rejected.",-
48 "Waiting.",-
49 "Revocation warning.",-
50 "Revoked."-
51 };-
52 static const struct status_map_st failure_map[] = {-
53 {TS_INFO_BAD_ALG,-
54 "unrecognized or unsupported algorithm identifier"},-
55 {TS_INFO_BAD_REQUEST,-
56 "transaction not permitted or supported"},-
57 {TS_INFO_BAD_DATA_FORMAT,-
58 "the data submitted has the wrong format"},-
59 {TS_INFO_TIME_NOT_AVAILABLE,-
60 "the TSA's time source is not available"},-
61 {TS_INFO_UNACCEPTED_POLICY,-
62 "the requested TSA policy is not supported by the TSA"},-
63 {TS_INFO_UNACCEPTED_EXTENSION,-
64 "the requested extension is not supported by the TSA"},-
65 {TS_INFO_ADD_INFO_NOT_AVAILABLE,-
66 "the additional information requested could not be understood "-
67 "or is not available"},-
68 {TS_INFO_SYSTEM_FAILURE,-
69 "the request cannot be handled due to system failure"},-
70 {-1, NULL}-
71 };-
72 long status;-
73 int i, lines = 0;-
74-
75 BIO_printf(bio, "Status: ");-
76 status = ASN1_INTEGER_get(a->status);-
77 if (0 <= status && status < (long)OSSL_NELEM(status_map))
0 <= statusDescription
TRUEevaluated 136 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 35 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
status < (long...atus_map)[0]))Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 131 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
5-136
78 BIO_printf(bio, "%s\n", status_map[status]);
executed 5 times by 1 test: BIO_printf(bio, "%s\n", status_map[status]);
Executed by:
  • libcrypto.so.1.1
5
79 else-
80 BIO_printf(bio, "out of bounds\n");
executed 166 times by 1 test: BIO_printf(bio, "out of bounds\n");
Executed by:
  • libcrypto.so.1.1
166
81-
82 BIO_printf(bio, "Status description: ");-
83 for (i = 0; i < sk_ASN1_UTF8STRING_num(a->text); ++i) {
i < sk_ASN1_UT...G_num(a->text)Description
TRUEevaluated 6183 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 171 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
171-6183
84 if (i > 0)
i > 0Description
TRUEevaluated 6031 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 152 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
152-6031
85 BIO_puts(bio, "\t");
executed 6031 times by 1 test: BIO_puts(bio, "\t");
Executed by:
  • libcrypto.so.1.1
6031
86 ASN1_STRING_print_ex(bio, sk_ASN1_UTF8STRING_value(a->text, i), 0);-
87 BIO_puts(bio, "\n");-
88 }
executed 6183 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
6183
89 if (i == 0)
i == 0Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 152 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
19-152
90 BIO_printf(bio, "unspecified\n");
executed 19 times by 1 test: BIO_printf(bio, "unspecified\n");
Executed by:
  • libcrypto.so.1.1
19
91-
92 BIO_printf(bio, "Failure info: ");-
93 if (a->failure_info != NULL)
a->failure_info != ((void *)0)Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 159 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
12-159
94 lines = ts_status_map_print(bio, failure_map, a->failure_info);
executed 12 times by 1 test: lines = ts_status_map_print(bio, failure_map, a->failure_info);
Executed by:
  • libcrypto.so.1.1
12
95 if (lines == 0)
lines == 0Description
TRUEevaluated 160 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
11-160
96 BIO_printf(bio, "unspecified");
executed 160 times by 1 test: BIO_printf(bio, "unspecified");
Executed by:
  • libcrypto.so.1.1
160
97 BIO_printf(bio, "\n");-
98-
99 return 1;
executed 171 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
171
100}-
101-
102static int ts_status_map_print(BIO *bio, const struct status_map_st *a,-
103 const ASN1_BIT_STRING *v)-
104{-
105 int lines = 0;-
106-
107 for (; a->bit >= 0; ++a) {
a->bit >= 0Description
TRUEevaluated 96 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
12-96
108 if (ASN1_BIT_STRING_get_bit(v, a->bit)) {
ASN1_BIT_STRIN...bit(v, a->bit)Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 62 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
34-62
109 if (++lines > 1)
++lines > 1Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
11-23
110 BIO_printf(bio, ", ");
executed 23 times by 1 test: BIO_printf(bio, ", ");
Executed by:
  • libcrypto.so.1.1
23
111 BIO_printf(bio, "%s", a->text);-
112 }
executed 34 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
34
113 }
executed 96 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
96
114-
115 return lines;
executed 12 times by 1 test: return lines;
Executed by:
  • libcrypto.so.1.1
12
116}-
117-
118int TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a)-
119{-
120 int v;-
121-
122 if (a == NULL)
a == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
123 return 0;
never executed: return 0;
0
124-
125 v = ASN1_INTEGER_get(a->version);-
126 BIO_printf(bio, "Version: %d\n", v);-
127-
128 BIO_printf(bio, "Policy OID: ");-
129 TS_OBJ_print_bio(bio, a->policy_id);-
130-
131 TS_MSG_IMPRINT_print_bio(bio, a->msg_imprint);-
132-
133 BIO_printf(bio, "Serial number: ");-
134 if (a->serial == NULL)
a->serial == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
135 BIO_printf(bio, "unspecified");
never executed: BIO_printf(bio, "unspecified");
0
136 else-
137 TS_ASN1_INTEGER_print_bio(bio, a->serial);
never executed: TS_ASN1_INTEGER_print_bio(bio, a->serial);
0
138 BIO_write(bio, "\n", 1);-
139-
140 BIO_printf(bio, "Time stamp: ");-
141 ASN1_GENERALIZEDTIME_print(bio, a->time);-
142 BIO_write(bio, "\n", 1);-
143-
144 BIO_printf(bio, "Accuracy: ");-
145 if (a->accuracy == NULL)
a->accuracy == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
146 BIO_printf(bio, "unspecified");
never executed: BIO_printf(bio, "unspecified");
0
147 else-
148 ts_ACCURACY_print_bio(bio, a->accuracy);
never executed: ts_ACCURACY_print_bio(bio, a->accuracy);
0
149 BIO_write(bio, "\n", 1);-
150-
151 BIO_printf(bio, "Ordering: %s\n", a->ordering ? "yes" : "no");-
152-
153 BIO_printf(bio, "Nonce: ");-
154 if (a->nonce == NULL)
a->nonce == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
155 BIO_printf(bio, "unspecified");
never executed: BIO_printf(bio, "unspecified");
0
156 else-
157 TS_ASN1_INTEGER_print_bio(bio, a->nonce);
never executed: TS_ASN1_INTEGER_print_bio(bio, a->nonce);
0
158 BIO_write(bio, "\n", 1);-
159-
160 BIO_printf(bio, "TSA: ");-
161 if (a->tsa == NULL)
a->tsa == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
162 BIO_printf(bio, "unspecified");
never executed: BIO_printf(bio, "unspecified");
0
163 else {-
164 STACK_OF(CONF_VALUE) *nval;-
165 if ((nval = i2v_GENERAL_NAME(NULL, a->tsa, NULL)))
(nval = i2v_GE...((void *)0) ))Description
TRUEnever evaluated
FALSEnever evaluated
0
166 X509V3_EXT_val_prn(bio, nval, 0, 0);
never executed: X509V3_EXT_val_prn(bio, nval, 0, 0);
0
167 sk_CONF_VALUE_pop_free(nval, X509V3_conf_free);-
168 }
never executed: end of block
0
169 BIO_write(bio, "\n", 1);-
170-
171 TS_ext_print_bio(bio, a->extensions);-
172-
173 return 1;
never executed: return 1;
0
174}-
175-
176static int ts_ACCURACY_print_bio(BIO *bio, const TS_ACCURACY *a)-
177{-
178 if (a->seconds != NULL)
a->seconds != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
179 TS_ASN1_INTEGER_print_bio(bio, a->seconds);
never executed: TS_ASN1_INTEGER_print_bio(bio, a->seconds);
0
180 else-
181 BIO_printf(bio, "unspecified");
never executed: BIO_printf(bio, "unspecified");
0
182 BIO_printf(bio, " seconds, ");-
183 if (a->millis != NULL)
a->millis != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
184 TS_ASN1_INTEGER_print_bio(bio, a->millis);
never executed: TS_ASN1_INTEGER_print_bio(bio, a->millis);
0
185 else-
186 BIO_printf(bio, "unspecified");
never executed: BIO_printf(bio, "unspecified");
0
187 BIO_printf(bio, " millis, ");-
188 if (a->micros != NULL)
a->micros != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
189 TS_ASN1_INTEGER_print_bio(bio, a->micros);
never executed: TS_ASN1_INTEGER_print_bio(bio, a->micros);
0
190 else-
191 BIO_printf(bio, "unspecified");
never executed: BIO_printf(bio, "unspecified");
0
192 BIO_printf(bio, " micros");-
193-
194 return 1;
never executed: return 1;
0
195}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2