diff options
author | cvs2svn <admin@example.com> | 2025-04-14 17:32:06 +0000 |
---|---|---|
committer | cvs2svn <admin@example.com> | 2025-04-14 17:32:06 +0000 |
commit | eb8dd9dca1228af0cd132f515509051ecfabf6f6 (patch) | |
tree | edb6da6af7e865d488dc1a29309f1e1ec226e603 /src/lib/libcrypto/asn1/x_x509a.c | |
parent | 247f0352e0ed72a4f476db9dc91f4d982bc83eb2 (diff) | |
download | openbsd-tb_20250414.tar.gz openbsd-tb_20250414.tar.bz2 openbsd-tb_20250414.zip |
This commit was manufactured by cvs2git to create tag 'tb_20250414'.tb_20250414
Diffstat (limited to 'src/lib/libcrypto/asn1/x_x509a.c')
-rw-r--r-- | src/lib/libcrypto/asn1/x_x509a.c | 282 |
1 files changed, 0 insertions, 282 deletions
diff --git a/src/lib/libcrypto/asn1/x_x509a.c b/src/lib/libcrypto/asn1/x_x509a.c deleted file mode 100644 index aaa22d1351..0000000000 --- a/src/lib/libcrypto/asn1/x_x509a.c +++ /dev/null | |||
@@ -1,282 +0,0 @@ | |||
1 | /* $OpenBSD: x_x509a.c,v 1.22 2024/04/09 13:55:02 beck Exp $ */ | ||
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | ||
3 | * project 1999. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 1999 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/asn1t.h> | ||
62 | #include <openssl/evp.h> | ||
63 | #include <openssl/x509.h> | ||
64 | |||
65 | #include "x509_local.h" | ||
66 | |||
67 | /* X509_CERT_AUX routines. These are used to encode additional | ||
68 | * user modifiable data about a certificate. This data is | ||
69 | * appended to the X509 encoding when the *_X509_AUX routines | ||
70 | * are used. This means that the "traditional" X509 routines | ||
71 | * will simply ignore the extra data. | ||
72 | */ | ||
73 | |||
74 | static X509_CERT_AUX *aux_get(X509 *x); | ||
75 | |||
76 | static const ASN1_TEMPLATE X509_CERT_AUX_seq_tt[] = { | ||
77 | { | ||
78 | .flags = ASN1_TFLG_SEQUENCE_OF | ASN1_TFLG_OPTIONAL, | ||
79 | .offset = offsetof(X509_CERT_AUX, trust), | ||
80 | .field_name = "trust", | ||
81 | .item = &ASN1_OBJECT_it, | ||
82 | }, | ||
83 | { | ||
84 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SEQUENCE_OF | | ||
85 | ASN1_TFLG_OPTIONAL, | ||
86 | .tag = 0, | ||
87 | .offset = offsetof(X509_CERT_AUX, reject), | ||
88 | .field_name = "reject", | ||
89 | .item = &ASN1_OBJECT_it, | ||
90 | }, | ||
91 | { | ||
92 | .flags = ASN1_TFLG_OPTIONAL, | ||
93 | .offset = offsetof(X509_CERT_AUX, alias), | ||
94 | .field_name = "alias", | ||
95 | .item = &ASN1_UTF8STRING_it, | ||
96 | }, | ||
97 | { | ||
98 | .flags = ASN1_TFLG_OPTIONAL, | ||
99 | .offset = offsetof(X509_CERT_AUX, keyid), | ||
100 | .field_name = "keyid", | ||
101 | .item = &ASN1_OCTET_STRING_it, | ||
102 | }, | ||
103 | { | ||
104 | .flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_SEQUENCE_OF | | ||
105 | ASN1_TFLG_OPTIONAL, | ||
106 | .tag = 1, | ||
107 | .offset = offsetof(X509_CERT_AUX, other), | ||
108 | .field_name = "other", | ||
109 | .item = &X509_ALGOR_it, | ||
110 | }, | ||
111 | }; | ||
112 | |||
113 | const ASN1_ITEM X509_CERT_AUX_it = { | ||
114 | .itype = ASN1_ITYPE_SEQUENCE, | ||
115 | .utype = V_ASN1_SEQUENCE, | ||
116 | .templates = X509_CERT_AUX_seq_tt, | ||
117 | .tcount = sizeof(X509_CERT_AUX_seq_tt) / sizeof(ASN1_TEMPLATE), | ||
118 | .size = sizeof(X509_CERT_AUX), | ||
119 | .sname = "X509_CERT_AUX", | ||
120 | }; | ||
121 | |||
122 | |||
123 | X509_CERT_AUX * | ||
124 | d2i_X509_CERT_AUX(X509_CERT_AUX **a, const unsigned char **in, long len) | ||
125 | { | ||
126 | return (X509_CERT_AUX *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, | ||
127 | &X509_CERT_AUX_it); | ||
128 | } | ||
129 | |||
130 | int | ||
131 | i2d_X509_CERT_AUX(X509_CERT_AUX *a, unsigned char **out) | ||
132 | { | ||
133 | return ASN1_item_i2d((ASN1_VALUE *)a, out, &X509_CERT_AUX_it); | ||
134 | } | ||
135 | |||
136 | X509_CERT_AUX * | ||
137 | X509_CERT_AUX_new(void) | ||
138 | { | ||
139 | return (X509_CERT_AUX *)ASN1_item_new(&X509_CERT_AUX_it); | ||
140 | } | ||
141 | |||
142 | void | ||
143 | X509_CERT_AUX_free(X509_CERT_AUX *a) | ||
144 | { | ||
145 | ASN1_item_free((ASN1_VALUE *)a, &X509_CERT_AUX_it); | ||
146 | } | ||
147 | |||
148 | static X509_CERT_AUX * | ||
149 | aux_get(X509 *x) | ||
150 | { | ||
151 | if (!x) | ||
152 | return NULL; | ||
153 | if (!x->aux && !(x->aux = X509_CERT_AUX_new())) | ||
154 | return NULL; | ||
155 | return x->aux; | ||
156 | } | ||
157 | |||
158 | int | ||
159 | X509_alias_set1(X509 *x, const unsigned char *name, int len) | ||
160 | { | ||
161 | X509_CERT_AUX *aux; | ||
162 | if (!name) { | ||
163 | if (!x || !x->aux || !x->aux->alias) | ||
164 | return 1; | ||
165 | ASN1_UTF8STRING_free(x->aux->alias); | ||
166 | x->aux->alias = NULL; | ||
167 | return 1; | ||
168 | } | ||
169 | if (!(aux = aux_get(x))) | ||
170 | return 0; | ||
171 | if (!aux->alias && !(aux->alias = ASN1_UTF8STRING_new())) | ||
172 | return 0; | ||
173 | return ASN1_STRING_set(aux->alias, name, len); | ||
174 | } | ||
175 | LCRYPTO_ALIAS(X509_alias_set1); | ||
176 | |||
177 | int | ||
178 | X509_keyid_set1(X509 *x, const unsigned char *id, int len) | ||
179 | { | ||
180 | X509_CERT_AUX *aux; | ||
181 | if (!id) { | ||
182 | if (!x || !x->aux || !x->aux->keyid) | ||
183 | return 1; | ||
184 | ASN1_OCTET_STRING_free(x->aux->keyid); | ||
185 | x->aux->keyid = NULL; | ||
186 | return 1; | ||
187 | } | ||
188 | if (!(aux = aux_get(x))) | ||
189 | return 0; | ||
190 | if (!aux->keyid && !(aux->keyid = ASN1_OCTET_STRING_new())) | ||
191 | return 0; | ||
192 | return ASN1_STRING_set(aux->keyid, id, len); | ||
193 | } | ||
194 | LCRYPTO_ALIAS(X509_keyid_set1); | ||
195 | |||
196 | unsigned char * | ||
197 | X509_alias_get0(X509 *x, int *len) | ||
198 | { | ||
199 | if (!x->aux || !x->aux->alias) | ||
200 | return NULL; | ||
201 | if (len) | ||
202 | *len = x->aux->alias->length; | ||
203 | return x->aux->alias->data; | ||
204 | } | ||
205 | LCRYPTO_ALIAS(X509_alias_get0); | ||
206 | |||
207 | unsigned char * | ||
208 | X509_keyid_get0(X509 *x, int *len) | ||
209 | { | ||
210 | if (!x->aux || !x->aux->keyid) | ||
211 | return NULL; | ||
212 | if (len) | ||
213 | *len = x->aux->keyid->length; | ||
214 | return x->aux->keyid->data; | ||
215 | } | ||
216 | LCRYPTO_ALIAS(X509_keyid_get0); | ||
217 | |||
218 | int | ||
219 | X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj) | ||
220 | { | ||
221 | X509_CERT_AUX *aux; | ||
222 | ASN1_OBJECT *objtmp; | ||
223 | int rc; | ||
224 | |||
225 | if (!(objtmp = OBJ_dup(obj))) | ||
226 | return 0; | ||
227 | if (!(aux = aux_get(x))) | ||
228 | goto err; | ||
229 | if (!aux->trust && !(aux->trust = sk_ASN1_OBJECT_new_null())) | ||
230 | goto err; | ||
231 | rc = sk_ASN1_OBJECT_push(aux->trust, objtmp); | ||
232 | if (rc != 0) | ||
233 | return rc; | ||
234 | |||
235 | err: | ||
236 | ASN1_OBJECT_free(objtmp); | ||
237 | return 0; | ||
238 | } | ||
239 | LCRYPTO_ALIAS(X509_add1_trust_object); | ||
240 | |||
241 | int | ||
242 | X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj) | ||
243 | { | ||
244 | X509_CERT_AUX *aux; | ||
245 | ASN1_OBJECT *objtmp; | ||
246 | int rc; | ||
247 | |||
248 | if (!(objtmp = OBJ_dup(obj))) | ||
249 | return 0; | ||
250 | if (!(aux = aux_get(x))) | ||
251 | goto err; | ||
252 | if (!aux->reject && !(aux->reject = sk_ASN1_OBJECT_new_null())) | ||
253 | goto err; | ||
254 | rc = sk_ASN1_OBJECT_push(aux->reject, objtmp); | ||
255 | if (rc != 0) | ||
256 | return rc; | ||
257 | |||
258 | err: | ||
259 | ASN1_OBJECT_free(objtmp); | ||
260 | return 0; | ||
261 | } | ||
262 | LCRYPTO_ALIAS(X509_add1_reject_object); | ||
263 | |||
264 | void | ||
265 | X509_trust_clear(X509 *x) | ||
266 | { | ||
267 | if (x->aux && x->aux->trust) { | ||
268 | sk_ASN1_OBJECT_pop_free(x->aux->trust, ASN1_OBJECT_free); | ||
269 | x->aux->trust = NULL; | ||
270 | } | ||
271 | } | ||
272 | LCRYPTO_ALIAS(X509_trust_clear); | ||
273 | |||
274 | void | ||
275 | X509_reject_clear(X509 *x) | ||
276 | { | ||
277 | if (x->aux && x->aux->reject) { | ||
278 | sk_ASN1_OBJECT_pop_free(x->aux->reject, ASN1_OBJECT_free); | ||
279 | x->aux->reject = NULL; | ||
280 | } | ||
281 | } | ||
282 | LCRYPTO_ALIAS(X509_reject_clear); | ||