EVP_VERIFYINIT(3SSL)

πŸ’– NAME πŸ’–

okay so bestie, this whole page is about the EVP signature verification squad ✨ β€” the girlies that check whether a signature is legit. We got:

  • EVP_VerifyInit_ex
  • EVP_VerifyInit
  • EVP_VerifyUpdate
  • EVP_VerifyFinal_ex
  • EVP_VerifyFinal

they're the EVP signature verification functions, and yes they all live in the OpenSSL 3SSL manual, part of the OpenSSL fam 🫢


✨ SYNOPSIS ✨

like, here's the receipts, copy-paste exactly:

#include <openssl/evp.h>

int EVP_VerifyInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
int EVP_VerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
int EVP_VerifyFinal_ex(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
                       unsigned int siglen, EVP_PKEY *pkey,
                       OSSL_LIB_CTX *libctx, const char *propq);
int EVP_VerifyFinal(EVP_MD_CTX *ctx, unsigned char *sigbuf, unsigned int siglen,
                    EVP_PKEY *pkey);

int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type);

🌸 DESCRIPTION 🌸

The EVP signature verification routines are literally a high-level interface to digital signatures. no cap, it's giving "let the library handle the algorithm drama, you just verify the vibe" πŸ’…

  • EVP_VerifyInit_ex() sets up the verification context ctx to use digest type. And bestie listen β€” ctx must be created by calling EVP_MD_CTX_new() before you call this function, no exceptions. Also impl must be NULL. periodt.
  • EVP_VerifyUpdate() hashes cnt bytes of data at d into the verification context ctx. You can call this several times on the same ctx to pile on more data πŸ“šβœ¨
  • EVP_VerifyFinal_ex() verifies the data in ctx using the public key pkey and siglen bytes in sigbuf. The library context libctx and property query propq are used when creating a context to use with the key pkey. iykyk πŸ”₯
  • EVP_VerifyFinal() is similar to EVP_VerifyFinal_ex() but uses default values of NULL for the library context libctx and the property query propq. it's the chill, no-extra-args version πŸŽ€
  • EVP_VerifyInit() initializes the verification context ctx to use the default implementation of digest type.

πŸ’€ RETURN VALUES πŸ’€

okay so here's the scoreboard:

  • EVP_VerifyInit_ex() and EVP_VerifyUpdate() return 1 for success and 0 for failure. simple as πŸ“
  • EVP_VerifyFinal_ex() and EVP_VerifyFinal() return 1 for a correct signature πŸ‘‘, 0 for failure, and a negative value if some other error occurred 😭
  • The error codes can be obtained by ERR_get_error(3).

πŸ¦‹ NOTES πŸ¦‹

ngl, the EVP interface to digital signatures should almost always be used in preference to the low-level interfaces. Why? because the code then becomes transparent to the algorithm used and much more flexible. main character energy fr fr πŸ’…

The call to EVP_VerifyFinal() internally finalizes a copy of the digest context. Which means calls to EVP_VerifyUpdate() and EVP_VerifyFinal() can be called later to digest and verify additional data. Applications may disable this behavior by setting the EVP_MD_CTX_FLAG_FINALISE context flag via EVP_MD_CTX_set_flags(3).

🚨 bestie this is the important one: since only a copy of the digest context is ever finalized, the context must be cleaned up after use by calling EVP_MD_CTX_free() β€” or a memory leak will occur. don't leave her hanging, free her πŸ’–

Note that not all providers support continuation. In case the selected provider does not allow to duplicate contexts, EVP_VerifyFinal() will finalize the digest context and attempting to process additional data via EVP_VerifyUpdate() will result in an error. so watch out πŸ‘€


πŸ™ˆ BUGS πŸ™ˆ

  • Older versions of this documentation wrongly stated that calls to EVP_VerifyUpdate() could not be made after calling EVP_VerifyFinal(). yeah that was a lie, and it's been corrected 😭
  • Since the public key is passed in the call to EVP_SignFinal() any error relating to the private key (for example an unsuitable key and digest combination) will not be indicated until after potentially large amounts of data have been passed through EVP_SignUpdate(). it's giving "we told you too late" πŸ’€
  • It is not possible to change the signing parameters using these function.
  • The previous two bugs are fixed in the newer EVP_DigestVerify*() function. slay ✨

🌈 SEE ALSO 🌈

(yes, evp(7) is listed twice in the original β€” iconic of her honestly πŸ‘‘)


⭐ HISTORY ⭐

The function EVP_VerifyFinal_ex() was added in OpenSSL 3.0. new girl on the block πŸ’…


Copyright 2000-2025 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>.


okay that's the whole page bestie, go verify some signatures, you're gonna eat πŸ’–βœ¨

signing off from the EVP_VERIFYINIT(3SSL) page β€” OpenSSL 3SSL, version 4.0.3, dated 2026-09-29 🫢🌷
πŸ“¦ where this page comes from