deprecate EC precomputation functionality
[openssl.git] / doc / man3 / X509_LOOKUP.pod
1 =pod
2
3 =head1 NAME
4
5 X509_LOOKUP, X509_LOOKUP_TYPE,
6 X509_LOOKUP_new, X509_LOOKUP_free, X509_LOOKUP_init,
7 X509_LOOKUP_shutdown,
8 X509_LOOKUP_set_method_data, X509_LOOKUP_get_method_data,
9 X509_LOOKUP_ctrl,
10 X509_LOOKUP_load_file, X509_LOOKUP_add_dir, X509_LOOKUP_add_store,
11 X509_LOOKUP_load_store,
12 X509_LOOKUP_get_store, X509_LOOKUP_by_subject,
13 X509_LOOKUP_by_issuer_serial, X509_LOOKUP_by_fingerprint,
14 X509_LOOKUP_by_alias
15 - OpenSSL certificate lookup mechanisms
16
17 =head1 SYNOPSIS
18
19  #include <openssl/x509_vfy.h>
20
21  typedef x509_lookup_st X509_LOOKUP;
22
23  typedef enum X509_LOOKUP_TYPE;
24
25  X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method);
26  int X509_LOOKUP_init(X509_LOOKUP *ctx);
27  int X509_LOOKUP_shutdown(X509_LOOKUP *ctx);
28  void X509_LOOKUP_free(X509_LOOKUP *ctx);
29
30  int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data);
31  void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx);
32
33  int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
34                       long argl, char **ret);
35  int X509_LOOKUP_load_file(X509_LOOKUP *ctx, char *name, long type);
36  int X509_LOOKUP_add_dir(X509_LOOKUP *ctx, char *name, long type);
37  int X509_LOOKUP_add_store(X509_LOOKUP *ctx, char *uri);
38  int X509_LOOKUP_load_store(X509_LOOKUP *ctx, char *uri);
39
40  X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx);
41
42  int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
43                             const X509_NAME *name, X509_OBJECT *ret);
44  int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
45                                   const X509_NAME *name,
46                                   const ASN1_INTEGER *serial, X509_OBJECT *ret);
47  int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
48                                 const unsigned char *bytes, int len,
49                                 X509_OBJECT *ret);
50  int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
51                           const char *str, int len, X509_OBJECT *ret);
52
53 =head1 DESCRIPTION
54
55 The B<X509_LOOKUP> structure holds the information needed to look up
56 certificates and CRLs according to an associated L<X509_LOOKUP_METHOD(3)>.
57 Multiple B<X509_LOOKUP> instances can be added to an L<X509_STORE(3)>
58 to enable lookup in that store.
59
60 X509_LOOKUP_new() creates a new B<X509_LOOKUP> using the given lookup
61 I<method>.
62 It can also be created by calling L<X509_STORE_add_lookup(3)>, which
63 will associate a B<X509_STORE> with the lookup mechanism.
64
65 X509_LOOKUP_init() initializes the internal state and resources as
66 needed by the given B<X509_LOOKUP> to do its work.
67
68 X509_LOOKUP_shutdown() tears down the internal state and resources of
69 the given B<X509_LOOKUP>.
70
71 X509_LOOKUP_free() destructs the given B<X509_LOOKUP>.
72
73 X509_LOOKUP_set_method_data() and X509_LOOKUP_get_method_data()
74 associates and retrieves a pointer to application data to and from the
75 given B<X509_LOOKUP>, respectively.
76
77 X509_LOOKUP_ctrl() is used to set or get additional data to or from a
78 B<X509_LOOKUP> structure or its associated L<X509_LOOKUP_METHOD(3)>.
79 The arguments of the control command are passed via I<argc> and I<argl>,
80 its return value via I<*ret>.
81 The meaning of the arguments depends on the I<cmd> number of the
82 control command. In general, this function is not called directly, but
83 wrapped by a macro call, see below.
84 The control I<cmd>s known to OpenSSL are discussed in more depth
85 in L</Control Commands>.
86
87 X509_LOOKUP_load_file() passes a filename to be loaded immediately
88 into the associated B<X509_STORE>.
89 I<type> indicates what type of object is expected.
90 This can only be used with a lookup using the implementation
91 L<X509_LOOKUP_file(3)>.
92
93 X509_LOOKUP_add_dir() passes a directory specification from which
94 certificates and CRLs are loaded on demand into the associated
95 B<X509_STORE>.
96 I<type> indicates what type of object is expected.
97 This can only be used with a lookup using the implementation
98 L<X509_LOOKUP_hash_dir(3)>.
99
100 X509_LOOKUP_add_store() passes a URI for a directory-like structure
101 from which containers with certificates and CRLs are loaded on demand
102 into the associated B<X509_STORE>.
103 X509_LOOKUP_load_store() passes a URI for a single container from
104 which certificates and CRLs are immediately loaded into the associated
105 B<X509_STORE>.
106 These functions can only be used with a lookup using the
107 implementation L<X509_LOOKUP_store(3)>.
108
109 X509_LOOKUP_load_file(), X509_LOOKUP_add_dir(),
110 X509_LOOKUP_add_store(), and X509_LOOKUP_load_store() are implemented
111 as macros that use X509_LOOKUP_ctrl().
112
113 X509_LOOKUP_by_subject(), X509_LOOKUP_by_issuer_serial(),
114 X509_LOOKUP_by_fingerprint(), and X509_LOOKUP_by_alias() look up
115 certificates and CRLs in the L<X509_STORE(3)> associated with the
116 B<X509_LOOKUP> using different criteria, where the looked up object is
117 stored in I<ret>.
118 Some of the underlying B<X509_LOOKUP_METHOD>s will also cache objects
119 matching the criteria in the associated B<X509_STORE>, which makes it
120 possible to handle cases where the criteria have more than one hit.
121
122 =head2 Control Commands
123
124 The B<X509_LOOKUP_METHOD>s built into OpenSSL recognise the following
125 X509_LOOKUP_ctrl() I<cmd>s:
126
127 =over 4
128
129 =item B<X509_L_FILE_LOAD>
130
131 This is the command that X509_LOOKUP_load_file() uses.
132 The filename is passed in I<argc>, and the type in I<argl>.
133
134 =item B<X509_L_ADD_DIR>
135
136 This is the command that X509_LOOKUP_add_dir() uses.
137 The directory specification is passed in I<argc>, and the type in
138 I<argl>.
139
140 =item B<X509_L_ADD_STORE>
141
142 This is the command that X509_LOOKUP_add_store() uses.
143 The URI is passed in I<argc>.
144
145 =item B<X509_L_LOAD_STORE>
146
147 This is the command that X509_LOOKUP_load_store() uses.
148 The URI is passed in I<argc>.
149
150 =back
151
152 =head1 RETURN VALUES
153
154 X509_LOOKUP_new() returns a B<X509_LOOKUP> pointer when successful,
155 or NULL on error.
156
157 X509_LOOKUP_init() and X509_LOOKUP_shutdown() return 1 on success, or
158 0 on error.
159
160 X509_LOOKUP_ctrl() returns -1 if the B<X509_LOOKUP> doesn't have an
161 associated B<X509_LOOKUP_METHOD>, or 1 if the X<509_LOOKUP_METHOD>
162 doesn't have a control function.
163 Otherwise, it returns what the control function in the
164 B<X509_LOOKUP_METHOD> returns, which is usually 1 on success and 0 in
165 error.
166
167 X509_LOOKUP_get_store() returns a B<X509_STORE> pointer if there is
168 one, otherwise NULL.
169
170 X509_LOOKUP_by_subject(), X509_LOOKUP_by_issuer_serial(),
171 X509_LOOKUP_by_fingerprint(), and X509_LOOKUP_by_alias() all return 0
172 if there is no B<X509_LOOKUP_METHOD> or that method doesn't implement
173 the corresponding function.
174 Otherwise, it returns what the corresponding function in the
175 B<X509_LOOKUP_METHOD> returns, which is usually 1 on success and 0 in
176 error.
177
178 =head1 SEE ALSO
179
180 L<X509_LOOKUP_METHOD(3)>, L<X509_STORE(3)>
181
182 =head1 COPYRIGHT
183
184 Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
185
186 Licensed under the Apache License 2.0 (the "License").  You may not use
187 this file except in compliance with the License.  You can obtain a copy
188 in the file LICENSE in the source distribution or at
189 L<https://www.openssl.org/source/license.html>.
190
191 =cut