Debian Codegraph @

debian/rust-vendor/openssl-src/openssl/crypto/x509/x509_meth.c

raw
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 {
22 X509_LOOKUP_METHOD *method = OPENSSL_zalloc(sizeof(X509_LOOKUP_METHOD));
23
24 if (method != NULL) {
25 method->name = OPENSSL_strdup(name);
26 if (method->name == NULL)
27 goto err;
28 }
29
30 return method;
31
32 err:
33 OPENSSL_free(method);
34 return NULL;
35 }
36
37 void X509_LOOKUP_meth_free(X509_LOOKUP_METHOD *method)
38 {
39 if (method != NULL)
40 OPENSSL_free(method->name);
41 OPENSSL_free(method);
42 }
43
44 int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD *method,
45 int (*new_item)(X509_LOOKUP *ctx))
46 {
47 method->new_item = new_item;
48 return 1;
49 }
50
51 int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD *method))(X509_LOOKUP *ctx)
52 {
53 return method->new_item;
54 }
55
56 int X509_LOOKUP_meth_set_free(
57 X509_LOOKUP_METHOD *method,
58 void (*free_fn)(X509_LOOKUP *ctx))
59 {
60 method->free = free_fn;
61 return 1;
62 }
63
64 void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD *method))(X509_LOOKUP *ctx)
65 {
66 return method->free;
67 }
68
69 int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD *method,
70 int (*init)(X509_LOOKUP *ctx))
71 {
72 method->init = init;
73 return 1;
74 }
75
76 int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD *method))(X509_LOOKUP *ctx)
77 {
78 return method->init;
79 }
80
81 int X509_LOOKUP_meth_set_shutdown(
82 X509_LOOKUP_METHOD *method,
83 int (*shutdown)(X509_LOOKUP *ctx))
84 {
85 method->shutdown = shutdown;
86 return 1;
87 }
88
89 int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD *method))(X509_LOOKUP *ctx)
90 {
91 return method->shutdown;
92 }
93
94 int X509_LOOKUP_meth_set_ctrl(
95 X509_LOOKUP_METHOD *method,
96 X509_LOOKUP_ctrl_fn ctrl)
97 {
98 method->ctrl = ctrl;
99 return 1;
100 }
101
102 X509_LOOKUP_ctrl_fn X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD *method)
103 {
104 return method->ctrl;
105 }
106
107 int X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD *method,
108 X509_LOOKUP_get_by_subject_fn get_by_subject)
109 {
110 method->get_by_subject = get_by_subject;
111 return 1;
112 }
113
114 X509_LOOKUP_get_by_subject_fn X509_LOOKUP_meth_get_get_by_subject(
115 const X509_LOOKUP_METHOD *method)
116 {
117 return method->get_by_subject;
118 }
119
120 int X509_LOOKUP_meth_set_get_by_issuer_serial(X509_LOOKUP_METHOD *method,
121 X509_LOOKUP_get_by_issuer_serial_fn get_by_issuer_serial)
122 {
123 method->get_by_issuer_serial = get_by_issuer_serial;
124 return 1;
125 }
126
127 X509_LOOKUP_get_by_issuer_serial_fn
128 X509_LOOKUP_meth_get_get_by_issuer_serial(const X509_LOOKUP_METHOD *method)
129 {
130 return method->get_by_issuer_serial;
131 }
132
133 int X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD *method,
134 X509_LOOKUP_get_by_fingerprint_fn get_by_fingerprint)
135 {
136 method->get_by_fingerprint = get_by_fingerprint;
137 return 1;
138 }
139
140 X509_LOOKUP_get_by_fingerprint_fn X509_LOOKUP_meth_get_get_by_fingerprint(
141 const X509_LOOKUP_METHOD *method)
142 {
143 return method->get_by_fingerprint;
144 }
145
146 int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD *method,
147 X509_LOOKUP_get_by_alias_fn get_by_alias)
148 {
149 method->get_by_alias = get_by_alias;
150 return 1;
151 }
152
153 X509_LOOKUP_get_by_alias_fn X509_LOOKUP_meth_get_get_by_alias(
154 const X509_LOOKUP_METHOD *method)
155 {
156 return method->get_by_alias;
157 }