OpenCoverage

ts_rsp_utils.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/ts/ts_rsp_utils.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* $OpenBSD: ts_rsp_utils.c,v 1.7 2018/05/13 15:35:46 tb Exp $ */-
2/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL-
3 * project 2002.-
4 */-
5/* ====================================================================-
6 * Copyright (c) 2006 The OpenSSL Project. All rights reserved.-
7 *-
8 * Redistribution and use in source and binary forms, with or without-
9 * modification, are permitted provided that the following conditions-
10 * are met:-
11 *-
12 * 1. Redistributions of source code must retain the above copyright-
13 * notice, this list of conditions and the following disclaimer.-
14 *-
15 * 2. Redistributions in binary form must reproduce the above copyright-
16 * notice, this list of conditions and the following disclaimer in-
17 * the documentation and/or other materials provided with the-
18 * distribution.-
19 *-
20 * 3. All advertising materials mentioning features or use of this-
21 * software must display the following acknowledgment:-
22 * "This product includes software developed by the OpenSSL Project-
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"-
24 *-
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to-
26 * endorse or promote products derived from this software without-
27 * prior written permission. For written permission, please contact-
28 * licensing@OpenSSL.org.-
29 *-
30 * 5. Products derived from this software may not be called "OpenSSL"-
31 * nor may "OpenSSL" appear in their names without prior written-
32 * permission of the OpenSSL Project.-
33 *-
34 * 6. Redistributions of any form whatsoever must retain the following-
35 * acknowledgment:-
36 * "This product includes software developed by the OpenSSL Project-
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"-
38 *-
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY-
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR-
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR-
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT-
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;-
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)-
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,-
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)-
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED-
50 * OF THE POSSIBILITY OF SUCH DAMAGE.-
51 * ====================================================================-
52 *-
53 * This product includes cryptographic software written by Eric Young-
54 * (eay@cryptsoft.com). This product includes software written by Tim-
55 * Hudson (tjh@cryptsoft.com).-
56 *-
57 */-
58-
59#include <stdio.h>-
60-
61#include <openssl/err.h>-
62#include <openssl/objects.h>-
63#include <openssl/pkcs7.h>-
64#include <openssl/ts.h>-
65-
66/* Function definitions. */-
67-
68int-
69TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *status_info)-
70{-
71 TS_STATUS_INFO *new_status_info;-
72-
73 if (a->status_info == status_info)
a->status_info == status_infoDescription
TRUEnever evaluated
FALSEnever evaluated
0
74 return 1;
never executed: return 1;
0
75 new_status_info = TS_STATUS_INFO_dup(status_info);-
76 if (new_status_info == NULL) {
new_status_info == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
77 TSerror(ERR_R_MALLOC_FAILURE);-
78 return 0;
never executed: return 0;
0
79 }-
80 TS_STATUS_INFO_free(a->status_info);-
81 a->status_info = new_status_info;-
82-
83 return 1;
never executed: return 1;
0
84}-
85-
86TS_STATUS_INFO *-
87TS_RESP_get_status_info(TS_RESP *a)-
88{-
89 return a->status_info;
never executed: return a->status_info;
0
90}-
91-
92/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */-
93void-
94TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info)-
95{-
96 /* Set new PKCS7 and TST_INFO objects. */-
97 PKCS7_free(a->token);-
98 a->token = p7;-
99 TS_TST_INFO_free(a->tst_info);-
100 a->tst_info = tst_info;-
101}
never executed: end of block
0
102-
103PKCS7 *-
104TS_RESP_get_token(TS_RESP *a)-
105{-
106 return a->token;
never executed: return a->token;
0
107}-
108-
109TS_TST_INFO *-
110TS_RESP_get_tst_info(TS_RESP *a)-
111{-
112 return a->tst_info;
never executed: return a->tst_info;
0
113}-
114-
115int-
116TS_TST_INFO_set_version(TS_TST_INFO *a, long version)-
117{-
118 return ASN1_INTEGER_set(a->version, version);
never executed: return ASN1_INTEGER_set(a->version, version);
0
119}-
120-
121long-
122TS_TST_INFO_get_version(const TS_TST_INFO *a)-
123{-
124 return ASN1_INTEGER_get(a->version);
never executed: return ASN1_INTEGER_get(a->version);
0
125}-
126-
127int-
128TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy)-
129{-
130 ASN1_OBJECT *new_policy;-
131-
132 if (a->policy_id == policy)
a->policy_id == policyDescription
TRUEnever evaluated
FALSEnever evaluated
0
133 return 1;
never executed: return 1;
0
134 new_policy = OBJ_dup(policy);-
135 if (new_policy == NULL) {
new_policy == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
136 TSerror(ERR_R_MALLOC_FAILURE);-
137 return 0;
never executed: return 0;
0
138 }-
139 ASN1_OBJECT_free(a->policy_id);-
140 a->policy_id = new_policy;-
141 return 1;
never executed: return 1;
0
142}-
143-
144ASN1_OBJECT *-
145TS_TST_INFO_get_policy_id(TS_TST_INFO *a)-
146{-
147 return a->policy_id;
never executed: return a->policy_id;
0
148}-
149-
150int-
151TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint)-
152{-
153 TS_MSG_IMPRINT *new_msg_imprint;-
154-
155 if (a->msg_imprint == msg_imprint)
a->msg_imprint == msg_imprintDescription
TRUEnever evaluated
FALSEnever evaluated
0
156 return 1;
never executed: return 1;
0
157 new_msg_imprint = TS_MSG_IMPRINT_dup(msg_imprint);-
158 if (new_msg_imprint == NULL) {
new_msg_imprint == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
159 TSerror(ERR_R_MALLOC_FAILURE);-
160 return 0;
never executed: return 0;
0
161 }-
162 TS_MSG_IMPRINT_free(a->msg_imprint);-
163 a->msg_imprint = new_msg_imprint;-
164 return 1;
never executed: return 1;
0
165}-
166-
167TS_MSG_IMPRINT *-
168TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a)-
169{-
170 return a->msg_imprint;
never executed: return a->msg_imprint;
0
171}-
172-
173int-
174TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial)-
175{-
176 ASN1_INTEGER *new_serial;-
177-
178 if (a->serial == serial)
a->serial == serialDescription
TRUEnever evaluated
FALSEnever evaluated
0
179 return 1;
never executed: return 1;
0
180 new_serial = ASN1_INTEGER_dup(serial);-
181 if (new_serial == NULL) {
new_serial == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
182 TSerror(ERR_R_MALLOC_FAILURE);-
183 return 0;
never executed: return 0;
0
184 }-
185 ASN1_INTEGER_free(a->serial);-
186 a->serial = new_serial;-
187 return 1;
never executed: return 1;
0
188}-
189-
190const ASN1_INTEGER *-
191TS_TST_INFO_get_serial(const TS_TST_INFO *a)-
192{-
193 return a->serial;
never executed: return a->serial;
0
194}-
195-
196int-
197TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime)-
198{-
199 ASN1_GENERALIZEDTIME *new_time;-
200-
201 if (a->time == gtime)
a->time == gtimeDescription
TRUEnever evaluated
FALSEnever evaluated
0
202 return 1;
never executed: return 1;
0
203 new_time = ASN1_STRING_dup(gtime);-
204 if (new_time == NULL) {
new_time == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
205 TSerror(ERR_R_MALLOC_FAILURE);-
206 return 0;
never executed: return 0;
0
207 }-
208 ASN1_GENERALIZEDTIME_free(a->time);-
209 a->time = new_time;-
210 return 1;
never executed: return 1;
0
211}-
212-
213const ASN1_GENERALIZEDTIME *-
214TS_TST_INFO_get_time(const TS_TST_INFO *a)-
215{-
216 return a->time;
never executed: return a->time;
0
217}-
218-
219int-
220TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy)-
221{-
222 TS_ACCURACY *new_accuracy;-
223-
224 if (a->accuracy == accuracy)
a->accuracy == accuracyDescription
TRUEnever evaluated
FALSEnever evaluated
0
225 return 1;
never executed: return 1;
0
226 new_accuracy = TS_ACCURACY_dup(accuracy);-
227 if (new_accuracy == NULL) {
new_accuracy == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
228 TSerror(ERR_R_MALLOC_FAILURE);-
229 return 0;
never executed: return 0;
0
230 }-
231 TS_ACCURACY_free(a->accuracy);-
232 a->accuracy = new_accuracy;-
233 return 1;
never executed: return 1;
0
234}-
235-
236TS_ACCURACY *-
237TS_TST_INFO_get_accuracy(TS_TST_INFO *a)-
238{-
239 return a->accuracy;
never executed: return a->accuracy;
0
240}-
241-
242int-
243TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds)-
244{-
245 ASN1_INTEGER *new_seconds;-
246-
247 if (a->seconds == seconds)
a->seconds == secondsDescription
TRUEnever evaluated
FALSEnever evaluated
0
248 return 1;
never executed: return 1;
0
249 new_seconds = ASN1_INTEGER_dup(seconds);-
250 if (new_seconds == NULL) {
new_seconds == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
251 TSerror(ERR_R_MALLOC_FAILURE);-
252 return 0;
never executed: return 0;
0
253 }-
254 ASN1_INTEGER_free(a->seconds);-
255 a->seconds = new_seconds;-
256 return 1;
never executed: return 1;
0
257}-
258-
259const ASN1_INTEGER *-
260TS_ACCURACY_get_seconds(const TS_ACCURACY *a)-
261{-
262 return a->seconds;
never executed: return a->seconds;
0
263}-
264-
265int-
266TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis)-
267{-
268 ASN1_INTEGER *new_millis = NULL;-
269-
270 if (a->millis == millis)
a->millis == millisDescription
TRUEnever evaluated
FALSEnever evaluated
0
271 return 1;
never executed: return 1;
0
272 if (millis != NULL) {
millis != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
273 new_millis = ASN1_INTEGER_dup(millis);-
274 if (new_millis == NULL) {
new_millis == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
275 TSerror(ERR_R_MALLOC_FAILURE);-
276 return 0;
never executed: return 0;
0
277 }-
278 }
never executed: end of block
0
279 ASN1_INTEGER_free(a->millis);-
280 a->millis = new_millis;-
281 return 1;
never executed: return 1;
0
282}-
283-
284const ASN1_INTEGER *-
285TS_ACCURACY_get_millis(const TS_ACCURACY *a)-
286{-
287 return a->millis;
never executed: return a->millis;
0
288}-
289-
290int-
291TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros)-
292{-
293 ASN1_INTEGER *new_micros = NULL;-
294-
295 if (a->micros == micros)
a->micros == microsDescription
TRUEnever evaluated
FALSEnever evaluated
0
296 return 1;
never executed: return 1;
0
297 if (micros != NULL) {
micros != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
298 new_micros = ASN1_INTEGER_dup(micros);-
299 if (new_micros == NULL) {
new_micros == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
300 TSerror(ERR_R_MALLOC_FAILURE);-
301 return 0;
never executed: return 0;
0
302 }-
303 }
never executed: end of block
0
304 ASN1_INTEGER_free(a->micros);-
305 a->micros = new_micros;-
306 return 1;
never executed: return 1;
0
307}-
308-
309const ASN1_INTEGER *-
310TS_ACCURACY_get_micros(const TS_ACCURACY *a)-
311{-
312 return a->micros;
never executed: return a->micros;
0
313}-
314-
315int-
316TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering)-
317{-
318 a->ordering = ordering ? 0xFF : 0x00;
orderingDescription
TRUEnever evaluated
FALSEnever evaluated
0
319 return 1;
never executed: return 1;
0
320}-
321-
322int-
323TS_TST_INFO_get_ordering(const TS_TST_INFO *a)-
324{-
325 return a->ordering ? 1 : 0;
never executed: return a->ordering ? 1 : 0;
a->orderingDescription
TRUEnever evaluated
FALSEnever evaluated
0
326}-
327-
328int-
329TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce)-
330{-
331 ASN1_INTEGER *new_nonce;-
332-
333 if (a->nonce == nonce)
a->nonce == nonceDescription
TRUEnever evaluated
FALSEnever evaluated
0
334 return 1;
never executed: return 1;
0
335 new_nonce = ASN1_INTEGER_dup(nonce);-
336 if (new_nonce == NULL) {
new_nonce == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
337 TSerror(ERR_R_MALLOC_FAILURE);-
338 return 0;
never executed: return 0;
0
339 }-
340 ASN1_INTEGER_free(a->nonce);-
341 a->nonce = new_nonce;-
342 return 1;
never executed: return 1;
0
343}-
344-
345const ASN1_INTEGER *-
346TS_TST_INFO_get_nonce(const TS_TST_INFO *a)-
347{-
348 return a->nonce;
never executed: return a->nonce;
0
349}-
350-
351int-
352TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa)-
353{-
354 GENERAL_NAME *new_tsa;-
355-
356 if (a->tsa == tsa)
a->tsa == tsaDescription
TRUEnever evaluated
FALSEnever evaluated
0
357 return 1;
never executed: return 1;
0
358 new_tsa = GENERAL_NAME_dup(tsa);-
359 if (new_tsa == NULL) {
new_tsa == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
360 TSerror(ERR_R_MALLOC_FAILURE);-
361 return 0;
never executed: return 0;
0
362 }-
363 GENERAL_NAME_free(a->tsa);-
364 a->tsa = new_tsa;-
365 return 1;
never executed: return 1;
0
366}-
367-
368GENERAL_NAME *-
369TS_TST_INFO_get_tsa(TS_TST_INFO *a)-
370{-
371 return a->tsa;
never executed: return a->tsa;
0
372}-
373-
374STACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a)-
375{-
376 return a->extensions;
never executed: return a->extensions;
0
377}-
378-
379void-
380TS_TST_INFO_ext_free(TS_TST_INFO *a)-
381{-
382 if (!a)
!aDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • freenull
FALSEnever evaluated
0-1
383 return;
executed 1 time by 1 test: return;
Executed by:
  • freenull
1
384 sk_X509_EXTENSION_pop_free(a->extensions, X509_EXTENSION_free);-
385 a->extensions = NULL;-
386}
never executed: end of block
0
387-
388int-
389TS_TST_INFO_get_ext_count(TS_TST_INFO *a)-
390{-
391 return X509v3_get_ext_count(a->extensions);
never executed: return X509v3_get_ext_count(a->extensions);
0
392}-
393-
394int-
395TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos)-
396{-
397 return X509v3_get_ext_by_NID(a->extensions, nid, lastpos);
never executed: return X509v3_get_ext_by_NID(a->extensions, nid, lastpos);
0
398}-
399-
400int-
401TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, const ASN1_OBJECT *obj, int lastpos)-
402{-
403 return X509v3_get_ext_by_OBJ(a->extensions, obj, lastpos);
never executed: return X509v3_get_ext_by_OBJ(a->extensions, obj, lastpos);
0
404}-
405-
406int-
407TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos)-
408{-
409 return X509v3_get_ext_by_critical(a->extensions, crit, lastpos);
never executed: return X509v3_get_ext_by_critical(a->extensions, crit, lastpos);
0
410}-
411-
412X509_EXTENSION *-
413TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc)-
414{-
415 return X509v3_get_ext(a->extensions, loc);
never executed: return X509v3_get_ext(a->extensions, loc);
0
416}-
417-
418X509_EXTENSION *-
419TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc)-
420{-
421 return X509v3_delete_ext(a->extensions, loc);
never executed: return X509v3_delete_ext(a->extensions, loc);
0
422}-
423-
424int-
425TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc)-
426{-
427 return X509v3_add_ext(&a->extensions, ex, loc) != NULL;
never executed: return X509v3_add_ext(&a->extensions, ex, loc) != ((void *)0) ;
0
428}-
429-
430void *-
431TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx)-
432{-
433 return X509V3_get_d2i(a->extensions, nid, crit, idx);
never executed: return X509V3_get_d2i(a->extensions, nid, crit, idx);
0
434}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2