2 * Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
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
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"
20 X509_LOOKUP_METHOD
*X509_LOOKUP_meth_new(const char *name
)
22 X509_LOOKUP_METHOD
*method
= OPENSSL_zalloc(sizeof(X509_LOOKUP_METHOD
));
25 method
->name
= OPENSSL_strdup(name
);
26 if (method
->name
== NULL
)
37 void X509_LOOKUP_meth_free(X509_LOOKUP_METHOD
*method
)
40 OPENSSL_free(method
->name
);
44 int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD
*method
,
45 int (*new_item
) (X509_LOOKUP
*ctx
))
47 method
->new_item
= new_item
;
51 int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD
* method
))
54 return method
->new_item
;
57 int X509_LOOKUP_meth_set_free(
58 X509_LOOKUP_METHOD
*method
,
59 void (*free_fn
) (X509_LOOKUP
*ctx
))
61 method
->free
= free_fn
;
65 void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD
* method
))
71 int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD
*method
,
72 int (*init
) (X509_LOOKUP
*ctx
))
78 int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD
* method
))
84 int X509_LOOKUP_meth_set_shutdown(
85 X509_LOOKUP_METHOD
*method
,
86 int (*shutdown
) (X509_LOOKUP
*ctx
))
88 method
->shutdown
= shutdown
;
92 int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD
* method
))
95 return method
->shutdown
;
98 int X509_LOOKUP_meth_set_ctrl(
99 X509_LOOKUP_METHOD
*method
,
100 X509_LOOKUP_ctrl_fn ctrl
)
106 X509_LOOKUP_ctrl_fn
X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD
*method
)
111 int X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD
*method
,
112 X509_LOOKUP_get_by_subject_fn get_by_subject
)
114 method
->get_by_subject
= get_by_subject
;
118 X509_LOOKUP_get_by_subject_fn
X509_LOOKUP_meth_get_get_by_subject(
119 const X509_LOOKUP_METHOD
*method
)
121 return method
->get_by_subject
;
125 int X509_LOOKUP_meth_set_get_by_issuer_serial(X509_LOOKUP_METHOD
*method
,
126 X509_LOOKUP_get_by_issuer_serial_fn get_by_issuer_serial
)
128 method
->get_by_issuer_serial
= get_by_issuer_serial
;
132 X509_LOOKUP_get_by_issuer_serial_fn
133 X509_LOOKUP_meth_get_get_by_issuer_serial(const X509_LOOKUP_METHOD
*method
)
135 return method
->get_by_issuer_serial
;
139 int X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD
*method
,
140 X509_LOOKUP_get_by_fingerprint_fn get_by_fingerprint
)
142 method
->get_by_fingerprint
= get_by_fingerprint
;
146 X509_LOOKUP_get_by_fingerprint_fn
X509_LOOKUP_meth_get_get_by_fingerprint(
147 const X509_LOOKUP_METHOD
*method
)
149 return method
->get_by_fingerprint
;
152 int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD
*method
,
153 X509_LOOKUP_get_by_alias_fn get_by_alias
)
155 method
->get_by_alias
= get_by_alias
;
159 X509_LOOKUP_get_by_alias_fn
X509_LOOKUP_meth_get_get_by_alias(
160 const X509_LOOKUP_METHOD
*method
)
162 return method
->get_by_alias
;