Coverage Report

Created: 2025-12-10 06:24

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl/crypto/x509/x_crl.c
Line
Count
Source
1
/*
2
 * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved.
3
 *
4
 * Licensed under the Apache License 2.0 (the "License").  You may not use
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
8
 */
9
10
#include <stdio.h>
11
#include "internal/cryptlib.h"
12
#include <openssl/asn1t.h>
13
#include <openssl/x509.h>
14
#include "crypto/x509.h"
15
#include <openssl/x509v3.h>
16
#include "x509_local.h"
17
18
static int X509_REVOKED_cmp(const X509_REVOKED *const *a,
19
    const X509_REVOKED *const *b);
20
static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp);
21
22
ASN1_SEQUENCE(X509_REVOKED) = {
23
    ASN1_EMBED(X509_REVOKED, serialNumber, ASN1_INTEGER),
24
    ASN1_SIMPLE(X509_REVOKED, revocationDate, ASN1_TIME),
25
    ASN1_SEQUENCE_OF_OPT(X509_REVOKED, extensions, X509_EXTENSION)
26
0
} ASN1_SEQUENCE_END(X509_REVOKED)
27
0
28
0
static int def_crl_verify(X509_CRL *crl, EVP_PKEY *r);
29
0
static int def_crl_lookup(X509_CRL *crl,
30
0
    X509_REVOKED **ret, const ASN1_INTEGER *serial,
31
0
    const X509_NAME *issuer);
32
0
33
0
static X509_CRL_METHOD int_crl_meth = {
34
0
    0,
35
0
    0, 0,
36
0
    def_crl_lookup,
37
0
    def_crl_verify
38
0
};
39
0
40
0
static const X509_CRL_METHOD *default_crl_method = &int_crl_meth;
41
0
42
0
/*
43
0
 * The X509_CRL_INFO structure needs a bit of customisation. Since we cache
44
0
 * the original encoding the signature won't be affected by reordering of the
45
0
 * revoked field.
46
0
 */
47
0
static int crl_inf_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
48
0
    void *exarg)
49
0
{
50
0
    X509_CRL_INFO *a = (X509_CRL_INFO *)*pval;
51
52
0
    if (!a || !a->revoked)
53
0
        return 1;
54
0
    switch (operation) {
55
        /*
56
         * Just set cmp function here. We don't sort because that would
57
         * affect the output of X509_CRL_print().
58
         */
59
0
    case ASN1_OP_D2I_POST:
60
0
        (void)sk_X509_REVOKED_set_cmp_func(a->revoked, X509_REVOKED_cmp);
61
0
        break;
62
0
    }
63
0
    return 1;
64
0
}
65
66
ASN1_SEQUENCE_enc(X509_CRL_INFO, enc, crl_inf_cb) = {
67
    ASN1_OPT(X509_CRL_INFO, version, ASN1_INTEGER),
68
    ASN1_EMBED(X509_CRL_INFO, sig_alg, X509_ALGOR),
69
    ASN1_SIMPLE(X509_CRL_INFO, issuer, X509_NAME),
70
    ASN1_SIMPLE(X509_CRL_INFO, lastUpdate, ASN1_TIME),
71
    ASN1_OPT(X509_CRL_INFO, nextUpdate, ASN1_TIME),
72
    ASN1_SEQUENCE_OF_OPT(X509_CRL_INFO, revoked, X509_REVOKED),
73
    ASN1_EXP_SEQUENCE_OF_OPT(X509_CRL_INFO, extensions, X509_EXTENSION, 0)
74
} ASN1_SEQUENCE_END_enc(X509_CRL_INFO, X509_CRL_INFO)
75
76
/*
77
 * Set CRL entry issuer according to CRL certificate issuer extension. Check
78
 * for unhandled critical CRL entry extensions.
79
 */
