---
name: "libressl-EC_KEY_METHOD_new"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-EC_KEY_METHOD_new"
---

# libressl-EC\_KEY\_METHOD\_new(3)

custom EC\_KEY implementations

## NAME

**EC\_KEY\_METHOD\_new**, **EC\_KEY\_METHOD\_free**, **EC\_KEY\_METHOD\_set\_init**, **EC\_KEY\_METHOD\_get\_init**, **EC\_KEY\_METHOD\_set\_sign**, **EC\_KEY\_METHOD\_get\_sign**, **EC\_KEY\_METHOD\_set\_verify**, **EC\_KEY\_METHOD\_get\_verify**, **EC\_KEY\_METHOD\_set\_keygen**, **EC\_KEY\_METHOD\_get\_keygen**, **EC\_KEY\_METHOD\_set\_compute\_key**, **EC\_KEY\_METHOD\_get\_compute\_key**, **EC\_KEY\_OpenSSL**, **EC\_KEY\_set\_default\_method**, **EC\_KEY\_get\_default\_method**, **EC\_KEY\_new\_method**, **EC\_KEY\_set\_method**, **EC\_KEY\_get\_method** – custom EC\_KEY implementations

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/ec.h\>**

*EC\_KEY\_METHOD* *\**\

**EC\_KEY\_METHOD\_new**(*const EC\_KEY\_METHOD \*meth*);

*void*\

**EC\_KEY\_METHOD\_free**(*EC\_KEY\_METHOD \*meth*);

*void*\

**EC\_KEY\_METHOD\_set\_init**(*EC\_KEY\_METHOD \*meth*, *int (\*init)(EC\_KEY \*key)*, *void (\*finish)(EC\_KEY \*key)*, *int (\*copy)(EC\_KEY \*dest, const EC\_KEY \*src)*, *int (\*set\_group)(EC\_KEY \*key, const EC\_GROUP \*grp)*, *int (\*set\_private)(EC\_KEY \*key, const BIGNUM \*priv\_key)*, *int (\*set\_public)(EC\_KEY \*key, const EC\_POINT \*pub\_key)*);

*void*\

**EC\_KEY\_METHOD\_get\_init**(*const EC\_KEY\_METHOD \*meth*, *int (\*\*pinit)(EC\_KEY \*key)*, *void (\*\*pfinish)(EC\_KEY \*key)*, *int (\*\*pcopy)(EC\_KEY \*dest, const EC\_KEY \*src)*, *int (\*\*pset\_group)(EC\_KEY \*key, const EC\_GROUP \*grp)*, *int (\*\*pset\_private)(EC\_KEY \*key, const BIGNUM \*priv\_key)*, *int (\*\*pset\_public)(EC\_KEY \*key, const EC\_POINT \*pub\_key)*);

*void*\

**EC\_KEY\_METHOD\_set\_sign**(*EC\_KEY\_METHOD \*meth*, *int (\*sign)(int type, const unsigned char \*dgst, int dgstlen, unsigned char \*sig, unsigned int \*siglen, const BIGNUM \*kinv, const BIGNUM \*r, EC\_KEY \*eckey)*, *int (\*sign\_setup)(EC\_KEY \*eckey, BN\_CTX \*ctx, BIGNUM \*\*kinv, BIGNUM \*\*rp)*, *ECDSA\_SIG \*(\*sign\_sig)(const unsigned char \*dgst, int dgstlen, const BIGNUM \*kinv, const BIGNUM \*rp, EC\_KEY \*eckey)*);

*void*\

**EC\_KEY\_METHOD\_get\_sign**(*const EC\_KEY\_METHOD \*meth*, *int (\*\*psign)(int type, const unsigned char \*dgst, int dgstlen, unsigned char \*sig, unsigned int \*siglen, const BIGNUM \*kinv, const BIGNUM \*r, EC\_KEY \*eckey)*, *int (\*\*psign\_setup)(EC\_KEY \*eckey, BN\_CTX \*ctx, BIGNUM \*\*kinv, BIGNUM \*\*rp)*, *ECDSA\_SIG \*(\*\*psign\_sig)(const unsigned char \*dgst, int dgstlen, const BIGNUM \*kinv, const BIGNUM \*rp, EC\_KEY \*eckey)*);

*void*\

**EC\_KEY\_METHOD\_set\_verify**(*EC\_KEY\_METHOD \*meth*, *int (\*verify)(int type, const unsigned char \*dgst, int dgst\_len, const unsigned char \*sigbuf, int sig\_len, EC\_KEY \*eckey)*, *int (\*verify\_sig)(const unsigned char \*dgst, int dgst\_len, const ECDSA\_SIG \*sig, EC\_KEY \*eckey)*);

*void*\

**EC\_KEY\_METHOD\_get\_verify**(*const EC\_KEY\_METHOD \*meth*, *int (\*\*pverify)(int type, const unsigned char \*dgst, int dgst\_len, const unsigned char \*sigbuf, int sig\_len, EC\_KEY \*eckey)*, *int (\*\*pverify\_sig)(const unsigned char \*dgst, int dgst\_len, const ECDSA\_SIG \*sig, EC\_KEY \*eckey)*);

*void*\

**EC\_KEY\_METHOD\_set\_keygen**(*EC\_KEY\_METHOD \*meth*, *int (\*keygen)(EC\_KEY \*key)*);

*void*\

**EC\_KEY\_METHOD\_get\_keygen**(*const EC\_KEY\_METHOD \*meth*, *int (\*\*pkeygen)(EC\_KEY \*key)*);

*void*\

