Import the first cut for manual pages.
[openssl.git] / doc / rc4.doc
1 The RC4 library.
2 RC4 is a stream cipher that operates on a byte stream.  It can be used with
3 any length key but I would recommend normally using 16 bytes.
4
5 This library requires the inclusion of 'rc4.h'.
6
7 The RC4 encryption function takes what is called an RC4_KEY as an argument.
8 The RC4_KEY is generated by the RC4_set_key function from the key bytes.
9
10 RC4, being a stream cipher, does not have an encryption or decryption mode.
11 It produces a stream of bytes that the input stream is xor'ed against and
12 so decryption is just a case of 'encrypting' again with the same key.
13
14 I have only put in one 'mode' for RC4 which is the normal one.  This means
15 there is no initialisation vector and there is no feedback of the cipher
16 text into the cipher.  This implies that you should not ever use the
17 same key twice if you can help it.  If you do, you leave yourself open to
18 known plain text attacks; if you know the plain text and
19 corresponding cipher text in one message, all messages that used the same
20 key can have the cipher text decoded for the corresponding positions in the
21 cipher stream.
22
23 The main positive feature of RC4 is that it is a very fast cipher; about 4
24 times faster that DES.  This makes it ideally suited to protocols where the
25 key is randomly chosen, like SSL.
26
27 The functions are as follows:
28
29 void RC4_set_key(
30 RC4_KEY *key;
31 int len;
32 unsigned char *data);
33         This function initialises the RC4_KEY structure with the key passed
34         in 'data', which is 'len' bytes long.  The key data can be any
35         length but 16 bytes seems to be a good number.
36
37 void RC4(
38 RC4_KEY *key;
39 unsigned long len;
40 unsigned char *in;
41 unsigned char *out);
42         Do the actual RC4 encryption/decryption.  Using the 'key', 'len'
43         bytes are transformed from 'in' to 'out'.  As mentioned above,
44         decryption is the operation as encryption.