---
name: "libressl-d2i_ECPKParameters"
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-d2i_ECPKParameters"
---

# libressl-d2i\_ECPKParameters(3)

decode and encode ASN.1 representations of elliptic curve entities

## NAME

**d2i\_ECPKParameters**, **i2d\_ECPKParameters**, **d2i\_ECPKParameters\_bio**, **i2d\_ECPKParameters\_bio**, **d2i\_ECPKParameters\_fp**, **i2d\_ECPKParameters\_fp**, **d2i\_ECParameters**, **i2d\_ECParameters**, **ECParameters\_dup**, **d2i\_ECPrivateKey**, **i2d\_ECPrivateKey**, **d2i\_ECPrivateKey\_bio**, **i2d\_ECPrivateKey\_bio**, **d2i\_ECPrivateKey\_fp**, **i2d\_ECPrivateKey\_fp**, **o2i\_ECPublicKey**, **i2o\_ECPublicKey**, **ECPKParameters\_print**, **ECPKParameters\_print\_fp**, **ECParameters\_print**, **ECParameters\_print\_fp**, **d2i\_EC\_PUBKEY**, **i2d\_EC\_PUBKEY**, **d2i\_EC\_PUBKEY\_bio**, **i2d\_EC\_PUBKEY\_bio**, **d2i\_EC\_PUBKEY\_fp**, **i2d\_EC\_PUBKEY\_fp** – decode and encode ASN.1 representations of elliptic curve entities

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*EC\_GROUP* *\**\

**d2i\_ECPKParameters**(*EC\_GROUP \*\*val\_out*, *const unsigned char \*\*der\_in*, *long length*);

*int*\

**i2d\_ECPKParameters**(*const EC\_GROUP \*val\_in*, *unsigned char \*\*der\_out*);

*EC\_GROUP* *\**\

**d2i\_ECPKParameters\_bio**(*BIO \*in\_bio*, *EC\_GROUP \*\*val\_out*);

*int*\

**i2d\_ECPKParameters\_bio**(*BIO \*out\_bio*, *EC\_GROUP \*val\_in*);

*EC\_GROUP* *\**\

**d2i\_ECPKParameters\_fp**(*FILE \*in\_fp*, *EC\_GROUP \*\*val\_out*);

*int*\

**i2d\_ECPKParameters\_fp**(*FILE \*out\_fp*, *EC\_GROUP \*val\_in*);

*EC\_KEY* *\**\

**d2i\_ECParameters**(*EC\_KEY \*\*val\_out*, *const unsigned char \*\*der\_in*, *long length*);

*int*\

**i2d\_ECParameters**(*EC\_KEY \*val\_in*, *unsigned char \*\*der\_out*);

*EC\_KEY* *\**\

**ECParameters\_dup**(*EC\_KEY \*val\_in*);

*EC\_KEY* *\**\

**d2i\_ECPrivateKey**(*EC\_KEY \*\*val\_out*, *const unsigned char \*\*der\_in*, *long length*);

*int*\

**i2d\_ECPrivateKey**(*EC\_KEY \*val\_in*, *unsigned char \*\*der\_out*);

*EC\_KEY* *\**\

**d2i\_ECPrivateKey\_bio**(*BIO \*in\_bio*, *EC\_KEY \*\*val\_out*);

*int*\

**i2d\_ECPrivateKey\_bio**(*BIO \*out\_bio*, *EC\_KEY \*val\_in*);

*EC\_KEY* *\**\

**d2i\_ECPrivateKey\_fp**(*FILE \*in\_fp*, *EC\_KEY \*\*val\_out*);

*int*\

**i2d\_ECPrivateKey\_fp**(*FILE \*out\_fp*, *EC\_KEY \*val\_in*);

*EC\_KEY* *\**\

**o2i\_ECPublicKey**(*EC\_KEY \*\*val\_out*, *const unsigned char \*\*der\_in*, *long length*);

*int*\

**i2o\_ECPublicKey**(*const EC\_KEY \*val\_in*, *unsigned char \*\*der\_out*);

