
#use wml::openssl-macros area=docs page=EVP_VerifyInit

<title>Documents, EVP_VerifyInit(3)</title>

<h1>EVP_VerifyInit(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
	<LI><A HREF="#NOTES">NOTES</A>
	<LI><A HREF="#BUGS">BUGS</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
	<LI><A HREF="#HISTORY">HISTORY</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
EVP_VerifyInit, EVP_VerifyUpdate, EVP_VerifyFinal - EVP signature
verification functions

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/evp.h&gt;
</PRE>
<PRE> 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(EVP_MD_CTX *ctx,unsigned char *sigbuf, unsigned int siglen,EVP_PKEY *pkey);
</PRE>
<PRE> int EVP_VerifyInit(EVP_MD_CTX *ctx, const EVP_MD *type);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
The EVP signature verification routines are a high level interface to
digital signatures.

</P>
<P>
<CODE>EVP_VerifyInit_ex()</CODE> sets up verification context <STRONG>ctx</STRONG> to use digest
<STRONG>type</STRONG> from ENGINE <STRONG>impl</STRONG>. <STRONG>ctx</STRONG> must be initialized by calling <CODE>EVP_MD_CTX_init()</CODE> before
calling this function.

</P>
<P>
<CODE>EVP_VerifyUpdate()</CODE> hashes <STRONG>cnt</STRONG> bytes of data at <STRONG>d</STRONG> into the verification context <STRONG>ctx</STRONG>. This function can be called several times on the same <STRONG>ctx</STRONG> to include additional data.

</P>
<P>
<CODE>EVP_VerifyFinal()</CODE> verifies the data in <STRONG>ctx</STRONG> using the public key <STRONG>pkey</STRONG>
and against the <STRONG>siglen</STRONG> bytes at <STRONG>sigbuf</STRONG>.

</P>
<P>
<CODE>EVP_VerifyInit()</CODE> initializes verification context <STRONG>ctx</STRONG> to use the default implementation of digest <STRONG>type</STRONG>.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>EVP_VerifyInit_ex()</CODE> and <CODE>EVP_VerifyUpdate()</CODE> return
1 for success and 0 for failure.

</P>
<P>
<CODE>EVP_VerifyFinal()</CODE> returns 1 for a correct signature, 0 for
failure and -1 if some other error occurred.

</P>
<P>
The error codes can be obtained by <A HREF="../crypto/ERR_get_error.html#">ERR_get_error(3)</A>.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
The <STRONG>EVP</STRONG> interface to digital signatures should almost always be used in preference
to the low level interfaces. This is because the code then becomes
transparent to the algorithm used and much more flexible.

</P>
<P>
Due to the link between message digests and public key algorithms the
correct digest algorithm must be used with the correct public key type. A
list of algorithms and associated public key algorithms appears in 
<A HREF="../crypto/EVP_DigestInit.html#">EVP_DigestInit(3)</A>.

</P>
<P>
The call to <CODE>EVP_VerifyFinal()</CODE> internally finalizes a copy of
the digest context. This means that calls to
<CODE>EVP_VerifyUpdate()</CODE> and <CODE>EVP_VerifyFinal()</CODE> can be
called later to digest and verify additional data.

</P>
<P>
Since only a copy of the digest context is ever finalized the context must
be cleaned up after use by calling <CODE>EVP_MD_CTX_cleanup()</CODE> or a
memory leak will occur.

</P>
<P>
<HR>
<H1><A NAME="BUGS">BUGS</A></H1>
<P>
Older versions of this documentation wrongly stated that calls to
<CODE>EVP_VerifyUpdate()</CODE> could not be made after calling
<CODE>EVP_VerifyFinal().</CODE>

</P>
<P>
Since the public key is passed in the call to <CODE>EVP_SignFinal()</CODE>
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 <CODE>EVP_SignUpdate().</CODE>

</P>
<P>
It is not possible to change the signing parameters using these function.

</P>
<P>
The previous two bugs are fixed in the newer EVP_VerifyDigest*() function.

</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../crypto/evp.html#">evp(3)</A>,
<A HREF="../crypto/EVP_SignInit.html#">EVP_SignInit(3)</A>,
<A HREF="../crypto/EVP_DigestInit.html#">EVP_DigestInit(3)</A>, <A HREF="../crypto/err.html#">err(3)</A>,
<A HREF="../crypto/evp.html#">evp(3)</A>, <A HREF="../crypto/hmac.html#">hmac(3)</A>, <A HREF="../crypto/md5.html#">md2(3)</A>,
<A HREF="../crypto/md5.html#">md5(3)</A>, <A HREF="../crypto/mdc2.html#">mdc2(3)</A>, <A HREF="../crypto/ripemd.html#">ripemd(3)</A>,
<A HREF="../crypto/sha.html#">sha(3)</A>, <A HREF="../apps/dgst.html#">dgst(1)</A>



</P>
<P>
<HR>
<H1><A NAME="HISTORY">HISTORY</A></H1>
<P>
<CODE>EVP_VerifyInit(),</CODE> <CODE>EVP_VerifyUpdate()</CODE> and
<CODE>EVP_VerifyFinal()</CODE> are available in all versions of SSLeay and
OpenSSL.

</P>
<P>
<CODE>EVP_VerifyInit_ex()</CODE> was added in OpenSSL 0.9.7

</P>
:}


