X509_DIGEST(3ossl)
Hey bestie! Welcome to the X509_DIGEST(3ossl) page β it's an OpenSSL section 3 manual page, and we're about to get into some digest drama. No cap, this one's actually useful. π
π NAME π
Okay so these are the functions that live here, and they're all about getting digests of various objects. Slay:
X509_digestX509_digest_sigX509_CRL_digestX509_pubkey_digestX509_NAME_digestX509_REQ_digestPKCS7_ISSUER_AND_SERIAL_digest
πΈ SYNOPSIS πΈ
Like, here's the exact code you need to include and the signatures, periodt:
#include <openssl/x509.h>
int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md,
unsigned int *len);
ASN1_OCTET_STRING *X509_digest_sig(const X509 *cert,
EVP_MD **md_used, int *md_is_fallback);
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 π
β¨ X509_digest_sig() β the main character
Okay so X509_digest_sig() calculates a digest of the given certificate cert using the same hash algorithm as in its signature, if the digest is an integral part of the certificate signature algorithm identifier. Otherwise, a fallback hash algorithm is determined like this:
SHA512if the signature algorithm isED25519SHAKE256if it isED448- otherwise
SHA256
The output parameters are assigned as follows. Unless md_used is NULL, the hash algorithm used is provided in *md_used and must be freed by the caller (if it is not NULL). Unless md_is_fallback is NULL, the *md_is_fallback is set to 1 if the hash algorithm used is a fallback, otherwise to 0.
β οΈ Bestie, listen: if*md_usedisn'tNULL, you gotta free it yourself. That's not a drill. π
π¦ X509_pubkey_digest() β public key only
X509_pubkey_digest() returns a digest of the DER representation of the public key in the specified X509 data object. It's giving "just the key, none of the extra". π
π All the other functions
All other functions described here return a digest of the DER representation of their entire data objects. Simple as that.
π Common parameters
The type parameter specifies the digest to be used, such as EVP_sha1(). The md is a pointer to the buffer where the digest will be copied and is assumed to be large enough; the constant EVP_MAX_MD_SIZE is suggested. The len parameter, if not NULL, points to a place where the digest size will be stored.
π«Ά Friendly reminder:mdis assumed to be large enough. Don't come for me if you undersize your buffer.EVP_MAX_MD_SIZEis the suggested constant, iykyk.
π RETURN VALUES π
X509_digest_sig()returns anASN1_OCTET_STRINGpointer on success, elseNULL.- All other functions described here return
1for success and0for failure.
β¨ SEE ALSO β¨
π¦ HISTORY π¦
The X509_digest_sig() function was added in OpenSSL 3.0. Iconic behavior, honestly.
π COPYRIGHT π
Copyright 2017-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>.
This page is from OpenSSL 3.5.0 and dated 2026-09-25. That's the tea! πβ¨
π¦ 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