X509_DIGEST(3)

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

πŸ’– X509_DIGEST(3) πŸ’–

okay bestie, so this is part of libcrypto and it's literally the manual for getting digests of a bunch of X.509-ish objects. no cap, the header on this one is X509_DIGEST(3) β€” we're in the Library Functions Manual, mwah πŸ’…


✨ NAME ✨

X509_digest, X509_CRL_digest, X509_pubkey_digest, X509_NAME_digest, X509_REQ_digest, PKCS7_ISSUER_AND_SERIAL_digest β€” get digests of various objects πŸŽ€


🌸 SYNOPSIS 🌸

library β€œlibcrypto” #include <openssl/x509.h>

int
X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md,
    unsigned int *len);

int
X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,
    unsigned char *md, unsigned int *len);

int
X509_pubkey_digest(const X509 *data, const EVP_MD *type,
    unsigned char *md, unsigned int *len);

int
X509_REQ_digest(const X509_REQ *data, const EVP_MD *type,
    unsigned char *md, unsigned int *len);

int
X509_NAME_digest(const X509_NAME *data, const EVP_MD *type,
    unsigned char *md, unsigned int *len);

#include <openssl/pkcs7.h>

int
PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,
    const EVP_MD *type, unsigned char *md, unsigned int *len);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, bestie β˜• X509_pubkey_digest() gives you a digest of the DER representation of the public key contained in data. and literally all the other functions on this page? they give you a digest of the DER representation of their entire data object. like, the whole thing, no holding back πŸ’β€β™€οΈ

the type parameter is where you say which digest you want β€” something like EVP_sha1(3) πŸ‘‘

md is a pointer to the buffer where the digest gets copied, and it just assumes the buffer is big enough (rude but okay πŸ™ˆ). a size of at least EVP_MAX_MD_SIZE bytes is suggested, ngl please listen to that ✨

and the len parameter? if it's not NULL, it points to a place where the digest size gets stored 🎯


πŸ‘‘ RETURN VALUES πŸ‘‘

these functions return 1 for success or 0 for failure. that's it, that's the vibe check πŸ’€ periodt.


πŸ”₯ SEE ALSO πŸ”₯

EVP_get_digestbyname(3), X509_cmp(3), X509_CRL_new(3), X509_NAME_new(3), X509_new(3), X509_REQ_new(3) β€” go read these next bestie, iykyk 🫢


🌈 HISTORY 🌈

so the lore goes deep, fr fr:

  • X509_digest(), X509_NAME_digest(), and PKCS7_ISSUER_AND_SERIAL_digest() first appeared in SSLeay 0.6.5 and have been available since OpenBSD 2.4. iconic elders πŸ‘΅βœ¨
  • X509_CRL_digest() and X509_REQ_digest() first appeared in OpenSSL 0.9.6 and have been available since OpenBSD 2.9. glow up era 🌱
  • X509_pubkey_digest() first appeared in OpenSSL 0.9.7 and has been available since OpenBSD 3.2. late bloomer but we love her πŸ¦‹

and that's the whole page, bestie πŸ’– this diva came to us from Debian, dated June 8, 2025, and it's the X509_DIGEST(3) manual page β€” go forth and digest responsibly, mwah πŸ˜­πŸ’…πŸŽ€

πŸ“¦ where this page comes from