**EC\_KEY\_METHOD\_set\_compute\_key**(*EC\_KEY\_METHOD \*meth*, *int (\*ckey)(void \*out, size\_t outlen, const EC\_POINT \*pub\_key, EC\_KEY \*ecdh, void \*(\*KDF) (const void \*in, size\_t inlen, void \*out, size\_t \*outlen))*);

*void*\

**EC\_KEY\_METHOD\_get\_compute\_key**(*const EC\_KEY\_METHOD \*meth*, *int (\*\*pck)(void \*out, size\_t outlen, const EC\_POINT \*pub\_key, EC\_KEY \*ecdh, void \*(\*KDF) (const void \*in, size\_t inlen, void \*out, size\_t \*outlen))*);

*const* *EC\_KEY\_METHOD* *\**\

**EC\_KEY\_OpenSSL**(*void*);

*void*\

**EC\_KEY\_set\_default\_method**(*const EC\_KEY\_METHOD \*meth*);

*const* *EC\_KEY\_METHOD* *\**\

**EC\_KEY\_get\_default\_method**(*void*);

*EC\_KEY* *\**\

**EC\_KEY\_new\_method**(*ENGINE \*engine*);

*int*\

**EC\_KEY\_set\_method**(*EC\_KEY \*key*, *const EC\_KEY\_METHOD \*meth*);

*const* *EC\_KEY\_METHOD* *\**\

**EC\_KEY\_get\_method**(*const EC\_KEY \*key*);

## DESCRIPTION

An *EC\_KEY\_METHOD* object holds function pointers used for *EC\_KEY* operations.

**EC\_KEY\_METHOD\_new**() creates a shallow copy of *meth*, or an empty *EC\_KEY\_METHOD* object if *meth* is NULL.

**EC\_KEY\_METHOD\_free**() frees *meth*. If *meth* is NULL or the return value of **EC\_KEY\_OpenSSL**(), no action occurs.

**EC\_KEY\_METHOD\_set\_init**() and **EC\_KEY\_METHOD\_get\_init**() set and retrieve optional callback functions called at the following places:

- *init*

  at the end of **EC\_KEY\_new\_method**() and **EC\_KEY\_set\_method**()

- *finish*

  at the beginning of EC\_KEY\_free(3), EC\_KEY\_copy(3), and **EC\_KEY\_set\_method**()

- *copy*

  at the end of EC\_KEY\_copy(3)

- *set\_group*

  at the end of EC\_KEY\_set\_group(3) and EC\_KEY\_new\_by\_curve\_name(3)

- *set\_private*

  at the beginning of EC\_KEY\_set\_private\_key(3)

- *set\_public*

  at the beginning of EC\_KEY\_set\_public\_key(3)

If any of these callbacks returns 0, the calling function fails. By default, all these callbacks are NULL. Arguments of **EC\_KEY\_METHOD\_get\_init**() can be set to NULL to selectively retrieve callback function pointers.

**EC\_KEY\_METHOD\_set\_sign**() and **EC\_KEY\_METHOD\_get\_sign**() set and retrieve the functions implementing ECDSA\_sign(3) and ECDSA\_do\_sign(3).

**EC\_KEY\_METHOD\_set\_verify**() and **EC\_KEY\_METHOD\_get\_verify**() set and retrieve the functions implementing ECDSA\_verify(3) and ECDSA\_do\_verify(3).

**EC\_KEY\_METHOD\_set\_keygen**() and **EC\_KEY\_METHOD\_get\_keygen**() set and retrieve the function implementing EC\_KEY\_generate\_key(3).

**EC\_KEY\_METHOD\_set\_compute\_key**() and **EC\_KEY\_METHOD\_get\_compute\_key**() set and retrieve the function implementing ECDH\_compute\_key(3).

**EC\_KEY\_set\_default\_method**() chooses the *meth* to be used for the creation of new *EC\_KEY* objects by future invocations of **EC\_KEY\_new\_method**(), or reverts to the default implementation if *meth* is NULL.

**EC\_KEY\_new\_method**() creates and initializes a new *EC\_KEY* object using the *EC\_KEY\_METHOD* set with **EC\_KEY\_set\_default\_method**(). The *ENGINE*, *\*engine* argument is always ignored and passing NULL is recommended.

**EC\_KEY\_set\_method**() dissociates the *key* from the *ENGINE* it is using, if any, and causes it to use *meth* in the future.

## RETURN VALUES

**EC\_KEY\_METHOD\_new**() returns the newly allocated *EC\_KEY\_METHOD* object or NULL if an error occurs.

**EC\_KEY\_OpenSSL**() returns a static object representing the default EC\_KEY implementation.

**EC\_KEY\_get\_default\_method**() returns the *EC\_KEY\_METHOD* that **EC\_KEY\_new\_method**() will use for the creation of new *EC\_KEY* objects in the future.

**EC\_KEY\_new\_method**() returns the newly allocated *EC\_KEY* object or NULL if an error occurs.

**EC\_KEY\_set\_method**() returns 1 for success or 0 for failure.

**EC\_KEY\_get\_method**() returns the EC\_KEY implementation used by the given *key*.

## SEE ALSO

[crypto(3)](/crypto/3.md), EC\_GROUP\_check(3), EC\_GROUP\_get\_curve\_name(3), EC\_GROUP\_new\_by\_curve\_name(3), EC\_GROUP\_new\_curve\_GFp(3), EC\_KEY\_new(3), EC\_POINT\_add(3), EC\_POINT\_get\_affine\_coordinates(3), EC\_POINT\_new(3), EC\_POINT\_point2oct(3), ECDSA\_sign(3)

## HISTORY

These functions first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 6.5.
