finalise NEWS.stable
[gnulib.git] / lib / arcfour.h
1 /* arcfour.h --- The arcfour stream cipher
2  * Copyright (C) 2000-2005, 2009-2011 Free Software Foundation, Inc.
3  *
4  * This file is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published
6  * by the Free Software Foundation; either version 2, or (at your
7  * option) any later version.
8  *
9  * This file is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this file; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  */
20
21 /* Code from Libgcrypt adapted for gnulib by Simon Josefsson. */
22
23 #ifndef ARCFOUR_H
24 # define ARCFOUR_H
25
26 # include <stddef.h>
27 # include <stdint.h>
28
29 #define ARCFOUR_SBOX_SIZE 256
30
31 typedef struct
32 {
33   char sbox[ARCFOUR_SBOX_SIZE];
34   uint8_t idx_i, idx_j;
35 } arcfour_context;
36
37 /* Apply ARCFOUR stream to INBUF placing the result in OUTBUF, both of
38    LENGTH size.  CONTEXT must be initialized with arcfour_setkey
39    before this function is called. */
40 extern void
41 arcfour_stream (arcfour_context * context,
42                 const char *inbuf, char *outbuf, size_t length);
43
44 /* Initialize CONTEXT using encryption KEY of KEYLEN bytes.  KEY
45    should be 40 bits (5 bytes) or longer.  The KEY cannot be zero
46    length.  */
47 extern void
48 arcfour_setkey (arcfour_context * context, const char *key, size_t keylen);
49
50 #endif /* ARCFOUR_H */