Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/x509v3/v3_lib.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /* $OpenBSD: v3_lib.c,v 1.18 2018/05/19 10:41:53 tb 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 | /* X509 v3 extension utilities */ | - | ||||||||||||
59 | - | |||||||||||||
60 | #include <stdio.h> | - | ||||||||||||
61 | - | |||||||||||||
62 | #include <openssl/conf.h> | - | ||||||||||||
63 | #include <openssl/err.h> | - | ||||||||||||
64 | #include <openssl/x509v3.h> | - | ||||||||||||
65 | - | |||||||||||||
66 | #include "ext_dat.h" | - | ||||||||||||
67 | - | |||||||||||||
68 | static STACK_OF(X509V3_EXT_METHOD) *ext_list = NULL; | - | ||||||||||||
69 | - | |||||||||||||
70 | static int ext_cmp(const X509V3_EXT_METHOD * const *a, | - | ||||||||||||
71 | const X509V3_EXT_METHOD * const *b); | - | ||||||||||||
72 | static void ext_list_free(X509V3_EXT_METHOD *ext); | - | ||||||||||||
73 | - | |||||||||||||
74 | int | - | ||||||||||||
75 | X509V3_EXT_add(X509V3_EXT_METHOD *ext) | - | ||||||||||||
76 | { | - | ||||||||||||
77 | if (!ext_list && !(ext_list = sk_X509V3_EXT_METHOD_new(ext_cmp))) {
| 0 | ||||||||||||
78 | X509V3error(ERR_R_MALLOC_FAILURE); | - | ||||||||||||
79 | return 0; never executed: return 0; | 0 | ||||||||||||
80 | } | - | ||||||||||||
81 | if (!sk_X509V3_EXT_METHOD_push(ext_list, ext)) {
| 0 | ||||||||||||
82 | X509V3error(ERR_R_MALLOC_FAILURE); | - | ||||||||||||
83 | return 0; never executed: return 0; | 0 | ||||||||||||
84 | } | - | ||||||||||||
85 | return 1; never executed: return 1; | 0 | ||||||||||||
86 | } | - | ||||||||||||
87 | - | |||||||||||||
88 | static int | - | ||||||||||||
89 | ext_cmp(const X509V3_EXT_METHOD * const *a, const X509V3_EXT_METHOD * const *b) | - | ||||||||||||
90 | { | - | ||||||||||||
91 | return ((*a)->ext_nid - (*b)->ext_nid); executed 2712 times by 7 tests: return ((*a)->ext_nid - (*b)->ext_nid); Executed by:
| 2712 | ||||||||||||
92 | } | - | ||||||||||||
93 | - | |||||||||||||
94 | static int ext_cmp_BSEARCH_CMP_FN(const void *, const void *); | - | ||||||||||||
95 | static int ext_cmp(const X509V3_EXT_METHOD * const *, const X509V3_EXT_METHOD * const *); | - | ||||||||||||
96 | static const X509V3_EXT_METHOD * *OBJ_bsearch_ext(const X509V3_EXT_METHOD * *key, const X509V3_EXT_METHOD * const *base, int num); | - | ||||||||||||
97 | - | |||||||||||||
98 | static int | - | ||||||||||||
99 | ext_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) | - | ||||||||||||
100 | { | - | ||||||||||||
101 | const X509V3_EXT_METHOD * const *a = a_; | - | ||||||||||||
102 | const X509V3_EXT_METHOD * const *b = b_; | - | ||||||||||||
103 | return ext_cmp(a, b); executed 2712 times by 7 tests: return ext_cmp(a, b); Executed by:
| 2712 | ||||||||||||
104 | } | - | ||||||||||||
105 | - | |||||||||||||
106 | static const X509V3_EXT_METHOD * * | - | ||||||||||||
107 | OBJ_bsearch_ext(const X509V3_EXT_METHOD * *key, const X509V3_EXT_METHOD * const *base, int num) | - | ||||||||||||
108 | { | - | ||||||||||||
109 | return (const X509V3_EXT_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const X509V3_EXT_METHOD *), executed 577 times by 7 tests: return (const X509V3_EXT_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const X509V3_EXT_METHOD *), ext_cmp_BSEARCH_CMP_FN); Executed by:
| 577 | ||||||||||||
110 | ext_cmp_BSEARCH_CMP_FN); executed 577 times by 7 tests: return (const X509V3_EXT_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const X509V3_EXT_METHOD *), ext_cmp_BSEARCH_CMP_FN); Executed by:
| 577 | ||||||||||||
111 | } | - | ||||||||||||
112 | - | |||||||||||||
113 | const X509V3_EXT_METHOD * | - | ||||||||||||
114 | X509V3_EXT_get_nid(int nid) | - | ||||||||||||
115 | { | - | ||||||||||||
116 | X509V3_EXT_METHOD tmp; | - | ||||||||||||
117 | const X509V3_EXT_METHOD *t = &tmp, * const *ret; | - | ||||||||||||
118 | int idx; | - | ||||||||||||
119 | - | |||||||||||||
120 | if (nid < 0)
| 0-577 | ||||||||||||
121 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
122 | tmp.ext_nid = nid; | - | ||||||||||||
123 | ret = OBJ_bsearch_ext(&t, standard_exts, STANDARD_EXTENSION_COUNT); | - | ||||||||||||
124 | if (ret)
| 0-577 | ||||||||||||
125 | return *ret; executed 577 times by 7 tests: return *ret; Executed by:
| 577 | ||||||||||||
126 | if (!ext_list)
| 0 | ||||||||||||
127 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
128 | idx = sk_X509V3_EXT_METHOD_find(ext_list, &tmp); | - | ||||||||||||
129 | if (idx == -1)
| 0 | ||||||||||||
130 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
131 | return sk_X509V3_EXT_METHOD_value(ext_list, idx); never executed: return ((X509V3_EXT_METHOD *)sk_value(((_STACK*) (1 ? (ext_list) : (struct stack_st_X509V3_EXT_METHOD*)0)), (idx))); | 0 | ||||||||||||
132 | } | - | ||||||||||||
133 | - | |||||||||||||
134 | const X509V3_EXT_METHOD * | - | ||||||||||||
135 | X509V3_EXT_get(X509_EXTENSION *ext) | - | ||||||||||||
136 | { | - | ||||||||||||
137 | int nid; | - | ||||||||||||
138 | - | |||||||||||||
139 | if ((nid = OBJ_obj2nid(ext->object)) == NID_undef)
| 0-564 | ||||||||||||
140 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
141 | return X509V3_EXT_get_nid(nid); executed 564 times by 7 tests: return X509V3_EXT_get_nid(nid); Executed by:
| 564 | ||||||||||||
142 | } | - | ||||||||||||
143 | - | |||||||||||||
144 | int | - | ||||||||||||
145 | X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist) | - | ||||||||||||
146 | { | - | ||||||||||||
147 | for (; extlist->ext_nid!=-1; extlist++)
| 0 | ||||||||||||
148 | if (!X509V3_EXT_add(extlist))
| 0 | ||||||||||||
149 | return 0; never executed: return 0; | 0 | ||||||||||||
150 | return 1; never executed: return 1; | 0 | ||||||||||||
151 | } | - | ||||||||||||
152 | - | |||||||||||||
153 | int | - | ||||||||||||
154 | X509V3_EXT_add_alias(int nid_to, int nid_from) | - | ||||||||||||
155 | { | - | ||||||||||||
156 | const X509V3_EXT_METHOD *ext; | - | ||||||||||||
157 | X509V3_EXT_METHOD *tmpext; | - | ||||||||||||
158 | - | |||||||||||||
159 | if (!(ext = X509V3_EXT_get_nid(nid_from))) {
| 0 | ||||||||||||
160 | X509V3error(X509V3_R_EXTENSION_NOT_FOUND); | - | ||||||||||||
161 | return 0; never executed: return 0; | 0 | ||||||||||||
162 | } | - | ||||||||||||
163 | if (!(tmpext = malloc(sizeof(X509V3_EXT_METHOD)))) {
| 0 | ||||||||||||
164 | X509V3error(ERR_R_MALLOC_FAILURE); | - | ||||||||||||
165 | return 0; never executed: return 0; | 0 | ||||||||||||
166 | } | - | ||||||||||||
167 | *tmpext = *ext; | - | ||||||||||||
168 | tmpext->ext_nid = nid_to; | - | ||||||||||||
169 | tmpext->ext_flags |= X509V3_EXT_DYNAMIC; | - | ||||||||||||
170 | return X509V3_EXT_add(tmpext); never executed: return X509V3_EXT_add(tmpext); | 0 | ||||||||||||
171 | } | - | ||||||||||||
172 | - | |||||||||||||
173 | void | - | ||||||||||||
174 | X509V3_EXT_cleanup(void) | - | ||||||||||||
175 | { | - | ||||||||||||
176 | sk_X509V3_EXT_METHOD_pop_free(ext_list, ext_list_free); | - | ||||||||||||
177 | ext_list = NULL; | - | ||||||||||||
178 | } never executed: end of block | 0 | ||||||||||||
179 | - | |||||||||||||
180 | static void | - | ||||||||||||
181 | ext_list_free(X509V3_EXT_METHOD *ext) | - | ||||||||||||
182 | { | - | ||||||||||||
183 | if (ext->ext_flags & X509V3_EXT_DYNAMIC)
| 0 | ||||||||||||
184 | free(ext); never executed: free(ext); | 0 | ||||||||||||
185 | } never executed: end of block | 0 | ||||||||||||
186 | - | |||||||||||||
187 | /* Legacy function: we don't need to add standard extensions | - | ||||||||||||
188 | * any more because they are now kept in ext_dat.h. | - | ||||||||||||
189 | */ | - | ||||||||||||
190 | - | |||||||||||||
191 | int | - | ||||||||||||
192 | X509V3_add_standard_extensions(void) | - | ||||||||||||
193 | { | - | ||||||||||||
194 | return 1; never executed: return 1; | 0 | ||||||||||||
195 | } | - | ||||||||||||
196 | - | |||||||||||||
197 | /* Return an extension internal structure */ | - | ||||||||||||
198 | - | |||||||||||||
199 | void * | - | ||||||||||||
200 | X509V3_EXT_d2i(X509_EXTENSION *ext) | - | ||||||||||||
201 | { | - | ||||||||||||
202 | const X509V3_EXT_METHOD *method; | - | ||||||||||||
203 | const unsigned char *p; | - | ||||||||||||
204 | - | |||||||||||||
205 | if (!(method = X509V3_EXT_get(ext)))
| 0-561 | ||||||||||||
206 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
207 | p = ext->value->data; | - | ||||||||||||
208 | if (method->it)
| 0-561 | ||||||||||||
209 | return ASN1_item_d2i(NULL, &p, ext->value->length, executed 561 times by 6 tests: return ASN1_item_d2i( ((void *)0) , &p, ext->value->length, method->it); Executed by:
| 561 | ||||||||||||
210 | method->it); executed 561 times by 6 tests: return ASN1_item_d2i( ((void *)0) , &p, ext->value->length, method->it); Executed by:
| 561 | ||||||||||||
211 | return method->d2i(NULL, &p, ext->value->length); never executed: return method->d2i( ((void *)0) , &p, ext->value->length); | 0 | ||||||||||||
212 | } | - | ||||||||||||
213 | - | |||||||||||||
214 | /* Get critical flag and decoded version of extension from a NID. | - | ||||||||||||
215 | * The "idx" variable returns the last found extension and can | - | ||||||||||||
216 | * be used to retrieve multiple extensions of the same NID. | - | ||||||||||||
217 | * However multiple extensions with the same NID is usually | - | ||||||||||||
218 | * due to a badly encoded certificate so if idx is NULL we | - | ||||||||||||
219 | * choke if multiple extensions exist. | - | ||||||||||||
220 | * The "crit" variable is set to the critical value. | - | ||||||||||||
221 | * The return value is the decoded extension or NULL on | - | ||||||||||||
222 | * error. The actual error can have several different causes, | - | ||||||||||||
223 | * the value of *crit reflects the cause: | - | ||||||||||||
224 | * >= 0, extension found but not decoded (reflects critical value). | - | ||||||||||||
225 | * -1 extension not found. | - | ||||||||||||
226 | * -2 extension occurs more than once. | - | ||||||||||||
227 | */ | - | ||||||||||||
228 | - | |||||||||||||
229 | void * | - | ||||||||||||
230 | X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit, int *idx) | - | ||||||||||||
231 | { | - | ||||||||||||
232 | int lastpos, i; | - | ||||||||||||
233 | X509_EXTENSION *ex, *found_ex = NULL; | - | ||||||||||||
234 | - | |||||||||||||
235 | if (!x) {
| 15-1997 | ||||||||||||
236 | if (idx)
| 0-15 | ||||||||||||
237 | *idx = -1; never executed: *idx = -1; | 0 | ||||||||||||
238 | if (crit)
| 0-15 | ||||||||||||
239 | *crit = -1; never executed: *crit = -1; | 0 | ||||||||||||
240 | return NULL; executed 15 times by 1 test: return ((void *)0) ; Executed by:
| 15 | ||||||||||||
241 | } | - | ||||||||||||
242 | if (idx)
| 0-1997 | ||||||||||||
243 | lastpos = *idx + 1; never executed: lastpos = *idx + 1; | 0 | ||||||||||||
244 | else | - | ||||||||||||
245 | lastpos = 0; executed 1997 times by 6 tests: lastpos = 0; Executed by:
| 1997 | ||||||||||||
246 | if (lastpos < 0)
| 0-1997 | ||||||||||||
247 | lastpos = 0; never executed: lastpos = 0; | 0 | ||||||||||||
248 | for (i = lastpos; i < sk_X509_EXTENSION_num(x); i++) {
| 1997-6715 | ||||||||||||
249 | ex = sk_X509_EXTENSION_value(x, i); | - | ||||||||||||
250 | if (OBJ_obj2nid(ex->object) == nid) {
| 561-6154 | ||||||||||||
251 | if (idx) {
| 0-561 | ||||||||||||
252 | *idx = i; | - | ||||||||||||
253 | found_ex = ex; | - | ||||||||||||
254 | break; never executed: break; | 0 | ||||||||||||
255 | } else if (found_ex) {
| 0-561 | ||||||||||||
256 | /* Found more than one */ | - | ||||||||||||
257 | if (crit)
| 0 | ||||||||||||
258 | *crit = -2; never executed: *crit = -2; | 0 | ||||||||||||
259 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
260 | } | - | ||||||||||||
261 | found_ex = ex; | - | ||||||||||||
262 | } executed 561 times by 6 tests: end of block Executed by:
| 561 | ||||||||||||
263 | } executed 6715 times by 6 tests: end of block Executed by:
| 6715 | ||||||||||||
264 | if (found_ex) {
| 561-1436 | ||||||||||||
265 | /* Found it */ | - | ||||||||||||
266 | if (crit)
| 0-561 | ||||||||||||
267 | *crit = X509_EXTENSION_get_critical(found_ex); never executed: *crit = X509_EXTENSION_get_critical(found_ex); | 0 | ||||||||||||
268 | return X509V3_EXT_d2i(found_ex); executed 561 times by 6 tests: return X509V3_EXT_d2i(found_ex); Executed by:
| 561 | ||||||||||||
269 | } | - | ||||||||||||
270 | - | |||||||||||||
271 | /* Extension not found */ | - | ||||||||||||
272 | if (idx)
| 0-1436 | ||||||||||||
273 | *idx = -1; never executed: *idx = -1; | 0 | ||||||||||||
274 | if (crit)
| 198-1238 | ||||||||||||
275 | *crit = -1; executed 198 times by 5 tests: *crit = -1; Executed by:
| 198 | ||||||||||||
276 | return NULL; executed 1436 times by 5 tests: return ((void *)0) ; Executed by:
| 1436 | ||||||||||||
277 | } | - | ||||||||||||
278 | - | |||||||||||||
279 | /* This function is a general extension append, replace and delete utility. | - | ||||||||||||
280 | * The precise operation is governed by the 'flags' value. The 'crit' and | - | ||||||||||||
281 | * 'value' arguments (if relevant) are the extensions internal structure. | - | ||||||||||||
282 | */ | - | ||||||||||||
283 | - | |||||||||||||
284 | int | - | ||||||||||||
285 | X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, | - | ||||||||||||
286 | int crit, unsigned long flags) | - | ||||||||||||
287 | { | - | ||||||||||||
288 | int extidx = -1; | - | ||||||||||||
289 | int errcode; | - | ||||||||||||
290 | X509_EXTENSION *ext, *extmp; | - | ||||||||||||
291 | unsigned long ext_op = flags & X509V3_ADD_OP_MASK; | - | ||||||||||||
292 | - | |||||||||||||
293 | /* If appending we don't care if it exists, otherwise | - | ||||||||||||
294 | * look for existing extension. | - | ||||||||||||
295 | */ | - | ||||||||||||
296 | if (ext_op != X509V3_ADD_APPEND)
| 0-13 | ||||||||||||
297 | extidx = X509v3_get_ext_by_NID(*x, nid, -1); executed 13 times by 1 test: extidx = X509v3_get_ext_by_NID(*x, nid, -1); Executed by:
| 13 | ||||||||||||
298 | - | |||||||||||||
299 | /* See if extension exists */ | - | ||||||||||||
300 | if (extidx >= 0) {
| 0-13 | ||||||||||||
301 | /* If keep existing, nothing to do */ | - | ||||||||||||
302 | if (ext_op == X509V3_ADD_KEEP_EXISTING)
| 0 | ||||||||||||
303 | return 1; never executed: return 1; | 0 | ||||||||||||
304 | /* If default then its an error */ | - | ||||||||||||
305 | if (ext_op == X509V3_ADD_DEFAULT) {
| 0 | ||||||||||||
306 | errcode = X509V3_R_EXTENSION_EXISTS; | - | ||||||||||||
307 | goto err; never executed: goto err; | 0 | ||||||||||||
308 | } | - | ||||||||||||
309 | /* If delete, just delete it */ | - | ||||||||||||
310 | if (ext_op == X509V3_ADD_DELETE) {
| 0 | ||||||||||||
311 | if (!sk_X509_EXTENSION_delete(*x, extidx))
| 0 | ||||||||||||
312 | return -1; never executed: return -1; | 0 | ||||||||||||
313 | return 1; never executed: return 1; | 0 | ||||||||||||
314 | } | - | ||||||||||||
315 | } else { never executed: end of block | 0 | ||||||||||||
316 | /* If replace existing or delete, error since | - | ||||||||||||
317 | * extension must exist | - | ||||||||||||
318 | */ | - | ||||||||||||
319 | if ((ext_op == X509V3_ADD_REPLACE_EXISTING) ||
| 0-13 | ||||||||||||
320 | (ext_op == X509V3_ADD_DELETE)) {
| 0-13 | ||||||||||||
321 | errcode = X509V3_R_EXTENSION_NOT_FOUND; | - | ||||||||||||
322 | goto err; never executed: goto err; | 0 | ||||||||||||
323 | } | - | ||||||||||||
324 | } executed 13 times by 1 test: end of block Executed by:
| 13 | ||||||||||||
325 | - | |||||||||||||
326 | /* If we get this far then we have to create an extension: | - | ||||||||||||
327 | * could have some flags for alternative encoding schemes... | - | ||||||||||||
328 | */ | - | ||||||||||||
329 | - | |||||||||||||
330 | ext = X509V3_EXT_i2d(nid, crit, value); | - | ||||||||||||
331 | - | |||||||||||||
332 | if (!ext) {
| 0-13 | ||||||||||||
333 | X509V3error(X509V3_R_ERROR_CREATING_EXTENSION); | - | ||||||||||||
334 | return 0; never executed: return 0; | 0 | ||||||||||||
335 | } | - | ||||||||||||
336 | - | |||||||||||||
337 | /* If extension exists replace it.. */ | - | ||||||||||||
338 | if (extidx >= 0) {
| 0-13 | ||||||||||||
339 | extmp = sk_X509_EXTENSION_value(*x, extidx); | - | ||||||||||||
340 | X509_EXTENSION_free(extmp); | - | ||||||||||||
341 | if (!sk_X509_EXTENSION_set(*x, extidx, ext))
| 0 | ||||||||||||
342 | return -1; never executed: return -1; | 0 | ||||||||||||
343 | return 1; never executed: return 1; | 0 | ||||||||||||
344 | } | - | ||||||||||||
345 | - | |||||||||||||
346 | if (!*x && !(*x = sk_X509_EXTENSION_new_null()))
| 0-13 | ||||||||||||
347 | return -1; never executed: return -1; | 0 | ||||||||||||
348 | if (!sk_X509_EXTENSION_push(*x, ext))
| 0-13 | ||||||||||||
349 | return -1; never executed: return -1; | 0 | ||||||||||||
350 | - | |||||||||||||
351 | return 1; executed 13 times by 1 test: return 1; Executed by:
| 13 | ||||||||||||
352 | - | |||||||||||||
353 | err: | - | ||||||||||||
354 | if (!(flags & X509V3_ADD_SILENT))
| 0 | ||||||||||||
355 | X509V3error(errcode); never executed: ERR_put_error(34,(0xfff),(errcode),__FILE__,355); | 0 | ||||||||||||
356 | return 0; never executed: return 0; | 0 | ||||||||||||
357 | } | - | ||||||||||||
Source code | Switch to Preprocessed file |