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

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

<h1>EVP_OpenInit(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="#NOTES">NOTES</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</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_OpenInit, EVP_OpenUpdate, EVP_OpenFinal - EVP envelope decryption

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/evp.h&gt;
</PRE>
<PRE> int EVP_OpenInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,unsigned char *ek,
                int ekl,unsigned char *iv,EVP_PKEY *priv);
 int EVP_OpenUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
         int *outl, unsigned char *in, int inl);
 int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
         int *outl);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
The EVP envelope routines are a high level interface to envelope
decryption. They decrypt a public key encrypted symmetric key and then
decrypt data using it.

</P>
<P>
<CODE>EVP_OpenInit()</CODE> initializes a cipher context <STRONG>ctx</STRONG> for decryption with cipher <STRONG>type</STRONG>. It decrypts the encrypted symmetric key of length
<STRONG>ekl</STRONG> bytes passed in the <STRONG>ek</STRONG> parameter using the private key <STRONG>priv</STRONG>. The IV is supplied in the <STRONG>iv</STRONG> parameter.

</P>
<P>
<CODE>EVP_OpenUpdate()</CODE> and <CODE>EVP_OpenFinal()</CODE> have exactly
the same properties as the <CODE>EVP_DecryptUpdate()</CODE> and
<CODE>EVP_DecryptFinal()</CODE> routines, as documented on the <A HREF="../crypto/EVP_EncryptInit.html#">EVP_EncryptInit(3)</A> manual page.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
It is possible to call <CODE>EVP_OpenInit()</CODE> twice in the same way as
<CODE>EVP_DecryptInit().</CODE> The first call should have <STRONG>priv</STRONG> set to NULL and (after setting any cipher parameters) it should be called
again with <STRONG>type</STRONG> set to NULL.

</P>
<P>
If the cipher passed in the <STRONG>type</STRONG> parameter is a variable length cipher then the key length will be set to
the value of the recovered key length. If the cipher is a fixed length
cipher then the recovered key length must match the fixed cipher length.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>EVP_OpenInit()</CODE> returns 0 on error or a non zero integer
(actually the recovered secret key size) if successful.

</P>
<P>
<CODE>EVP_OpenUpdate()</CODE> returns 1 for success or 0 for failure.

</P>
<P>
<CODE>EVP_OpenFinal()</CODE> returns 0 if the decrypt failed or 1 for
success.

</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../crypto/evp.html#">evp(3)</A>, <A HREF="../crypto/rand.html#">rand(3)</A>,
<A HREF="../crypto/EVP_EncryptInit.html#">EVP_EncryptInit(3)</A>,
<A HREF="../crypto/EVP_SealInit.html#">EVP_SealInit(3)</A>



</P>
<P>
<HR>
<H1><A NAME="HISTORY">HISTORY</A></H1>
:}


