cfb8: Fix decrypt path
[gd/nettle] / arctwo.h
1 /* arctwo.h
2
3    The arctwo/rfc2268 block cipher.
4
5    Copyright (C) 2004 Simon Josefsson
6    Copyright (C) 2002, 2004, 2014 Niels Möller
7
8    This file is part of GNU Nettle.
9
10    GNU Nettle is free software: you can redistribute it and/or
11    modify it under the terms of either:
12
13      * the GNU Lesser General Public License as published by the Free
14        Software Foundation; either version 3 of the License, or (at your
15        option) any later version.
16
17    or
18
19      * the GNU General Public License as published by the Free
20        Software Foundation; either version 2 of the License, or (at your
21        option) any later version.
22
23    or both in parallel, as here.
24
25    GNU Nettle is distributed in the hope that it will be useful,
26    but WITHOUT ANY WARRANTY; without even the implied warranty of
27    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
28    General Public License for more details.
29
30    You should have received copies of the GNU General Public License and
31    the GNU Lesser General Public License along with this program.  If
32    not, see http://www.gnu.org/licenses/.
33 */
34
35 #ifndef NETTLE_ARCTWO_H_INCLUDED
36 #define NETTLE_ARCTWO_H_INCLUDED
37
38 #include "nettle-types.h"
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 /* Name mangling */
45 #define arctwo_set_key nettle_arctwo_set_key
46 #define arctwo_set_key_ekb nettle_arctwo_set_key_ekb
47 #define arctwo_set_key_gutmann nettle_arctwo_set_key_gutmann
48 #define arctwo40_set_key nettle_arctwo40_set_key
49 #define arctwo64_set_key nettle_arctwo64_set_key
50 #define arctwo128_set_key nettle_arctwo128_set_key
51 #define arctwo128_set_key_gutmann nettle_arctwo128_set_key_gutmann
52 #define arctwo_encrypt nettle_arctwo_encrypt
53 #define arctwo_decrypt nettle_arctwo_decrypt
54
55 #define ARCTWO_BLOCK_SIZE 8
56
57 /* Variable key size from 1 byte to 128 bytes. */
58 #define ARCTWO_MIN_KEY_SIZE 1
59 #define ARCTWO_MAX_KEY_SIZE 128
60
61 #define ARCTWO_KEY_SIZE 8
62
63 struct arctwo_ctx
64 {
65   uint16_t S[64];
66 };
67
68 /* Key expansion function that takes the "effective key bits", 1-1024,
69    as an explicit argument. 0 means maximum key bits. */
70 void
71 arctwo_set_key_ekb (struct arctwo_ctx *ctx,
72                     size_t length, const uint8_t * key, unsigned ekb);
73
74 /* Equvivalent to arctwo_set_key_ekb, with ekb = 8 * length */
75 void
76 arctwo_set_key (struct arctwo_ctx *ctx, size_t length, const uint8_t *key);
77 void
78 arctwo40_set_key (struct arctwo_ctx *ctx, const uint8_t *key);
79 void
80 arctwo64_set_key (struct arctwo_ctx *ctx, const uint8_t *key);
81 void
82 arctwo128_set_key (struct arctwo_ctx *ctx, const uint8_t *key);
83
84 /* Equvivalent to arctwo_set_key_ekb, with ekb = 1024 */
85 void
86 arctwo_set_key_gutmann (struct arctwo_ctx *ctx,
87                         size_t length, const uint8_t *key);
88 void
89 arctwo128_set_key_gutmann (struct arctwo_ctx *ctx,
90                            const uint8_t *key);
91
92 void
93 arctwo_encrypt (struct arctwo_ctx *ctx,
94                 size_t length, uint8_t *dst, const uint8_t *src);
95 void
96 arctwo_decrypt (struct arctwo_ctx *ctx,
97                 size_t length, uint8_t *dst, const uint8_t *src);
98
99 #ifdef __cplusplus
100 }
101 #endif
102
103 #endif /* NETTLE_ARCTWO_H_INCLUDED */