summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ts/ts_rsp_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/ts/ts_rsp_utils.c')
-rw-r--r--src/lib/libcrypto/ts/ts_rsp_utils.c503
1 files changed, 0 insertions, 503 deletions
diff --git a/src/lib/libcrypto/ts/ts_rsp_utils.c b/src/lib/libcrypto/ts/ts_rsp_utils.c
deleted file mode 100644
index 34994adce8..0000000000
--- a/src/lib/libcrypto/ts/ts_rsp_utils.c
+++ /dev/null
@@ -1,503 +0,0 @@
1/* $OpenBSD: ts_rsp_utils.c,v 1.11 2023/07/07 19:37:54 beck 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#include "ts_local.h"
67
68/* Function definitions. */
69
70int
71TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *status_info)
72{
73 TS_STATUS_INFO *new_status_info;
74
75 if (a->status_info == status_info)
76 return 1;
77 new_status_info = TS_STATUS_INFO_dup(status_info);
78 if (new_status_info == NULL) {
79 TSerror(ERR_R_MALLOC_FAILURE);
80 return 0;
81 }
82 TS_STATUS_INFO_free(a->status_info);
83 a->status_info = new_status_info;
84
85 return 1;
86}
87LCRYPTO_ALIAS(TS_RESP_set_status_info);
88
89TS_STATUS_INFO *
90TS_RESP_get_status_info(TS_RESP *a)
91{
92 return a->status_info;
93}
94LCRYPTO_ALIAS(TS_RESP_get_status_info);
95
96const ASN1_UTF8STRING *
97TS_STATUS_INFO_get0_failure_info(const TS_STATUS_INFO *si)
98{
99 return si->failure_info;
100}
101LCRYPTO_ALIAS(TS_STATUS_INFO_get0_failure_info);
102
103const STACK_OF(ASN1_UTF8STRING) *
104TS_STATUS_INFO_get0_text(const TS_STATUS_INFO *si)
105{
106 return si->text;
107}
108LCRYPTO_ALIAS(TS_STATUS_INFO_get0_text);
109
110const ASN1_INTEGER *
111TS_STATUS_INFO_get0_status(const TS_STATUS_INFO *si)
112{
113 return si->status;
114}
115LCRYPTO_ALIAS(TS_STATUS_INFO_get0_status);
116
117int
118TS_STATUS_INFO_set_status(TS_STATUS_INFO *si, int i)
119{
120 return ASN1_INTEGER_set(si->status, i);
121}
122LCRYPTO_ALIAS(TS_STATUS_INFO_set_status);
123
124/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */
125void
126TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info)
127{
128 /* Set new PKCS7 and TST_INFO objects. */
129 PKCS7_free(a->token);
130 a->token = p7;
131 TS_TST_INFO_free(a->tst_info);
132 a->tst_info = tst_info;
133}
134LCRYPTO_ALIAS(TS_RESP_set_tst_info);
135
136PKCS7 *
137TS_RESP_get_token(TS_RESP *a)
138{
139 return a->token;
140}
141LCRYPTO_ALIAS(TS_RESP_get_token);
142
143TS_TST_INFO *
144TS_RESP_get_tst_info(TS_RESP *a)
145{
146 return a->tst_info;
147}
148LCRYPTO_ALIAS(TS_RESP_get_tst_info);
149
150int
151TS_TST_INFO_set_version(TS_TST_INFO *a, long version)
152{
153 return ASN1_INTEGER_set(a->version, version);
154}
155LCRYPTO_ALIAS(TS_TST_INFO_set_version);
156
157long
158TS_TST_INFO_get_version(const TS_TST_INFO *a)
159{
160 return ASN1_INTEGER_get(a->version);
161}
162LCRYPTO_ALIAS(TS_TST_INFO_get_version);
163
164int
165TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy)
166{
167 ASN1_OBJECT *new_policy;
168
169 if (a->policy_id == policy)
170 return 1;
171 new_policy = OBJ_dup(policy);
172 if (new_policy == NULL) {
173 TSerror(ERR_R_MALLOC_FAILURE);
174 return 0;
175 }
176 ASN1_OBJECT_free(a->policy_id);
177 a->policy_id = new_policy;
178 return 1;
179}
180LCRYPTO_ALIAS(TS_TST_INFO_set_policy_id);
181
182ASN1_OBJECT *
183TS_TST_INFO_get_policy_id(TS_TST_INFO *a)
184{
185 return a->policy_id;
186}
187LCRYPTO_ALIAS(TS_TST_INFO_get_policy_id);
188
189int
190TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint)
191{
192 TS_MSG_IMPRINT *new_msg_imprint;
193
194 if (a->msg_imprint == msg_imprint)
195 return 1;
196 new_msg_imprint = TS_MSG_IMPRINT_dup(msg_imprint);
197 if (new_msg_imprint == NULL) {
198 TSerror(ERR_R_MALLOC_FAILURE);
199 return 0;
200 }
201 TS_MSG_IMPRINT_free(a->msg_imprint);
202 a->msg_imprint = new_msg_imprint;
203 return 1;
204}
205LCRYPTO_ALIAS(TS_TST_INFO_set_msg_imprint);
206
207TS_MSG_IMPRINT *
208TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a)
209{
210 return a->msg_imprint;
211}
212LCRYPTO_ALIAS(TS_TST_INFO_get_msg_imprint);
213
214int
215TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial)
216{
217 ASN1_INTEGER *new_serial;
218
219 if (a->serial == serial)
220 return 1;
221 new_serial = ASN1_INTEGER_dup(serial);
222 if (new_serial == NULL) {
223 TSerror(ERR_R_MALLOC_FAILURE);
224 return 0;
225 }
226 ASN1_INTEGER_free(a->serial);
227 a->serial = new_serial;
228 return 1;
229}
230LCRYPTO_ALIAS(TS_TST_INFO_set_serial);
231
232const ASN1_INTEGER *
233TS_TST_INFO_get_serial(const TS_TST_INFO *a)
234{
235 return a->serial;
236}
237LCRYPTO_ALIAS(TS_TST_INFO_get_serial);
238
239int
240TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime)
241{
242 ASN1_GENERALIZEDTIME *new_time;
243
244 if (a->time == gtime)
245 return 1;
246 new_time = ASN1_STRING_dup(gtime);
247 if (new_time == NULL) {
248 TSerror(ERR_R_MALLOC_FAILURE);
249 return 0;
250 }
251 ASN1_GENERALIZEDTIME_free(a->time);
252 a->time = new_time;
253 return 1;
254}
255LCRYPTO_ALIAS(TS_TST_INFO_set_time);
256
257const ASN1_GENERALIZEDTIME *
258TS_TST_INFO_get_time(const TS_TST_INFO *a)
259{
260 return a->time;
261}
262LCRYPTO_ALIAS(TS_TST_INFO_get_time);
263
264int
265TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy)
266{
267 TS_ACCURACY *new_accuracy;
268
269 if (a->accuracy == accuracy)
270 return 1;
271 new_accuracy = TS_ACCURACY_dup(accuracy);
272 if (new_accuracy == NULL) {
273 TSerror(ERR_R_MALLOC_FAILURE);
274 return 0;
275 }
276 TS_ACCURACY_free(a->accuracy);
277 a->accuracy = new_accuracy;
278 return 1;
279}
280LCRYPTO_ALIAS(TS_TST_INFO_set_accuracy);
281
282TS_ACCURACY *
283TS_TST_INFO_get_accuracy(TS_TST_INFO *a)
284{
285 return a->accuracy;
286}
287LCRYPTO_ALIAS(TS_TST_INFO_get_accuracy);
288
289int
290TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds)
291{
292 ASN1_INTEGER *new_seconds;
293
294 if (a->seconds == seconds)
295 return 1;
296 new_seconds = ASN1_INTEGER_dup(seconds);
297 if (new_seconds == NULL) {
298 TSerror(ERR_R_MALLOC_FAILURE);
299 return 0;
300 }
301 ASN1_INTEGER_free(a->seconds);
302 a->seconds = new_seconds;
303 return 1;
304}
305LCRYPTO_ALIAS(TS_ACCURACY_set_seconds);
306
307const ASN1_INTEGER *
308TS_ACCURACY_get_seconds(const TS_ACCURACY *a)
309{
310 return a->seconds;
311}
312LCRYPTO_ALIAS(TS_ACCURACY_get_seconds);
313
314int
315TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis)
316{
317 ASN1_INTEGER *new_millis = NULL;
318
319 if (a->millis == millis)
320 return 1;
321 if (millis != NULL) {
322 new_millis = ASN1_INTEGER_dup(millis);
323 if (new_millis == NULL) {
324 TSerror(ERR_R_MALLOC_FAILURE);
325 return 0;
326 }
327 }
328 ASN1_INTEGER_free(a->millis);
329 a->millis = new_millis;
330 return 1;
331}
332LCRYPTO_ALIAS(TS_ACCURACY_set_millis);
333
334const ASN1_INTEGER *
335TS_ACCURACY_get_millis(const TS_ACCURACY *a)
336{
337 return a->millis;
338}
339LCRYPTO_ALIAS(TS_ACCURACY_get_millis);
340
341int
342TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros)
343{
344 ASN1_INTEGER *new_micros = NULL;
345
346 if (a->micros == micros)
347 return 1;
348 if (micros != NULL) {
349 new_micros = ASN1_INTEGER_dup(micros);
350 if (new_micros == NULL) {
351 TSerror(ERR_R_MALLOC_FAILURE);
352 return 0;
353 }
354 }
355 ASN1_INTEGER_free(a->micros);
356 a->micros = new_micros;
357 return 1;
358}
359LCRYPTO_ALIAS(TS_ACCURACY_set_micros);
360
361const ASN1_INTEGER *
362TS_ACCURACY_get_micros(const TS_ACCURACY *a)
363{
364 return a->micros;
365}
366LCRYPTO_ALIAS(TS_ACCURACY_get_micros);
367
368int
369TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering)
370{
371 a->ordering = ordering ? 0xFF : 0x00;
372 return 1;
373}
374LCRYPTO_ALIAS(TS_TST_INFO_set_ordering);
375
376int
377TS_TST_INFO_get_ordering(const TS_TST_INFO *a)
378{
379 return a->ordering ? 1 : 0;
380}
381LCRYPTO_ALIAS(TS_TST_INFO_get_ordering);
382
383int
384TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce)
385{
386 ASN1_INTEGER *new_nonce;
387
388 if (a->nonce == nonce)
389 return 1;
390 new_nonce = ASN1_INTEGER_dup(nonce);
391 if (new_nonce == NULL) {
392 TSerror(ERR_R_MALLOC_FAILURE);
393 return 0;
394 }
395 ASN1_INTEGER_free(a->nonce);
396 a->nonce = new_nonce;
397 return 1;
398}
399LCRYPTO_ALIAS(TS_TST_INFO_set_nonce);
400
401const ASN1_INTEGER *
402TS_TST_INFO_get_nonce(const TS_TST_INFO *a)
403{
404 return a->nonce;
405}
406LCRYPTO_ALIAS(TS_TST_INFO_get_nonce);
407
408int
409TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa)
410{
411 GENERAL_NAME *new_tsa;
412
413 if (a->tsa == tsa)
414 return 1;
415 new_tsa = GENERAL_NAME_dup(tsa);
416 if (new_tsa == NULL) {
417 TSerror(ERR_R_MALLOC_FAILURE);
418 return 0;
419 }
420 GENERAL_NAME_free(a->tsa);
421 a->tsa = new_tsa;
422 return 1;
423}
424LCRYPTO_ALIAS(TS_TST_INFO_set_tsa);
425
426GENERAL_NAME *
427TS_TST_INFO_get_tsa(TS_TST_INFO *a)
428{
429 return a->tsa;
430}
431LCRYPTO_ALIAS(TS_TST_INFO_get_tsa);
432
433STACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a)
434{
435 return a->extensions;
436}
437LCRYPTO_ALIAS(TS_TST_INFO_get_exts);
438
439void
440TS_TST_INFO_ext_free(TS_TST_INFO *a)
441{
442 if (!a)
443 return;
444 sk_X509_EXTENSION_pop_free(a->extensions, X509_EXTENSION_free);
445 a->extensions = NULL;
446}
447LCRYPTO_ALIAS(TS_TST_INFO_ext_free);
448
449int
450TS_TST_INFO_get_ext_count(TS_TST_INFO *a)
451{
452 return X509v3_get_ext_count(a->extensions);
453}
454LCRYPTO_ALIAS(TS_TST_INFO_get_ext_count);
455
456int
457TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos)
458{
459 return X509v3_get_ext_by_NID(a->extensions, nid, lastpos);
460}
461LCRYPTO_ALIAS(TS_TST_INFO_get_ext_by_NID);
462
463int
464TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, const ASN1_OBJECT *obj, int lastpos)
465{
466 return X509v3_get_ext_by_OBJ(a->extensions, obj, lastpos);
467}
468LCRYPTO_ALIAS(TS_TST_INFO_get_ext_by_OBJ);
469
470int
471TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos)
472{
473 return X509v3_get_ext_by_critical(a->extensions, crit, lastpos);
474}
475LCRYPTO_ALIAS(TS_TST_INFO_get_ext_by_critical);
476
477X509_EXTENSION *
478TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc)
479{
480 return X509v3_get_ext(a->extensions, loc);
481}
482LCRYPTO_ALIAS(TS_TST_INFO_get_ext);
483
484X509_EXTENSION *
485TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc)
486{
487 return X509v3_delete_ext(a->extensions, loc);
488}
489LCRYPTO_ALIAS(TS_TST_INFO_delete_ext);
490
491int
492TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc)
493{
494 return X509v3_add_ext(&a->extensions, ex, loc) != NULL;
495}
496LCRYPTO_ALIAS(TS_TST_INFO_add_ext);
497
498void *
499TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx)
500{
501 return X509V3_get_d2i(a->extensions, nid, crit, idx);
502}
503LCRYPTO_ALIAS(TS_TST_INFO_get_ext_d2i);