]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man7/provider-signature.pod
Enable DH "keys" which only contain domain parameters
[thirdparty/openssl.git] / doc / man7 / provider-signature.pod
CommitLineData
4f62f5d9
MC
1=pod
2
3=head1 NAME
4
5provider-signature - The signature library E<lt>-E<gt> provider functions
6
7=head1 SYNOPSIS
8
9=for comment multiple includes
10
11 #include <openssl/core_numbers.h>
12 #include <openssl/core_names.h>
13
14 /*
15 * None of these are actual functions, but are displayed like this for
16 * the function signatures for functions that are offered as function
17 * pointers in OSSL_DISPATCH arrays.
18 */
19
20 /* Context management */
21 void *OP_signature_newctx(void *provctx);
22 void OP_signature_freectx(void *ctx);
23 void *OP_signature_dupctx(void *ctx);
24
25 /* Signing */
26 int OP_signature_sign_init(void *ctx, void *provkey);
27 int OP_signature_sign(void *ctx, unsigned char *sig, size_t *siglen,
28 size_t sigsize, const unsigned char *tbs, size_t tbslen);
29
30 /* Verifying */
31 int OP_signature_verify_init(void *ctx, void *provkey);
32 int OP_signature_verify(void *ctx, const unsigned char *sig, size_t siglen,
33 const unsigned char *tbs, size_t tbslen);
34
35 /* Verify Recover */
36 int OP_signature_verify_recover_init(void *ctx, void *provkey);
37 int OP_signature_verify_recover(void *ctx, unsigned char *rout,
38 size_t *routlen, size_t routsize,
39 const unsigned char *sig, size_t siglen);
40
41 /* Signature parameters */
42 int OP_signature_set_params(void *ctx, const OSSL_PARAM params[]);
43
44
45=head1 DESCRIPTION
46
47This documentation is primarily aimed at provider authors. See L<provider(7)>
48for further information.
49
50The signature (OSSL_OP_SIGNATURE) operation enables providers to implement
51signature algorithms and make them available to applications via the API
52functions L<EVP_PKEY_sign_init_ex(3)>, L<EVP_PKEY_sign(3)>,
53L<EVP_PKEY_verify_init_ex(3)>, L<EVP_PKEY_verify(3)>,
54L<EVP_PKEY_verify_recover_init_ex(3)> and L<EVP_PKEY_verify_recover(3)> (as well
55as other related functions).
56
57All "functions" mentioned here are passed as function pointers between
58F<libcrypto> and the provider in B<OSSL_DISPATCH> arrays via
59B<OSSL_ALGORITHM> arrays that are returned by the provider's
60provider_query_operation() function
61(see L<provider-base(7)/Provider Functions>).
62
63All these "functions" have a corresponding function type definition
64named B<OSSL_{name}_fn>, and a helper function to retrieve the
65function pointer from an B<OSSL_DISPATCH> element named
66B<OSSL_get_{name}>.
67For example, the "function" OP_signature_newctx() has these:
68
69 typedef void *(OSSL_OP_signature_newctx_fn)(void *provctx);
70 static ossl_inline OSSL_OP_signature_newctx_fn
71 OSSL_get_OP_signature_newctx(const OSSL_DISPATCH *opf);
72
73B<OSSL_DISPATCH> arrays are indexed by numbers that are provided as
74macros in L<openssl-core_numbers.h(7)>, as follows:
75
76 OP_signature_newctx OSSL_FUNC_SIGNATURE_NEWCTX
77 OP_signature_freectx OSSL_FUNC_SIGNATURE_FREECTX
78 OP_signature_dupctx OSSL_FUNC_SIGNATURE_DUPCTX
79
80 OP_signature_sign_init OSSL_FUNC_SIGNATURE_SIGN_INIT
81 OP_signature_sign OSSL_FUNC_SIGNATURE_SIGN
82
83 OP_signature_verify_init OSSL_FUNC_SIGNATURE_VERIFY_INIT
84 OP_signature_verify OSSL_FUNC_SIGNATURE_VERIFY
85
86 OP_signature_verify_recover_init OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT
87 OP_signature_verify_recover OSSL_FUNC_SIGNATURE_VERIFY_RECOVER
88
89 OP_signature_set_params OSSL_FUNC_SIGNATURE_SET_PARAMS
90
91A signature algorithm implementation may not implement all of these functions.
92In order to be a consistent set of functions a provider must implement
93OP_signature_newctx and OP_signature_freectx.
94It must also implement both of OP_signature_sign_init and OP_signature_sign,
95or both of OP_signature_verify_init and OP_signature_verify, or both of
96OP_signature_verify_recover_init and OP_signature_verify_recover.
97All other functions are optional.
98
99A signature algorithm must also implement some mechanism for generating,
100loading or importing keys via the key management (OSSL_OP_KEYMGMT) operation.
101See L<provider-keymgmt(7)> for further details.
102
103=head2 Context Management Functions
104
105OP_signature_newctx() should create and return a pointer to a provider side
106structure for holding context information during a signature operation.
107A pointer to this context will be passed back in a number of the other signature
108operation function calls.
109The parameter B<provctx> is the provider context generated during provider
110initialisation (see L<provider(3)>).
111
112OP_signature_freectx() is passed a pointer to the provider side signature
113context in the B<ctx> parameter.
114This function should free any resources associated with that context.
115
116OP_signature_dupctx() should duplicate the provider side signature context in
117the B<ctx> parameter and return the duplicate copy.
118
119=head2 Signing Functions
120
121OP_signature_sign_init() initialises a context for signing given a provider side
122signature context in the B<ctx> parameter, and a pointer to a provider key object
123in the B<provkey> parameter.
124The key object should have been previously generated, loaded or imported into
125the provider using the key management (OSSL_OP_KEYMGMT) operation (see
126provider-keymgmt(7)>.
127
128OP_signature_sign() performs the actual signing itself.
129A previously initialised signature context is passed in the B<ctx>
130parameter.
131The data to be signed is pointed to be the B<tbs> parameter which is B<tbslen>
132bytes long.
133Unless B<sig> is NULL, the signature should be written to the location pointed
134to by the B<sig> parameter and it should not exceed B<sigsize> bytes in length.
135The length of the signature should be written to B<*siglen>.
136If B<sig> is NULL then the maximum length of the signature should be written to
137B<*siglen>.
138
139=head2 Verify Functions
140
141OP_signature_verify_init() initialises a context for verifying a signature given
142a provider side signature context in the B<ctx> parameter, and a pointer to a
143provider key object in the B<provkey> parameter.
144The key object should have been previously generated, loaded or imported into
145the provider using the key management (OSSL_OP_KEYMGMT) operation (see
146provider-keymgmt(7)>.
147
148OP_signature_verify() performs the actual verification itself.
149A previously initialised signature context is passed in the B<ctx> parameter.
150The data that the signature covers is pointed to be the B<tbs> parameter which
151is B<tbslen> bytes long.
152The signature is pointed to by the B<sig> parameter which is B<siglen> bytes
153long.
154
155=head2 Verify Recover Functions
156
157OP_signature_verify_recover_init() initialises a context for recovering the
158signed data given a provider side signature context in the B<ctx> parameter, and
159a pointer to a provider key object in the B<provkey> parameter.
160The key object should have been previously generated, loaded or imported into
161the provider using the key management (OSSL_OP_KEYMGMT) operation (see
162provider-keymgmt(7)>.
163
164OP_signature_verify_recover() performs the actual verify recover itself.
165A previously initialised signature context is passed in the B<ctx> parameter.
166The signature is pointed to by the B<sig> parameter which is B<siglen> bytes
167long.
168Unless B<rout> is NULL, the recovered data should be written to the location
169pointed to by B<rout> which should not exceed B<routsize> bytes in length.
170The length of the recovered data should be written to B<*routlen>.
171If B<rout> is B<NULL> then the maximum size of the output buffer is written to
172the B<routlen> parameter.
173
174=head2 Signature Parameters
175
176See L<OSSL_PARAM(3)> for further details on the parameters structure used by
177the OP_signature_set_params() function.
178
179OP_signature_set_params() sets signature parameters associated with the given
180provider side key exchange context B<ctx> to B<params>.
181Any parameter settings are additional to any that were previously set.
182
183Parameters currently recognised by built-in signature algorithms are as
184follows.
185Not all parameters are relevant to, or are understood by all signature
186algorithms:
187
188=over 4
189
190=item B<OSSL_SIGNATURE_PARAM_DIGEST> (UTF8 string)
191
192Sets the name of the digest algorithm used for the input to the signature
193functions.
194
195=item B<OSSL_SIGNATURE_PARAM_DIGEST_SIZE> (size_t)
196
197Sets the output size of the digest algorithm used for the input to the signature
198functions.
199
200=back
201
202=head1 RETURN VALUES
203
204OP_signature_newctx() and OP_signature_dupctx() should return the newly created
205provider side signature, or NULL on failure.
206
207OP_signature_sign_init(), OP_signature_sign(), OP_signature_verify_init(),
208OP_signature_verify(), OP_signature_verify_recover_init(),
209OP_signature_verify_recover() and OP_signature_set_params() should return 1 for
210success or 0 on error.
211
212=head1 SEE ALSO
213
214L<provider(7)>
215
216=head1 HISTORY
217
218The provider SIGNATURE interface was introduced in OpenSSL 3.0.
219
220=head1 COPYRIGHT
221
222Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
223
224Licensed under the Apache License 2.0 (the "License"). You may not use
225this file except in compliance with the License. You can obtain a copy
226in the file LICENSE in the source distribution or at
227L<https://www.openssl.org/source/license.html>.
228
229=cut