2
0

X509_digest.pod 3.0 KB

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