X509_ALGOR_DUP(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… X509_ALGOR_DUP β€” algorithm identifier functions, bestie

okay so this is from the OpenSSL manual, section 3ossl, and it's literally all about AlgorithmIdentifier β€” the little "which algorithm + what params" combo that shows up everywhere in X.509 land. stay with me, it's actually not scary πŸ¦‹


✨ SYNOPSIS ✨

#include <openssl/x509.h>

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);
void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md);
int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b);
int X509_ALGOR_copy(X509_ALGOR *dest, const X509_ALGOR *src);

🌸 DESCRIPTION 🌸

  • X509_ALGOR_dup() β€” returns a copy of alg. that's it. that's the whole function. dupe it, girl πŸ’–
  • X509_ALGOR_set0() β€” sets the algorithm OID of alg to aobj, and sets the associated parameter type to ptype with value pval. if ptype is V_ASN1_UNDEF the parameter is just... omitted, gone, not invited to the party. otherwise ptype and pval mean exactly the same thing as the type and value parameters to ASN1_TYPE_set() (iykyk).
⚠️ listen to me. all the supplied parameters are used internally, so they must NOT be freed after this call succeeds. if the call doesn't succeed, ownership stays with you (the caller) and alg is left untouched. no takebacksies either way 🫢
  • X509_ALGOR_get0() β€” the inverse of X509_ALGOR_set0(). it hands you back the algorithm OID in *paobj and the associated parameter in *pptype and *ppval, pulled out of the AlgorithmIdentifier alg. get0 is giving "read the receipt" energy 🧾
  • X509_ALGOR_set_md() β€” sets the AlgorithmIdentifier alg to the appropriate values for the message digest md. md goes in, correct algorithm identifier comes out. slay ✨
  • X509_ALGOR_cmp() β€” compares a and b, returns 0 if they have identical encodings and nonzero otherwise. classic.
  • X509_ALGOR_copy() β€” copies the source values into the dest structs, making a duplicate of each one (and frees anything pointed to from within *dest). so it's a "copy over, but clean up your room first" situation πŸŽ€

πŸ‘‘ RETURN VALUES πŸ‘‘

  • X509_ALGOR_dup() β€” returns a valid X509_ALGOR structure, or NULL if an error occurred. NULL is the "it's giving nothing, because something broke" case 😭
  • X509_ALGOR_set0() and X509_ALGOR_copy() β€” return 1 on success or 0 on error.
  • X509_ALGOR_get0() and X509_ALGOR_set_md() β€” return no values. they're void, they simply do not report back, main character energy πŸ’…
  • X509_ALGOR_cmp() β€” returns 0 if the two parameters have identical encodings and nonzero otherwise. (yep, same as up top β€” that's fr fr what it says.)

⭐ HISTORY ⭐

the X509_ALGOR_copy() was added in 1.1.1e. new-ish but iconic.


Copyright 2002-2022 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.


okay that's the whole page, you ate that πŸ’–βœ¨ this was X509_ALGOR_DUP(3ossl) from OpenSSL version 3.5.0, dated 2026-09-25 β€” go forth and dup responsibly, mwah πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from