provider-asym_cipher - The asym_cipher library <-> provider functions
#include <openssl/core_numbers.h>
#include <openssl/core_names.h>
/*
* 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_asym_cipher_newctx(void *provctx);
void OP_asym_cipher_freectx(void *ctx);
void *OP_asym_cipher_dupctx(void *ctx);
/* Encryption */
int OP_asym_cipher_encrypt_init(void *ctx, void *provkey);
int OP_asym_cipher_encrypt(void *ctx, unsigned char *out, size_t *outlen,
size_t outsize, const unsigned char *in,
size_t inlen);
/* Decryption */
int OP_asym_cipher_decrypt_init(void *ctx, void *provkey);
int OP_asym_cipher_decrypt(void *ctx, unsigned char *out, size_t *outlen,
size_t outsize, const unsigned char *in,
size_t inlen);
/* Asymmetric Cipher parameters */
int OP_asym_cipher_get_ctx_params(void *ctx, OSSL_PARAM params[]);
const OSSL_PARAM *OP_asym_cipher_gettable_ctx_params(void);
int OP_asym_cipher_set_ctx_params(void *ctx, const OSSL_PARAM params[]);
const OSSL_PARAM *OP_asym_cipher_settable_ctx_params(void);
This documentation is primarily aimed at provider authors. See EVP_PKEY_encrypt(3), "Provider Functions" in provider-base(7)).
All these "functions" have a corresponding function type definition named OSSL_{name}_fn, and a helper function to retrieve the function pointer from an OSSL_DISPATCH element named OSSL_get_{name}. For example, the "function" OP_asym_cipher_newctx() has these:
typedef void *(OSSL_OP_asym_cipher_newctx_fn)(void *provctx);
static ossl_inline OSSL_OP_asym_cipher_newctx_fn
OSSL_get_OP_asym_cipher_newctx(const OSSL_DISPATCH *opf);
OSSL_DISPATCH arrays are indexed by numbers that are provided as macros in provider-keymgmt(7) for further details.
OP_asym_cipher_newctx() should create and return a pointer to a provider side structure for holding context information during an asymmetric cipher operation. A pointer to this context will be passed back in a number of the other asymmetric cipher operation function calls. The parameter provctx is the provider context generated during provider initialisation (see Encryption Functions
OP_asym_cipher_encrypt_init() initialises a context for an asymmetric encryption given a provider side asymmetric cipher context in the ctx parameter, and a pointer to a provider key object in the provkey 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_asym_cipher_encrypt() performs the actual encryption itself. A previously initialised asymmetric cipher context is passed in the ctx parameter. The data to be encrypted is pointed to by the in parameter which is inlen bytes long. Unless out is NULL, the encrypted data should be written to the location pointed to by the out parameter and it should not exceed outsize bytes in length. The length of the encrypted data should be written to *outlen. If out is NULL then the maximum length of the encrypted data should be written to *outlen. OP_asym_cipher_decrypt_init() initialises a context for an asymmetric decryption given a provider side asymmetric cipher context in the ctx parameter, and a pointer to a provider key object in the provkey 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_asym_cipher_decrypt() performs the actual decryption itself. A previously initialised asymmetric cipher context is passed in the ctx parameter. The data to be decrypted is pointed to by the in parameter which is inlen bytes long. Unless out is NULL, the decrypted data should be written to the location pointed to by the out parameter and it should not exceed outsize bytes in length. The length of the decrypted data should be written to *outlen. If out is NULL then the maximum length of the decrypted data should be written to *outlen. See "pad-mode" (OSSL_ASYM_CIPHER_PARAM_PAD_MODE) <integer>
The type of padding to be used. The interpretation of this value will depend on the algorithm in use. The default provider understands these RSA padding modes: 1 (RSA_PKCS1_PADDING), 2 (RSA_SSLV23_PADDING), 3 (RSA_NO_PADDING), 4 (RSA_PKCS1_OAEP_PADDING), 5 (RSA_X931_PADDING), 6 (RSA_PKCS1_PSS_PADDING) and 7 (RSA_PKCS1_WITH_TLS_PADDING). See "digest" (OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST) <UTF8 string>
Gets or sets the name of the OAEP digest algorithm used when OAEP padding is in use. Gets or sets the properties to use when fetching the OAEP digest algorithm. Gets or sets the name of the MGF1 digest algorithm used when OAEP or PSS padding is in use. Gets or sets the properties to use when fetching the MGF1 digest algorithm. Gets or sets the OAEP label used when OAEP padding is in use. Gets the length of an OAEP label when OAEP padding is in use. The TLS protocol version first requested by the client. See RSA_PKCS1_WITH_TLS_PADDING on the page "tls-negotiated-version" (OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION) <unsigned integer>
The negotiated TLS protocol version. See RSA_PKCS1_WITH_TLS_PADDING on the page OSSL_PARAM(3) for the use of OSSL_PARAM as parameter descriptor. OP_asym_cipher_newctx() and OP_asym_cipher_dupctx() should return the newly created provider side asymmetric cipher context, or NULL on failure. All other functions should return 1 for success or 0 on error. HISTORY
The provider ASYM_CIPHER interface was introduced in OpenSSL 3.0. 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 https://www.openssl.org/source/license.html.Decryption Functions
Asymmetric Cipher Parameters
RETURN VALUES
SEE ALSO
COPYRIGHT