2 * Copyright 1995-2020 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
11 * RC4 low level APIs are deprecated for public use, but still ok for internal
14 #include "internal/deprecated.h"
16 #include <openssl/rc4.h>
17 #include "rc4_local.h"
20 * RC4 as implemented from a posting from
21 * Newsgroups: sci.crypt
22 * Subject: RC4 Algorithm revealed.
23 * Message-ID: <sternCvKL4B.Hyy@netcom.com>
24 * Date: Wed, 14 Sep 1994 06:35:31 GMT
27 void RC4(RC4_KEY *key, size_t len, const unsigned char *indata,
28 unsigned char *outdata)
31 register RC4_INT x, y, tx, ty;
38 #define LOOP(in,out) \
44 (out) = d[(tx+ty)&0xff]^ (in);
49 LOOP(indata[0], outdata[0]);
50 LOOP(indata[1], outdata[1]);
51 LOOP(indata[2], outdata[2]);
52 LOOP(indata[3], outdata[3]);
53 LOOP(indata[4], outdata[4]);
54 LOOP(indata[5], outdata[5]);
55 LOOP(indata[6], outdata[6]);
56 LOOP(indata[7], outdata[7]);
66 LOOP(indata[0], outdata[0]);
69 LOOP(indata[1], outdata[1]);
72 LOOP(indata[2], outdata[2]);
75 LOOP(indata[3], outdata[3]);
78 LOOP(indata[4], outdata[4]);
81 LOOP(indata[5], outdata[5]);
84 LOOP(indata[6], outdata[6]);