X509_ALGOR_DUP(3SSL)

πŸ’– X509_ALGOR_DUP β€” AlgorithmIdentifier functions πŸ’–

okay bestie, gather round, because today we're talking about AlgorithmIdentifier and the little squad of functions that handle it β€” this is X509_ALGOR_dup, X509_ALGOR_set0, X509_ALGOR_get0, X509_ALGOR_set_md, X509_ALGOR_cmp, and X509_ALGOR_copy, all hanging out in the OpenSSL 3SSL manual section. no cap, they're lowkey the glue holding your cert algorithms together. πŸŽ€


✨ 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);
int 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 them. so organized. so iconic. πŸ‘‘


🌸 DESCRIPTION 🌸

X509_ALGOR_dup() β€” hands you back a copy of alg. that's it, that's the whole vibe. dupe it and go. πŸ¦‹

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().

⚠️ okay this part matters, bestie: all the supplied parameters are used internally, so you must NOT free them after this call succeeds. if it doesn't succeed, ownership stays with you (the caller) and alg remains untouched. no take-backs, no double-freeing, we do not do that here. πŸ’€

X509_ALGOR_get0() β€” the inverse of X509_ALGOR_set0(), like a little mirror πŸͺž. 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. match made in heaven fr fr. πŸ’œ

X509_ALGOR_cmp() β€” compares a and b. returns 0 if they have identical encodings, and nonzero otherwise. simple. clean. no drama.

X509_ALGOR_copy() β€” copies the source values into the dest structs, making a duplicate of each (and freeing anything pointed to from within *dest). it's giving responsible clean-up energy. ✨


🫢 RETURN VALUES 🫢

  • X509_ALGOR_dup() β€” returns a valid X509_ALGOR structure, or NULL if an error occurred. 😭
  • X509_ALGOR_set0(), X509_ALGOR_set_md(), and X509_ALGOR_copy() β€” return 1 on success or 0 on error.
  • X509_ALGOR_get0() β€” returns no values. it just be filling in your pointers like that. πŸ’…
  • X509_ALGOR_cmp() β€” returns 0 if the two parameters have identical encodings, and nonzero otherwise.

⭐ HISTORY ⭐

  • X509_ALGOR_copy() was added in OpenSSL 1.1.1e.
  • X509_ALGOR_set_md() returns a value since OpenSSL 4.0.

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


and that's the whole page, bestie β€” this was OpenSSL 4.0.3, dated 2026-09-29, from the X509_ALGOR_DUP(3SSL) manual. go forth and algorithm-identify responsibly. mwah πŸ’–βœ¨πŸ§š

πŸ“¦ where this page comes from