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