*int*\

**ECPKParameters\_print**(*BIO \*out\_bio*, *const EC\_GROUP \*val\_in*, *int indent*);

*int*\

**ECPKParameters\_print\_fp**(*FILE \*out\_fp*, *const EC\_GROUP \*val\_in*, *int indent*);

*int*\

**ECParameters\_print**(*BIO \*out\_bio*, *const EC\_KEY \*val\_in*);

*int*\

**ECParameters\_print\_fp**(*FILE \*out\_fp*, *const EC\_KEY \*val\_in*);

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

*EC\_KEY* *\**\

**d2i\_EC\_PUBKEY**(*EC\_KEY \*\*val\_out*, *const unsigned char \*\*der\_in*, *long length*);

*int*\

**i2d\_EC\_PUBKEY**(*EC\_KEY \*val\_in*, *unsigned char \*\*der\_out*);

*EC\_KEY* *\**\

**d2i\_EC\_PUBKEY\_bio**(*BIO \*in\_bio*, *EC\_KEY \*\*val\_out*);

*int*\

**i2d\_EC\_PUBKEY\_bio**(*BIO \*out\_bio*, *EC\_KEY \*val\_in*);

*EC\_KEY* *\**\

**d2i\_EC\_PUBKEY\_fp**(*FILE \*in\_fp*, *EC\_KEY \*\*val\_out*);

*int*\

**i2d\_EC\_PUBKEY\_fp**(*FILE \*out\_fp*, *EC\_KEY \*val\_in*);

## DESCRIPTION

These functions decode and encode elliptic curve keys and parameters. For details about the semantics, examples, caveats, and bugs, see ASN1\_item\_d2i(3).

**d2i\_ECPKParameters**() and **i2d\_ECPKParameters**() decode and encode the parameters of an elliptic curve. **d2i\_ECPKParameters\_bio**(), **i2d\_ECPKParameters\_bio**(), **d2i\_ECPKParameters\_fp**(), and **i2d\_ECPKParameters\_fp**() are similar except that they decode or encode using a *BIO* or *FILE* pointer. These four functions are currently implemented as macros.

**d2i\_ECParameters**() does the same parsing as **d2i\_ECPKParameters**() but saves the result in the *group* field of an *EC\_KEY* structure.

**i2d\_ECParameters**() produces the same output as **i2d\_ECPKParameters**() but uses *val\_in-\>group* for input instead of *val\_in*.

**ECParameters\_dup**() allocates and initializes an empty *EC\_KEY* object and copies the EC parameters from *val\_in* to it by calling **i2d\_ECParameters**() and **d2i\_ECParameters**(). If a private or public key or any flags are present in *val\_in*, they are not copied.

**d2i\_ECPrivateKey**() and **i2d\_ECPrivateKey**() decode and encode an EC private key using an ASN.1 *ECPrivateKey* structure defined in RFC 5915 section 3 and used for the privateKey field of the ASN.1 *PrivateKeyInfo* structure defined in RFC 5208 section 5, see PKCS8\_PRIV\_KEY\_INFO\_new(3). **d2i\_ECPrivateKey\_bio**(), **i2d\_ECPrivateKey\_bio**(), **d2i\_ECPrivateKey\_fp**(), and **i2d\_ECPrivateKey\_fp**() are similar except that they decode or encode using a *BIO* or *FILE* pointer.

**o2i\_ECPublicKey**() and **i2o\_ECPublicKey**() decode and encode an EC public key. In contrast to ASN1\_item\_d2i(3), **o2i\_ECPublicKey**() requires *val\_out*, \**val\_out*, and (\**val\_out*)-\>*group* to be non-NULL.

**ECPKParameters\_print**() and **ECPKParameters\_print\_fp**() print human-readable output of the public parameters of the *EC\_GROUP* to *out\_bio* or *out\_fp*. The output lines are indented by *indent* spaces.

**ECParameters\_print**() and **ECParameters\_print\_fp**() print the parameter components of *val\_in* to *out\_bio* or *out\_fp*.

