=pod =head1 NAME provider-signature - The signature library E-E provider functions =head1 SYNOPSIS =for comment multiple includes #include #include /* * None of these are actual functions, but are displayed like this for * the function signatures for functions that are offered as function * pointers in OSSL_DISPATCH arrays. */ /* Context management */ void *OP_signature_newctx(void *provctx); void OP_signature_freectx(void *ctx); void *OP_signature_dupctx(void *ctx); /* Signing */ int OP_signature_sign_init(void *ctx, void *provkey); int OP_signature_sign(void *ctx, unsigned char *sig, size_t *siglen, size_t sigsize, const unsigned char *tbs, size_t tbslen); /* Verifying */ int OP_signature_verify_init(void *ctx, void *provkey); int OP_signature_verify(void *ctx, const unsigned char *sig, size_t siglen, const unsigned char *tbs, size_t tbslen); /* Verify Recover */ int OP_signature_verify_recover_init(void *ctx, void *provkey); int OP_signature_verify_recover(void *ctx, unsigned char *rout, size_t *routlen, size_t routsize, const unsigned char *sig, size_t siglen); /* Signature parameters */ int OP_signature_get_ctx_params(void *ctx, OSSL_PARAM params[]); const OSSL_PARAM *OP_signature_gettable_ctx_params(void); int OP_signature_set_ctx_params(void *ctx, const OSSL_PARAM params[]); const OSSL_PARAM *OP_signature_settable_ctx_params(void); =head1 DESCRIPTION This documentation is primarily aimed at provider authors. See L for further information. The signature (OSSL_OP_SIGNATURE) operation enables providers to implement signature algorithms and make them available to applications via the API functions L, L, L, L, L and L (as well as other related functions). All "functions" mentioned here are passed as function pointers between F and the provider in B arrays via B arrays that are returned by the provider's provider_query_operation() function (see L). All these "functions" have a corresponding function type definition named B, and a helper function to retrieve the function pointer from an B element named B. For example, the "function" OP_signature_newctx() has these: typedef void *(OSSL_OP_signature_newctx_fn)(void *provctx); static ossl_inline OSSL_OP_signature_newctx_fn OSSL_get_OP_signature_newctx(const OSSL_DISPATCH *opf); B arrays are indexed by numbers that are provided as macros in L, as follows: OP_signature_newctx OSSL_FUNC_SIGNATURE_NEWCTX OP_signature_freectx OSSL_FUNC_SIGNATURE_FREECTX OP_signature_dupctx OSSL_FUNC_SIGNATURE_DUPCTX OP_signature_sign_init OSSL_FUNC_SIGNATURE_SIGN_INIT OP_signature_sign OSSL_FUNC_SIGNATURE_SIGN OP_signature_verify_init OSSL_FUNC_SIGNATURE_VERIFY_INIT OP_signature_verify OSSL_FUNC_SIGNATURE_VERIFY OP_signature_verify_recover_init OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT OP_signature_verify_recover OSSL_FUNC_SIGNATURE_VERIFY_RECOVER OP_signature_get_ctx_params OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS OP_signature_gettable_ctx_params OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS OP_signature_set_ctx_params OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS OP_signature_settable_ctx_params OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS A signature algorithm implementation may not implement all of these functions. In order to be a consistent set of functions a provider must implement OP_signature_newctx and OP_signature_freectx. It must also implement both of OP_signature_sign_init and OP_signature_sign, or both of OP_signature_verify_init and OP_signature_verify, or both of OP_signature_verify_recover_init and OP_signature_verify_recover. All other functions are optional. A signature algorithm must also implement some mechanism for generating, loading or importing keys via the key management (OSSL_OP_KEYMGMT) operation. See L for further details. =head2 Context Management Functions OP_signature_newctx() should create and return a pointer to a provider side structure for holding context information during a signature operation. A pointer to this context will be passed back in a number of the other signature operation function calls. The parameter B is the provider context generated during provider initialisation (see L). OP_signature_freectx() is passed a pointer to the provider side signature context in the B parameter. This function should free any resources associated with that context. OP_signature_dupctx() should duplicate the provider side signature context in the B parameter and return the duplicate copy. =head2 Signing Functions OP_signature_sign_init() initialises a context for signing given a provider side signature context in the B parameter, and a pointer to a provider key object in the B parameter. The key object should have been previously generated, loaded or imported into the provider using the key management (OSSL_OP_KEYMGMT) operation (see provider-keymgmt(7)>. OP_signature_sign() performs the actual signing itself. A previously initialised signature context is passed in the B parameter. The data to be signed is pointed to be the B parameter which is B bytes long. Unless B is NULL, the signature should be written to the location pointed to by the B parameter and it should not exceed B bytes in length. The length of the signature should be written to B<*siglen>. If B is NULL then the maximum length of the signature should be written to B<*siglen>. =head2 Verify Functions OP_signature_verify_init() initialises a context for verifying a signature given a provider side signature context in the B parameter, and a pointer to a provider key object in the B parameter. The key object should have been previously generated, loaded or imported into the provider using the key management (OSSL_OP_KEYMGMT) operation (see provider-keymgmt(7)>. OP_signature_verify() performs the actual verification itself. A previously initialised signature context is passed in the B parameter. The data that the signature covers is pointed to be the B parameter which is B bytes long. The signature is pointed to by the B parameter which is B bytes long. =head2 Verify Recover Functions OP_signature_verify_recover_init() initialises a context for recovering the signed data given a provider side signature context in the B parameter, and a pointer to a provider key object in the B parameter. The key object should have been previously generated, loaded or imported into the provider using the key management (OSSL_OP_KEYMGMT) operation (see provider-keymgmt(7)>. OP_signature_verify_recover() performs the actual verify recover itself. A previously initialised signature context is passed in the B parameter. The signature is pointed to by the B parameter which is B bytes long. Unless B is NULL, the recovered data should be written to the location pointed to by B which should not exceed B bytes in length. The length of the recovered data should be written to B<*routlen>. If B is B then the maximum size of the output buffer is written to the B parameter. =head2 Signature Parameters See L for further details on the parameters structure used by the OP_signature_get_ctx_params() and OP_signature_set_ctx_params() functions. OP_signature_get_ctx_params() gets signature parameters associated with the given provider side signature context B and stored them in B. OP_signature_set_ctx_params() sets the signature parameters associated with the given provider side signature context B to B. Any parameter settings are additional to any that were previously set. Parameters currently recognised by built-in signature algorithms are as follows. Not all parameters are relevant to, or are understood by all signature algorithms: =over 4 =item B ("digest") Get or sets the name of the digest algorithm used for the input to the signature functions. =item B ("digest-size") Gets or sets the output size of the digest algorithm used for the input to the signature functions. The length of the "digest-size" parameter should not exceed that of a B. =back OP_signature_gettable_ctx_params() and OP_signature_settable_ctx_params() get a constant B array that decribes the gettable and settable parameters, i.e. parameters that can be used with OP_signature_get_ctx_params() and OP_signature_set_ctx_params() respectively. See L for the use of B as parameter descriptor. =head1 RETURN VALUES OP_signature_newctx() and OP_signature_dupctx() should return the newly created provider side signature, or NULL on failure. All other functions should return 1 for success or 0 on error. =head1 SEE ALSO L =head1 HISTORY The provider SIGNATURE interface was introduced in OpenSSL 3.0. =head1 COPYRIGHT Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at L. =cut