[INCLUDE]
[reactos.git] / reactos / include / reactos / libs / gnutls / nettle / camellia.h
1 /* camellia.h
2 *
3 * Copyright (C) 2006,2007
4 * NTT (Nippon Telegraph and Telephone Corporation).
5 *
6 * Copyright (C) 2010 Niels Möller
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #ifndef NETTLE_CAMELLIA_H_INCLUDED
24 #define NETTLE_CAMELLIA_H_INCLUDED
25
26 #include "nettle-types.h"
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 /* Name mangling */
33 #define camellia_set_encrypt_key nettle_camellia_set_encrypt_key
34 #define camellia_set_decrypt_key nettle_camellia_set_decrypt_key
35 #define camellia_invert_key nettle_camellia_invert_key
36 #define camellia_crypt nettle_camellia_crypt
37 #define camellia_crypt nettle_camellia_crypt
38
39 #define CAMELLIA_BLOCK_SIZE 16
40 /* Valid key sizes are 128, 192 or 256 bits (16, 24 or 32 bytes) */
41 #define CAMELLIA_MIN_KEY_SIZE 16
42 #define CAMELLIA_MAX_KEY_SIZE 32
43 #define CAMELLIA_KEY_SIZE 32
44
45 struct camellia_ctx {
46 /* Number of subkeys. */
47 unsigned nkeys;
48
49 /* For 128-bit keys, there are 18 regular rounds, pre- and
50 post-whitening, and two FL and FLINV rounds, using a total of 26
51 subkeys, each of 64 bit. For 192- and 256-bit keys, there are 6
52 additional regular rounds and one additional FL and FLINV, using
53 a total of 34 subkeys. */
54 /* The clever combination of subkeys imply one of the pre- and
55 post-whitening keys is folded with the round keys, so that subkey
56 #1 and the last one (#25 or #33) is not used. The result is that
57 we have only 24 or 32 subkeys at the end of key setup. */
58 uint64_t keys[32];
59 };
60
61 void
62 camellia_set_encrypt_key(struct camellia_ctx *ctx,
63 unsigned length, const uint8_t * key);
64
65 void
66 camellia_set_decrypt_key(struct camellia_ctx *ctx,
67 unsigned length, const uint8_t * key);
68
69 void
70 camellia_invert_key(struct camellia_ctx *dst,
71 const struct camellia_ctx *src);
72
73 void
74 camellia_crypt(const struct camellia_ctx *ctx,
75 unsigned length, uint8_t * dst,
76 const uint8_t * src);
77 #ifdef __cplusplus
78 }
79 #endif
80 #endif /* NETTLE_CAMELLIA_H_INCLUDED */