80
81
static int crl_set_issuers(X509_CRL *crl)
82
0
{
83
84
0
    int i, j;
85
0
    GENERAL_NAMES *most_recent_issuer, *gtmp;
86
0
    STACK_OF(X509_REVOKED) *revoked;
87
88
    /*
89
     * The CRL's nextUpdate field is optional, but we will still verify
90
     * lastUpdate and treat missing or invalid values as a failure.
91
     */
92
0
    if (crl->crl.lastUpdate == NULL) {
93
0
        crl->flags |= EXFLAG_INVALID;
94
0
        return 0;
95
0
    }
96
97
0
    revoked = X509_CRL_get_REVOKED(crl);
98
99
    /*
100
     * If this extension is not present on the first entry in an indirect CRL,
101
     * the certificate issuer defaults to the CRL issuer. Subsequent entries in
102
     * an indirect CRL, if this extension is not present, the certificate issuer
103
     * for the entry is the same as that for the preceding entry.
104
     * https://datatracker.ietf.org/doc/html/rfc5280#section-5.3.3
105
     */
106
0
    most_recent_issuer = NULL;
107
108
0
    for (i = 0; i < sk_X509_REVOKED_num(revoked); i++) {
109
0
        X509_REVOKED *rev = sk_X509_REVOKED_value(revoked, i);
110
0
        STACK_OF(X509_EXTENSION) *exts;
111
0
        ASN1_ENUMERATED *reason;
112
0
        X509_EXTENSION *ext;
113
0
        const ASN1_TIME *rev_date;
114
0
        ASN1_GENERALIZEDTIME *inv_date;
115
0
        int nid;
116
117
        /*
118
         * The revocation date is a mandatory attribute. If we get NULL here, it
119
         * means the validation has failed and an error has been pushed onto the
120
         * error stack.
121
         */
122
0
        if ((rev_date = X509_REVOKED_get0_revocationDate(rev)) == NULL) {
123
0
            crl->flags |= EXFLAG_INVALID;
124
0
            return 0;
125
0
        }
126
127
0
        gtmp = X509_REVOKED_get_ext_d2i(rev, NID_certificate_issuer, &j, NULL);
128
0
        if (gtmp == NULL && j != -1) {
129
0
            crl->flags |= EXFLAG_INVALID;
130
0
            return 1;
131
0
        }
132
133
0
        if (gtmp != NULL) {
134
            /*
135
             * Validation to ensure Certificate Issuer extensions in CRL
136
             * entries only appear when the Indirect CRL flag is TRUE in the
137
             * Issuing Distribution Point (IDP) extension, as required by
138
             * https://datatracker.ietf.org/doc/html/rfc5280#section-5.3.3
139
             */
140
0
            if (crl->idp == NULL || !crl->idp->indirectCRL) {
141
0
                crl->flags |= EXFLAG_INVALID;
142
0
                GENERAL_NAMES_free(gtmp);
143
0
                return 0;
144
0
            }
145
146
0
            if (crl->issuers == NULL) {
147
0
                crl->issuers = sk_GENERAL_NAMES_new_null();
148
0
                if (crl->issuers == NULL) {
149
0
                    GENERAL_NAMES_free(gtmp);
150
0
                    return 0;
151
0
                }
152
0
            }
153
0
            if (!sk_GENERAL_NAMES_push(crl->issuers, gtmp)) {
154
0
                GENERAL_NAMES_free(gtmp);
155
0
                return 0;
156
0
            }
157
0
            most_recent_issuer = gtmp;
158
0
        }
159
0
        rev->issuer = most_recent_issuer;
160
161
0
        reason = X509_REVOKED_get_ext_d2i(rev, NID_crl_reason, &j, NULL);
162
0
        if (reason == NULL && j != -1) {
163
0
            crl->flags |= EXFLAG_INVALID;
164
0
            return 1;
165
0
        }
166
167
0
        if (reason != NULL) {
168
0
            rev->reason = ASN1_ENUMERATED_get(reason);
169
0
            ASN1_ENUMERATED_free(reason);
170
0
        } else
171
0
            rev->reason = CRL_REASON_NONE;
172
173
        /* Check for critical CRL entry extensions and validate time. */
174
175
0
        exts = rev->extensions;
176
177
0
        for (j = 0; j < sk_X509_EXTENSION_num(exts); j++) {
178
0
            ext = sk_X509_EXTENSION_value(exts, j);
179
0
            nid = OBJ_obj2nid(X509_EXTENSION_get_object(ext));
180
181
            /*
182
             * If we obtain the extension but the time is NULL, it means that
183
             * the validation has failed and the reason will be pushed onto the
184
             * error stack.
185
             */
186
0
            if (nid == NID_invalidity_date) {
187
0
                if ((inv_date = X509V3_EXT_d2i(ext)) == NULL) {
188
0
                    crl->flags |= EXFLAG_INVALID;
189
0
                    return 0;
190
0
                }
191
0
                ASN1_GENERALIZEDTIME_free(inv_date);
192
0
            }
193
0
            if (X509_EXTENSION_get_critical(ext)) {
194
0
                if (nid == NID_certificate_issuer)
195
0
                    continue;
196
0
                crl->flags |= EXFLAG_CRITICAL;
197
0
            }
198
0
        }
199
0
    }
200
201
0
    return 1;
202
0
}
203
204
/*
205
 * The X509_CRL structure needs a bit of customisation. Cache some extensions
206
 * and hash of the whole CRL or set EXFLAG_NO_FINGERPRINT if this fails.
207
 */