**d2i\_EC\_PUBKEY**() and **i2d\_EC\_PUBKEY**() decode and encode an EC public key using an ASN.1 *SubjectPublicKeyInfo* structure defined in RFC 5280 section 4.1 and documented in X509\_PUBKEY\_new(3). **d2i\_EC\_PUBKEY\_bio**(), **i2d\_EC\_PUBKEY\_bio**(), **d2i\_EC\_PUBKEY\_fp**(), and **i2d\_EC\_PUBKEY\_fp**() are similar except that they decode or encode using a *BIO* or *FILE* pointer.

## RETURN VALUES

**d2i\_ECPKParameters**(), **d2i\_ECPKParameters\_bio**(), and **d2i\_ECPKParameters\_fp**() return a valid *EC\_GROUP* structure or NULL if an error occurs.

**d2i\_ECParameters**(), **ECParameters\_dup**(), **d2i\_ECPrivateKey**(), **d2i\_ECPrivateKey\_bio**(), **d2i\_ECPrivateKey\_fp**(), **o2i\_ECPublicKey**(), **d2i\_EC\_PUBKEY**(), **d2i\_EC\_PUBKEY\_bio**(), and **d2i\_EC\_PUBKEY\_fp**() return a valid *EC\_KEY* structure or NULL if an error occurs.

**i2d\_ECPKParameters**(), **i2d\_ECParameters**(), **i2d\_ECPrivateKey**(), **i2o\_ECPublicKey**(), and **i2d\_EC\_PUBKEY**() return the number of bytes successfully encoded or a negative value if an error occurs.

**i2d\_ECPKParameters\_bio**(), **i2d\_ECPKParameters\_fp**(), **i2d\_ECPrivateKey\_bio**(), **i2d\_ECPrivateKey\_fp**(), **ECPKParameters\_print**(), **ECPKParameters\_print\_fp**(), **ECParameters\_print**(), **ECParameters\_print\_fp**(), **i2d\_EC\_PUBKEY\_bio**(), and **i2d\_EC\_PUBKEY\_fp**() return 1 for success or 0 if an error occurs.

## SEE ALSO

ASN1\_item\_d2i(3), EC\_GROUP\_new\_by\_curve\_name(3), EC\_KEY\_new(3), EVP\_PKEY\_set1\_EC\_KEY(3), PEM\_write\_ECPrivateKey(3), PKCS8\_PRIV\_KEY\_INFO\_new(3), X509\_PUBKEY\_new(3)

## STANDARDS

RFC 5915: Elliptic Curve Private Key Structure

RFC 5208: Public-Key Cryptography Standards (PKCS) #8: Private-Key Information Syntax Specification

RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile, section 4.1: Basic Certificate Fields

## HISTORY

**d2i\_ECPKParameters**(), **i2d\_ECPKParameters**(), **d2i\_ECPKParameters\_bio**(), **i2d\_ECPKParameters\_bio**(), **d2i\_ECPKParameters\_fP**(), **i2d\_ECPKParameters\_fp**(), **d2i\_ECParameters**(), **i2d\_ECParameters**(), **ECParameters\_dup**(), **d2i\_ECPrivateKey**(), **i2d\_ECPrivateKey**(), **d2i\_ECPrivateKey\_bio**(), **i2d\_ECPrivateKey\_bio**(), **d2i\_ECPrivateKey\_fp**(), **i2d\_ECPrivateKey\_fp**(), **o2i\_ECPublicKey**(), **i2o\_ECPublicKey**(), **ECPKParameters\_print**(), **ECPKParameters\_print\_fp**(), **ECParameters\_print**(), **ECParameters\_print\_fp**(), **d2i\_EC\_PUBKEY**(), **i2d\_EC\_PUBKEY**(), **d2i\_EC\_PUBKEY\_bio**(), **i2d\_EC\_PUBKEY\_bio**(), **d2i\_EC\_PUBKEY\_fp**(), and **i2d\_EC\_PUBKEY\_fp**() first appeared in OpenSSL 0.9.8 and have been available since OpenBSD 4.5.
