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