exp2l: Work around a NetBSD 10.0/i386 bug.
[gnulib.git] / lib / arctwo.h
blob0dc0d8a93482510167283e21680921204cc485ee
1 /* arctwo.h --- The arctwo block cipher
2 * Copyright (C) 2000-2003, 2005, 2009-2024 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 Lesser General Public License as
6 * published by the Free Software Foundation; either version 2.1 of the
7 * License, or (at your option) any later version.
9 * This file is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 /* Code from Libgcrypt adapted for gnulib by Simon Josefsson. */
21 #ifndef ARCTWO_H
22 # define ARCTWO_H
24 # include <stddef.h>
25 # include <stdint.h>
27 typedef struct
29 uint16_t S[64];
30 } arctwo_context;
32 #define ARCTWO_BLOCK_SIZE 8
34 /* Initialize CONTEXT using KEY of KEYLEN length. If
35 EFFECTIVE_KEYLEN, truncate the key (using a special algorithm) to
36 only be of EFFECTIVE_KEYLEN bits. Normally, you use
37 EFFECTIVE_KEYLEN of 0, but see RFC 2268 for more information. */
38 void
39 arctwo_setkey_ekb (arctwo_context *context,
40 size_t keylen, const char *key, size_t effective_keylen);
42 #define arctwo_setkey(context,keylen,key) \
43 arctwo_setkey_ekb (context, keylen, key, 8 * (keylen))
45 /* Encrypt INBUF of size LENGTH into OUTBUF. LENGTH must be a
46 multiple of ARCTWO_BLOCK_SIZE. CONTEXT hold the encryption key,
47 and must have been initialized with arctwo_setkey or
48 arctwo_setkey_ekb. */
49 extern void
50 arctwo_encrypt (arctwo_context *context, const char *inbuf,
51 char *restrict outbuf, size_t length);
53 /* Decrypt INBUF of size LENGTH into OUTBUF. LENGTH must be a
54 multiple of ARCTWO_BLOCK_SIZE. CONTEXT hold the decryption key,
55 and must have been initialized with arctwo_setkey or
56 arctwo_setkey_ekb. */
57 extern void
58 arctwo_decrypt (arctwo_context *context, const char *inbuf,
59 char *restrict outbuf, size_t length);
61 #endif /* ARCTWO_H */