]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/x509/v3_crld.c
Copyright year updates
[thirdparty/openssl.git] / crypto / x509 / v3_crld.c
CommitLineData
0f113f3e 1/*
b6461792 2 * Copyright 1999-2024 The OpenSSL Project Authors. All Rights Reserved.
d943e372 3 *
4286ca47 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
d2e9e320
RS
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
d943e372
DSH
8 */
9
10#include <stdio.h>
b39fc560 11#include "internal/cryptlib.h"
ec577822
BM
12#include <openssl/conf.h>
13#include <openssl/asn1.h>
9d6b1ce6 14#include <openssl/asn1t.h>
ec577822 15#include <openssl/x509v3.h>
d943e372 16
25f2138b 17#include "crypto/x509.h"
df2ee0e2 18#include "ext_dat.h"
c90c4693 19#include "x509_local.h"
2743e38c 20
babb3798 21static void *v2i_crld(const X509V3_EXT_METHOD *method,
0f113f3e 22 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
babb3798 23static int i2r_crldp(const X509V3_EXT_METHOD *method, void *pcrldp, BIO *out,
0f113f3e
MC
24 int indent);
25
47864aea 26const X509V3_EXT_METHOD ossl_v3_crld = {
0f113f3e
MC
27 NID_crl_distribution_points, 0, ASN1_ITEM_ref(CRL_DIST_POINTS),
28 0, 0, 0, 0,
29 0, 0,
30 0,
31 v2i_crld,
32 i2r_crldp, 0,
33 NULL
34};
35
47864aea 36const X509V3_EXT_METHOD ossl_v3_freshest_crl = {
0f113f3e
MC
37 NID_freshest_crl, 0, ASN1_ITEM_ref(CRL_DIST_POINTS),
38 0, 0, 0, 0,
39 0, 0,
40 0,
41 v2i_crld,
42 i2r_crldp, 0,
43 NULL
44};
45
46static STACK_OF(GENERAL_NAME) *gnames_from_sectname(X509V3_CTX *ctx,
47 char *sect)
48{
49 STACK_OF(CONF_VALUE) *gnsect;
50 STACK_OF(GENERAL_NAME) *gens;
51 if (*sect == '@')
52 gnsect = X509V3_get_section(ctx, sect + 1);
53 else
54 gnsect = X509V3_parse_list(sect);
55 if (!gnsect) {
9311d0c4 56 ERR_raise(ERR_LIB_X509V3, X509V3_R_SECTION_NOT_FOUND);
0f113f3e
MC
57 return NULL;
58 }
59 gens = v2i_GENERAL_NAMES(NULL, ctx, gnsect);
60 if (*sect == '@')
61 X509V3_section_free(ctx, gnsect);
62 else
63 sk_CONF_VALUE_pop_free(gnsect, X509V3_conf_free);
64 return gens;
65}
0745d089 66
0537f968 67static int set_dist_point_name(DIST_POINT_NAME **pdp, X509V3_CTX *ctx,
0f113f3e
MC
68 CONF_VALUE *cnf)
69{
70 STACK_OF(GENERAL_NAME) *fnm = NULL;
71 STACK_OF(X509_NAME_ENTRY) *rnm = NULL;
86885c28 72
bac7e687
NH
73 if (cnf->value == NULL) {
74 ERR_raise(ERR_LIB_X509V3, X509V3_R_MISSING_VALUE);
75 goto err;
76 }
77
2ff286c2 78 if (HAS_PREFIX(cnf->name, "fullname")) {
0f113f3e
MC
79 fnm = gnames_from_sectname(ctx, cnf->value);
80 if (!fnm)
81 goto err;
86885c28 82 } else if (strcmp(cnf->name, "relativename") == 0) {
0f113f3e
MC
83 int ret;
84 STACK_OF(CONF_VALUE) *dnsect;
85 X509_NAME *nm;
86 nm = X509_NAME_new();
90945fa3 87 if (nm == NULL)
0f113f3e
MC
88 return -1;
89 dnsect = X509V3_get_section(ctx, cnf->value);
90 if (!dnsect) {
10481d33 91 X509_NAME_free(nm);
9311d0c4 92 ERR_raise(ERR_LIB_X509V3, X509V3_R_SECTION_NOT_FOUND);
0f113f3e
MC
93 return -1;
94 }
95 ret = X509V3_NAME_from_section(nm, dnsect, MBSTRING_ASC);
96 X509V3_section_free(ctx, dnsect);
97 rnm = nm->entries;
98 nm->entries = NULL;
99 X509_NAME_free(nm);
100 if (!ret || sk_X509_NAME_ENTRY_num(rnm) <= 0)
101 goto err;
102 /*
103 * Since its a name fragment can't have more than one RDNSequence
104 */
105 if (sk_X509_NAME_ENTRY_value(rnm,
106 sk_X509_NAME_ENTRY_num(rnm) - 1)->set) {
9311d0c4 107 ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_MULTIPLE_RDNS);
0f113f3e
MC
108 goto err;
109 }
110 } else
111 return 0;
112
113 if (*pdp) {
9311d0c4 114 ERR_raise(ERR_LIB_X509V3, X509V3_R_DISTPOINT_ALREADY_SET);
0f113f3e
MC
115 goto err;
116 }
117
118 *pdp = DIST_POINT_NAME_new();
90945fa3 119 if (*pdp == NULL)
0f113f3e
MC
120 goto err;
121 if (fnm) {
122 (*pdp)->type = 0;
123 (*pdp)->name.fullname = fnm;
124 } else {
125 (*pdp)->type = 1;
126 (*pdp)->name.relativename = rnm;
127 }
128
129 return 1;
130
131 err:
25aaa98a 132 sk_GENERAL_NAME_pop_free(fnm, GENERAL_NAME_free);
222561fe 133 sk_X509_NAME_ENTRY_pop_free(rnm, X509_NAME_ENTRY_free);
0f113f3e
MC
134 return -1;
135}
0745d089 136
0745d089 137static const BIT_STRING_BITNAME reason_flags[] = {
0f113f3e
MC
138 {0, "Unused", "unused"},
139 {1, "Key Compromise", "keyCompromise"},
140 {2, "CA Compromise", "CACompromise"},
141 {3, "Affiliation Changed", "affiliationChanged"},
142 {4, "Superseded", "superseded"},
143 {5, "Cessation Of Operation", "cessationOfOperation"},
144 {6, "Certificate Hold", "certificateHold"},
145 {7, "Privilege Withdrawn", "privilegeWithdrawn"},
146 {8, "AA Compromise", "AACompromise"},
147 {-1, NULL, NULL}
d943e372
DSH
148};
149
0745d089 150static int set_reasons(ASN1_BIT_STRING **preas, char *value)
0f113f3e
MC
151{
152 STACK_OF(CONF_VALUE) *rsk = NULL;
153 const BIT_STRING_BITNAME *pbn;
154 const char *bnam;
155 int i, ret = 0;
156 rsk = X509V3_parse_list(value);
723412d4 157 if (rsk == NULL)
0f113f3e 158 return 0;
723412d4
MC
159 if (*preas != NULL)
160 goto err;
0f113f3e
MC
161 for (i = 0; i < sk_CONF_VALUE_num(rsk); i++) {
162 bnam = sk_CONF_VALUE_value(rsk, i)->name;
90945fa3 163 if (*preas == NULL) {
0f113f3e 164 *preas = ASN1_BIT_STRING_new();
90945fa3 165 if (*preas == NULL)
0f113f3e
MC
166 goto err;
167 }
168 for (pbn = reason_flags; pbn->lname; pbn++) {
86885c28 169 if (strcmp(pbn->sname, bnam) == 0) {
0f113f3e
MC
170 if (!ASN1_BIT_STRING_set_bit(*preas, pbn->bitnum, 1))
171 goto err;
172 break;
173 }
174 }
12a765a5 175 if (pbn->lname == NULL)
0f113f3e
MC
176 goto err;
177 }
178 ret = 1;
179
180 err:
181 sk_CONF_VALUE_pop_free(rsk, X509V3_conf_free);
182 return ret;
183}
0745d089
DSH
184
185static int print_reasons(BIO *out, const char *rname,
0f113f3e
MC
186 ASN1_BIT_STRING *rflags, int indent)
187{
188 int first = 1;
189 const BIT_STRING_BITNAME *pbn;
190 BIO_printf(out, "%*s%s:\n%*s", indent, "", rname, indent + 2, "");
191 for (pbn = reason_flags; pbn->lname; pbn++) {
192 if (ASN1_BIT_STRING_get_bit(rflags, pbn->bitnum)) {
193 if (first)
194 first = 0;
195 else
196 BIO_puts(out, ", ");
197 BIO_puts(out, pbn->lname);
198 }
199 }
200 if (first)
201 BIO_puts(out, "<EMPTY>\n");
202 else
203 BIO_puts(out, "\n");
204 return 1;
205}
0745d089
DSH
206
207static DIST_POINT *crldp_from_section(X509V3_CTX *ctx,
0f113f3e
MC
208 STACK_OF(CONF_VALUE) *nval)
209{
210 int i;
211 CONF_VALUE *cnf;
270a4bba
F
212 DIST_POINT *point = DIST_POINT_new();
213
90945fa3 214 if (point == NULL)
0f113f3e
MC
215 goto err;
216 for (i = 0; i < sk_CONF_VALUE_num(nval); i++) {
217 int ret;
218 cnf = sk_CONF_VALUE_value(nval, i);
219 ret = set_dist_point_name(&point->distpoint, ctx, cnf);
220 if (ret > 0)
221 continue;
222 if (ret < 0)
223 goto err;
86885c28 224 if (strcmp(cnf->name, "reasons") == 0) {
0f113f3e
MC
225 if (!set_reasons(&point->reasons, cnf->value))
226 goto err;
86885c28 227 } else if (strcmp(cnf->name, "CRLissuer") == 0) {
0f113f3e 228 point->CRLissuer = gnames_from_sectname(ctx, cnf->value);
12a765a5 229 if (point->CRLissuer == NULL)
0f113f3e
MC
230 goto err;
231 }
232 }
233
234 return point;
235
236 err:
25aaa98a 237 DIST_POINT_free(point);
0f113f3e
MC
238 return NULL;
239}
0745d089 240
babb3798 241static void *v2i_crld(const X509V3_EXT_METHOD *method,
0f113f3e
MC
242 X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval)
243{
270a4bba 244 STACK_OF(DIST_POINT) *crld;
0f113f3e
MC
245 GENERAL_NAMES *gens = NULL;
246 GENERAL_NAME *gen = NULL;
247 CONF_VALUE *cnf;
270a4bba 248 const int num = sk_CONF_VALUE_num(nval);
0f113f3e 249 int i;
75ebbd9a 250
7a908204 251 crld = sk_DIST_POINT_new_reserve(NULL, num);
e077455e
RL
252 if (crld == NULL) {
253 ERR_raise(ERR_LIB_X509V3, ERR_R_CRYPTO_LIB);
254 goto err;
255 }
270a4bba 256 for (i = 0; i < num; i++) {
0f113f3e 257 DIST_POINT *point;
270a4bba 258
0f113f3e 259 cnf = sk_CONF_VALUE_value(nval, i);
c90c4693 260 if (cnf->value == NULL) {
0f113f3e
MC
261 STACK_OF(CONF_VALUE) *dpsect;
262 dpsect = X509V3_get_section(ctx, cnf->name);
263 if (!dpsect)
264 goto err;
265 point = crldp_from_section(ctx, dpsect);
266 X509V3_section_free(ctx, dpsect);
12a765a5 267 if (point == NULL)
0f113f3e 268 goto err;
270a4bba 269 sk_DIST_POINT_push(crld, point); /* no failure as it was reserved */
0f113f3e 270 } else {
75ebbd9a 271 if ((gen = v2i_GENERAL_NAME(method, ctx, cnf)) == NULL)
0f113f3e 272 goto err;
e077455e
RL
273 if ((gens = GENERAL_NAMES_new()) == NULL) {
274 ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
275 goto err;
276 }
277 if (!sk_GENERAL_NAME_push(gens, gen)) {
278 ERR_raise(ERR_LIB_X509V3, ERR_R_CRYPTO_LIB);
279 goto err;
280 }
0f113f3e 281 gen = NULL;
e077455e
RL
282 if ((point = DIST_POINT_new()) == NULL) {
283 ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
284 goto err;
285 }
270a4bba 286 sk_DIST_POINT_push(crld, point); /* no failure as it was reserved */
e077455e
RL
287 if ((point->distpoint = DIST_POINT_NAME_new()) == NULL) {
288 ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
289 goto err;
290 }
0f113f3e
MC
291 point->distpoint->name.fullname = gens;
292 point->distpoint->type = 0;
293 gens = NULL;
294 }
295 }
296 return crld;
297
0f113f3e
MC
298 err:
299 GENERAL_NAME_free(gen);
300 GENERAL_NAMES_free(gens);
301 sk_DIST_POINT_pop_free(crld, DIST_POINT_free);
302 return NULL;
d943e372
DSH
303}
304
3e727a3b 305static int dpn_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
0f113f3e
MC
306 void *exarg)
307{
308 DIST_POINT_NAME *dpn = (DIST_POINT_NAME *)*pval;
309
310 switch (operation) {
311 case ASN1_OP_NEW_POST:
312 dpn->dpname = NULL;
313 break;
314
315 case ASN1_OP_FREE_POST:
222561fe 316 X509_NAME_free(dpn->dpname);
0f113f3e
MC
317 break;
318 }
319 return 1;
320}
d943e372 321
3e727a3b
DSH
322
323ASN1_CHOICE_cb(DIST_POINT_NAME, dpn_cb) = {
0f113f3e
MC
324 ASN1_IMP_SEQUENCE_OF(DIST_POINT_NAME, name.fullname, GENERAL_NAME, 0),
325 ASN1_IMP_SET_OF(DIST_POINT_NAME, name.relativename, X509_NAME_ENTRY, 1)
3e727a3b
DSH
326} ASN1_CHOICE_END_cb(DIST_POINT_NAME, DIST_POINT_NAME, type)
327
d943e372 328
9d6b1ce6 329IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT_NAME)
d943e372 330
9d6b1ce6 331ASN1_SEQUENCE(DIST_POINT) = {
0f113f3e
MC
332 ASN1_EXP_OPT(DIST_POINT, distpoint, DIST_POINT_NAME, 0),
333 ASN1_IMP_OPT(DIST_POINT, reasons, ASN1_BIT_STRING, 1),
334 ASN1_IMP_SEQUENCE_OF_OPT(DIST_POINT, CRLissuer, GENERAL_NAME, 2)
d339187b 335} ASN1_SEQUENCE_END(DIST_POINT)
d943e372 336
9d6b1ce6 337IMPLEMENT_ASN1_FUNCTIONS(DIST_POINT)
d943e372 338
0f113f3e
MC
339ASN1_ITEM_TEMPLATE(CRL_DIST_POINTS) =
340 ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, CRLDistributionPoints, DIST_POINT)
d339187b 341ASN1_ITEM_TEMPLATE_END(CRL_DIST_POINTS)
d943e372 342
9d6b1ce6 343IMPLEMENT_ASN1_FUNCTIONS(CRL_DIST_POINTS)
231493c9
DSH
344
345ASN1_SEQUENCE(ISSUING_DIST_POINT) = {
0f113f3e
MC
346 ASN1_EXP_OPT(ISSUING_DIST_POINT, distpoint, DIST_POINT_NAME, 0),
347 ASN1_IMP_OPT(ISSUING_DIST_POINT, onlyuser, ASN1_FBOOLEAN, 1),
348 ASN1_IMP_OPT(ISSUING_DIST_POINT, onlyCA, ASN1_FBOOLEAN, 2),
349 ASN1_IMP_OPT(ISSUING_DIST_POINT, onlysomereasons, ASN1_BIT_STRING, 3),
350 ASN1_IMP_OPT(ISSUING_DIST_POINT, indirectCRL, ASN1_FBOOLEAN, 4),
351 ASN1_IMP_OPT(ISSUING_DIST_POINT, onlyattr, ASN1_FBOOLEAN, 5)
231493c9
DSH
352} ASN1_SEQUENCE_END(ISSUING_DIST_POINT)
353
0537f968
DSH
354IMPLEMENT_ASN1_FUNCTIONS(ISSUING_DIST_POINT)
355
babb3798 356static int i2r_idp(const X509V3_EXT_METHOD *method, void *pidp, BIO *out,
0f113f3e 357 int indent);
babb3798 358static void *v2i_idp(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
0f113f3e
MC
359 STACK_OF(CONF_VALUE) *nval);
360
47864aea 361const X509V3_EXT_METHOD ossl_v3_idp = {
0f113f3e
MC
362 NID_issuing_distribution_point, X509V3_EXT_MULTILINE,
363 ASN1_ITEM_ref(ISSUING_DIST_POINT),
364 0, 0, 0, 0,
365 0, 0,
366 0,
367 v2i_idp,
368 i2r_idp, 0,
369 NULL
370};
231493c9 371
babb3798 372static void *v2i_idp(const X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
0f113f3e
MC
373 STACK_OF(CONF_VALUE) *nval)
374{
375 ISSUING_DIST_POINT *idp = NULL;
376 CONF_VALUE *cnf;
377 char *name, *val;
378 int i, ret;
379 idp = ISSUING_DIST_POINT_new();
e077455e
RL
380 if (idp == NULL) {
381 ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
382 goto err;
383 }
0f113f3e
MC
384 for (i = 0; i < sk_CONF_VALUE_num(nval); i++) {
385 cnf = sk_CONF_VALUE_value(nval, i);
386 name = cnf->name;
387 val = cnf->value;
388 ret = set_dist_point_name(&idp->distpoint, ctx, cnf);
389 if (ret > 0)
390 continue;
391 if (ret < 0)
392 goto err;
86885c28 393 if (strcmp(name, "onlyuser") == 0) {
0f113f3e
MC
394 if (!X509V3_get_value_bool(cnf, &idp->onlyuser))
395 goto err;
86885c28 396 } else if (strcmp(name, "onlyCA") == 0) {
0f113f3e
MC
397 if (!X509V3_get_value_bool(cnf, &idp->onlyCA))
398 goto err;
86885c28 399 } else if (strcmp(name, "onlyAA") == 0) {
0f113f3e
MC
400 if (!X509V3_get_value_bool(cnf, &idp->onlyattr))
401 goto err;
86885c28 402 } else if (strcmp(name, "indirectCRL") == 0) {
0f113f3e
MC
403 if (!X509V3_get_value_bool(cnf, &idp->indirectCRL))
404 goto err;
86885c28 405 } else if (strcmp(name, "onlysomereasons") == 0) {
0f113f3e
MC
406 if (!set_reasons(&idp->onlysomereasons, val))
407 goto err;
408 } else {
9311d0c4 409 ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_NAME);
c90c4693 410 X509V3_conf_add_error_name_value(cnf);
0f113f3e
MC
411 goto err;
412 }
413 }
414 return idp;
415
0f113f3e
MC
416 err:
417 ISSUING_DIST_POINT_free(idp);
418 return NULL;
419}
0537f968 420
9aa9d70d 421static int print_gens(BIO *out, STACK_OF(GENERAL_NAME) *gens, int indent)
0f113f3e
MC
422{
423 int i;
424 for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) {
a4c467c9
DO
425 if (i > 0)
426 BIO_puts(out, "\n");
0f113f3e
MC
427 BIO_printf(out, "%*s", indent + 2, "");
428 GENERAL_NAME_print(out, sk_GENERAL_NAME_value(gens, i));
0f113f3e
MC
429 }
430 return 1;
431}
9aa9d70d
DSH
432
433static int print_distpoint(BIO *out, DIST_POINT_NAME *dpn, int indent)
0f113f3e
MC
434{
435 if (dpn->type == 0) {
436 BIO_printf(out, "%*sFull Name:\n", indent, "");
437 print_gens(out, dpn->name.fullname, indent);
438 } else {
439 X509_NAME ntmp;
440 ntmp.entries = dpn->name.relativename;
441 BIO_printf(out, "%*sRelative Name:\n%*s", indent, "", indent + 2, "");
442 X509_NAME_print_ex(out, &ntmp, 0, XN_FLAG_ONELINE);
443 BIO_puts(out, "\n");
444 }
445 return 1;
446}
231493c9 447
babb3798 448static int i2r_idp(const X509V3_EXT_METHOD *method, void *pidp, BIO *out,
0f113f3e
MC
449 int indent)
450{
451 ISSUING_DIST_POINT *idp = pidp;
452 if (idp->distpoint)
453 print_distpoint(out, idp->distpoint, indent);
454 if (idp->onlyuser > 0)
455 BIO_printf(out, "%*sOnly User Certificates\n", indent, "");
456 if (idp->onlyCA > 0)
457 BIO_printf(out, "%*sOnly CA Certificates\n", indent, "");
458 if (idp->indirectCRL > 0)
459 BIO_printf(out, "%*sIndirect CRL\n", indent, "");
460 if (idp->onlysomereasons)
461 print_reasons(out, "Only Some Reasons", idp->onlysomereasons, indent);
462 if (idp->onlyattr > 0)
463 BIO_printf(out, "%*sOnly Attribute Certificates\n", indent, "");
464 if (!idp->distpoint && (idp->onlyuser <= 0) && (idp->onlyCA <= 0)
465 && (idp->indirectCRL <= 0) && !idp->onlysomereasons
466 && (idp->onlyattr <= 0))
467 BIO_printf(out, "%*s<EMPTY>\n", indent, "");
468
469 return 1;
470}
9aa9d70d 471
babb3798 472static int i2r_crldp(const X509V3_EXT_METHOD *method, void *pcrldp, BIO *out,
0f113f3e
MC
473 int indent)
474{
475 STACK_OF(DIST_POINT) *crld = pcrldp;
476 DIST_POINT *point;
477 int i;
478 for (i = 0; i < sk_DIST_POINT_num(crld); i++) {
a4c467c9
DO
479 if (i > 0)
480 BIO_puts(out, "\n");
0f113f3e
MC
481 point = sk_DIST_POINT_value(crld, i);
482 if (point->distpoint)
483 print_distpoint(out, point->distpoint, indent);
484 if (point->reasons)
485 print_reasons(out, "Reasons", point->reasons, indent);
486 if (point->CRLissuer) {
487 BIO_printf(out, "%*sCRL Issuer:\n", indent, "");
488 print_gens(out, point->CRLissuer, indent);
489 }
490 }
491 return 1;
492}
3e727a3b 493
1e41dadf 494/* Append any nameRelativeToCRLIssuer in dpn to iname, set in dpn->dpname */
8cc86b81 495int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, const X509_NAME *iname)
0f113f3e
MC
496{
497 int i;
498 STACK_OF(X509_NAME_ENTRY) *frag;
499 X509_NAME_ENTRY *ne;
1e41dadf
DDO
500
501 if (dpn == NULL || dpn->type != 1)
0f113f3e
MC
502 return 1;
503 frag = dpn->name.relativename;
1e41dadf 504 X509_NAME_free(dpn->dpname); /* just in case it was already set */
0f113f3e 505 dpn->dpname = X509_NAME_dup(iname);
1e41dadf 506 if (dpn->dpname == NULL)
0f113f3e
MC
507 return 0;
508 for (i = 0; i < sk_X509_NAME_ENTRY_num(frag); i++) {
509 ne = sk_X509_NAME_ENTRY_value(frag, i);
1e41dadf
DDO
510 if (!X509_NAME_add_entry(dpn->dpname, ne, -1, i ? 0 : 1))
511 goto err;
0f113f3e
MC
512 }
513 /* generate cached encoding of name */
1e41dadf
DDO
514 if (i2d_X509_NAME(dpn->dpname, NULL) >= 0)
515 return 1;
516
517 err:
518 X509_NAME_free(dpn->dpname);
519 dpn->dpname = NULL;
520 return 0;
0f113f3e 521}