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

# libressl-X509\_ALGOR\_dup(3)

create, change, and inspect algorithm identifiers

## NAME

**X509\_ALGOR\_new**, **X509\_ALGOR\_free**, **X509\_ALGOR\_dup**, **X509\_ALGOR\_set0**, **X509\_ALGOR\_get0**, **X509\_ALGOR\_cmp** – create, change, and inspect algorithm identifiers

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

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

*X509\_ALGOR* *\**\

**X509\_ALGOR\_new**(*void*);

*void*\

**X509\_ALGOR\_free**(*X509\_ALGOR \*alg*);

*X509\_ALGOR* *\**\

**X509\_ALGOR\_dup**(*X509\_ALGOR \*alg*);

*int*\

**X509\_ALGOR\_set0**(*X509\_ALGOR \*alg*, *ASN1\_OBJECT \*aobj*, *int ptype*, *void \*pval*);

*void*\

**X509\_ALGOR\_get0**(*const ASN1\_OBJECT \*\*paobj*, *int \*pptype*, *const void \*\*ppval*, *const X509\_ALGOR \*alg*);

*int*\

**X509\_ALGOR\_cmp**(*const X509\_ALGOR \*a*, *const X509\_ALGOR \*b*);

## DESCRIPTION

An *X509\_ALGOR* object represents an ASN.1 *AlgorithmIdentifier* structure defined in RFC 5280 section 4.1.1.2. It specifies a cryptographic *algorithm* by an ASN.1 object identifier (OID) that can be obtained from OBJ\_nid2obj(3), together with optional algorithm-specific *parameters* of the type *ASN1\_TYPE*, see ASN1\_TYPE\_set(3). *X509\_ALGOR* objects are used by many other objects, for example certificates, certificate revocation lists, and certificate requests.

**X509\_ALGOR\_new**() allocates a new *X509\_ALGOR* object containing the object that OBJ\_nid2obj(3) returns for NID\_undef as the *algorithm* and a NULL pointer as the *parameters*.

**X509\_ALGOR\_free**() frees *alg* and any data contained in it. If *alg* is NULL, no action occurs.

**X509\_ALGOR\_dup**() creates a deep copy of *alg*. It is implemented by calling ASN1\_item\_dup(3) with arguments of X509\_ALGOR\_it and *alg*, which is equivalent to calling i2d\_X509\_ALGOR(3) and d2i\_X509\_ALGOR(3).

**X509\_ALGOR\_set0**() sets the algorithm OID of *alg* to *aobj* and the associated parameter type to *ptype* with value *pval*. If *ptype* is V\_ASN1\_UNDEF, the parameter is omitted and *pval* is ignored. If *ptype* is zero, *pval* is ignored and the existing parameter is left unchanged, or if *alg* does not contain a parameter, a new, empty parameter of type V\_ASN1\_UNDEF is added. Otherwise *ptype* and *pval* have the same meaning as the *type* and *value* parameters to ASN1\_TYPE\_set(3). Ownership of *aobj* and, unless it is ignored, of *pval* is transferred to *alg* on success.

**X509\_ALGOR\_get0**() returns *alg*'s algorithm OID in \**paobj*, its parameter type in \**pptype*, and its parameter value in \**ppval*. Any of *paobj*, *pptype*, and *ppval* can be NULL. If *pptype*, *is* NULL or if \**pptype* is V\_ASN1\_UNDEF then \**ppval*'s value is undefined.

**X509\_ALGOR\_cmp**() compares *a* and *b*.

## RETURN VALUES

**X509\_ALGOR\_new**() and **X509\_ALGOR\_dup**() return a new *X509\_ALGOR* object or NULL if an error occurs.

**X509\_ALGOR\_set0**() returns 1 for success or 0 if *alg* is NULL or memory allocation fails.

**X509\_ALGOR\_cmp**() returns 0 if *a* and *b* have identical encodings or non-zero otherwise.

## SEE ALSO

ASN1\_TYPE\_set(3), d2i\_X509\_ALGOR(3), EVP\_DigestInit(3), OBJ\_nid2obj(3), X509\_get0\_signature(3), X509\_new(3), X509\_PUBKEY\_get0\_param(3), X509\_signature\_dump(3)

## STANDARDS

RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile

## HISTORY

**X509\_ALGOR\_new**() and **X509\_ALGOR\_free**() appeared in SSLeay 0.4 or earlier and have been available since OpenBSD 2.4.

**X509\_ALGOR\_dup**() first appeared in SSLeay 0.9.1 and has been available since OpenBSD 2.6.

**X509\_ALGOR\_set0**() and **X509\_ALGOR\_get0**() first appeared in OpenSSL 0.9.8h and have been available since OpenBSD 4.5.

**X509\_ALGOR\_cmp**() first appeared in OpenSSL 0.9.8zd, 1.0.0p, and 1.0.1k and has been available since OpenBSD 4.9.
