EVP_PKEY_GET...LT_DIGEST_NID(3ossl)
π EVP_PKEY_GET_DEFAULT_DIGEST_NAME / EVP_PKEY_GET_DEFAULT_DIGEST_NID π
okay bestie, so this is a page from the OpenSSL manual β yes, that OpenSSL, the one your whole internet secretly runs on π«Ά β and it's all about the two lil' functions that tell you which digest a key wants for signing. grab a boba, we're getting into it β¨
πΈ NAME πΈ
EVP_PKEY_get_default_digest_nid, EVP_PKEY_get_default_digest_name β get the default signature digest, that's the whole vibe π«
π¦ SYNOPSIS π¦
#include <openssl/evp.h>
int EVP_PKEY_get_default_digest_name(EVP_PKEY *pkey,
char *mdname, size_t mdname_sz);
int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);
look at them, so tidy, so iconic π
π DESCRIPTION π
β¨ EVP_PKEY_get_default_digest_name() β¨
so this one fills in the default message digest name for the public key signature operations that go with the key pkey β and it drops that name into mdname, writing up to at most mdname_sz bytes, and that count includes the ending NUL byte, so don't forget to leave room for the terminator bestie π
and here's the fun part: the name could be "UNDEF", which is basically the function saying "idk, digest is optional-ish" β it means a digest must (that's for return value 2) or may (that's for return value 1) be left unspecified. iykyk π
β¨ EVP_PKEY_get_default_digest_nid() β¨
this one sets pnid to the default message digest NID for the public key signature operations associated with pkey. lowkey important detail: some signature algorithms β looking at you, Ed25519 and Ed448 π β do not use a digest during signing. in that case pnid gets set to NID_undef, no drama.
and ngl, this function is only reliable for legacy keys β meaning keys with aEVP_PKEY_ASN1_METHOD. those keys have typically been loaded from engines, or created withEVP_PKEY_assign_RSA(3)or something similar. bestie please note the "only reliable", it's giving fine-print for a reason π
π NOTES π
for all current standard OpenSSL public key algorithms, SHA256 is returned. that's it, that's the note. slay, consistency π
π₯ RETURN VALUES π₯
both EVP_PKEY_get_default_digest_name() and EVP_PKEY_get_default_digest_nid() return:
1if the message digest is advisory β meaning, other digests can be used π«Ά2if it is mandatory β meaning, other digests can not be used, periodt π«
and for failure? they return 0 or a negative value. and in particular β mark this in your notes bestie β
a return value of -2 means the operation is not supported by the public key algorithm π
π SEE ALSO π
go read these next, they're in the group chat too:
EVP_PKEY_CTX_new(3)EVP_PKEY_sign(3)EVP_PKEY_digestsign_supports_digest(3)EVP_PKEY_verify(3)EVP_PKEY_verify_recover(3)
π§ HISTORY π§
this function was added in OpenSSL 1.0.0 β a true elder, been serving looks since day one β
π COPYRIGHT π
Copyright 2006-2023 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>.
so yeah, read the license, it's the rules π
and that's the page!! mwah π β this little beauty is from OpenSSL 3.5.6, dated 2026-04-0, and it's the EVP_PKEY_GET...LT_DIGEST_NID(3ossl) page, so now you know exactly who to thank when your signatures just work πΈπ¦β¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms