X509_ALGOR_DUP(3ossl)

πŸ’– X509_ALGOR_DUP πŸ’–

okay bestie, so this is a page from the OpenSSL manuals, and it's all about the AlgorithmIdentifier functions β€” X509_ALGOR_dup, X509_ALGOR_set0, X509_ALGOR_get0, X509_ALGOR_set_md, X509_ALGOR_cmp, and X509_ALGOR_copy. yes the name is giving "six functions in one trenchcoat" but that's literally how OpenSSL do it. 🫢


✨ 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);

like look at that lineup. six icons. no notes. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

  • X509_ALGOR_dup() β€” hands you back a copy of alg. that's it, that's the whole job, and she does it flawlessly.
  • 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, then the parameter is just… omitted, gone, not invited. otherwise ptype and pval mean exactly the same thing as the type and value parameters to ASN1_TYPE_set(). and now the important part bestie:
🚨 all the supplied parameters are used internally, so you must NOT free them after this call succeeded. otherwise, ownership stays with you (the caller) and alg is left completely untouched. so like, either it takes the whole thing or it takes nothing. no in-between, no half-committed situationships. πŸ’…
  • X509_ALGOR_get0() β€” the inverse of X509_ALGOR_set0(), the two of them are literally mirror selfies. it returns the algorithm OID in *paobj, and the associated parameter in *pptype and *ppval, pulled from the AlgorithmIdentifier alg.
  • X509_ALGOR_set_md() β€” sets the AlgorithmIdentifier alg to the appropriate values for the message digest md. she's the matchmaker fr fr. πŸŽ€
  • X509_ALGOR_cmp() β€” compares a and b, and returns 0 if they have identical encodings, nonzero otherwise. it's a vibe check on the encoding level, not a personality test.
  • X509_ALGOR_copy() β€” copies the source values into the dest structs, making a duplicate of each one. and yes, it also frees anything pointed to from within *dest, so it's a clean overwrite, not a messy pile-up. ✨

🌈 RETURN VALUES 🌈

  • X509_ALGOR_dup() β€” returns a valid X509_ALGOR structure, or NULL if an error occurred. 😭 (that NULL is the "we need to talk" text of return values)
  • 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 at all. they simply do the thing and leave. main character energy. πŸ’…
  • X509_ALGOR_cmp() β€” returns 0 if the two parameters have identical encodings, and nonzero otherwise.

🌸 HISTORY 🌸

so X509_ALGOR_copy() is the baby of the group β€” she was added in 1.1.1e. the others were already out here thriving before her. ⭐


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 and that's the whole page, periodt πŸŽ€ this was X509_ALGOR_DUP from the OpenSSL 3ossl manual set, dated 2026-09-29, version 3.5.9 β€” take care of her, she's iconic πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from