2 * Copyright 2018 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/ossl_typ.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
) {
27 X509err(X509_F_X509_LOOKUP_METH_NEW
, ERR_R_MALLOC_FAILURE
);
39 void X509_LOOKUP_meth_free(X509_LOOKUP_METHOD
*method
)
42 OPENSSL_free(method
->name
);
46 int X509_LOOKUP_meth_set_new_item(X509_LOOKUP_METHOD
*method
,
47 int (*new_item
) (X509_LOOKUP
*ctx
))
49 method
->new_item
= new_item
;
53 int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD
* method
))
56 return method
->new_item
;
59 int X509_LOOKUP_meth_set_free(
60 X509_LOOKUP_METHOD
*method
,
61 void (*free_fn
) (X509_LOOKUP
*ctx
))
63 method
->free
= free_fn
;
67 void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD
* method
))
73 int X509_LOOKUP_meth_set_init(X509_LOOKUP_METHOD
*method
,
74 int (*init
) (X509_LOOKUP
*ctx
))
80 int (*X509_LOOKUP_meth_get_init(const X509_LOOKUP_METHOD
* method
))
86 int X509_LOOKUP_meth_set_shutdown(
87 X509_LOOKUP_METHOD
*method
,
88 int (*shutdown
) (X509_LOOKUP
*ctx
))
90 method
->shutdown
= shutdown
;
94 int (*X509_LOOKUP_meth_get_shutdown(const X509_LOOKUP_METHOD
* method
))
97 return method
->shutdown
;
100 int X509_LOOKUP_meth_set_ctrl(
101 X509_LOOKUP_METHOD
*method
,
102 X509_LOOKUP_ctrl_fn ctrl
)
108 X509_LOOKUP_ctrl_fn
X509_LOOKUP_meth_get_ctrl(const X509_LOOKUP_METHOD
*method
)
113 int X509_LOOKUP_meth_set_get_by_subject(X509_LOOKUP_METHOD
*method
,
114 X509_LOOKUP_get_by_subject_fn get_by_subject
)
116 method
->get_by_subject
= get_by_subject
;
120 X509_LOOKUP_get_by_subject_fn
X509_LOOKUP_meth_get_get_by_subject(
121 const X509_LOOKUP_METHOD
*method
)
123 return method
->get_by_subject
;
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
)
130 method
->get_by_issuer_serial
= get_by_issuer_serial
;
134 X509_LOOKUP_get_by_issuer_serial_fn
135 X509_LOOKUP_meth_get_get_by_issuer_serial(const X509_LOOKUP_METHOD
*method
)
137 return method
->get_by_issuer_serial
;
141 int X509_LOOKUP_meth_set_get_by_fingerprint(X509_LOOKUP_METHOD
*method
,
142 X509_LOOKUP_get_by_fingerprint_fn get_by_fingerprint
)
144 method
->get_by_fingerprint
= get_by_fingerprint
;
148 X509_LOOKUP_get_by_fingerprint_fn
X509_LOOKUP_meth_get_get_by_fingerprint(
149 const X509_LOOKUP_METHOD
*method
)
151 return method
->get_by_fingerprint
;
154 int X509_LOOKUP_meth_set_get_by_alias(X509_LOOKUP_METHOD
*method
,
155 X509_LOOKUP_get_by_alias_fn get_by_alias
)
157 method
->get_by_alias
= get_by_alias
;
161 X509_LOOKUP_get_by_alias_fn
X509_LOOKUP_meth_get_get_by_alias(
162 const X509_LOOKUP_METHOD
*method
)
164 return method
->get_by_alias
;