Skip to content

EVP_EC_gen

NAME

EVP_EC_gen, EVP_EC_affine2oct - EVP routines for EC keys

SYNOPSIS

#include <openssl/evp.h>

EVP_PKEY *EVP_EC_gen(const char *curve);
int EVP_EC_affine2oct(const BIGNUM *x, const BIGNUM *y, size_t field_len,
                      unsigned char **pbuf, size_t *pbsize);

DESCRIPTION

EVP_EC_gen() generates a new EC key pair on the given curve.

EVP_EC_affine2oct() converts affine coordinates x and y of an EC point to an octet string conforming to Sec. 2.3.4 of the SECG SEC 1 ("Elliptic Curve Cryptography") standard. This octet string can further be passed to OSSL_PARAM_BLD_push_octet_string(). The length of the field degree representation (in bytes) must be passed to field_len. The function allocates a buffer for octet string and places a pointer to *pbuf. It's the caller's responsibility to free this buffer with OPENSSL_free().

RETURN VALUES

EVP_EC_gen() returns the EC key pair generated or NULL on error.

EVP_EC_affine2oct() returns 1 on success or 0 on error.

HISTORY

EVP_EC_gen() was added in OpenSSL 3.0.

EVP_EC_affine2oct() was added in OpenSSL 4.1.

Copyright 2013-2026 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.