Encrypt data with a public key using a context from EVP_PKEY_encrypt_init().

Synopsis

Declared in <openssl/evp.h>

int
EVP_PKEY_encrypt(
    EVP_PKEY_CTX* ctx,
    unsigned char* out,
    size_t* outlen,
    unsigned char const* in,
    size_t inlen);

Return Value

1 on success, or a non‐positive value on failure.

Parameters

Name

Description

ctx

Encryption context holding the public key.

out

Output buffer for ciphertext, or NULL to query the required size via outlen.

outlen

On entry, capacity of out when non‐NULL; on return, bytes written or required.

in

Plaintext bytes to encrypt.

inlen

Length of in in bytes.

Created with MrDocs