208
static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
209
    void *exarg)
210
0
{
211
0
    X509_CRL *crl = (X509_CRL *)*pval;
212
0
    STACK_OF(X509_EXTENSION) *exts;
213
0
    X509_EXTENSION *ext;
214
0
    int idx, i;
215
216
0
    switch (operation) {
217
0
    case ASN1_OP_D2I_PRE:
218
0
        if (crl->meth->crl_free) {
219
0
            if (!crl->meth->crl_free(crl))
220
0
                return 0;
221
0
        }
222
0
        AUTHORITY_KEYID_free(crl->akid);
223
0
        ISSUING_DIST_POINT_free(crl->idp);
224
0
        ASN1_INTEGER_free(crl->crl_number);
225
0
        ASN1_INTEGER_free(crl->base_crl_number);
226
0
        sk_GENERAL_NAMES_pop_free(crl->issuers, GENERAL_NAMES_free);
227
        /* fall through */
228
229
0
    case ASN1_OP_NEW_POST:
230
0
        crl->idp = NULL;
231
0
        crl->akid = NULL;
232
0
        crl->flags = 0;
233
0
        crl->idp_flags = 0;
234
0
        crl->idp_reasons = CRLDP_ALL_REASONS;
235
0
        crl->meth = default_crl_method;
236
0
        crl->meth_data = NULL;
237
0
        crl->issuers = NULL;
238
0
        crl->crl_number = NULL;
239
0
        crl->base_crl_number = NULL;
240
0
        break;
241
242
0
    case ASN1_OP_D2I_POST:
243
0
        if (!X509_CRL_digest(crl, EVP_sha1(), crl->sha1_hash, NULL))
244
0
            crl->flags |= EXFLAG_NO_FINGERPRINT;
245
0
        crl->idp = X509_CRL_get_ext_d2i(crl,
246
0
            NID_issuing_distribution_point, &i,
247
0
            NULL);
248
0
        if (crl->idp != NULL) {
249
0
            if (!setup_idp(crl, crl->idp))
250
0
                crl->flags |= EXFLAG_INVALID;
251
0
        } else if (i != -1) {
252
0
            crl->flags |= EXFLAG_INVALID;
253
0
        }
254
255
0
        crl->akid = X509_CRL_get_ext_d2i(crl,
256
0
            NID_authority_key_identifier, &i,
257
0
            NULL);
258
0
        if (crl->akid == NULL && i != -1)
259
0
            crl->flags |= EXFLAG_INVALID;
260
261
0
        crl->crl_number = X509_CRL_get_ext_d2i(crl,
262
0
            NID_crl_number, &i, NULL);
263
0
        if (crl->crl_number == NULL && i != -1)
264
0
            crl->flags |= EXFLAG_INVALID;
265
266
0
        crl->base_crl_number = X509_CRL_get_ext_d2i(crl,
267
0
            NID_delta_crl, &i,
268
0
            NULL);
269
0
        if (crl->base_crl_number == NULL && i != -1)
270
0
            crl->flags |= EXFLAG_INVALID;
271
        /* Delta CRLs must have CRL number */
272
0
        if (crl->base_crl_number && !crl->crl_number)
273
0
            crl->flags |= EXFLAG_INVALID;
274
275
        /*
276
         * See if we have any unhandled critical CRL extensions and indicate
277
         * this in a flag. We only currently handle IDP so anything else
278
         * critical sets the flag. This code accesses the X509_CRL structure
279
         * directly: applications shouldn't do this.
280
         */
281
282
0
        exts = crl->crl.extensions;
283
284
0
        for (idx = 0; idx < sk_X509_EXTENSION_num(exts); idx++) {
285
0
            int nid;
286
0
            ext = sk_X509_EXTENSION_value(exts, idx);
287
0
            nid = OBJ_obj2nid(X509_EXTENSION_get_object(ext));
288
0
            if (nid == NID_freshest_crl)
289
0
                crl->flags |= EXFLAG_FRESHEST;
290
0
            if (X509_EXTENSION_get_critical(ext)) {
291
                /* We handle IDP and deltas */
292
0
                if ((nid == NID_issuing_distribution_point)
293
0
                    || (nid == NID_authority_key_identifier)
294
0
                    || (nid == NID_delta_crl))
295
0
                    continue;
296
0
                crl->flags |= EXFLAG_CRITICAL;
297
0
                break;
298
0
            }
299
0
        }
300
301
0
        if (!crl_set_issuers(crl))
302
0
            return 0;
303
304
0
        if (crl->meth->crl_init) {
305
0
            if (crl->meth->crl_init(crl) == 0)
306
0
                return 0;
307
0
        }
308
309
0
        crl->flags |= EXFLAG_SET;
310
0
        break;
311
312
0
    case ASN1_OP_FREE_POST:
313
0
        if (crl->meth != NULL && crl->meth->crl_free != NULL) {
314
0
            if (!crl->meth->crl_free(crl))
315
0
                return 0;
316
0
        }
317
0
        AUTHORITY_KEYID_free(crl->akid);
318
0
        ISSUING_DIST_POINT_free(crl->idp);
319
0
        ASN1_INTEGER_free(crl->crl_number);
320
0
        ASN1_INTEGER_free(crl->base_crl_number);
321
0
        sk_GENERAL_NAMES_pop_free(crl->issuers, GENERAL_NAMES_free);
322
0
        OPENSSL_free(crl->propq);
323
0
        break;
324
0
    case ASN1_OP_DUP_POST: {
325
0
        X509_CRL *old = exarg;
326
327
0
        if (!ossl_x509_crl_set0_libctx(crl, old->libctx, old->propq))
328
0
            return 0;
329
0
    } break;
330
0
    }
331
0
    return 1;
332
0
}
333
334
/* Convert IDP into a more convenient form */
335
336
static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp)
337
0
{
338
0
    int idp_only = 0;
339
0
    int ret = 0;
340
341
    /* Set various flags according to IDP */
342
0
    crl->idp_flags |= IDP_PRESENT;
343
0
    if (idp->onlyuser > 0) {
344
0
        idp_only++;
345
0
        crl->idp_flags |= IDP_ONLYUSER;
346
0
    }
347
0
    if (idp->onlyCA > 0) {
348
0
        idp_only++;
349
0
        crl->idp_flags |= IDP_ONLYCA;
350
0
    }
351
0
    if (idp->onlyattr > 0) {
352
0
        idp_only++;
353
0
        crl->idp_flags |= IDP_ONLYATTR;
354
0
    }
355
356
0
    if (idp_only > 1)
357
0
        crl->idp_flags |= IDP_INVALID;
358
359
0
    if (idp->indirectCRL > 0)
360
0
        crl->idp_flags |= IDP_INDIRECT;
361
362
0
    if (idp->onlysomereasons) {
363
0
        crl->idp_flags |= IDP_REASONS;
364
0
        if (idp->onlysomereasons->length > 0)
365
0
            crl->idp_reasons = idp->onlysomereasons->data[0];
366
0
        if (idp->onlysomereasons->length > 1)
367
0
            crl->idp_reasons |= (idp->onlysomereasons->data[1] << 8);
368
0
        crl->idp_reasons &= CRLDP_ALL_REASONS;
369
0
    }
370
371
0
    ret = DIST_POINT_set_dpname(idp->distpoint, X509_CRL_get_issuer(crl));
372
373
    /*
374
     * RFC5280 specifies that if onlyContainsUserCerts, onlyContainsCACerts,
375
     * indirectCRL, and OnlyContainsAttributeCerts are all FALSE, there must
376
     * be either a distributionPoint field or an onlySomeReasons field present.
377
     */
378
0
    if (crl->idp_flags == IDP_PRESENT && idp->distpoint == NULL)
379
0
        crl->idp_flags |= IDP_INVALID;
380
381
0
    return ret;
382
0
}
383
384
ASN1_SEQUENCE_ref(X509_CRL, crl_cb) = {
385
    ASN1_EMBED(X509_CRL, crl, X509_CRL_INFO),
386
    ASN1_EMBED(X509_CRL, sig_alg, X509_ALGOR),
387
    ASN1_EMBED(X509_CRL, signature, ASN1_BIT_STRING)
388
} ASN1_SEQUENCE_END_ref(X509_CRL, X509_CRL)
389
390
IMPLEMENT_ASN1_FUNCTIONS(X509_REVOKED)
391
392
IMPLEMENT_ASN1_DUP_FUNCTION(X509_REVOKED)
393
394
IMPLEMENT_ASN1_FUNCTIONS(X509_CRL_INFO)
395
396
IMPLEMENT_ASN1_FUNCTIONS(X509_CRL)
397
398
IMPLEMENT_ASN1_DUP_FUNCTION(X509_CRL)
399
400
static int X509_REVOKED_cmp(const X509_REVOKED *const *a,
401
    const X509_REVOKED *const *b)
