Debian Codegraph @

cipher/camellia.h

raw
1 /* camellia.h ver 1.2.0
2 *
3 * Copyright (C) 2006,2007
4 * NTT (Nippon Telegraph and Telephone Corporation).
5 *
6 * This file is part of Libgcrypt.
7 *
8 * Libgcrypt is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as
10 * published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * Libgcrypt 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
16 * GNU 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 program; if not, see <https://www.gnu.org/licenses/>.
20 * SPDX-License-Identifier: LGPL-2.1-or-later
21 */
22
23 #ifndef HEADER_CAMELLIA_H
24 #define HEADER_CAMELLIA_H
25
26 /* To use Camellia with libraries it is often useful to keep the name
27 * space of the library clean. The following macro is thus useful:
28 *
29 * #define CAMELLIA_EXT_SYM_PREFIX foo_
30 *
31 * This prefixes all external symbols with "foo_".
32 */
33 #ifdef HAVE_CONFIG_H
34 #include <config.h>
35 /* USE_ARM_ASM indicates whether to use ARM assembly code. */
36 # undef USE_ARM_ASM
37 # if defined(__ARMEL__)
38 # ifdef HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS
39 # define USE_ARM_ASM 1
40 # endif
41 # endif
42 # if defined(__AARCH64EL__)
43 # ifdef HAVE_COMPATIBLE_GCC_AARCH64_PLATFORM_AS
44 # define USE_ARM_ASM 1
45 # endif
46 # endif
47 #endif
48 #ifdef CAMELLIA_EXT_SYM_PREFIX
49 #define CAMELLIA_PREFIX1(x,y) x ## y
50 #define CAMELLIA_PREFIX2(x,y) CAMELLIA_PREFIX1(x,y)
51 #define CAMELLIA_PREFIX(x) CAMELLIA_PREFIX2(CAMELLIA_EXT_SYM_PREFIX,x)
52 #define Camellia_Ekeygen CAMELLIA_PREFIX(Camellia_Ekeygen)
53 #define Camellia_EncryptBlock CAMELLIA_PREFIX(Camellia_EncryptBlock)
54 #define Camellia_DecryptBlock CAMELLIA_PREFIX(Camellia_DecryptBlock)
55 #define camellia_decrypt128 CAMELLIA_PREFIX(camellia_decrypt128)
56 #define camellia_decrypt256 CAMELLIA_PREFIX(camellia_decrypt256)
57 #define camellia_encrypt128 CAMELLIA_PREFIX(camellia_encrypt128)
58 #define camellia_encrypt256 CAMELLIA_PREFIX(camellia_encrypt256)
59 #define camellia_setup128 CAMELLIA_PREFIX(camellia_setup128)
60 #define camellia_setup192 CAMELLIA_PREFIX(camellia_setup192)
61 #define camellia_setup256 CAMELLIA_PREFIX(camellia_setup256)
62 #endif /*CAMELLIA_EXT_SYM_PREFIX*/
63
64
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68
69 #define CAMELLIA_BLOCK_SIZE 16
70 #define CAMELLIA_TABLE_BYTE_LEN 272
71 #define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
72
73 typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN];
74
75
76 void Camellia_Ekeygen(const int keyBitLength,
77 const unsigned char *rawKey,
78 KEY_TABLE_TYPE keyTable);
79
80 #ifndef USE_ARM_ASM
81 void Camellia_EncryptBlock(const int keyBitLength,
82 const unsigned char *plaintext,
83 const KEY_TABLE_TYPE keyTable,
84 unsigned char *cipherText);
85
86 void Camellia_DecryptBlock(const int keyBitLength,
87 const unsigned char *cipherText,
88 const KEY_TABLE_TYPE keyTable,
89 unsigned char *plaintext);
90 #endif /*!USE_ARM_ASM*/
91
92
93 #ifdef __cplusplus
94 }
95 #endif
96
97 #endif /* HEADER_CAMELLIA_H */