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