xref: /openbsd-src/sys/crypto/arc4.h (revision 753dd0db73c7ec9c639cb6ccdbeb9ecb87962a71)
1*753dd0dbSdjm /*	$OpenBSD: arc4.h,v 1.3 2007/09/11 12:07:05 djm Exp $	*/
238553144Smarkus /*
338553144Smarkus  * Copyright (c) 2003 Markus Friedl <markus@openbsd.org>
438553144Smarkus  *
538553144Smarkus  * Permission to use, copy, modify, and distribute this software for any
638553144Smarkus  * purpose with or without fee is hereby granted, provided that the above
738553144Smarkus  * copyright notice and this permission notice appear in all copies.
838553144Smarkus  *
938553144Smarkus  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1038553144Smarkus  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1138553144Smarkus  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1238553144Smarkus  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1338553144Smarkus  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1438553144Smarkus  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1538553144Smarkus  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1638553144Smarkus  */
1738553144Smarkus 
1838553144Smarkus #define RC4STATE 256
1938553144Smarkus #define RC4KEYLEN 16
2038553144Smarkus 
2138553144Smarkus struct rc4_ctx {
2238553144Smarkus 	u_int8_t x, y;
2338553144Smarkus 	u_int8_t state[RC4STATE];
2438553144Smarkus };
2538553144Smarkus 
26*753dd0dbSdjm void	rc4_keysetup(struct rc4_ctx *, u_char *, u_int32_t)
27*753dd0dbSdjm     __attribute__((__bounded__(__buffer__,2,3)));
28*753dd0dbSdjm void	rc4_crypt(struct rc4_ctx *, u_char *, u_char *, u_int32_t)
29*753dd0dbSdjm     __attribute__((__bounded__(__buffer__,2,4)))
30*753dd0dbSdjm     __attribute__((__bounded__(__buffer__,3,4)));
31*753dd0dbSdjm void	rc4_getbytes(struct rc4_ctx *, u_char *, u_int32_t)
32*753dd0dbSdjm     __attribute__((__bounded__(__buffer__,2,3)));
33c5823ff2Sdamien void	rc4_skip(struct rc4_ctx *, u_int32_t);
34