1 | =pod
|
---|
2 |
|
---|
3 | =head1 NAME
|
---|
4 |
|
---|
5 | provider-signature - The signature library E<lt>-E<gt> provider functions
|
---|
6 |
|
---|
7 | =head1 SYNOPSIS
|
---|
8 |
|
---|
9 | =for openssl multiple includes
|
---|
10 |
|
---|
11 | #include <openssl/core_dispatch.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 *OSSL_FUNC_signature_newctx(void *provctx, const char *propq);
|
---|
22 | void OSSL_FUNC_signature_freectx(void *ctx);
|
---|
23 | void *OSSL_FUNC_signature_dupctx(void *ctx);
|
---|
24 |
|
---|
25 | /* Get the key types that a signature algorithm supports */
|
---|
26 | const char **OSSL_FUNC_signature_query_key_types(void);
|
---|
27 |
|
---|
28 | /* Signing */
|
---|
29 | int OSSL_FUNC_signature_sign_init(void *ctx, void *provkey,
|
---|
30 | const OSSL_PARAM params[]);
|
---|
31 | int OSSL_FUNC_signature_sign(void *ctx, unsigned char *sig, size_t *siglen,
|
---|
32 | size_t sigsize, const unsigned char *tbs, size_t tbslen);
|
---|
33 | int OSSL_FUNC_signature_sign_message_init(void *ctx, void *provkey,
|
---|
34 | const OSSL_PARAM params[]);
|
---|
35 | int OSSL_FUNC_signature_sign_message_update(void *ctx, const unsigned char *in,
|
---|
36 | size_t inlen);
|
---|
37 | int OSSL_FUNC_signature_sign_message_final(void *ctx, unsigned char *sig,
|
---|
38 | size_t *siglen, size_t sigsize);
|
---|
39 |
|
---|
40 | /* Verifying */
|
---|
41 | int OSSL_FUNC_signature_verify_init(void *ctx, void *provkey,
|
---|
42 | const OSSL_PARAM params[]);
|
---|
43 | int OSSL_FUNC_signature_verify(void *ctx, const unsigned char *sig, size_t siglen,
|
---|
44 | const unsigned char *tbs, size_t tbslen);
|
---|
45 | int OSSL_FUNC_signature_verify_message_init(void *ctx, void *provkey,
|
---|
46 | const OSSL_PARAM params[]);
|
---|
47 | int OSSL_FUNC_signature_verify_message_update(void *ctx, const unsigned char *in,
|
---|
48 | size_t inlen);
|
---|
49 | /*
|
---|
50 | * OSSL_FUNC_signature_verify_message_final requires that the signature to be
|
---|
51 | * verified is specified via a "signature" OSSL_PARAM, which is given with a
|
---|
52 | * previous call of OSSL_FUNC_signature_set_ctx_params().
|
---|
53 | */
|
---|
54 | int OSSL_FUNC_signature_verify_message_final(void *ctx);
|
---|
55 |
|
---|
56 | /* Verify Recover */
|
---|
57 | int OSSL_FUNC_signature_verify_recover_init(void *ctx, void *provkey,
|
---|
58 | const OSSL_PARAM params[]);
|
---|
59 | int OSSL_FUNC_signature_verify_recover(void *ctx, unsigned char *rout,
|
---|
60 | size_t *routlen, size_t routsize,
|
---|
61 | const unsigned char *sig, size_t siglen);
|
---|
62 |
|
---|
63 | /* Digest Sign */
|
---|
64 | int OSSL_FUNC_signature_digest_sign_init(void *ctx, const char *mdname,
|
---|
65 | void *provkey,
|
---|
66 | const OSSL_PARAM params[]);
|
---|
67 | int OSSL_FUNC_signature_digest_sign_update(void *ctx, const unsigned char *data,
|
---|
68 | size_t datalen);
|
---|
69 | int OSSL_FUNC_signature_digest_sign_final(void *ctx, unsigned char *sig,
|
---|
70 | size_t *siglen, size_t sigsize);
|
---|
71 | int OSSL_FUNC_signature_digest_sign(void *ctx,
|
---|
72 | unsigned char *sig, size_t *siglen,
|
---|
73 | size_t sigsize, const unsigned char *tbs,
|
---|
74 | size_t tbslen);
|
---|
75 |
|
---|
76 | /* Digest Verify */
|
---|
77 | int OSSL_FUNC_signature_digest_verify_init(void *ctx, const char *mdname,
|
---|
78 | void *provkey,
|
---|
79 | const OSSL_PARAM params[]);
|
---|
80 | int OSSL_FUNC_signature_digest_verify_update(void *ctx,
|
---|
81 | const unsigned char *data,
|
---|
82 | size_t datalen);
|
---|
83 | int OSSL_FUNC_signature_digest_verify_final(void *ctx, const unsigned char *sig,
|
---|
84 | size_t siglen);
|
---|
85 | int OSSL_FUNC_signature_digest_verify(void *ctx, const unsigned char *sig,
|
---|
86 | size_t siglen, const unsigned char *tbs,
|
---|
87 | size_t tbslen);
|
---|
88 |
|
---|
89 | /* Signature parameters */
|
---|
90 | int OSSL_FUNC_signature_get_ctx_params(void *ctx, OSSL_PARAM params[]);
|
---|
91 | const OSSL_PARAM *OSSL_FUNC_signature_gettable_ctx_params(void *ctx,
|
---|
92 | void *provctx);
|
---|
93 | int OSSL_FUNC_signature_set_ctx_params(void *ctx, const OSSL_PARAM params[]);
|
---|
94 | const OSSL_PARAM *OSSL_FUNC_signature_settable_ctx_params(void *ctx,
|
---|
95 | void *provctx);
|
---|
96 | /* MD parameters */
|
---|
97 | int OSSL_FUNC_signature_get_ctx_md_params(void *ctx, OSSL_PARAM params[]);
|
---|
98 | const OSSL_PARAM * OSSL_FUNC_signature_gettable_ctx_md_params(void *ctx);
|
---|
99 | int OSSL_FUNC_signature_set_ctx_md_params(void *ctx, const OSSL_PARAM params[]);
|
---|
100 | const OSSL_PARAM * OSSL_FUNC_signature_settable_ctx_md_params(void *ctx);
|
---|
101 |
|
---|
102 | =head1 DESCRIPTION
|
---|
103 |
|
---|
104 | This documentation is primarily aimed at provider authors. See L<provider(7)>
|
---|
105 | for further information.
|
---|
106 |
|
---|
107 | The signature (OSSL_OP_SIGNATURE) operation enables providers to implement
|
---|
108 | signature algorithms and make them available to applications via the API
|
---|
109 | functions L<EVP_PKEY_sign(3)>, L<EVP_PKEY_verify(3)>,
|
---|
110 | and L<EVP_PKEY_verify_recover(3)> (as well
|
---|
111 | as other related functions).
|
---|
112 |
|
---|
113 | All "functions" mentioned here are passed as function pointers between
|
---|
114 | F<libcrypto> and the provider in L<OSSL_DISPATCH(3)> arrays via
|
---|
115 | L<OSSL_ALGORITHM(3)> arrays that are returned by the provider's
|
---|
116 | provider_query_operation() function
|
---|
117 | (see L<provider-base(7)/Provider Functions>).
|
---|
118 |
|
---|
119 | All these "functions" have a corresponding function type definition
|
---|
120 | named B<OSSL_FUNC_{name}_fn>, and a helper function to retrieve the
|
---|
121 | function pointer from an L<OSSL_DISPATCH(3)> element named
|
---|
122 | B<OSSL_FUNC_{name}>.
|
---|
123 | For example, the "function" OSSL_FUNC_signature_newctx() has these:
|
---|
124 |
|
---|
125 | typedef void *(OSSL_FUNC_signature_newctx_fn)(void *provctx, const char *propq);
|
---|
126 | static ossl_inline OSSL_FUNC_signature_newctx_fn
|
---|
127 | OSSL_FUNC_signature_newctx(const OSSL_DISPATCH *opf);
|
---|
128 |
|
---|
129 | L<OSSL_DISPATCH(3)> arrays are indexed by numbers that are provided as
|
---|
130 | macros in L<openssl-core_dispatch.h(7)>, as follows:
|
---|
131 |
|
---|
132 | OSSL_FUNC_signature_newctx OSSL_FUNC_SIGNATURE_NEWCTX
|
---|
133 | OSSL_FUNC_signature_freectx OSSL_FUNC_SIGNATURE_FREECTX
|
---|
134 | OSSL_FUNC_signature_dupctx OSSL_FUNC_SIGNATURE_DUPCTX
|
---|
135 |
|
---|
136 | OSSL_FUNC_signature_query_key_types OSSL_FUNC_SIGNATURE_QUERY_KEY_TYPES
|
---|
137 |
|
---|
138 | OSSL_FUNC_signature_sign_init OSSL_FUNC_SIGNATURE_SIGN_INIT
|
---|
139 | OSSL_FUNC_signature_sign OSSL_FUNC_SIGNATURE_SIGN
|
---|
140 | OSSL_FUNC_signature_sign_message_init OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_INIT
|
---|
141 | OSSL_FUNC_signature_sign_message_update OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_UPDATE
|
---|
142 | OSSL_FUNC_signature_sign_message_final OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_FINAL
|
---|
143 |
|
---|
144 | OSSL_FUNC_signature_verify_init OSSL_FUNC_SIGNATURE_VERIFY_INIT
|
---|
145 | OSSL_FUNC_signature_verify OSSL_FUNC_SIGNATURE_VERIFY
|
---|
146 | OSSL_FUNC_signature_verify_message_init OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_INIT
|
---|
147 | OSSL_FUNC_signature_verify_message_update OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_UPDATE
|
---|
148 | OSSL_FUNC_signature_verify_message_final OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_FINAL
|
---|
149 |
|
---|
150 | OSSL_FUNC_signature_verify_recover_init OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT
|
---|
151 | OSSL_FUNC_signature_verify_recover OSSL_FUNC_SIGNATURE_VERIFY_RECOVER
|
---|
152 |
|
---|
153 | OSSL_FUNC_signature_digest_sign_init OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT
|
---|
154 | OSSL_FUNC_signature_digest_sign_update OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE
|
---|
155 | OSSL_FUNC_signature_digest_sign_final OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL
|
---|
156 | OSSL_FUNC_signature_digest_sign OSSL_FUNC_SIGNATURE_DIGEST_SIGN
|
---|
157 |
|
---|
158 | OSSL_FUNC_signature_digest_verify_init OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT
|
---|
159 | OSSL_FUNC_signature_digest_verify_update OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE
|
---|
160 | OSSL_FUNC_signature_digest_verify_final OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL
|
---|
161 | OSSL_FUNC_signature_digest_verify OSSL_FUNC_SIGNATURE_DIGEST_VERIFY
|
---|
162 |
|
---|
163 | OSSL_FUNC_signature_get_ctx_params OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS
|
---|
164 | OSSL_FUNC_signature_gettable_ctx_params OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS
|
---|
165 | OSSL_FUNC_signature_set_ctx_params OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS
|
---|
166 | OSSL_FUNC_signature_settable_ctx_params OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS
|
---|
167 |
|
---|
168 | OSSL_FUNC_signature_get_ctx_md_params OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS
|
---|
169 | OSSL_FUNC_signature_gettable_ctx_md_params OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS
|
---|
170 | OSSL_FUNC_signature_set_ctx_md_params OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS
|
---|
171 | OSSL_FUNC_signature_settable_ctx_md_params OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS
|
---|
172 |
|
---|
173 | A signature algorithm implementation may not implement all of these functions.
|
---|
174 | In order to be a consistent set of functions we must have at least a set of
|
---|
175 | context functions (OSSL_FUNC_signature_newctx and OSSL_FUNC_signature_freectx) as well as a
|
---|
176 | set of "signature" functions, i.e. at least one of:
|
---|
177 |
|
---|
178 | =over 4
|
---|
179 |
|
---|
180 | =item OSSL_FUNC_signature_sign_init and OSSL_FUNC_signature_sign
|
---|
181 |
|
---|
182 | =item OSSL_FUNC_signature_sign_message_init and OSSL_FUNC_signature_sign
|
---|
183 |
|
---|
184 | =item OSSL_FUNC_signature_sign_message_init, OSSL_FUNC_signature_sign_message_update and OSSL_FUNC_signature_sign_message_final
|
---|
185 |
|
---|
186 | =item OSSL_FUNC_signature_verify_init and OSSL_FUNC_signature_verify
|
---|
187 |
|
---|
188 | =item OSSL_FUNC_signature_verify_message_init and OSSL_FUNC_signature_verify
|
---|
189 |
|
---|
190 | =item OSSL_FUNC_signature_verify_message_init, OSSL_FUNC_signature_verify_message_update and OSSL_FUNC_signature_verify_message_final
|
---|
191 |
|
---|
192 | =item OSSL_FUNC_signature_verify_recover_init and OSSL_FUNC_signature_verify_recover
|
---|
193 |
|
---|
194 | =item OSSL_FUNC_signature_digest_sign_init, OSSL_FUNC_signature_digest_sign_update and OSSL_FUNC_signature_digest_sign_final
|
---|
195 |
|
---|
196 | =item OSSL_FUNC_signature_digest_verify_init, OSSL_FUNC_signature_digest_verify_update and OSSL_FUNC_signature_digest_verify_final
|
---|
197 |
|
---|
198 | =item OSSL_FUNC_signature_digest_sign_init and OSSL_FUNC_signature_digest_sign
|
---|
199 |
|
---|
200 | =item OSSL_FUNC_signature_digest_verify_init and OSSL_FUNC_signature_digest_verify
|
---|
201 |
|
---|
202 | =back
|
---|
203 |
|
---|
204 | OSSL_FUNC_signature_set_ctx_params and OSSL_FUNC_signature_settable_ctx_params are optional,
|
---|
205 | but if one of them is present then the other one must also be present. The same
|
---|
206 | applies to OSSL_FUNC_signature_get_ctx_params and OSSL_FUNC_signature_gettable_ctx_params, as
|
---|
207 | well as the "md_params" functions. The OSSL_FUNC_signature_dupctx function is optional.
|
---|
208 |
|
---|
209 | A signature algorithm must also implement some mechanism for generating,
|
---|
210 | loading or importing keys via the key management (OSSL_OP_KEYMGMT) operation.
|
---|
211 | See L<provider-keymgmt(7)> for further details.
|
---|
212 |
|
---|
213 | =head2 Context Management Functions
|
---|
214 |
|
---|
215 | OSSL_FUNC_signature_newctx() should create and return a pointer to a provider side
|
---|
216 | structure for holding context information during a signature operation.
|
---|
217 | A pointer to this context will be passed back in a number of the other signature
|
---|
218 | operation function calls.
|
---|
219 | The parameter I<provctx> is the provider context generated during provider
|
---|
220 | initialisation (see L<provider(7)>). The I<propq> parameter is a property query
|
---|
221 | string that may be (optionally) used by the provider during any "fetches" that
|
---|
222 | it may perform (if it performs any).
|
---|
223 |
|
---|
224 | OSSL_FUNC_signature_freectx() is passed a pointer to the provider side signature
|
---|
225 | context in the I<ctx> parameter.
|
---|
226 | This function should free any resources associated with that context.
|
---|
227 |
|
---|
228 | OSSL_FUNC_signature_dupctx() should duplicate the provider side signature context in
|
---|
229 | the I<ctx> parameter and return the duplicate copy.
|
---|
230 |
|
---|
231 | =head2 Signing Functions
|
---|
232 |
|
---|
233 | OSSL_FUNC_signature_sign_init() initialises a context for signing given a provider side
|
---|
234 | signature context in the I<ctx> parameter, and a pointer to a provider key object
|
---|
235 | in the I<provkey> parameter.
|
---|
236 | The I<params>, if not NULL, should be set on the context in a manner similar to
|
---|
237 | using OSSL_FUNC_signature_set_ctx_params().
|
---|
238 | The key object should have been previously generated, loaded or imported into
|
---|
239 | the provider using the key management (OSSL_OP_KEYMGMT) operation (see
|
---|
240 | L<provider-keymgmt(7)>).
|
---|
241 |
|
---|
242 | OSSL_FUNC_signature_sign() performs the actual signing itself.
|
---|
243 | A previously initialised signature context is passed in the I<ctx>
|
---|
244 | parameter.
|
---|
245 | The data to be signed is pointed to be the I<tbs> parameter which is I<tbslen>
|
---|
246 | bytes long.
|
---|
247 | Unless I<sig> is NULL, the signature should be written to the location pointed
|
---|
248 | to by the I<sig> parameter and it should not exceed I<sigsize> bytes in length.
|
---|
249 | The length of the signature should be written to I<*siglen>.
|
---|
250 | If I<sig> is NULL then the maximum length of the signature should be written to
|
---|
251 | I<*siglen>.
|
---|
252 |
|
---|
253 | =head2 Message Signing Functions
|
---|
254 |
|
---|
255 | These functions are suitable for providers that implement algorithms that
|
---|
256 | accumulate a full message and sign the result of that accumulation, such as
|
---|
257 | RSA-SHA256.
|
---|
258 |
|
---|
259 | OSSL_FUNC_signature_sign_message_init() initialises a context for signing a
|
---|
260 | message given a provider side signature context in the I<ctx> parameter, and a
|
---|
261 | pointer to a provider key object in the I<provkey> parameter.
|
---|
262 | The I<params>, if not NULL, should be set on the context in a manner similar to
|
---|
263 | using OSSL_FUNC_signature_set_ctx_params().
|
---|
264 | The key object should have been previously generated, loaded or imported into
|
---|
265 | the provider using the key management (OSSL_OP_KEYMGMT) operation (see
|
---|
266 | L<provider-keymgmt(7)>).
|
---|
267 |
|
---|
268 | OSSL_FUNC_signature_sign_message_update() gathers the data pointed at by
|
---|
269 | I<in>, which is I<inlen> bytes long.
|
---|
270 |
|
---|
271 | OSSL_FUNC_signature_sign_message_final() performs the actual signing on the
|
---|
272 | data that was gathered with OSSL_FUNC_signature_sign_message_update().
|
---|
273 |
|
---|
274 | OSSL_FUNC_signature_sign() can be used for one-shot signature calls. In that
|
---|
275 | case, I<tbs> is expected to be the whole message to be signed, I<tbslen> bytes
|
---|
276 | long.
|
---|
277 |
|
---|
278 | For both OSSL_FUNC_signature_sign_message_final() and OSSL_FUNC_signature_sign(),
|
---|
279 | if I<sig> is not NULL, the signature should be written to the location pointed
|
---|
280 | to by I<sig>, and it should not exceed I<sigsize> bytes in length.
|
---|
281 | The length of the signature should be written to I<*siglen>.
|
---|
282 | If I<sig> is NULL then the maximum length of the signature should be written to
|
---|
283 | I<*siglen>.
|
---|
284 |
|
---|
285 | =head2 Verify Functions
|
---|
286 |
|
---|
287 | OSSL_FUNC_signature_verify_init() initialises a context for verifying a signature given
|
---|
288 | a provider side signature context in the I<ctx> parameter, and a pointer to a
|
---|
289 | provider key object in the I<provkey> parameter.
|
---|
290 | The I<params>, if not NULL, should be set on the context in a manner similar to
|
---|
291 | using OSSL_FUNC_signature_set_ctx_params().
|
---|
292 | The key object should have been previously generated, loaded or imported into
|
---|
293 | the provider using the key management (OSSL_OP_KEYMGMT) operation (see
|
---|
294 | L<provider-keymgmt(7)>).
|
---|
295 |
|
---|
296 | OSSL_FUNC_signature_verify() performs the actual verification itself.
|
---|
297 | A previously initialised signature context is passed in the I<ctx> parameter.
|
---|
298 | The data that the signature covers is pointed to be the I<tbs> parameter which
|
---|
299 | is I<tbslen> bytes long.
|
---|
300 | The signature is pointed to by the I<sig> parameter which is I<siglen> bytes
|
---|
301 | long.
|
---|
302 |
|
---|
303 | =head2 Message Verify Functions
|
---|
304 |
|
---|
305 | These functions are suitable for providers that implement algorithms that
|
---|
306 | accumulate a full message and verify a signature on the result of that
|
---|
307 | accumulation, such as RSA-SHA256.
|
---|
308 |
|
---|
309 | OSSL_FUNC_signature_verify_message_init() initialises a context for verifying
|
---|
310 | a signature on a message given a provider side signature context in the I<ctx>
|
---|
311 | parameter, and a pointer to a provider key object in the I<provkey> parameter.
|
---|
312 | The I<params>, if not NULL, should be set on the context in a manner similar to
|
---|
313 | using OSSL_FUNC_signature_set_ctx_params().
|
---|
314 | The key object should have been previously generated, loaded or imported into
|
---|
315 | the provider using the key management (OSSL_OP_KEYMGMT) operation (see
|
---|
316 | L<provider-keymgmt(7)>).
|
---|
317 |
|
---|
318 | OSSL_FUNC_signature_verify_message_update() gathers the data pointed at by
|
---|
319 | I<in>, which is I<inlen> bytes long.
|
---|
320 |
|
---|
321 | OSSL_FUNC_signature_verify_message_final() performs the actual verification on
|
---|
322 | the data that was gathered with OSSL_FUNC_signature_verify_message_update().
|
---|
323 | The signature itself must have been passed through the "signature"
|
---|
324 | (B<OSSL_SIGNATURE_PARAM_SIGNATURE>) L<Signature parameter|/Signature parameters>
|
---|
325 | before this function is called.
|
---|
326 |
|
---|
327 | OSSL_FUNC_signature_verify() can be used for one-shot verification calls. In
|
---|
328 | that case, I<tbs> is expected to be the whole message to be verified on,
|
---|
329 | I<tbslen> bytes long.
|
---|
330 |
|
---|
331 | =head2 Verify Recover Functions
|
---|
332 |
|
---|
333 | OSSL_FUNC_signature_verify_recover_init() initialises a context for recovering the
|
---|
334 | signed data given a provider side signature context in the I<ctx> parameter, and
|
---|
335 | a pointer to a provider key object in the I<provkey> parameter.
|
---|
336 | The I<params>, if not NULL, should be set on the context in a manner similar to
|
---|
337 | using OSSL_FUNC_signature_set_ctx_params().
|
---|
338 | The key object should have been previously generated, loaded or imported into
|
---|
339 | the provider using the key management (OSSL_OP_KEYMGMT) operation (see
|
---|
340 | L<provider-keymgmt(7)>).
|
---|
341 |
|
---|
342 | OSSL_FUNC_signature_verify_recover() performs the actual verify recover itself.
|
---|
343 | A previously initialised signature context is passed in the I<ctx> parameter.
|
---|
344 | The signature is pointed to by the I<sig> parameter which is I<siglen> bytes
|
---|
345 | long.
|
---|
346 | Unless I<rout> is NULL, the recovered data should be written to the location
|
---|
347 | pointed to by I<rout> which should not exceed I<routsize> bytes in length.
|
---|
348 | The length of the recovered data should be written to I<*routlen>.
|
---|
349 | If I<rout> is NULL then the maximum size of the output buffer is written to
|
---|
350 | the I<routlen> parameter.
|
---|
351 |
|
---|
352 | =head2 Digest Sign Functions
|
---|
353 |
|
---|
354 | OSSL_FUNC_signature_digest_sign_init() initialises a context for signing given a
|
---|
355 | provider side signature context in the I<ctx> parameter, and a pointer to a
|
---|
356 | provider key object in the I<provkey> parameter.
|
---|
357 | The I<params>, if not NULL, should be set on the context in a manner similar to
|
---|
358 | using OSSL_FUNC_signature_set_ctx_params() and
|
---|
359 | OSSL_FUNC_signature_set_ctx_md_params().
|
---|
360 | The key object should have been
|
---|
361 | previously generated, loaded or imported into the provider using the
|
---|
362 | key management (OSSL_OP_KEYMGMT) operation (see L<provider-keymgmt(7)>).
|
---|
363 | The name of the digest to be used will be in the I<mdname> parameter.
|
---|
364 |
|
---|
365 | OSSL_FUNC_signature_digest_sign_update() provides data to be signed in the I<data>
|
---|
366 | parameter which should be of length I<datalen>. A previously initialised
|
---|
367 | signature context is passed in the I<ctx> parameter. This function may be called
|
---|
368 | multiple times to cumulatively add data to be signed.
|
---|
369 |
|
---|
370 | OSSL_FUNC_signature_digest_sign_final() finalises a signature operation previously
|
---|
371 | started through OSSL_FUNC_signature_digest_sign_init() and
|
---|
372 | OSSL_FUNC_signature_digest_sign_update() calls. Once finalised no more data will be
|
---|
373 | added through OSSL_FUNC_signature_digest_sign_update(). A previously initialised
|
---|
374 | signature context is passed in the I<ctx> parameter. Unless I<sig> is NULL, the
|
---|
375 | signature should be written to the location pointed to by the I<sig> parameter
|
---|
376 | and it should not exceed I<sigsize> bytes in length. The length of the signature
|
---|
377 | should be written to I<*siglen>. If I<sig> is NULL then the maximum length of
|
---|
378 | the signature should be written to I<*siglen>.
|
---|
379 |
|
---|
380 | OSSL_FUNC_signature_digest_sign() implements a "one shot" digest sign operation
|
---|
381 | previously started through OSSL_FUNC_signature_digeset_sign_init(). A previously
|
---|
382 | initialised signature context is passed in the I<ctx> parameter. The data to be
|
---|
383 | signed is in I<tbs> which should be I<tbslen> bytes long. Unless I<sig> is NULL,
|
---|
384 | the signature should be written to the location pointed to by the I<sig>
|
---|
385 | parameter and it should not exceed I<sigsize> bytes in length. The length of the
|
---|
386 | signature should be written to I<*siglen>. If I<sig> is NULL then the maximum
|
---|
387 | length of the signature should be written to I<*siglen>.
|
---|
388 |
|
---|
389 | =head2 Digest Verify Functions
|
---|
390 |
|
---|
391 | OSSL_FUNC_signature_digeset_verify_init() initialises a context for verifying given a
|
---|
392 | provider side verification context in the I<ctx> parameter, and a pointer to a
|
---|
393 | provider key object in the I<provkey> parameter.
|
---|
394 | The I<params>, if not NULL, should be set on the context in a manner similar to
|
---|
395 | OSSL_FUNC_signature_set_ctx_params() and
|
---|
396 | OSSL_FUNC_signature_set_ctx_md_params().
|
---|
397 | The key object should have been
|
---|
398 | previously generated, loaded or imported into the provider using the
|
---|
399 | key management (OSSL_OP_KEYMGMT) operation (see L<provider-keymgmt(7)>).
|
---|
400 | The name of the digest to be used will be in the I<mdname> parameter.
|
---|
401 |
|
---|
402 | OSSL_FUNC_signature_digest_verify_update() provides data to be verified in the I<data>
|
---|
403 | parameter which should be of length I<datalen>. A previously initialised
|
---|
404 | verification context is passed in the I<ctx> parameter. This function may be
|
---|
405 | called multiple times to cumulatively add data to be verified.
|
---|
406 |
|
---|
407 | OSSL_FUNC_signature_digest_verify_final() finalises a verification operation previously
|
---|
408 | started through OSSL_FUNC_signature_digest_verify_init() and
|
---|
409 | OSSL_FUNC_signature_digest_verify_update() calls. Once finalised no more data will be
|
---|
410 | added through OSSL_FUNC_signature_digest_verify_update(). A previously initialised
|
---|
411 | verification context is passed in the I<ctx> parameter. The signature to be
|
---|
412 | verified is in I<sig> which is I<siglen> bytes long.
|
---|
413 |
|
---|
414 | OSSL_FUNC_signature_digest_verify() implements a "one shot" digest verify operation
|
---|
415 | previously started through OSSL_FUNC_signature_digeset_verify_init(). A previously
|
---|
416 | initialised verification context is passed in the I<ctx> parameter. The data to be
|
---|
417 | verified is in I<tbs> which should be I<tbslen> bytes long. The signature to be
|
---|
418 | verified is in I<sig> which is I<siglen> bytes long.
|
---|
419 |
|
---|
420 | =head2 Signature parameters
|
---|
421 |
|
---|
422 | See L<OSSL_PARAM(3)> for further details on the parameters structure used by
|
---|
423 | the OSSL_FUNC_signature_get_ctx_params() and OSSL_FUNC_signature_set_ctx_params() functions.
|
---|
424 |
|
---|
425 | OSSL_FUNC_signature_get_ctx_params() gets signature parameters associated with the
|
---|
426 | given provider side signature context I<ctx> and stored them in I<params>.
|
---|
427 | Passing NULL for I<params> should return true.
|
---|
428 |
|
---|
429 | OSSL_FUNC_signature_set_ctx_params() sets the signature parameters associated with the
|
---|
430 | given provider side signature context I<ctx> to I<params>.
|
---|
431 | Any parameter settings are additional to any that were previously set.
|
---|
432 | Passing NULL for I<params> should return true.
|
---|
433 |
|
---|
434 | Common parameters currently recognised by built-in signature algorithms are as
|
---|
435 | follows.
|
---|
436 |
|
---|
437 | =over 4
|
---|
438 |
|
---|
439 | =item "digest" (B<OSSL_SIGNATURE_PARAM_DIGEST>) <UTF8 string>
|
---|
440 |
|
---|
441 | Get or sets the name of the digest algorithm used for the input to the
|
---|
442 | signature functions. It is required in order to calculate the "algorithm-id".
|
---|
443 |
|
---|
444 | =item "properties" (B<OSSL_SIGNATURE_PARAM_PROPERTIES>) <UTF8 string>
|
---|
445 |
|
---|
446 | Sets the name of the property query associated with the "digest" algorithm.
|
---|
447 | NULL is used if this optional value is not set.
|
---|
448 |
|
---|
449 | =back
|
---|
450 |
|
---|
451 | Note that when implementing a signature algorithm that gathers a full message,
|
---|
452 | like RSA-SHA256, the "digest" and "properties" parameters should not be used.
|
---|
453 | For such implementations, it's acceptable to simply ignore them if they happen
|
---|
454 | to be passed in a call to OSSL_FUNC_signature_set_ctx_params(). For such
|
---|
455 | implementations, however, it is not acceptable to have them in the B<OSSL_PARAM>
|
---|
456 | array that's returned by OSSL_FUNC_signature_settable_ctx_params().
|
---|
457 |
|
---|
458 | =over 4
|
---|
459 |
|
---|
460 | =item "signature" (B<OSSL_SIGNATURE_PARAM_SIGNATURE>) <octet string>
|
---|
461 |
|
---|
462 | Sets the signature to verify, specifically when
|
---|
463 | OSSL_FUNC_signature_verify_message_final() is used.
|
---|
464 |
|
---|
465 | =item "digest-size" (B<OSSL_SIGNATURE_PARAM_DIGEST_SIZE>) <unsigned integer>
|
---|
466 |
|
---|
467 | Gets or sets the output size of the digest algorithm used for the input to the
|
---|
468 | signature functions.
|
---|
469 | The length of the "digest-size" parameter should not exceed that of a B<size_t>.
|
---|
470 |
|
---|
471 | =item "algorithm-id" (B<OSSL_SIGNATURE_PARAM_ALGORITHM_ID>) <octet string>
|
---|
472 |
|
---|
473 | Gets the DER encoded AlgorithmIdentifier that corresponds to the combination of
|
---|
474 | signature algorithm and digest algorithm for the signature operation.
|
---|
475 |
|
---|
476 | =item "nonce-type" (B<OSSL_SIGNATURE_PARAM_NONCE_TYPE>) <unsigned integer>
|
---|
477 |
|
---|
478 | Set this to 1 to use deterministic digital signature generation with
|
---|
479 | ECDSA or DSA, as defined in RFC 6979 (see Section 3.2 "Generation of
|
---|
480 | k"). In this case, the "digest" parameter must be explicitly set
|
---|
481 | (otherwise, deterministic nonce generation will fail). Before using
|
---|
482 | deterministic digital signature generation, please read RFC 6979
|
---|
483 | Section 4 "Security Considerations". The default value for
|
---|
484 | "nonce-type" is 0 and results in a random value being used for the
|
---|
485 | nonce B<k> as defined in FIPS 186-4 Section 6.3 "Secret Number
|
---|
486 | Generation".
|
---|
487 |
|
---|
488 | =item "kat" (B<OSSL_SIGNATURE_PARAM_KAT>) <unsigned integer>
|
---|
489 |
|
---|
490 | Sets a flag to modify the sign operation to return an error if the initial
|
---|
491 | calculated signature is invalid.
|
---|
492 | In the normal mode of operation - new random values are chosen until the
|
---|
493 | signature operation succeeds.
|
---|
494 | By default it retries until a signature is calculated.
|
---|
495 | Setting the value to 0 causes the sign operation to retry,
|
---|
496 | otherwise the sign operation is only tried once and returns whether or not it
|
---|
497 | was successful.
|
---|
498 | Known answer tests can be performed if the random generator is overridden to
|
---|
499 | supply known values that either pass or fail.
|
---|
500 |
|
---|
501 | =back
|
---|
502 |
|
---|
503 | The following parameters are used by the OpenSSL FIPS provider:
|
---|
504 |
|
---|
505 | =over 4
|
---|
506 |
|
---|
507 | =item "fips-indicator" (B<OSSL_SIGNATURE_PARAM_FIPS_APPROVED_INDICATOR>) <integer>
|
---|
508 |
|
---|
509 | A getter that returns 1 if the operation is FIPS approved, or 0 otherwise.
|
---|
510 | This may be used after calling either the sign or verify final functions. It may
|
---|
511 | return 0 if either the "digest-check", "key-check", or "sign-check" are set to 0.
|
---|
512 |
|
---|
513 | =item "verify-message" (B<OSSL_SIGNATURE_PARAM_FIPS_VERIFY_MESSAGE> <integer>
|
---|
514 |
|
---|
515 | A getter that returns 1 if a signature verification operation acted on
|
---|
516 | a raw message, or 0 if it verified a predigested message. A value of 0
|
---|
517 | indicates likely non-approved usage of the FIPS provider. This flag is
|
---|
518 | set when any signature verification initialisation function is called.
|
---|
519 | It is also set to 1 when any signing operation is performed to signify
|
---|
520 | compliance. See FIPS 140-3 IG 2.4.B for further information.
|
---|
521 |
|
---|
522 | =item "key-check" (B<OSSL_SIGNATURE_PARAM_FIPS_KEY_CHECK>) <integer>
|
---|
523 |
|
---|
524 | If required this parameter should be set early via an init function
|
---|
525 | (e.g. OSSL_FUNC_signature_sign_init() or OSSL_FUNC_signature_verify_init()).
|
---|
526 | The default value of 1 causes an error during the init if the key is not FIPS
|
---|
527 | approved (e.g. The key has a security strength of less than 112 bits).
|
---|
528 | Setting this to 0 will ignore the error and set the approved "indicator" to 0.
|
---|
529 | This option breaks FIPS compliance if it causes the approved "fips-indicator"
|
---|
530 | to return 0.
|
---|
531 |
|
---|
532 | =item "digest-check" (B<OSSL_SIGNATURE_PARAM_FIPS_DIGEST_CHECK>) <integer>
|
---|
533 |
|
---|
534 | If required this parameter should be set before the signature digest is set.
|
---|
535 | The default value of 1 causes an error when the digest is set if the digest is
|
---|
536 | not FIPS approved (e.g. SHA1 is used for signing). Setting this to 0 will ignore
|
---|
537 | the error and set the approved "fips-indicator" to 0.
|
---|
538 | This option breaks FIPS compliance if it causes the approved "fips-indicator"
|
---|
539 | to return 0.
|
---|
540 |
|
---|
541 | =item "sign-check" (B<OSSL_SIGNATURE_PARAM_FIPS_SIGN_CHECK>) <integer>
|
---|
542 |
|
---|
543 | If required this parameter should be set early via an init function.
|
---|
544 | The default value of 1 causes an error when a signing algorithm is used. (This
|
---|
545 | is triggered by deprecated signing algorithms).
|
---|
546 | Setting this to 0 will ignore the error and set the approved "fips-indicator" to 0.
|
---|
547 | This option breaks FIPS compliance if it causes the approved "fips-indicator" to
|
---|
548 | return 0.
|
---|
549 |
|
---|
550 | =item "sign-x931-pad-check" (B<OSSL_SIGNATURE_PARAM_FIPS_SIGN_X931_PAD_CHECK>) <integer>
|
---|
551 |
|
---|
552 | If required this parameter should be set before the padding mode is set.
|
---|
553 | The default value of 1 causes an error if the padding mode is set to X9.31 padding
|
---|
554 | for a RSA signing operation. Setting this to 0 will ignore the error and set the
|
---|
555 | approved "fips-indicator" to 0.
|
---|
556 | This option breaks FIPS compliance if it causes the approved "fips-indicator"
|
---|
557 | to return 0.
|
---|
558 |
|
---|
559 | =back
|
---|
560 |
|
---|
561 | OSSL_FUNC_signature_gettable_ctx_params() and OSSL_FUNC_signature_settable_ctx_params() get a
|
---|
562 | constant L<OSSL_PARAM(3)> array that describes the gettable and settable parameters,
|
---|
563 | i.e. parameters that can be used with OSSL_FUNC_signature_get_ctx_params() and
|
---|
564 | OSSL_FUNC_signature_set_ctx_params() respectively.
|
---|
565 |
|
---|
566 | =head2 MD parameters
|
---|
567 |
|
---|
568 | See L<OSSL_PARAM(3)> for further details on the parameters structure used by
|
---|
569 | the OSSL_FUNC_signature_get_md_ctx_params() and OSSL_FUNC_signature_set_md_ctx_params()
|
---|
570 | functions.
|
---|
571 |
|
---|
572 | OSSL_FUNC_signature_get_md_ctx_params() gets digest parameters associated with the
|
---|
573 | given provider side digest signature context I<ctx> and stores them in I<params>.
|
---|
574 | Passing NULL for I<params> should return true.
|
---|
575 |
|
---|
576 | OSSL_FUNC_signature_set_ms_ctx_params() sets the digest parameters associated with the
|
---|
577 | given provider side digest signature context I<ctx> to I<params>.
|
---|
578 | Any parameter settings are additional to any that were previously set.
|
---|
579 | Passing NULL for I<params> should return true.
|
---|
580 |
|
---|
581 | Parameters currently recognised by built-in signature algorithms are the same
|
---|
582 | as those for built-in digest algorithms. See
|
---|
583 | L<provider-digest(7)/Digest Parameters> for further information.
|
---|
584 |
|
---|
585 | OSSL_FUNC_signature_gettable_md_ctx_params() and OSSL_FUNC_signature_settable_md_ctx_params()
|
---|
586 | get a constant L<OSSL_PARAM(3)> array that describes the gettable and settable
|
---|
587 | digest parameters, i.e. parameters that can be used with
|
---|
588 | OSSL_FUNC_signature_get_md_ctx_params() and OSSL_FUNC_signature_set_md_ctx_params()
|
---|
589 | respectively.
|
---|
590 |
|
---|
591 | =head1 RETURN VALUES
|
---|
592 |
|
---|
593 | OSSL_FUNC_signature_newctx() and OSSL_FUNC_signature_dupctx() should return the newly created
|
---|
594 | provider side signature context, or NULL on failure.
|
---|
595 |
|
---|
596 | OSSL_FUNC_signature_gettable_ctx_params(), OSSL_FUNC_signature_settable_ctx_params(),
|
---|
597 | OSSL_FUNC_signature_gettable_md_ctx_params() and OSSL_FUNC_signature_settable_md_ctx_params(),
|
---|
598 | return the gettable or settable parameters in a constant L<OSSL_PARAM(3)> array.
|
---|
599 |
|
---|
600 | All other functions should return 1 for success or 0 on error.
|
---|
601 |
|
---|
602 | =head1 SEE ALSO
|
---|
603 |
|
---|
604 | L<provider(7)>
|
---|
605 |
|
---|
606 | =head1 HISTORY
|
---|
607 |
|
---|
608 | The provider SIGNATURE interface was introduced in OpenSSL 3.0.
|
---|
609 | The Signature Parameters "fips-indicator", "key-check" and "digest-check"
|
---|
610 | were added in OpenSSL 3.4.
|
---|
611 |
|
---|
612 | =head1 COPYRIGHT
|
---|
613 |
|
---|
614 | Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved.
|
---|
615 |
|
---|
616 | Licensed under the Apache License 2.0 (the "License"). You may not use
|
---|
617 | this file except in compliance with the License. You can obtain a copy
|
---|
618 | in the file LICENSE in the source distribution or at
|
---|
619 | L<https://www.openssl.org/source/license.html>.
|
---|
620 |
|
---|
621 | =cut
|
---|