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

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

<h1>RSA_private_encrypt(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="#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>
RSA_private_encrypt, RSA_public_decrypt - low level signature operations

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/rsa.h&gt;
</PRE>
<PRE> int RSA_private_encrypt(int flen, unsigned char *from,
    unsigned char *to, RSA *rsa, int padding);
</PRE>
<PRE> int RSA_public_decrypt(int flen, unsigned char *from, 
    unsigned char *to, RSA *rsa, int padding);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
These functions handle RSA signatures at a low level.

</P>
<P>
<CODE>RSA_private_encrypt()</CODE> signs the <STRONG>flen</STRONG> bytes at <STRONG>from</STRONG> (usually a message digest with an algorithm identifier) using the private
key
<STRONG>rsa</STRONG> and stores the signature in <STRONG>to</STRONG>. <STRONG>to</STRONG> must point to
<STRONG>RSA_size(rsa)</STRONG> bytes of memory.

</P>
<P>
<STRONG>padding</STRONG> denotes one of the following modes:

</P>
<DL>
<DT><STRONG><A NAME="item_RSA_PKCS1_PADDING">RSA_PKCS1_PADDING</A></STRONG><DD>
<P>
PKCS #1 v1.5 padding. This function does not handle the
<STRONG>algorithmIdentifier</STRONG> specified in PKCS #1. When generating or verifying PKCS #1 signatures, <A HREF="../crypto/RSA_sign.html#">RSA_sign(3)</A> and <A HREF="../crypto/RSA_sign.html#">RSA_verify(3)</A> should be used.

</P>
<DT><STRONG><A NAME="item_RSA_NO_PADDING">RSA_NO_PADDING</A></STRONG><DD>
<P>
Raw RSA signature. This mode should <EM>only</EM> be used to implement cryptographically sound padding modes in the
application code. Signing user data directly with RSA is insecure.

</P>
</DL>
<P>
<CODE>RSA_public_decrypt()</CODE> recovers the message digest from the <STRONG>flen</STRONG>
bytes long signature at <STRONG>from</STRONG> using the signer's public key
<STRONG>rsa</STRONG>. <STRONG>to</STRONG> must point to a memory section large enough to hold the message digest
(which is smaller than <STRONG>RSA_size(rsa) -
11</STRONG>). <STRONG>padding</STRONG> is the padding mode that was used to sign the data.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>RSA_private_encrypt()</CODE> returns the size of the signature (i.e.,
<CODE>RSA_size(rsa)).</CODE> <CODE>RSA_public_decrypt()</CODE> returns the
size of the recovered message digest.

</P>
<P>
On error, -1 is returned; 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="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../crypto/ERR_get_error.html#">ERR_get_error(3)</A>, <A HREF="../crypto/rsa.html#">rsa(3)</A>,
<A HREF="../crypto/RSA_sign.html#">RSA_sign(3)</A>, <A HREF="../crypto/RSA_sign.html#">RSA_verify(3)</A>



</P>
<P>
<HR>
<H1><A NAME="HISTORY">HISTORY</A></H1>
<P>
The <STRONG>padding</STRONG> argument was added in SSLeay 0.8. RSA_NO_PADDING is available since SSLeay
0.9.0.

</P>
:}

