Add documentation for the BIO_s_mem pecularities
[openssl.git] / doc / man3 / OSSL_PROVIDER.pod
1 =pod
2
3 =head1 NAME
4
5 OSSL_PROVIDER, OSSL_PROVIDER_load, OSSL_PROVIDER_unload,
6 OSSL_PROVIDER_get_param_types, OSSL_PROVIDER_get_params,
7 OSSL_PROVIDER_add_builtin - provider routines
8
9 =head1 SYNOPSIS
10
11  #include <openssl/provider.h>
12
13  typedef struct ossl_provider_st OSSL_PROVIDER;
14
15  OSSL_PROVIDER *OSSL_PROVIDER_load(OPENSSL_CTX *, const char *name);
16  int OSSL_PROVIDER_unload(OSSL_PROVIDER *prov);
17
18  const OSSL_ITEM *OSSL_PROVIDER_get_param_types(OSSL_PROVIDER *prov);
19  int OSSL_PROVIDER_get_params(OSSL_PROVIDER *prov, const OSSL_PARAM params[]);
20
21  int OSSL_PROVIDER_add_builtin(OPENSSL_CTX *, const char *name,
22                                ossl_provider_init_fn *init_fn);
23
24 =head1 DESCRIPTION
25
26 B<OSSL_PROVIDER> is a type that holds internal information about
27 implementation providers (see L<provider(7)> for information on what a
28 provider is).
29 A provider can be built in to the application or the OpenSSL
30 libraries, or can be a loadable module.
31 The functions described here handle both forms.
32
33 =head2 Functions
34
35 OSSL_PROVIDER_add_builtin() is used to add a built in provider to
36 B<OSSL_PROVIDER> store in the given library context, by associating a
37 provider name with a provider initialization function.
38 This name can then be used with OSSL_PROVIDER_load().
39
40 OSSL_PROVIDER_load() loads and initializes a provider.
41 This may simply initialize a provider that was previously added with
42 OSSL_PROVIDER_add_builtin() and run its given initialization function,
43 or load a provider module with the given name and run its provider
44 entry point, C<OSSL_provider_init>.
45
46 OSSL_PROVIDER_unload() unloads the given provider.
47 For a provider added with OSSL_PROVIDER_add_builtin(), this simply
48 runs its teardown function.
49
50 OSSL_PROVIDER_get_param_types() is used to get a provider parameter
51 descriptor set as an B<OSSL_ITEM> array.
52 Each element is a tuple of an B<OSSL_PARAM> parameter type and a name
53 in form of a C string.
54 See L<openssl-core.h(7)> for more information on B<OSSL_ITEM> and
55 parameter types.
56
57 OSSL_PROVIDER_get_params() is used to get provider parameter values.
58 The caller must prepare the B<OSSL_PARAM> array before calling this
59 function, and the variables acting as buffers for this parameter array
60 should be filled with data when it returns successfully.
61
62 =head1 RETURN VALUES
63
64 OSSL_PROVIDER_add() returns 1 on success, or 0 on error.
65
66 OSSL_PROVIDER_load() returns a pointer to a provider object on
67 success, or B<NULL> on error.
68
69 OSSL_PROVIDER_unload() returns 1 on success, or 0 on error.
70
71 OSSL_PROVIDER_get_param_types() returns a pointer to a constant array
72 of B<OSSL_ITEM>, or NULL if none is provided.
73
74 OSSL_PROVIDER_get_params() returns 1 on success, or 0 on error.
75
76 =head1 EXAMPLES
77
78 This demonstrates how to load the provider module "foo" and ask for
79 its build number.
80
81  OSSL_PROVIDER *prov = NULL;
82  const char *build = NULL;
83  size_t built_l = 0;
84  const OSSL_PARAM request[] = {
85      { "build", OSSL_PARAM_UTF8_STRING_PTR, &build, 0, &build_l },
86      { NULL, 0, NULL, 0, NULL }
87  };
88
89  if ((prov = OSSL_PROVIDER_load(NULL, "foo")) != NULL
90      && OSSL_PROVIDER_get_params(prov, request))
91      printf("Provider 'foo' build %s\n", build);
92  else
93      ERR_print_errors_fp(stderr);
94
95 =head1 SEE ALSO
96
97 L<openssl-core.h(7)>, L<provider(7)>
98
99 =head1 HISTORY
100
101 The type and functions described here were added in OpenSSL 3.0.
102
103 =head1 COPYRIGHT
104
105 Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
106
107 Licensed under the Apache License 2.0 (the "License").  You may not use
108 this file except in compliance with the License.  You can obtain a copy
109 in the file LICENSE in the source distribution or at
110 L<https://www.openssl.org/source/license.html>.
111
112 =cut