NEWS.stable: log cherry-pick [3180807]->[768eb31] doc/lgpl-2.1.texi
[gnulib.git] / lib / arctwo.h
1 /* arctwo.h --- The arctwo block cipher
2  * Copyright (C) 2000-2003, 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 ARCTWO_H
24 # define ARCTWO_H
25
26 # include <stddef.h>
27 # include <stdint.h>
28
29 typedef struct
30 {
31   uint16_t S[64];
32 } arctwo_context;
33
34 #define ARCTWO_BLOCK_SIZE 8
35
36 /* Initialize CONTEXT using KEY of KEYLEN length.  If
37    EFFECTIVE_KEYLEN, truncate the key (using a special algorithm) to
38    only be of EFFECTIVE_KEYLEN bits.  Normally, you use
39    EFFECTIVE_KEYLEN of 0, but see RFC 2268 for more information. */
40 void
41 arctwo_setkey_ekb (arctwo_context *context,
42                    size_t keylen, const char *key, size_t effective_keylen);
43
44 #define arctwo_setkey(context,keylen,key) \
45   arctwo_setkey_ekb (context, keylen, key, 8 * (keylen))
46
47 /* Encrypt INBUF of size LENGTH into OUTBUF.  LENGTH must be a
48    multiple of ARCTWO_BLOCK_SIZE.  CONTEXT hold the encryption key,
49    and must have been initialized with arctwo_setkey or
50    arctwo_setkey_ekb. */
51 extern void
52 arctwo_encrypt (arctwo_context *context, const char *inbuf,
53                 char *outbuf, size_t length);
54
55 /* Decrypt INBUF of size LENGTH into OUTBUF.  LENGTH must be a
56    multiple of ARCTWO_BLOCK_SIZE.  CONTEXT hold the decryption key,
57    and must have been initialized with arctwo_setkey or
58    arctwo_setkey_ekb. */
59 extern void
60 arctwo_decrypt (arctwo_context *context, const char *inbuf,
61                 char *outbuf, size_t length);
62
63 #endif /* ARCTWO_H */