X509_ALGOR_DUP(3ossl)
π 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 ofalg. that's it. that's the whole function. dupe it, girl πX509_ALGOR_set0()β sets the algorithm OID ofalgtoaobj, and sets the associated parameter type toptypewith valuepval. ifptypeisV_ASN1_UNDEFthe parameter is just... omitted, gone, not invited to the party. otherwiseptypeandpvalmean exactly the same thing as the type and value parameters toASN1_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 ofX509_ALGOR_set0(). it hands you back the algorithm OID in*paobjand the associated parameter in*pptypeand*ppval, pulled out of theAlgorithmIdentifieralg. get0 is giving "read the receipt" energy π§ΎX509_ALGOR_set_md()β sets theAlgorithmIdentifieralgto the appropriate values for the message digestmd. md goes in, correct algorithm identifier comes out. slay β¨X509_ALGOR_cmp()β comparesaandb, returns0if they have identical encodings and nonzero otherwise. classic.X509_ALGOR_copy()β copies the source values into thedeststructs, 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 validX509_ALGORstructure, orNULLif an error occurred.NULLis the "it's giving nothing, because something broke" case πX509_ALGOR_set0()andX509_ALGOR_copy()β return1on success or0on error.X509_ALGOR_get0()andX509_ALGOR_set_md()β return no values. they're void, they simply do not report back, main character energy πX509_ALGOR_cmp()β returns0if 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 π
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
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms