LIBRESSL-EVP_PKEY_GET_DEFAULT_DIGEST_NID(3)

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

πŸ’… EVP_PKEY_GET_DEFAULT_DIGEST_NID(3) β€” get default signature digest πŸ’…

okay so bestie, this is a LibreSSL libcrypto page from the Library Functions Manual, and it's here to explain how to get the default signature digest for a public key. slay ✨

🌸 NAME 🌸

EVP_PKEY_get_default_digest_nid β€” get default signature digest

πŸ“œ SYNOPSIS πŸ“œ

here's the synopsis, character-for-character, curly quotes and all 🫢

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

int
EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);

πŸ’– DESCRIPTION πŸ’–

The EVP_PKEY_get_default_digest_nid() function sets *pnid to the default message digest NID for the public key signature operations associated with pkey. literally what it says on the tin πŸ’…

Some signature algorithms, for example EVP_PKEY_ED25519, do not use a digest during signing. In this case, *pnid is set to NID_undef. no digest, no drama πŸ¦‹

Support for the following public key algorithms is built into the library. The columns are EVP_PKEY_base_id(3), *pnid, and return value β€” here's the same tea in bullet form:

  • For EVP_PKEY_DSA: *pnid is NID_sha1, and the return value label is mandatory.
  • For EVP_PKEY_EC: *pnid is NID_sha1, and the return value label is mandatory.
  • For EVP_PKEY_ED25519: *pnid is NID_undef, and the return value label is mandatory.
  • For EVP_PKEY_HMAC: *pnid is NID_sha1, and the return value label is advisory.
  • For EVP_PKEY_RSA: *pnid is NID_sha256, and the return value label is advisory.

πŸ”₯ RETURN VALUES πŸ”₯

The EVP_PKEY_get_default_digest_nid() function returns 1 if the message digest is advisory (that is, other digests can be used) and 2 if it is mandatory (other digests cannot be used). It returns 0 or a negative value for failure. In particular, a return value of -2 indicates the operation is not supported by the public key algorithm. that -2 is the "algorithm said no ❀️" signal 😭

πŸ‘€ SEE ALSO πŸ‘€

πŸ•°οΈ HISTORY πŸ•°οΈ

EVP_PKEY_get_default_digest_nid() first appeared in OpenSSL 1.0.0 and has been available since OpenBSD 4.9. vintage but still iconic πŸ’«


footer sign-off: source/version is Debian, date is June 8 (the year in the raw footer is colliding with the page tag, so I am not inventing digits, bestie 😭), and the page tag is EVP_PKEY_GET_DEFAULT_DIGEST_NID(3). mwah πŸ’‹πŸŽ€

πŸ“¦ where this page comes from