402
0
{
403
0
    return (ASN1_STRING_cmp((ASN1_STRING *)&(*a)->serialNumber,
404
0
        (ASN1_STRING *)&(*b)->serialNumber));
405
0
}
406
407
X509_CRL *X509_CRL_new_ex(OSSL_LIB_CTX *libctx, const char *propq)
408
0
{
409
0
    X509_CRL *crl = NULL;
410
411
0
    crl = (X509_CRL *)ASN1_item_new((X509_CRL_it()));
412
0
    if (!ossl_x509_crl_set0_libctx(crl, libctx, propq)) {
413
0
        X509_CRL_free(crl);
414
0
        crl = NULL;
415
0
    }
416
0
    return crl;
417
0
}
418
419
int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev)
420
0
{
421
0
    X509_CRL_INFO *inf;
422
423
0
    inf = &crl->crl;
424
0
    if (inf->revoked == NULL)
425
0
        inf->revoked = sk_X509_REVOKED_new(X509_REVOKED_cmp);
426
0
    if (inf->revoked == NULL || !sk_X509_REVOKED_push(inf->revoked, rev)) {
427
0
        ERR_raise(ERR_LIB_ASN1, ERR_R_CRYPTO_LIB);
428
0
        return 0;
429
0
    }
430
0
    inf->enc.modified = 1;
431
0
    return 1;
432
0
}
433
434
int X509_CRL_verify(X509_CRL *crl, EVP_PKEY *r)
435
0
{
436
0
    if (crl->meth->crl_verify)
437
0
        return crl->meth->crl_verify(crl, r);
438
0
    return 0;
439
0
}
440
441
int X509_CRL_get0_by_serial(X509_CRL *crl,
442
    X509_REVOKED **ret, const ASN1_INTEGER *serial)
