xref: /openbsd-src/lib/libcrypto/rc4/rc4.h (revision 515aa502ddfbfa9d16fb6d4368077c2ccf35cf3d)
1*515aa502Stb /* $OpenBSD: rc4.h,v 1.16 2025/01/25 17:59:44 tb Exp $ */
2913ec974Sbeck /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3913ec974Sbeck  * All rights reserved.
4913ec974Sbeck  *
5913ec974Sbeck  * This package is an SSL implementation written
6913ec974Sbeck  * by Eric Young (eay@cryptsoft.com).
7913ec974Sbeck  * The implementation was written so as to conform with Netscapes SSL.
8913ec974Sbeck  *
9913ec974Sbeck  * This library is free for commercial and non-commercial use as long as
10913ec974Sbeck  * the following conditions are aheared to.  The following conditions
11913ec974Sbeck  * apply to all code found in this distribution, be it the RC4, RSA,
12913ec974Sbeck  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13913ec974Sbeck  * included with this distribution is covered by the same copyright terms
14913ec974Sbeck  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15913ec974Sbeck  *
16913ec974Sbeck  * Copyright remains Eric Young's, and as such any Copyright notices in
17913ec974Sbeck  * the code are not to be removed.
18913ec974Sbeck  * If this package is used in a product, Eric Young should be given attribution
19913ec974Sbeck  * as the author of the parts of the library used.
20913ec974Sbeck  * This can be in the form of a textual message at program startup or
21913ec974Sbeck  * in documentation (online or textual) provided with the package.
22913ec974Sbeck  *
23913ec974Sbeck  * Redistribution and use in source and binary forms, with or without
24913ec974Sbeck  * modification, are permitted provided that the following conditions
25913ec974Sbeck  * are met:
26913ec974Sbeck  * 1. Redistributions of source code must retain the copyright
27913ec974Sbeck  *    notice, this list of conditions and the following disclaimer.
28913ec974Sbeck  * 2. Redistributions in binary form must reproduce the above copyright
29913ec974Sbeck  *    notice, this list of conditions and the following disclaimer in the
30913ec974Sbeck  *    documentation and/or other materials provided with the distribution.
31913ec974Sbeck  * 3. All advertising materials mentioning features or use of this software
32913ec974Sbeck  *    must display the following acknowledgement:
33913ec974Sbeck  *    "This product includes cryptographic software written by
34913ec974Sbeck  *     Eric Young (eay@cryptsoft.com)"
35913ec974Sbeck  *    The word 'cryptographic' can be left out if the rouines from the library
36913ec974Sbeck  *    being used are not cryptographic related :-).
37913ec974Sbeck  * 4. If you include any Windows specific code (or a derivative thereof) from
38913ec974Sbeck  *    the apps directory (application code) you must include an acknowledgement:
39913ec974Sbeck  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40913ec974Sbeck  *
41913ec974Sbeck  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42913ec974Sbeck  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43913ec974Sbeck  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44913ec974Sbeck  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45913ec974Sbeck  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46913ec974Sbeck  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47913ec974Sbeck  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48913ec974Sbeck  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49913ec974Sbeck  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50913ec974Sbeck  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51913ec974Sbeck  * SUCH DAMAGE.
52913ec974Sbeck  *
53913ec974Sbeck  * The licence and distribution terms for any publically available version or
54913ec974Sbeck  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55913ec974Sbeck  * copied and put under another distribution licence
56913ec974Sbeck  * [including the GNU Public Licence.]
57913ec974Sbeck  */
58913ec974Sbeck 
59913ec974Sbeck #ifndef HEADER_RC4_H
60913ec974Sbeck #define HEADER_RC4_H
61913ec974Sbeck 
624fcf65c5Sdjm #include <openssl/opensslconf.h> /* OPENSSL_NO_RC4, RC4_INT */
638cf4d6a6Sjsing 
640a5d6edeSdjm #include <stddef.h>
650a5d6edeSdjm 
66c109e398Sbeck #ifdef  __cplusplus
67c109e398Sbeck extern "C" {
68c109e398Sbeck #endif
69c109e398Sbeck 
703cb51deeSjsing typedef struct rc4_key_st {
71913ec974Sbeck 	RC4_INT x, y;
72913ec974Sbeck 	RC4_INT data[256];
73913ec974Sbeck } RC4_KEY;
74913ec974Sbeck 
75ba5406e9Sbeck void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data);
760a5d6edeSdjm void RC4(RC4_KEY *key, size_t len, const unsigned char *indata,
77913ec974Sbeck     unsigned char *outdata);
78913ec974Sbeck 
79913ec974Sbeck #ifdef  __cplusplus
80913ec974Sbeck }
81913ec974Sbeck #endif
82913ec974Sbeck 
83913ec974Sbeck #endif
84