EVP_MD_NID(3)

NAME
EVP_MD_nid, EVP_MD_type, EVP_MD_CTX_type, EVP_MD_name, EVP_MD_size, EVP_MD_CTX_size, EVP_MD_block_size, EVP_MD_CTX_block_size, EVP_MD_flags, EVP_MD_pkey_type - inspect EVP_MD objects

SYNOPSIS
libcrypto
#include <openssl/evp.h>
int
EVP_MD_nid(const EVP_MD *md);
int
EVP_MD_type(const EVP_MD *md);
int
EVP_MD_CTX_type(const EVP_MD_CTX *ctx);
const char *
EVP_MD_name(const EVP_MD *md);
int
EVP_MD_size(const EVP_MD *md);
int
EVP_MD_CTX_size(const EVP_MD_CTX *ctx);
int
EVP_MD_block_size(const EVP_MD *md);
int
EVP_MD_CTX_block_size(const EVP_MD_CTX *ctx);
unsigned long
EVP_MD_flags(const EVP_MD *md);
int
EVP_MD_pkey_type(const EVP_MD *md);

DESCRIPTION
EVP_MD_nid() and EVP_MD_type() are identical and return the numerical identifier (NID) of md. The NID is an internal value which may or may not have a corresponding ASN.1 OBJECT IDENTIFIER; see OBJ_nid2obj(3) for details. For example , EVP_MD_type(EVP_sha512()) returns NID_sha512. EVP_MD_CTX_type() returns the NID of the message digest algorithm that ctx is configured to use. These functions are normally used when setting ASN.1 OIDs.

EVP_MD_name() converts the NID of md to its short name with OBJ_nid2sn(3).

EVP_MD_size() returns the size in bytes of the message digests (hashes) produced by md. EVP_MD_CTX_size() return the size of the hashes produced by the message digest algorithm that ctx is configured to use.

EVP_MD_block_size() returns the block size in bytes of md. EVP_MD_CTX_block_size() returns the block size of the message digest algorithm that ctx is configured to use.

EVP_MD_flags() returns the message digest flags used by md. Be careful to not confuse these flags with the unrelated message digest context flags that can be inspected with EVP_MD_CTX_test_flags(3). The available flags are:

EVP_MD_FLAG_DIGALGID_NULL
    The parameters in a DigestAlgorithmIdentifier are encoded using an explicit ASN.1 NULL rather than omitting them. This is the default, which means that it takes effect for EVP_MD objects that do not have EVP_MD_FLAG_DIGALGID_ABSENT set.

EVP_MD_FLAG_DIGALGID_ABSENT
    The parameters in a DigestAlgorithmIdentifier are omitted from the ASN.1 encoding. This is used by the EVP_MD objects documented in the manual page EVP_sha3_224(3) and by the objects returned from EVP_sha512(3), EVP_sha512_256(3), EVP_sha512_224(3), EVP_sha384(3), EVP_sha256(3), EVP_sha224(3), EVP_sha1(3), and EVP_sm3(3).

EVP_MD_FLAG_DIGALGID_CUSTOM
    This flag is reserved for user-defined EVP_MD objects supporting custom DigestAlgorithmIdentifier handling via EVP_MD_CTX_ctrl(3), but actually, it is ignored by both LibreSSL and OpenSSL and such user-defined behaviour is not supported by the libraries.

EVP_MD_FLAG_FIPS
    Mark the digest method as suitable for FIPS mode. This flag is ignored by both LibreSSL and OpenSSL.

EVP_MD_FLAG_ONESHOT
    Intended to indicate that the digest method can only handle one block of input, but actually, this flag is ignored by both LibreSSL and OpenSSL.

EVP_MD_pkey_type() returns the NID of the public key signing algorithm associated with this digest. For example, EVP_sha512(3) is associated with RSA, so this returns NID_sha512WithRSAEncryption. Since digests and signature algorithms are no longer linked, this function is only retained for compatibility reasons.

EVP_MD_nid(), EVP_MD_CTX_type(), EVP_MD_name(), EVP_MD_CTX_size(), and EVP_MD_CTX_block_size() are implemented as macros.

RETURN VALUES
EVP_MD_nid(), EVP_MD_type(), EVP_MD_CTX_type(), and EVP_MD_pkey_type() return the NID of the corresponding OBJECT IDENTIFIER or NID_undef if none exists.

EVP_MD_name() returns a pointer to a string that is owned by an internal library object or NULL if the NID is neither built into the library nor added to the global object table by one of the functions documented in the manual page OBJ_create(3), or if the object does not contain a short name.

EVP_MD_size(), EVP_MD_CTX_size(), EVP_MD_block_size(), and EVP_MD_CTX_block_size() return the digest or block size in bytes.

SEE ALSO
evp(3), EVP_DigestInit(3), EVP_MD_CTX_ctrl(3), OBJ_nid2obj(3)

STANDARDS
RFC 5754: Using SHA2 Algorithms with Cryptographic Message Syntax
-   section 2: Message Digest Algorithms

HISTORY
EVP_MD_size() first appeared in SSLeay 0.6.6, EVP_MD_CTX_size() and EVP_MD_CTX_type() in SSLeay 0.8.0, EVP_MD_type() and EVP_MD_pkey_type() in SSLeay 0.8.1, and EVP_MD_block_size() and EVP_MD_CTX_block_size() in SSLeay 0.9.0. All these functions have been available since OpenBSD 2.4.

EVP_MD_nid() and EVP_MD_name() first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2.

EVP_MD_flags() first appeared in OpenSSL 1.0.0 and has been available since OpenBSD 4.9.

CAVEATS
The behaviour of the functions taking an EVP_MD_CTX argument is undefined if they are called on a ctx that has no message digest configured yet, for example one freshly returned from EVP_MD_CTX_new(3). In that case, the program may for example be terminated by a NULL pointer access.