1 1.1 christos =pod 2 1.1 christos 3 1.1 christos =head1 NAME 4 1.1 christos 5 1.1.1.2 christos X509_digest, 6 1.1.1.2 christos X509_digest_sig, 7 1.1.1.2 christos X509_CRL_digest, 8 1.1 christos X509_pubkey_digest, 9 1.1 christos X509_NAME_digest, 10 1.1 christos X509_REQ_digest, 11 1.1 christos PKCS7_ISSUER_AND_SERIAL_digest 12 1.1 christos - get digest of various objects 13 1.1 christos 14 1.1 christos =head1 SYNOPSIS 15 1.1 christos 16 1.1 christos #include <openssl/x509.h> 17 1.1 christos 18 1.1 christos int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, 19 1.1 christos unsigned int *len); 20 1.1.1.2 christos ASN1_OCTET_STRING *X509_digest_sig(const X509 *cert, 21 1.1.1.2 christos EVP_MD **md_used, int *md_is_fallback); 22 1.1 christos 23 1.1 christos int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md, 24 1.1 christos unsigned int *len); 25 1.1 christos 26 1.1 christos int X509_pubkey_digest(const X509 *data, const EVP_MD *type, 27 1.1 christos unsigned char *md, unsigned int *len); 28 1.1 christos 29 1.1 christos int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type, 30 1.1 christos unsigned char *md, unsigned int *len); 31 1.1 christos 32 1.1 christos int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, 33 1.1 christos unsigned char *md, unsigned int *len); 34 1.1 christos 35 1.1 christos #include <openssl/pkcs7.h> 36 1.1 christos 37 1.1 christos int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, 38 1.1 christos const EVP_MD *type, unsigned char *md, 39 1.1 christos unsigned int *len); 40 1.1 christos 41 1.1 christos =head1 DESCRIPTION 42 1.1 christos 43 1.1.1.2 christos X509_digest_sig() calculates a digest of the given certificate I<cert> 44 1.1.1.2 christos using the same hash algorithm as in its signature, if the digest 45 1.1.1.2 christos is an integral part of the certificate signature algorithm identifier. 46 1.1.1.2 christos Otherwise, a fallback hash algorithm is determined as follows: 47 1.1.1.3 christos SHA512 if the signature algorithm is ED25519, 48 1.1.1.2 christos SHAKE256 if it is ED448, otherwise SHA256. 49 1.1.1.3 christos The output parameters are assigned as follows. 50 1.1.1.2 christos Unless I<md_used> is NULL, the hash algorithm used is provided 51 1.1.1.2 christos in I<*md_used> and must be freed by the caller (if it is not NULL). 52 1.1.1.2 christos Unless I<md_is_fallback> is NULL, 53 1.1.1.2 christos the I<*md_is_fallback> is set to 1 if the hash algorithm used is a fallback, 54 1.1.1.2 christos otherwise to 0. 55 1.1.1.2 christos 56 1.1 christos X509_pubkey_digest() returns a digest of the DER representation of the public 57 1.1.1.2 christos key in the specified X509 I<data> object. 58 1.1.1.2 christos 59 1.1 christos All other functions described here return a digest of the DER representation 60 1.1.1.2 christos of their entire I<data> objects. 61 1.1 christos 62 1.1.1.2 christos The I<type> parameter specifies the digest to 63 1.1.1.2 christos be used, such as EVP_sha1(). The I<md> is a pointer to the buffer where the 64 1.1 christos digest will be copied and is assumed to be large enough; the constant 65 1.1.1.2 christos B<EVP_MAX_MD_SIZE> is suggested. The I<len> parameter, if not NULL, points 66 1.1 christos to a place where the digest size will be stored. 67 1.1 christos 68 1.1 christos =head1 RETURN VALUES 69 1.1 christos 70 1.1.1.2 christos X509_digest_sig() returns an ASN1_OCTET_STRING pointer on success, else NULL. 71 1.1.1.2 christos 72 1.1.1.2 christos All other functions described here return 1 for success and 0 for failure. 73 1.1 christos 74 1.1 christos =head1 SEE ALSO 75 1.1 christos 76 1.1 christos L<EVP_sha1(3)> 77 1.1 christos 78 1.1.1.2 christos =head1 HISTORY 79 1.1.1.2 christos 80 1.1.1.2 christos The X509_digest_sig() function was added in OpenSSL 3.0. 81 1.1.1.2 christos 82 1.1 christos =head1 COPYRIGHT 83 1.1 christos 84 1.1.1.3 christos Copyright 2017-2023 The OpenSSL Project Authors. All Rights Reserved. 85 1.1 christos 86 1.1.1.2 christos Licensed under the Apache License 2.0 (the "License"). You may not use 87 1.1 christos this file except in compliance with the License. You can obtain a copy 88 1.1 christos in the file LICENSE in the source distribution or at 89 1.1 christos L<https://www.openssl.org/source/license.html>. 90 1.1 christos 91 1.1 christos =cut 92