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

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

<h1>rc4(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="#NOTE">NOTE</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>
RC4_set_key, RC4 - RC4 encryption

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/rc4.h&gt;
</PRE>
<PRE> void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
</PRE>
<PRE> void RC4(RC4_KEY *key, unsigned long len, const unsigned char *indata,
          unsigned char *outdata);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
This library implements the Alleged RC4 cipher, which is described for
example in <EM>Applied Cryptography</EM>. It is believed to be compatible with RC4[TM], a proprietary cipher of RSA
Security Inc.

</P>
<P>
RC4 is a stream cipher with variable key length. Typically, 128 bit (16
byte) keys are used for strong encryption, but shorter insecure key sizes
have been widely used due to export restrictions.

</P>
<P>
RC4 consists of a key setup phase and the actual encryption or decryption
phase.

</P>
<P>
<CODE>RC4_set_key()</CODE> sets up the <STRONG>RC4_KEY</STRONG>  <STRONG>key</STRONG> using the <STRONG>len</STRONG> bytes long key at <STRONG>data</STRONG>.

</P>
<P>
<CODE>RC4()</CODE> encrypts or decrypts the <STRONG>len</STRONG> bytes of data at <STRONG>indata</STRONG> using
<STRONG>key</STRONG> and places the result at <STRONG>outdata</STRONG>. Repeated <CODE>RC4()</CODE> calls with the same <STRONG>key</STRONG> yield a continuous key stream.

</P>
<P>
Since RC4 is a stream cipher (the input is XORed with a pseudo-random key
stream to produce the output), decryption uses the same function calls as
encryption.

</P>
<P>
Applications should use the higher level functions
<A HREF="../crypto/EVP_EncryptInit.html#">EVP_EncryptInit(3)</A>
etc. instead of calling the RC4 functions directly.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>RC4_set_key()</CODE> and <CODE>RC4()</CODE> do not return values.

</P>
<P>
<HR>
<H1><A NAME="NOTE">NOTE</A></H1>
<P>
Certain conditions have to be observed to securely use stream ciphers. It
is not permissible to perform multiple encryptions using the same key
stream.

</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../crypto/blowfish.html#">blowfish(3)</A>, <A HREF="../crypto/des.html#">des(3)</A>, <EM>rc2(3)</EM>



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

</P>
:}