443
0
{
444
0
    if (crl->meth->crl_lookup)
445
0
        return crl->meth->crl_lookup(crl, ret, serial, NULL);
446
0
    return 0;
447
0
}
448
449
int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x)
450
0
{
451
0
    if (crl->meth->crl_lookup)
452
0
        return crl->meth->crl_lookup(crl, ret,
453
0
            X509_get0_serialNumber(x),
454
0
            X509_get_issuer_name(x));
455
0
    return 0;
456
0
}
457
458
static int def_crl_verify(X509_CRL *crl, EVP_PKEY *r)
459
0
{
460
0
    return ASN1_item_verify_ex(ASN1_ITEM_rptr(X509_CRL_INFO),
461
0
        &crl->sig_alg, &crl->signature, &crl->crl, NULL,
462
0
        r, crl->libctx, crl->propq);
463
0
}
464
465
static int crl_revoked_issuer_match(X509_CRL *crl, const X509_NAME *nm,
466
    X509_REVOKED *rev)
467
0
{
468
0
    int i;
469
470
0
    if (!rev->issuer) {
471
0
        if (!nm)
472
0
            return 1;
473
0
        if (!X509_NAME_cmp(nm, X509_CRL_get_issuer(crl)))
474
0
            return 1;
475
0
        return 0;
476
0
    }
477
478
0
    if (!nm)
479
0
        nm = X509_CRL_get_issuer(crl);
480
481
0
    for (i = 0; i < sk_GENERAL_NAME_num(rev->issuer); i++) {
482
0
        GENERAL_NAME *gen = sk_GENERAL_NAME_value(rev->issuer, i);
483
0
        if (gen->type != GEN_DIRNAME)
484
0
            continue;
485
0
        if (!X509_NAME_cmp(nm, gen->d.directoryName))
486
0
            return 1;
487
0
    }
488
0
    return 0;
489
0
}
490
491
static int def_crl_lookup(X509_CRL *crl,
492
    X509_REVOKED **ret, const ASN1_INTEGER *serial,
493
    const X509_NAME *issuer)
