xref: /freebsd/crypto/openssl/doc/man7/provider-signature.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1*b077aed3SPierre Pronchery=pod
2*b077aed3SPierre Pronchery
3*b077aed3SPierre Pronchery=head1 NAME
4*b077aed3SPierre Pronchery
5*b077aed3SPierre Proncheryprovider-signature - The signature library E<lt>-E<gt> provider functions
6*b077aed3SPierre Pronchery
7*b077aed3SPierre Pronchery=head1 SYNOPSIS
8*b077aed3SPierre Pronchery
9*b077aed3SPierre Pronchery=for openssl multiple includes
10*b077aed3SPierre Pronchery
11*b077aed3SPierre Pronchery #include <openssl/core_dispatch.h>
12*b077aed3SPierre Pronchery #include <openssl/core_names.h>
13*b077aed3SPierre Pronchery
14*b077aed3SPierre Pronchery /*
15*b077aed3SPierre Pronchery  * None of these are actual functions, but are displayed like this for
16*b077aed3SPierre Pronchery  * the function signatures for functions that are offered as function
17*b077aed3SPierre Pronchery  * pointers in OSSL_DISPATCH arrays.
18*b077aed3SPierre Pronchery  */
19*b077aed3SPierre Pronchery
20*b077aed3SPierre Pronchery /* Context management */
21*b077aed3SPierre Pronchery void *OSSL_FUNC_signature_newctx(void *provctx, const char *propq);
22*b077aed3SPierre Pronchery void OSSL_FUNC_signature_freectx(void *ctx);
23*b077aed3SPierre Pronchery void *OSSL_FUNC_signature_dupctx(void *ctx);
24*b077aed3SPierre Pronchery
25*b077aed3SPierre Pronchery /* Signing */
26*b077aed3SPierre Pronchery int OSSL_FUNC_signature_sign_init(void *ctx, void *provkey,
27*b077aed3SPierre Pronchery                                   const OSSL_PARAM params[]);
28*b077aed3SPierre Pronchery int OSSL_FUNC_signature_sign(void *ctx, unsigned char *sig, size_t *siglen,
29*b077aed3SPierre Pronchery                              size_t sigsize, const unsigned char *tbs, size_t tbslen);
30*b077aed3SPierre Pronchery
31*b077aed3SPierre Pronchery /* Verifying */
32*b077aed3SPierre Pronchery int OSSL_FUNC_signature_verify_init(void *ctx, void *provkey,
33*b077aed3SPierre Pronchery                                     const OSSL_PARAM params[]);
34*b077aed3SPierre Pronchery int OSSL_FUNC_signature_verify(void *ctx, const unsigned char *sig, size_t siglen,
35*b077aed3SPierre Pronchery                                const unsigned char *tbs, size_t tbslen);
36*b077aed3SPierre Pronchery
37*b077aed3SPierre Pronchery /* Verify Recover */
38*b077aed3SPierre Pronchery int OSSL_FUNC_signature_verify_recover_init(void *ctx, void *provkey,
39*b077aed3SPierre Pronchery                                             const OSSL_PARAM params[]);
40*b077aed3SPierre Pronchery int OSSL_FUNC_signature_verify_recover(void *ctx, unsigned char *rout,
41*b077aed3SPierre Pronchery                                        size_t *routlen, size_t routsize,
42*b077aed3SPierre Pronchery                                        const unsigned char *sig, size_t siglen);
43*b077aed3SPierre Pronchery
44*b077aed3SPierre Pronchery /* Digest Sign */
45*b077aed3SPierre Pronchery int OSSL_FUNC_signature_digest_sign_init(void *ctx, const char *mdname,
46*b077aed3SPierre Pronchery                                          void *provkey,
47*b077aed3SPierre Pronchery                                          const OSSL_PARAM params[]);
48*b077aed3SPierre Pronchery int OSSL_FUNC_signature_digest_sign_update(void *ctx, const unsigned char *data,
49*b077aed3SPierre Pronchery                                     size_t datalen);
50*b077aed3SPierre Pronchery int OSSL_FUNC_signature_digest_sign_final(void *ctx, unsigned char *sig,
51*b077aed3SPierre Pronchery                                           size_t *siglen, size_t sigsize);
52*b077aed3SPierre Pronchery int OSSL_FUNC_signature_digest_sign(void *ctx,
53*b077aed3SPierre Pronchery                              unsigned char *sigret, size_t *siglen,
54*b077aed3SPierre Pronchery                              size_t sigsize, const unsigned char *tbs,
55*b077aed3SPierre Pronchery                              size_t tbslen);
56*b077aed3SPierre Pronchery
57*b077aed3SPierre Pronchery /* Digest Verify */
58*b077aed3SPierre Pronchery int OSSL_FUNC_signature_digest_verify_init(void *ctx, const char *mdname,
59*b077aed3SPierre Pronchery                                            void *provkey,
60*b077aed3SPierre Pronchery                                            const OSSL_PARAM params[]);
61*b077aed3SPierre Pronchery int OSSL_FUNC_signature_digest_verify_update(void *ctx,
62*b077aed3SPierre Pronchery                                              const unsigned char *data,
63*b077aed3SPierre Pronchery                                              size_t datalen);
64*b077aed3SPierre Pronchery int OSSL_FUNC_signature_digest_verify_final(void *ctx, const unsigned char *sig,
65*b077aed3SPierre Pronchery                                      size_t siglen);
66*b077aed3SPierre Pronchery int OSSL_FUNC_signature_digest_verify(void *ctx, const unsigned char *sig,
67*b077aed3SPierre Pronchery                                size_t siglen, const unsigned char *tbs,
68*b077aed3SPierre Pronchery                                size_t tbslen);
69*b077aed3SPierre Pronchery
70*b077aed3SPierre Pronchery /* Signature parameters */
71*b077aed3SPierre Pronchery int OSSL_FUNC_signature_get_ctx_params(void *ctx, OSSL_PARAM params[]);
72*b077aed3SPierre Pronchery const OSSL_PARAM *OSSL_FUNC_signature_gettable_ctx_params(void *ctx,
73*b077aed3SPierre Pronchery                                                           void *provctx);
74*b077aed3SPierre Pronchery int OSSL_FUNC_signature_set_ctx_params(void *ctx, const OSSL_PARAM params[]);
75*b077aed3SPierre Pronchery const OSSL_PARAM *OSSL_FUNC_signature_settable_ctx_params(void *ctx,
76*b077aed3SPierre Pronchery                                                           void *provctx);
77*b077aed3SPierre Pronchery /* MD parameters */
78*b077aed3SPierre Pronchery int OSSL_FUNC_signature_get_ctx_md_params(void *ctx, OSSL_PARAM params[]);
79*b077aed3SPierre Pronchery const OSSL_PARAM * OSSL_FUNC_signature_gettable_ctx_md_params(void *ctx);
80*b077aed3SPierre Pronchery int OSSL_FUNC_signature_set_ctx_md_params(void *ctx, const OSSL_PARAM params[]);
81*b077aed3SPierre Pronchery const OSSL_PARAM * OSSL_FUNC_signature_settable_ctx_md_params(void *ctx);
82*b077aed3SPierre Pronchery
83*b077aed3SPierre Pronchery=head1 DESCRIPTION
84*b077aed3SPierre Pronchery
85*b077aed3SPierre ProncheryThis documentation is primarily aimed at provider authors. See L<provider(7)>
86*b077aed3SPierre Proncheryfor further information.
87*b077aed3SPierre Pronchery
88*b077aed3SPierre ProncheryThe signature (OSSL_OP_SIGNATURE) operation enables providers to implement
89*b077aed3SPierre Proncherysignature algorithms and make them available to applications via the API
90*b077aed3SPierre Proncheryfunctions L<EVP_PKEY_sign(3)>,
91*b077aed3SPierre ProncheryL<EVP_PKEY_verify(3)>,
92*b077aed3SPierre Proncheryand L<EVP_PKEY_verify_recover(3)> (as well
93*b077aed3SPierre Proncheryas other related functions).
94*b077aed3SPierre Pronchery
95*b077aed3SPierre ProncheryAll "functions" mentioned here are passed as function pointers between
96*b077aed3SPierre ProncheryF<libcrypto> and the provider in L<OSSL_DISPATCH(3)> arrays via
97*b077aed3SPierre ProncheryL<OSSL_ALGORITHM(3)> arrays that are returned by the provider's
98*b077aed3SPierre Proncheryprovider_query_operation() function
99*b077aed3SPierre Pronchery(see L<provider-base(7)/Provider Functions>).
100*b077aed3SPierre Pronchery
101*b077aed3SPierre ProncheryAll these "functions" have a corresponding function type definition
102*b077aed3SPierre Proncherynamed B<OSSL_FUNC_{name}_fn>, and a helper function to retrieve the
103*b077aed3SPierre Proncheryfunction pointer from an L<OSSL_DISPATCH(3)> element named
104*b077aed3SPierre ProncheryB<OSSL_FUNC_{name}>.
105*b077aed3SPierre ProncheryFor example, the "function" OSSL_FUNC_signature_newctx() has these:
106*b077aed3SPierre Pronchery
107*b077aed3SPierre Pronchery typedef void *(OSSL_FUNC_signature_newctx_fn)(void *provctx, const char *propq);
108*b077aed3SPierre Pronchery static ossl_inline OSSL_FUNC_signature_newctx_fn
109*b077aed3SPierre Pronchery     OSSL_FUNC_signature_newctx(const OSSL_DISPATCH *opf);
110*b077aed3SPierre Pronchery
111*b077aed3SPierre ProncheryL<OSSL_DISPATCH(3)> arrays are indexed by numbers that are provided as
112*b077aed3SPierre Proncherymacros in L<openssl-core_dispatch.h(7)>, as follows:
113*b077aed3SPierre Pronchery
114*b077aed3SPierre Pronchery OSSL_FUNC_signature_newctx                 OSSL_FUNC_SIGNATURE_NEWCTX
115*b077aed3SPierre Pronchery OSSL_FUNC_signature_freectx                OSSL_FUNC_SIGNATURE_FREECTX
116*b077aed3SPierre Pronchery OSSL_FUNC_signature_dupctx                 OSSL_FUNC_SIGNATURE_DUPCTX
117*b077aed3SPierre Pronchery
118*b077aed3SPierre Pronchery OSSL_FUNC_signature_sign_init              OSSL_FUNC_SIGNATURE_SIGN_INIT
119*b077aed3SPierre Pronchery OSSL_FUNC_signature_sign                   OSSL_FUNC_SIGNATURE_SIGN
120*b077aed3SPierre Pronchery
121*b077aed3SPierre Pronchery OSSL_FUNC_signature_verify_init            OSSL_FUNC_SIGNATURE_VERIFY_INIT
122*b077aed3SPierre Pronchery OSSL_FUNC_signature_verify                 OSSL_FUNC_SIGNATURE_VERIFY
123*b077aed3SPierre Pronchery
124*b077aed3SPierre Pronchery OSSL_FUNC_signature_verify_recover_init    OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT
125*b077aed3SPierre Pronchery OSSL_FUNC_signature_verify_recover         OSSL_FUNC_SIGNATURE_VERIFY_RECOVER
126*b077aed3SPierre Pronchery
127*b077aed3SPierre Pronchery OSSL_FUNC_signature_digest_sign_init       OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT
128*b077aed3SPierre Pronchery OSSL_FUNC_signature_digest_sign_update     OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE
129*b077aed3SPierre Pronchery OSSL_FUNC_signature_digest_sign_final      OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL
130*b077aed3SPierre Pronchery OSSL_FUNC_signature_digest_sign            OSSL_FUNC_SIGNATURE_DIGEST_SIGN
131*b077aed3SPierre Pronchery
132*b077aed3SPierre Pronchery OSSL_FUNC_signature_digest_verify_init     OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT
133*b077aed3SPierre Pronchery OSSL_FUNC_signature_digest_verify_update   OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE
134*b077aed3SPierre Pronchery OSSL_FUNC_signature_digest_verify_final    OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL
135*b077aed3SPierre Pronchery OSSL_FUNC_signature_digest_verify          OSSL_FUNC_SIGNATURE_DIGEST_VERIFY
136*b077aed3SPierre Pronchery
137*b077aed3SPierre Pronchery OSSL_FUNC_signature_get_ctx_params         OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS
138*b077aed3SPierre Pronchery OSSL_FUNC_signature_gettable_ctx_params    OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS
139*b077aed3SPierre Pronchery OSSL_FUNC_signature_set_ctx_params         OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS
140*b077aed3SPierre Pronchery OSSL_FUNC_signature_settable_ctx_params    OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS
141*b077aed3SPierre Pronchery
142*b077aed3SPierre Pronchery OSSL_FUNC_signature_get_ctx_md_params      OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS
143*b077aed3SPierre Pronchery OSSL_FUNC_signature_gettable_ctx_md_params OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS
144*b077aed3SPierre Pronchery OSSL_FUNC_signature_set_ctx_md_params      OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS
145*b077aed3SPierre Pronchery OSSL_FUNC_signature_settable_ctx_md_params OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS
146*b077aed3SPierre Pronchery
147*b077aed3SPierre ProncheryA signature algorithm implementation may not implement all of these functions.
148*b077aed3SPierre ProncheryIn order to be a consistent set of functions we must have at least a set of
149*b077aed3SPierre Proncherycontext functions (OSSL_FUNC_signature_newctx and OSSL_FUNC_signature_freectx) as well as a
150*b077aed3SPierre Proncheryset of "signature" functions, i.e. at least one of:
151*b077aed3SPierre Pronchery
152*b077aed3SPierre Pronchery=over 4
153*b077aed3SPierre Pronchery
154*b077aed3SPierre Pronchery=item OSSL_FUNC_signature_sign_init and OSSL_FUNC_signature_sign
155*b077aed3SPierre Pronchery
156*b077aed3SPierre Pronchery=item OSSL_FUNC_signature_verify_init and OSSL_FUNC_signature_verify
157*b077aed3SPierre Pronchery
158*b077aed3SPierre Pronchery=item OSSL_FUNC_signature_verify_recover_init and OSSL_FUNC_signature_verify_recover
159*b077aed3SPierre Pronchery
160*b077aed3SPierre Pronchery=item OSSL_FUNC_signature_digest_sign_init, OSSL_FUNC_signature_digest_sign_update and OSSL_FUNC_signature_digest_sign_final
161*b077aed3SPierre Pronchery
162*b077aed3SPierre Pronchery=item OSSL_FUNC_signature_digest_verify_init, OSSL_FUNC_signature_digest_verify_update and OSSL_FUNC_signature_digest_verify_final
163*b077aed3SPierre Pronchery
164*b077aed3SPierre Pronchery=item OSSL_FUNC_signature_digest_sign_init and OSSL_FUNC_signature_digest_sign
165*b077aed3SPierre Pronchery
166*b077aed3SPierre Pronchery=item OSSL_FUNC_signature_digest_verify_init and OSSL_FUNC_signature_digest_verify
167*b077aed3SPierre Pronchery
168*b077aed3SPierre Pronchery=back
169*b077aed3SPierre Pronchery
170*b077aed3SPierre ProncheryOSSL_FUNC_signature_set_ctx_params and OSSL_FUNC_signature_settable_ctx_params are optional,
171*b077aed3SPierre Proncherybut if one of them is present then the other one must also be present. The same
172*b077aed3SPierre Proncheryapplies to OSSL_FUNC_signature_get_ctx_params and OSSL_FUNC_signature_gettable_ctx_params, as
173*b077aed3SPierre Proncherywell as the "md_params" functions. The OSSL_FUNC_signature_dupctx function is optional.
174*b077aed3SPierre Pronchery
175*b077aed3SPierre ProncheryA signature algorithm must also implement some mechanism for generating,
176*b077aed3SPierre Proncheryloading or importing keys via the key management (OSSL_OP_KEYMGMT) operation.
177*b077aed3SPierre ProncherySee L<provider-keymgmt(7)> for further details.
178*b077aed3SPierre Pronchery
179*b077aed3SPierre Pronchery=head2 Context Management Functions
180*b077aed3SPierre Pronchery
181*b077aed3SPierre ProncheryOSSL_FUNC_signature_newctx() should create and return a pointer to a provider side
182*b077aed3SPierre Proncherystructure for holding context information during a signature operation.
183*b077aed3SPierre ProncheryA pointer to this context will be passed back in a number of the other signature
184*b077aed3SPierre Proncheryoperation function calls.
185*b077aed3SPierre ProncheryThe parameter I<provctx> is the provider context generated during provider
186*b077aed3SPierre Proncheryinitialisation (see L<provider(7)>). The I<propq> parameter is a property query
187*b077aed3SPierre Proncherystring that may be (optionally) used by the provider during any "fetches" that
188*b077aed3SPierre Proncheryit may perform (if it performs any).
189*b077aed3SPierre Pronchery
190*b077aed3SPierre ProncheryOSSL_FUNC_signature_freectx() is passed a pointer to the provider side signature
191*b077aed3SPierre Proncherycontext in the I<ctx> parameter.
192*b077aed3SPierre ProncheryThis function should free any resources associated with that context.
193*b077aed3SPierre Pronchery
194*b077aed3SPierre ProncheryOSSL_FUNC_signature_dupctx() should duplicate the provider side signature context in
195*b077aed3SPierre Proncherythe I<ctx> parameter and return the duplicate copy.
196*b077aed3SPierre Pronchery
197*b077aed3SPierre Pronchery=head2 Signing Functions
198*b077aed3SPierre Pronchery
199*b077aed3SPierre ProncheryOSSL_FUNC_signature_sign_init() initialises a context for signing given a provider side
200*b077aed3SPierre Proncherysignature context in the I<ctx> parameter, and a pointer to a provider key object
201*b077aed3SPierre Proncheryin the I<provkey> parameter.
202*b077aed3SPierre ProncheryThe I<params>, if not NULL, should be set on the context in a manner similar to
203*b077aed3SPierre Proncheryusing OSSL_FUNC_signature_set_ctx_params().
204*b077aed3SPierre ProncheryThe key object should have been previously generated, loaded or imported into
205*b077aed3SPierre Proncherythe provider using the key management (OSSL_OP_KEYMGMT) operation (see
206*b077aed3SPierre Proncheryprovider-keymgmt(7)>.
207*b077aed3SPierre Pronchery
208*b077aed3SPierre ProncheryOSSL_FUNC_signature_sign() performs the actual signing itself.
209*b077aed3SPierre ProncheryA previously initialised signature context is passed in the I<ctx>
210*b077aed3SPierre Proncheryparameter.
211*b077aed3SPierre ProncheryThe data to be signed is pointed to be the I<tbs> parameter which is I<tbslen>
212*b077aed3SPierre Proncherybytes long.
213*b077aed3SPierre ProncheryUnless I<sig> is NULL, the signature should be written to the location pointed
214*b077aed3SPierre Proncheryto by the I<sig> parameter and it should not exceed I<sigsize> bytes in length.
215*b077aed3SPierre ProncheryThe length of the signature should be written to I<*siglen>.
216*b077aed3SPierre ProncheryIf I<sig> is NULL then the maximum length of the signature should be written to
217*b077aed3SPierre ProncheryI<*siglen>.
218*b077aed3SPierre Pronchery
219*b077aed3SPierre Pronchery=head2 Verify Functions
220*b077aed3SPierre Pronchery
221*b077aed3SPierre ProncheryOSSL_FUNC_signature_verify_init() initialises a context for verifying a signature given
222*b077aed3SPierre Proncherya provider side signature context in the I<ctx> parameter, and a pointer to a
223*b077aed3SPierre Proncheryprovider key object in the I<provkey> parameter.
224*b077aed3SPierre ProncheryThe I<params>, if not NULL, should be set on the context in a manner similar to
225*b077aed3SPierre Proncheryusing OSSL_FUNC_signature_set_ctx_params().
226*b077aed3SPierre ProncheryThe key object should have been previously generated, loaded or imported into
227*b077aed3SPierre Proncherythe provider using the key management (OSSL_OP_KEYMGMT) operation (see
228*b077aed3SPierre Proncheryprovider-keymgmt(7)>.
229*b077aed3SPierre Pronchery
230*b077aed3SPierre ProncheryOSSL_FUNC_signature_verify() performs the actual verification itself.
231*b077aed3SPierre ProncheryA previously initialised signature context is passed in the I<ctx> parameter.
232*b077aed3SPierre ProncheryThe data that the signature covers is pointed to be the I<tbs> parameter which
233*b077aed3SPierre Proncheryis I<tbslen> bytes long.
234*b077aed3SPierre ProncheryThe signature is pointed to by the I<sig> parameter which is I<siglen> bytes
235*b077aed3SPierre Proncherylong.
236*b077aed3SPierre Pronchery
237*b077aed3SPierre Pronchery=head2 Verify Recover Functions
238*b077aed3SPierre Pronchery
239*b077aed3SPierre ProncheryOSSL_FUNC_signature_verify_recover_init() initialises a context for recovering the
240*b077aed3SPierre Proncherysigned data given a provider side signature context in the I<ctx> parameter, and
241*b077aed3SPierre Proncherya pointer to a provider key object in the I<provkey> parameter.
242*b077aed3SPierre ProncheryThe I<params>, if not NULL, should be set on the context in a manner similar to
243*b077aed3SPierre Proncheryusing OSSL_FUNC_signature_set_ctx_params().
244*b077aed3SPierre ProncheryThe key object should have been previously generated, loaded or imported into
245*b077aed3SPierre Proncherythe provider using the key management (OSSL_OP_KEYMGMT) operation (see
246*b077aed3SPierre Proncheryprovider-keymgmt(7)>.
247*b077aed3SPierre Pronchery
248*b077aed3SPierre ProncheryOSSL_FUNC_signature_verify_recover() performs the actual verify recover itself.
249*b077aed3SPierre ProncheryA previously initialised signature context is passed in the I<ctx> parameter.
250*b077aed3SPierre ProncheryThe signature is pointed to by the I<sig> parameter which is I<siglen> bytes
251*b077aed3SPierre Proncherylong.
252*b077aed3SPierre ProncheryUnless I<rout> is NULL, the recovered data should be written to the location
253*b077aed3SPierre Proncherypointed to by I<rout> which should not exceed I<routsize> bytes in length.
254*b077aed3SPierre ProncheryThe length of the recovered data should be written to I<*routlen>.
255*b077aed3SPierre ProncheryIf I<rout> is NULL then the maximum size of the output buffer is written to
256*b077aed3SPierre Proncherythe I<routlen> parameter.
257*b077aed3SPierre Pronchery
258*b077aed3SPierre Pronchery=head2 Digest Sign Functions
259*b077aed3SPierre Pronchery
260*b077aed3SPierre ProncheryOSSL_FUNC_signature_digeset_sign_init() initialises a context for signing given a
261*b077aed3SPierre Proncheryprovider side signature context in the I<ctx> parameter, and a pointer to a
262*b077aed3SPierre Proncheryprovider key object in the I<provkey> parameter.
263*b077aed3SPierre ProncheryThe I<params>, if not NULL, should be set on the context in a manner similar to
264*b077aed3SPierre Proncheryusing OSSL_FUNC_signature_set_ctx_params() and
265*b077aed3SPierre ProncheryOSSL_FUNC_signature_set_ctx_md_params().
266*b077aed3SPierre ProncheryThe key object should have been
267*b077aed3SPierre Proncherypreviously generated, loaded or imported into the provider using the
268*b077aed3SPierre Proncherykey management (OSSL_OP_KEYMGMT) operation (see provider-keymgmt(7)>.
269*b077aed3SPierre ProncheryThe name of the digest to be used will be in the I<mdname> parameter.
270*b077aed3SPierre Pronchery
271*b077aed3SPierre ProncheryOSSL_FUNC_signature_digest_sign_update() provides data to be signed in the I<data>
272*b077aed3SPierre Proncheryparameter which should be of length I<datalen>. A previously initialised
273*b077aed3SPierre Proncherysignature context is passed in the I<ctx> parameter. This function may be called
274*b077aed3SPierre Proncherymultiple times to cumulatively add data to be signed.
275*b077aed3SPierre Pronchery
276*b077aed3SPierre ProncheryOSSL_FUNC_signature_digest_sign_final() finalises a signature operation previously
277*b077aed3SPierre Proncherystarted through OSSL_FUNC_signature_digest_sign_init() and
278*b077aed3SPierre ProncheryOSSL_FUNC_signature_digest_sign_update() calls. Once finalised no more data will be
279*b077aed3SPierre Proncheryadded through OSSL_FUNC_signature_digest_sign_update(). A previously initialised
280*b077aed3SPierre Proncherysignature context is passed in the I<ctx> parameter. Unless I<sig> is NULL, the
281*b077aed3SPierre Proncherysignature should be written to the location pointed to by the I<sig> parameter
282*b077aed3SPierre Proncheryand it should not exceed I<sigsize> bytes in length. The length of the signature
283*b077aed3SPierre Proncheryshould be written to I<*siglen>. If I<sig> is NULL then the maximum length of
284*b077aed3SPierre Proncherythe signature should be written to I<*siglen>.
285*b077aed3SPierre Pronchery
286*b077aed3SPierre ProncheryOSSL_FUNC_signature_digest_sign() implements a "one shot" digest sign operation
287*b077aed3SPierre Proncherypreviously started through OSSL_FUNC_signature_digeset_sign_init(). A previously
288*b077aed3SPierre Proncheryinitialised signature context is passed in the I<ctx> parameter. The data to be
289*b077aed3SPierre Proncherysigned is in I<tbs> which should be I<tbslen> bytes long. Unless I<sig> is NULL,
290*b077aed3SPierre Proncherythe signature should be written to the location pointed to by the I<sig>
291*b077aed3SPierre Proncheryparameter and it should not exceed I<sigsize> bytes in length. The length of the
292*b077aed3SPierre Proncherysignature should be written to I<*siglen>. If I<sig> is NULL then the maximum
293*b077aed3SPierre Proncherylength of the signature should be written to I<*siglen>.
294*b077aed3SPierre Pronchery
295*b077aed3SPierre Pronchery=head2 Digest Verify Functions
296*b077aed3SPierre Pronchery
297*b077aed3SPierre ProncheryOSSL_FUNC_signature_digeset_verify_init() initialises a context for verifying given a
298*b077aed3SPierre Proncheryprovider side verification context in the I<ctx> parameter, and a pointer to a
299*b077aed3SPierre Proncheryprovider key object in the I<provkey> parameter.
300*b077aed3SPierre ProncheryThe I<params>, if not NULL, should be set on the context in a manner similar to
301*b077aed3SPierre ProncheryOSSL_FUNC_signature_set_ctx_params() and
302*b077aed3SPierre ProncheryOSSL_FUNC_signature_set_ctx_md_params().
303*b077aed3SPierre ProncheryThe key object should have been
304*b077aed3SPierre Proncherypreviously generated, loaded or imported into the provider using the
305*b077aed3SPierre Proncherykey management (OSSL_OP_KEYMGMT) operation (see provider-keymgmt(7)>.
306*b077aed3SPierre ProncheryThe name of the digest to be used will be in the I<mdname> parameter.
307*b077aed3SPierre Pronchery
308*b077aed3SPierre ProncheryOSSL_FUNC_signature_digest_verify_update() provides data to be verified in the I<data>
309*b077aed3SPierre Proncheryparameter which should be of length I<datalen>. A previously initialised
310*b077aed3SPierre Proncheryverification context is passed in the I<ctx> parameter. This function may be
311*b077aed3SPierre Proncherycalled multiple times to cumulatively add data to be verified.
312*b077aed3SPierre Pronchery
313*b077aed3SPierre ProncheryOSSL_FUNC_signature_digest_verify_final() finalises a verification operation previously
314*b077aed3SPierre Proncherystarted through OSSL_FUNC_signature_digest_verify_init() and
315*b077aed3SPierre ProncheryOSSL_FUNC_signature_digest_verify_update() calls. Once finalised no more data will be
316*b077aed3SPierre Proncheryadded through OSSL_FUNC_signature_digest_verify_update(). A previously initialised
317*b077aed3SPierre Proncheryverification context is passed in the I<ctx> parameter. The signature to be
318*b077aed3SPierre Proncheryverified is in I<sig> which is I<siglen> bytes long.
319*b077aed3SPierre Pronchery
320*b077aed3SPierre ProncheryOSSL_FUNC_signature_digest_verify() implements a "one shot" digest verify operation
321*b077aed3SPierre Proncherypreviously started through OSSL_FUNC_signature_digeset_verify_init(). A previously
322*b077aed3SPierre Proncheryinitialised verification context is passed in the I<ctx> parameter. The data to be
323*b077aed3SPierre Proncheryverified is in I<tbs> which should be I<tbslen> bytes long. The signature to be
324*b077aed3SPierre Proncheryverified is in I<sig> which is I<siglen> bytes long.
325*b077aed3SPierre Pronchery
326*b077aed3SPierre Pronchery=head2 Signature parameters
327*b077aed3SPierre Pronchery
328*b077aed3SPierre ProncherySee L<OSSL_PARAM(3)> for further details on the parameters structure used by
329*b077aed3SPierre Proncherythe OSSL_FUNC_signature_get_ctx_params() and OSSL_FUNC_signature_set_ctx_params() functions.
330*b077aed3SPierre Pronchery
331*b077aed3SPierre ProncheryOSSL_FUNC_signature_get_ctx_params() gets signature parameters associated with the
332*b077aed3SPierre Proncherygiven provider side signature context I<ctx> and stored them in I<params>.
333*b077aed3SPierre ProncheryPassing NULL for I<params> should return true.
334*b077aed3SPierre Pronchery
335*b077aed3SPierre ProncheryOSSL_FUNC_signature_set_ctx_params() sets the signature parameters associated with the
336*b077aed3SPierre Proncherygiven provider side signature context I<ctx> to I<params>.
337*b077aed3SPierre ProncheryAny parameter settings are additional to any that were previously set.
338*b077aed3SPierre ProncheryPassing NULL for I<params> should return true.
339*b077aed3SPierre Pronchery
340*b077aed3SPierre ProncheryCommon parameters currently recognised by built-in signature algorithms are as
341*b077aed3SPierre Proncheryfollows.
342*b077aed3SPierre Pronchery
343*b077aed3SPierre Pronchery=over 4
344*b077aed3SPierre Pronchery
345*b077aed3SPierre Pronchery=item "digest" (B<OSSL_SIGNATURE_PARAM_DIGEST>) <UTF8 string>
346*b077aed3SPierre Pronchery
347*b077aed3SPierre ProncheryGet or sets the name of the digest algorithm used for the input to the
348*b077aed3SPierre Proncherysignature functions. It is required in order to calculate the "algorithm-id".
349*b077aed3SPierre Pronchery
350*b077aed3SPierre Pronchery=item "properties" (B<OSSL_SIGNATURE_PARAM_PROPERTIES>) <UTF8 string>
351*b077aed3SPierre Pronchery
352*b077aed3SPierre ProncherySets the name of the property query associated with the "digest" algorithm.
353*b077aed3SPierre ProncheryNULL is used if this optional value is not set.
354*b077aed3SPierre Pronchery
355*b077aed3SPierre Pronchery=item "digest-size" (B<OSSL_SIGNATURE_PARAM_DIGEST_SIZE>) <unsigned integer>
356*b077aed3SPierre Pronchery
357*b077aed3SPierre ProncheryGets or sets the output size of the digest algorithm used for the input to the
358*b077aed3SPierre Proncherysignature functions.
359*b077aed3SPierre ProncheryThe length of the "digest-size" parameter should not exceed that of a B<size_t>.
360*b077aed3SPierre Pronchery
361*b077aed3SPierre Pronchery=item "algorithm-id" (B<OSSL_SIGNATURE_PARAM_ALGORITHM_ID>) <octet string>
362*b077aed3SPierre Pronchery
363*b077aed3SPierre ProncheryGets the DER encoded AlgorithmIdentifier that corresponds to the combination of
364*b077aed3SPierre Proncherysignature algorithm and digest algorithm for the signature operation.
365*b077aed3SPierre Pronchery
366*b077aed3SPierre Pronchery=item "kat" (B<OSSL_SIGNATURE_PARAM_KAT>) <unsigned integer>
367*b077aed3SPierre Pronchery
368*b077aed3SPierre ProncherySets a flag to modify the sign operation to return an error if the initial
369*b077aed3SPierre Proncherycalculated signature is invalid.
370*b077aed3SPierre ProncheryIn the normal mode of operation - new random values are chosen until the
371*b077aed3SPierre Proncherysignature operation succeeds.
372*b077aed3SPierre ProncheryBy default it retries until a signature is calculated.
373*b077aed3SPierre ProncherySetting the value to 0 causes the sign operation to retry,
374*b077aed3SPierre Proncheryotherwise the sign operation is only tried once and returns whether or not it
375*b077aed3SPierre Proncherywas successful.
376*b077aed3SPierre ProncheryKnown answer tests can be performed if the random generator is overridden to
377*b077aed3SPierre Proncherysupply known values that either pass or fail.
378*b077aed3SPierre Pronchery
379*b077aed3SPierre Pronchery=back
380*b077aed3SPierre Pronchery
381*b077aed3SPierre ProncheryOSSL_FUNC_signature_gettable_ctx_params() and OSSL_FUNC_signature_settable_ctx_params() get a
382*b077aed3SPierre Proncheryconstant L<OSSL_PARAM(3)> array that describes the gettable and settable parameters,
383*b077aed3SPierre Proncheryi.e. parameters that can be used with OSSL_FUNC_signature_get_ctx_params() and
384*b077aed3SPierre ProncheryOSSL_FUNC_signature_set_ctx_params() respectively.
385*b077aed3SPierre Pronchery
386*b077aed3SPierre Pronchery=head2 MD parameters
387*b077aed3SPierre Pronchery
388*b077aed3SPierre ProncherySee L<OSSL_PARAM(3)> for further details on the parameters structure used by
389*b077aed3SPierre Proncherythe OSSL_FUNC_signature_get_md_ctx_params() and OSSL_FUNC_signature_set_md_ctx_params()
390*b077aed3SPierre Proncheryfunctions.
391*b077aed3SPierre Pronchery
392*b077aed3SPierre ProncheryOSSL_FUNC_signature_get_md_ctx_params() gets digest parameters associated with the
393*b077aed3SPierre Proncherygiven provider side digest signature context I<ctx> and stores them in I<params>.
394*b077aed3SPierre ProncheryPassing NULL for I<params> should return true.
395*b077aed3SPierre Pronchery
396*b077aed3SPierre ProncheryOSSL_FUNC_signature_set_ms_ctx_params() sets the digest parameters associated with the
397*b077aed3SPierre Proncherygiven provider side digest signature context I<ctx> to I<params>.
398*b077aed3SPierre ProncheryAny parameter settings are additional to any that were previously set.
399*b077aed3SPierre ProncheryPassing NULL for I<params> should return true.
400*b077aed3SPierre Pronchery
401*b077aed3SPierre ProncheryParameters currently recognised by built-in signature algorithms are the same
402*b077aed3SPierre Proncheryas those for built-in digest algorithms. See
403*b077aed3SPierre ProncheryL<provider-digest(7)/Digest Parameters> for further information.
404*b077aed3SPierre Pronchery
405*b077aed3SPierre ProncheryOSSL_FUNC_signature_gettable_md_ctx_params() and OSSL_FUNC_signature_settable_md_ctx_params()
406*b077aed3SPierre Proncheryget a constant L<OSSL_PARAM(3)> array that describes the gettable and settable
407*b077aed3SPierre Proncherydigest parameters, i.e. parameters that can be used with
408*b077aed3SPierre ProncheryOSSL_FUNC_signature_get_md_ctx_params() and OSSL_FUNC_signature_set_md_ctx_params()
409*b077aed3SPierre Proncheryrespectively.
410*b077aed3SPierre Pronchery
411*b077aed3SPierre Pronchery=head1 RETURN VALUES
412*b077aed3SPierre Pronchery
413*b077aed3SPierre ProncheryOSSL_FUNC_signature_newctx() and OSSL_FUNC_signature_dupctx() should return the newly created
414*b077aed3SPierre Proncheryprovider side signature context, or NULL on failure.
415*b077aed3SPierre Pronchery
416*b077aed3SPierre ProncheryOSSL_FUNC_signature_gettable_ctx_params(), OSSL_FUNC_signature_settable_ctx_params(),
417*b077aed3SPierre ProncheryOSSL_FUNC_signature_gettable_md_ctx_params() and OSSL_FUNC_signature_settable_md_ctx_params(),
418*b077aed3SPierre Proncheryreturn the gettable or settable parameters in a constant L<OSSL_PARAM(3)> array.
419*b077aed3SPierre Pronchery
420*b077aed3SPierre ProncheryAll other functions should return 1 for success or 0 on error.
421*b077aed3SPierre Pronchery
422*b077aed3SPierre Pronchery=head1 SEE ALSO
423*b077aed3SPierre Pronchery
424*b077aed3SPierre ProncheryL<provider(7)>
425*b077aed3SPierre Pronchery
426*b077aed3SPierre Pronchery=head1 HISTORY
427*b077aed3SPierre Pronchery
428*b077aed3SPierre ProncheryThe provider SIGNATURE interface was introduced in OpenSSL 3.0.
429*b077aed3SPierre Pronchery
430*b077aed3SPierre Pronchery=head1 COPYRIGHT
431*b077aed3SPierre Pronchery
432*b077aed3SPierre ProncheryCopyright 2019-2023 The OpenSSL Project Authors. All Rights Reserved.
433*b077aed3SPierre Pronchery
434*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
435*b077aed3SPierre Proncherythis file except in compliance with the License.  You can obtain a copy
436*b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at
437*b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>.
438*b077aed3SPierre Pronchery
439*b077aed3SPierre Pronchery=cut
440