uchar C++ tests: Fix build error on FreeBSD 12.
[gnulib.git] / lib / arcfour.h
blobcc4e37d5949aa834433523b5413bf97f093bd3cf
1 /* arcfour.h --- The arcfour stream cipher
2 * Copyright (C) 2000-2005, 2009-2020 Free Software Foundation, Inc.
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.
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.
14 * You should have received a copy of the GNU General Public License
15 * along with this file; if not, see <https://www.gnu.org/licenses/>.
19 /* Code from Libgcrypt adapted for gnulib by Simon Josefsson. */
21 #ifndef ARCFOUR_H
22 # define ARCFOUR_H
24 # include <stddef.h>
25 # include <stdint.h>
27 #define ARCFOUR_SBOX_SIZE 256
29 typedef struct
31 char sbox[ARCFOUR_SBOX_SIZE];
32 uint8_t idx_i, idx_j;
33 } arcfour_context;
35 /* Apply ARCFOUR stream to INBUF placing the result in OUTBUF, both of
36 LENGTH size. CONTEXT must be initialized with arcfour_setkey
37 before this function is called. */
38 extern void
39 arcfour_stream (arcfour_context * context,
40 const char *inbuf, char *restrict outbuf, size_t length);
42 /* Initialize CONTEXT using encryption KEY of KEYLEN bytes. KEY
43 should be 40 bits (5 bytes) or longer. The KEY cannot be zero
44 length. */
45 extern void
46 arcfour_setkey (arcfour_context * context, const char *key, size_t keylen);
48 #endif /* ARCFOUR_H */