494
0
{
495
0
    X509_REVOKED rtmp, *rev;
496
0
    int idx, num;
497
498
0
    if (crl->crl.revoked == NULL)
499
0
        return 0;
500
501
    /*
502
     * Sort revoked into serial number order if not already sorted. Do this
503
     * under a lock to avoid race condition.
504
     */
505
0
    if (!sk_X509_REVOKED_is_sorted(crl->crl.revoked)) {
506
0
        if (!CRYPTO_THREAD_write_lock(crl->lock))
507
0
            return 0;
508
0
        sk_X509_REVOKED_sort(crl->crl.revoked);
509
0
        CRYPTO_THREAD_unlock(crl->lock);
510
0
    }
511
0
    rtmp.serialNumber = *serial;
512
0
    idx = sk_X509_REVOKED_find(crl->crl.revoked, &rtmp);
513
0
    if (idx < 0)
514
0
        return 0;
515
    /* Need to look for matching name */
516
0
    for (num = sk_X509_REVOKED_num(crl->crl.revoked); idx < num; idx++) {
517
0
        rev = sk_X509_REVOKED_value(crl->crl.revoked, idx);
518
0
        if (ASN1_INTEGER_cmp(&rev->serialNumber, serial))
519
0
            return 0;
520
0
        if (crl_revoked_issuer_match(crl, issuer, rev)) {
521
0
            if (ret)
522
0
                *ret = rev;
523
0
            if (rev->reason == CRL_REASON_REMOVE_FROM_CRL)
524
0
                return 2;
525
0
            return 1;
526
0
        }
527
0
    }
528
0
    return 0;
529
0
}
530
531
void X509_CRL_set_default_method(const X509_CRL_METHOD *meth)
532
0
{
533
0
    if (meth == NULL)
534
0
        default_crl_method = &int_crl_meth;
535
0
    else
536
0
        default_crl_method = meth;
537
0
}
538
539
X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init)(X509_CRL *crl),
540
    int (*crl_free)(X509_CRL *crl),
541
    int (*crl_lookup)(X509_CRL *crl,
542
        X509_REVOKED **ret,
543
        const ASN1_INTEGER *ser,
544
        const X509_NAME *issuer),
545
    int (*crl_verify)(X509_CRL *crl,
546
        EVP_PKEY *pk))
547
0
{
548
0
    X509_CRL_METHOD *m = OPENSSL_malloc(sizeof(*m));
549
550
0
    if (m == NULL)
551
0
        return NULL;
552
0
    m->crl_init = crl_init;
553
0
    m->crl_free = crl_free;
554
0
    m->crl_lookup = crl_lookup;
555
0
    m->crl_verify = crl_verify;
556
0
    m->flags = X509_CRL_METHOD_DYNAMIC;
557
0
    return m;
558
0
}
559
560
void X509_CRL_METHOD_free(X509_CRL_METHOD *m)
561
0
{
562
0
    if (m == NULL || !(m->flags & X509_CRL_METHOD_DYNAMIC))
563
0
        return;
564
0
    OPENSSL_free(m);
565
0
}
566
567
void X509_CRL_set_meth_data(X509_CRL *crl, void *dat)
568
0
{
569
0
    crl->meth_data = dat;
570
0
}
571
572
void *X509_CRL_get_meth_data(X509_CRL *crl)
573
0
{
574
0
    return crl->meth_data;
575
0
}
576
577
int ossl_x509_crl_set0_libctx(X509_CRL *x, OSSL_LIB_CTX *libctx,
578
    const char *propq)
579
0
{
580
0
    if (x != NULL) {
581
0
        x->libctx = libctx;
582
0
        OPENSSL_free(x->propq);
583
0
        x->propq = NULL;
584
0
        if (propq != NULL) {
585
0
            x->propq = OPENSSL_strdup(propq);
586
0
            if (x->propq == NULL)
587
0
                return 0;
588
0
        }
589
0
    }
590
0
    return 1;
591
0
}