OSSL_ENCODER_CTX_new_for_pkey

Create an encoder context preconfigured to encode an EVP_PKEY.

Synopsis

Declared in <openssl/encoder.h>

OSSL_ENCODER_CTX*
OSSL_ENCODER_CTX_new_for_pkey(
    EVP_PKEY const* pkey,
    int selection,
    char const* output_type,
    char const* output_struct,
    char const* propquery);

Description

Performs an implicit encoder fetch suitable for pkey, which is more useful than calling OSSL_ENCODER_CTX_new() alone. The returned context may have zero encoders if none matched; check with OSSL_ENCODER_CTX_get_num_encoders().

Return Value

New encoder context, or NULL on error; free with OSSL_ENCODER_CTX_free().

Parameters

NameDescription
pkeyAssigned public or private key to encode.
selectionOSSL_KEYMGMT_SELECT_* mask for components to encode.
output_typeDesired ending output type (for example "DER" or "PEM").
output_structDesired output structure name (for example "pkcs8"), or NULL.
propqueryOptional property query for encoder fetching, or NULL.