Coverage Report

Created: 2025-04-22 06:18

/src/openssl/crypto/x509/x509_meth.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2018-2020 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 <time.h>
12
#include <errno.h>
13
14
#include "internal/cryptlib.h"
15
#include <openssl/asn1.h>
16
#include <openssl/x509.h>
17
#include <openssl/types.h>
18
#include "x509_local.h"
19
20
X509_LOOKUP_METHOD *X509_LOOKUP_meth_new(const char *name)
21
0
{
22
0
    X509_LOOKUP_METHOD *method = OPENSSL_zalloc(sizeof(X509_LOOKUP_METHOD));
23
24
0
    if (method != NULL) {
25
0
        method->name = OPENSSL_strdup(name);
26
0
        if (method->name == NULL) {
27
0
            ERR_raise(ERR_LIB_X509, ERR_R_MALLOC_FAILURE);
28
0
            goto err;
29
0
        }
30
0
    }
31
32
0
    return method;
33
34
0
err:
35
0
    OPENSSL_free(method);
36
0
    return NULL;
37
0
}
38
39
void X509_LOOKUP_meth_free(X509_LOOKUP_METHOD *method)
40
0
{
41
0
    if (method != NULL)
42
0
        OPENSSL_free(method->name);
43
0
    OPENSSL_free(method);
44
0
}
45
46
int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method,
47
                                  int (*new_item) (X509_LOOKUP *ctx))
48
0
{
49
0
    method->new_item = new_item;
50
0
    return 1;
51
0
}
52
53
int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD* method))
54
    (X509_LOOKUP *ctx)
55
0
{
56
0
    return method->new_item;
57
0
}
58
59
int X509_LOOKUP_meth_set_free(
60
    X509_LOOKUP_METHOD *method,
61
    void (*free_fn) (X509_LOOKUP *ctx))
62
0
{
63
0
    method->free = free_fn;
64
0
    return 1;
65
0
}
66
67
void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD* method))
68
    (X509_LOOKUP *ctx)
69
0
{
70
0
    return method->free;
71
0
}
72
73
int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method,
74
                              int (*init) (X509_LOOKUP *ctx))
75
0
{
76
0
    method->init = init;
77
0
    return 1;
78
0
}
79
80
int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD* method))
81
    (X509_LOOKUP *ctx)
82
0
{
83
0
    return method->init;
84
0
}
85
86
int X509_LOOKUP_meth_set_shutdown(
87
    X509_LOOKUP_METHOD *method,
88
    int (*shutdown) (X509_LOOKUP *ctx))
89
0
{
90
0
    method->shutdown = shutdown;
91
0
    return 1;
92
0
}
93
94
int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD* method))
95
    (X509_LOOKUP *ctx)
96
0
{
97
0
    return method->shutdown;
98
0
}
99
100
int X509_LOOKUP_meth_set_ctrl(
101
    X509_LOOKUP_METHOD *method,
102
    X509_LOOKUP_ctrl_fn ctrl)
103
0
{
104
0
    method->ctrl = ctrl;
105
0
    return 1;
106
0
}
107
108
X509_LOOKUP_ctrl_fn X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD *method)
109
0
{
110
0
    return method->ctrl;
111
0
}
112
113
int X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD *method,
114
    X509_LOOKUP_get_by_subject_fn get_by_subject)
115
0
{
116
0
    method->get_by_subject = get_by_subject;
117
0
    return 1;
118
0
}
119
120
X509_LOOKUP_get_by_subject_fn X509_LOOKUP_meth_get_get_by_subject(
121
    const X509_LOOKUP_METHOD *method)
122
0
{
123
0
    return method->get_by_subject;
124
0
}
125
126
127
int X509_LOOKUP_meth_set_get_by_issuer_serial(X509_LOOKUP_METHOD *method,
128
    X509_LOOKUP_get_by_issuer_serial_fn get_by_issuer_serial)
129
0
{
130
0
    method->get_by_issuer_serial = get_by_issuer_serial;
131
0
    return 1;
132
0
}
133
134
X509_LOOKUP_get_by_issuer_serial_fn
135
    X509_LOOKUP_meth_get_get_by_issuer_serial(const X509_LOOKUP_METHOD *method)
136
0
{
137
0
    return method->get_by_issuer_serial;
138
0
}
139
140
141
int X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD *method,
142
    X509_LOOKUP_get_by_fingerprint_fn get_by_fingerprint)
143
0
{
144
0
    method->get_by_fingerprint = get_by_fingerprint;
145
0
    return 1;
146
0
}
147
148
X509_LOOKUP_get_by_fingerprint_fn X509_LOOKUP_meth_get_get_by_fingerprint(
149
    const X509_LOOKUP_METHOD *method)
150
0
{
151
0
    return method->get_by_fingerprint;
152
0
}
153
154
int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method,
155
                                      X509_LOOKUP_get_by_alias_fn get_by_alias)
156
0
{
157
0
    method->get_by_alias = get_by_alias;
158
0
    return 1;
159
0
}
160
161
X509_LOOKUP_get_by_alias_fn X509_LOOKUP_meth_get_get_by_alias(
162
    const X509_LOOKUP_METHOD *method)
163
0
{
164
0
    return method->get_by_alias;
165
0
}
166