xref: /openssl/doc/man3/OSSL_STORE_INFO.pod (revision 7ed6de99)
1=pod
2
3=head1 NAME
4
5OSSL_STORE_INFO, OSSL_STORE_INFO_get_type, OSSL_STORE_INFO_get0_NAME,
6OSSL_STORE_INFO_get0_NAME_description,
7OSSL_STORE_INFO_get0_PARAMS, OSSL_STORE_INFO_get0_PUBKEY,
8OSSL_STORE_INFO_get0_PKEY, OSSL_STORE_INFO_get0_CERT, OSSL_STORE_INFO_get0_CRL,
9OSSL_STORE_INFO_get1_NAME, OSSL_STORE_INFO_get1_NAME_description,
10OSSL_STORE_INFO_get1_PARAMS, OSSL_STORE_INFO_get1_PUBKEY,
11OSSL_STORE_INFO_get1_PKEY, OSSL_STORE_INFO_get1_CERT, OSSL_STORE_INFO_get1_CRL,
12OSSL_STORE_INFO_type_string, OSSL_STORE_INFO_free,
13OSSL_STORE_INFO_new_NAME, OSSL_STORE_INFO_set0_NAME_description,
14OSSL_STORE_INFO_new_PARAMS, OSSL_STORE_INFO_new_PUBKEY,
15OSSL_STORE_INFO_new_PKEY, OSSL_STORE_INFO_new_CERT, OSSL_STORE_INFO_new_CRL,
16OSSL_STORE_INFO_new, OSSL_STORE_INFO_get0_data
17- Functions to manipulate OSSL_STORE_INFO objects
18
19=head1 SYNOPSIS
20
21 #include <openssl/store.h>
22
23 typedef struct ossl_store_info_st OSSL_STORE_INFO;
24
25 int OSSL_STORE_INFO_get_type(const OSSL_STORE_INFO *store_info);
26 const char *OSSL_STORE_INFO_get0_NAME(const OSSL_STORE_INFO *store_info);
27 char *OSSL_STORE_INFO_get1_NAME(const OSSL_STORE_INFO *store_info);
28 const char *OSSL_STORE_INFO_get0_NAME_description(const OSSL_STORE_INFO
29                                                   *store_info);
30 char *OSSL_STORE_INFO_get1_NAME_description(const OSSL_STORE_INFO *store_info);
31 EVP_PKEY *OSSL_STORE_INFO_get0_PARAMS(const OSSL_STORE_INFO *store_info);
32 EVP_PKEY *OSSL_STORE_INFO_get1_PARAMS(const OSSL_STORE_INFO *store_info);
33 EVP_PKEY *OSSL_STORE_INFO_get0_PUBKEY(const OSSL_STORE_INFO *info);
34 EVP_PKEY *OSSL_STORE_INFO_get1_PUBKEY(const OSSL_STORE_INFO *info);
35 EVP_PKEY *OSSL_STORE_INFO_get0_PKEY(const OSSL_STORE_INFO *store_info);
36 EVP_PKEY *OSSL_STORE_INFO_get1_PKEY(const OSSL_STORE_INFO *store_info);
37 X509 *OSSL_STORE_INFO_get0_CERT(const OSSL_STORE_INFO *store_info);
38 X509 *OSSL_STORE_INFO_get1_CERT(const OSSL_STORE_INFO *store_info);
39 X509_CRL *OSSL_STORE_INFO_get0_CRL(const OSSL_STORE_INFO *store_info);
40 X509_CRL *OSSL_STORE_INFO_get1_CRL(const OSSL_STORE_INFO *store_info);
41
42 const char *OSSL_STORE_INFO_type_string(int type);
43
44 void OSSL_STORE_INFO_free(OSSL_STORE_INFO *store_info);
45
46 OSSL_STORE_INFO *OSSL_STORE_INFO_new_NAME(char *name);
47 int OSSL_STORE_INFO_set0_NAME_description(OSSL_STORE_INFO *info, char *desc);
48 OSSL_STORE_INFO *OSSL_STORE_INFO_new_PARAMS(DSA *dsa_params);
49 OSSL_STORE_INFO *OSSL_STORE_INFO_new_PUBKEY(EVP_PKEY *pubkey);
50 OSSL_STORE_INFO *OSSL_STORE_INFO_new_PKEY(EVP_PKEY *pkey);
51 OSSL_STORE_INFO *OSSL_STORE_INFO_new_CERT(X509 *x509);
52 OSSL_STORE_INFO *OSSL_STORE_INFO_new_CRL(X509_CRL *crl);
53
54 OSSL_STORE_INFO *OSSL_STORE_INFO_new(int type, void *data);
55 void *OSSL_STORE_INFO_get0_data(int type, const OSSL_STORE_INFO *info);
56
57=head1 DESCRIPTION
58
59These functions are primarily useful for applications to retrieve
60supported objects from B<OSSL_STORE_INFO> objects and for scheme specific
61loaders to create B<OSSL_STORE_INFO> holders.
62
63=head2 Types
64
65B<OSSL_STORE_INFO> is an opaque type that's just an intermediary holder for
66the objects that have been retrieved by OSSL_STORE_load() and similar functions.
67Supported OpenSSL type object can be extracted using one of
68STORE_INFO_get0_<TYPE>() where <TYPE> can be NAME, PARAMS, PKEY, CERT, or CRL.
69The life time of this extracted object is as long as the life time of
70the B<OSSL_STORE_INFO> it was extracted from, so care should be taken not
71to free the latter too early.
72As an alternative, STORE_INFO_get1_<TYPE>() extracts a duplicate (or the
73same object with its reference count increased), which can be used
74after the containing B<OSSL_STORE_INFO> has been freed.
75The object returned by STORE_INFO_get1_<TYPE>() must be freed separately
76by the caller.
77See L</SUPPORTED OBJECTS> for more information on the types that are supported.
78
79=head2 Functions
80
81OSSL_STORE_INFO_get_type() takes a B<OSSL_STORE_INFO> and returns the STORE
82type number for the object inside.
83
84STORE_INFO_get_type_string() takes a STORE type number and returns a
85short string describing it.
86
87OSSL_STORE_INFO_get0_NAME(), OSSL_STORE_INFO_get0_NAME_description(),
88OSSL_STORE_INFO_get0_PARAMS(), OSSL_STORE_INFO_get0_PUBKEY(),
89OSSL_STORE_INFO_get0_PKEY(), OSSL_STORE_INFO_get0_CERT(),
90OSSL_STORE_INFO_get0_CRL()
91all take a B<OSSL_STORE_INFO> and return the object it holds if the
92B<OSSL_STORE_INFO> type (as returned by OSSL_STORE_INFO_get_type())
93matches the function, otherwise NULL.
94
95OSSL_STORE_INFO_get1_NAME(), OSSL_STORE_INFO_get1_NAME_description(),
96OSSL_STORE_INFO_get1_PARAMS(), OSSL_STORE_INFO_get1_PUBKEY(),
97OSSL_STORE_INFO_get1_PKEY(), OSSL_STORE_INFO_get1_CERT() and
98OSSL_STORE_INFO_get1_CRL()
99all take a B<OSSL_STORE_INFO> and return a duplicate the object it
100holds if the B<OSSL_STORE_INFO> type (as returned by
101OSSL_STORE_INFO_get_type()) matches the function, otherwise NULL.
102
103OSSL_STORE_INFO_free() frees a B<OSSL_STORE_INFO> and its contained type.
104If the argument is NULL, nothing is done.
105
106OSSL_STORE_INFO_new_NAME() , OSSL_STORE_INFO_new_PARAMS(),
107, OSSL_STORE_INFO_new_PUBKEY(), OSSL_STORE_INFO_new_PKEY(),
108OSSL_STORE_INFO_new_CERT() and OSSL_STORE_INFO_new_CRL()
109create a B<OSSL_STORE_INFO> object to hold the given input object.
110On success the input object is consumed.
111
112Additionally, for B<OSSL_STORE_INFO_NAME> objects,
113OSSL_STORE_INFO_set0_NAME_description() can be used to add an extra
114description.
115This description is meant to be human readable and should be used for
116information printout.
117
118OSSL_STORE_INFO_new() creates a B<OSSL_STORE_INFO> with an arbitrary I<type>
119number and I<data> structure.  It's the responsibility of the caller to
120define type numbers other than the ones defined by F<< <openssl/store.h> >>,
121and to handle freeing the associated data structure on their own.
122I<Using type numbers that are defined by F<< <openssl/store.h> >> may cause
123undefined behaviours, including crashes>.
124
125OSSL_STORE_INFO_get0_data() returns the data pointer that was passed to
126OSSL_STORE_INFO_new() if I<type> matches the type number in I<info>.
127
128OSSL_STORE_INFO_new() and OSSL_STORE_INFO_get0_data() may be useful for
129applications that define their own STORE data, but must be used with care.
130
131=head1 SUPPORTED OBJECTS
132
133Currently supported object types are:
134
135=over 4
136
137=item OSSL_STORE_INFO_NAME
138
139A name is exactly that, a name.
140It's like a name in a directory, but formatted as a complete URI.
141For example, the path in URI C<file:/foo/bar/> could include a file
142named C<cookie.pem>, and in that case, the returned B<OSSL_STORE_INFO_NAME>
143object would have the URI C<file:/foo/bar/cookie.pem>, which can be
144used by the application to get the objects in that file.
145This can be applied to all schemes that can somehow support a listing
146of object URIs.
147
148For C<file:> URIs that are used without the explicit scheme, the
149returned name will be the path of each object, so if C</foo/bar> was
150given and that path has the file C<cookie.pem>, the name
151C</foo/bar/cookie.pem> will be returned.
152
153The returned URI is considered canonical and must be unique and permanent
154for the storage where the object (or collection of objects) resides.
155Each loader is responsible for ensuring that it only returns canonical
156URIs.
157However, it's possible that certain schemes allow an object (or collection
158thereof) to be reached with alternative URIs; just because one URI is
159canonical doesn't mean that other variants can't be used.
160
161At the discretion of the loader that was used to get these names, an
162extra description may be attached as well.
163
164=item OSSL_STORE_INFO_PARAMS
165
166Key parameters.
167
168=item OSSL_STORE_INFO_PKEY
169
170A keypair or just a private key (possibly with key parameters).
171
172=item OSSL_STORE_INFO_PUBKEY
173
174A public key (possibly with key parameters).
175
176=item OSSL_STORE_INFO_CERT
177
178An X.509 certificate.
179
180=item OSSL_STORE_INFO_CRL
181
182A X.509 certificate revocation list.
183
184=back
185
186=head1 RETURN VALUES
187
188OSSL_STORE_INFO_get_type() returns the STORE type number of the given
189B<OSSL_STORE_INFO>.
190There is no error value.
191
192OSSL_STORE_INFO_get0_NAME(), OSSL_STORE_INFO_get0_NAME_description(),
193OSSL_STORE_INFO_get0_PARAMS(), OSSL_STORE_INFO_get0_PKEY(),
194OSSL_STORE_INFO_get0_CERT() and OSSL_STORE_INFO_get0_CRL() all return
195a pointer to the OpenSSL object on success, NULL otherwise.
196
197OSSL_STORE_INFO_get1_NAME(), OSSL_STORE_INFO_get1_NAME_description(),
198OSSL_STORE_INFO_get1_PARAMS(), OSSL_STORE_INFO_get1_PKEY(),
199OSSL_STORE_INFO_get1_CERT() and OSSL_STORE_INFO_get1_CRL() all return
200a pointer to a duplicate of the OpenSSL object on success, NULL otherwise.
201
202OSSL_STORE_INFO_type_string() returns a string on success, or NULL on
203failure.
204
205OSSL_STORE_INFO_new_NAME(), OSSL_STORE_INFO_new_PARAMS(),
206OSSL_STORE_INFO_new_PKEY(), OSSL_STORE_INFO_new_CERT() and
207OSSL_STORE_INFO_new_CRL() return a B<OSSL_STORE_INFO>
208pointer on success, or NULL on failure.
209
210OSSL_STORE_INFO_set0_NAME_description() returns 1 on success, or 0 on
211failure.
212
213=head1 SEE ALSO
214
215L<ossl_store(7)>, L<OSSL_STORE_open(3)>, L<OSSL_STORE_register_loader(3)>
216
217=head1 HISTORY
218
219The OSSL_STORE API was added in OpenSSL 1.1.1.
220
221The OSSL_STORE_INFO_PUBKEY object type was added in OpenSSL 3.0.
222
223=head1 COPYRIGHT
224
225Copyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
226
227Licensed under the Apache License 2.0 (the "License").  You may not use
228this file except in compliance with the License.  You can obtain a copy
229in the file LICENSE in the source distribution or at
230L<https://www.openssl.org/source/license.html>.
231
232=cut
233