ASN1_ITEM_DIGEST(3)

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

🌸 ASN1_ITEM_DIGEST(3) 🌸

okay bestie, welcome to the Library Functions Manual page for ASN1_ITEM_DIGEST(3) β€” yes, all caps, iconic, we move πŸ’…


✨ NAME ✨

ASN1_item_digest β€” DER-encode and hash an ASN.1 value. That's the whole mission, no cap: DER-encode it, hash it, done 🫢

πŸ“œ SYNOPSIS πŸ“œ

here's the signature, copied exactly because we do not mess with code, periodt:

#include <openssl/x509.h>

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. Then it encodes that value into DER format by calling ASN1_item_i2d(3), hashes the resulting byte array using the digest type by calling EVP_Digest(3), and places the digest value into *md. Unless s is NULL, it also places the length in bytes of the digest into *s.

Providing a buffer *md large enough to contain the digest is your responsibility, bestie β€” the caller's job, not a vibe we can skip. Providing a buffer of EVP_MAX_MD_SIZE bytes is recommended. That's lowkey the buffer glow-up, slay 🧚

πŸŽ€ RETURN VALUES πŸŽ€

ASN1_item_digest() returns 1 for success or 0 if encoding or hashing fails. That's it β€” no secret third option, vibe check passed, iykyk 😌

πŸ¦‹ SEE ALSO πŸ¦‹

go read these too, bestie, they're in the group chat 🌈

⭐ HISTORY ⭐

ASN1_item_digest() first appeared in OpenSSL 0.9.7 and has been available since OpenBSD 3.1. history lesson served fresh πŸ‘‘


okay that's the page! source/version: Debian; date: September 11, 2022 β€” mwah, stay hydrated and hash responsibly πŸ’‹

πŸ“¦ where this page comes from