ASN1_ITEM_DIGEST(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’– ASN1_ITEM_DIGEST(3) πŸ’–

okay bestie, welcome to the ASN1_ITEM_DIGEST(3) page from the Library Functions Manual β€” it's giving β€œDER-encode an ASN.1 value and then hash it” energy, and honestly? iconic. πŸ¦‹


✨ NAME ✨

ASN1_item_digest β€” DER-encode and hash an ASN.1 value πŸ’…


🌸 SYNOPSIS 🌸

so you're linking libcrypto, and the include is literally:

#include <openssl/x509.h>

then the function signature is exactly this, no cap:

int
ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *val_in,
    unsigned char *md, unsigned int *s);

πŸŽ€ DESCRIPTION πŸŽ€

okay so ASN1_item_digest() assumes that val_in is an ASN1_VALUE of the type specified by it. it encodes it into DER format by calling ASN1_item_i2d(3), then hashes the resulting byte array using the digest type by calling EVP_Digest(3). πŸ’«

then it places the digest value into *md, and β€” unless s is NULL β€” it places the length in bytes of the digest into *s. simple as that, bestie. 🫢

⚠️ okay but fr fr: providing a buffer *md large enough to contain the digest is your responsibility, not the function's. providing a buffer of EVP_MAX_MD_SIZE bytes is recommended. don't forget, iykyk. πŸ’€

πŸ”₯ RETURN VALUES πŸ”₯

ASN1_item_digest() returns 1 for success or 0 if encoding or hashing fails. that's the whole vibe check. ✨


🌈 SEE ALSO 🌈


πŸ‘‘ HISTORY πŸ‘‘

ASN1_item_digest() first appeared in OpenSSL 0.9.7 and has been available since OpenBSD 3.1. vintage but still slaying. πŸ’œ


mwah πŸ’‹ this page came from Debian, dated June 8, 2025 β€” bye bestie, go hash something cute πŸŽ€

πŸ“¦ where this page comes from