]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/rc4/rc4_enc.c
2 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include <openssl/rc4.h>
14 * RC4 as implemented from a posting from
15 * Newsgroups: sci.crypt
16 * Subject: RC4 Algorithm revealed.
17 * Message-ID: <sternCvKL4B.Hyy@netcom.com>
18 * Date: Wed, 14 Sep 1994 06:35:31 GMT
21 void RC4(RC4_KEY
*key
, size_t len
, const unsigned char *indata
,
22 unsigned char *outdata
)
25 register RC4_INT x
, y
, tx
, ty
;
32 #define LOOP(in,out) \
38 (out) = d[(tx+ty)&0xff]^ (in);
43 LOOP(indata
[0], outdata
[0]);
44 LOOP(indata
[1], outdata
[1]);
45 LOOP(indata
[2], outdata
[2]);
46 LOOP(indata
[3], outdata
[3]);
47 LOOP(indata
[4], outdata
[4]);
48 LOOP(indata
[5], outdata
[5]);
49 LOOP(indata
[6], outdata
[6]);
50 LOOP(indata
[7], outdata
[7]);
60 LOOP(indata
[0], outdata
[0]);
63 LOOP(indata
[1], outdata
[1]);
66 LOOP(indata
[2], outdata
[2]);
69 LOOP(indata
[3], outdata
[3]);
72 LOOP(indata
[4], outdata
[4]);
75 LOOP(indata
[5], outdata
[5]);
78 LOOP(indata
[6], outdata
[6]);