[Title] Add packaging/nettle.spec to build nettle on OBS system
[external/nettle.git] / camellia-internal.h
1 /* camellia-internal.h
2  *
3  * The camellia block cipher.
4  */
5
6 /* Copyright (C) 2006,2007
7  * NTT (Nippon Telegraph and Telephone Corporation).
8  *
9  * Copyright (C) 2010 Niels Möller
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this library; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
24  */
25
26 /*
27  * Algorithm Specification 
28  *  http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html
29  */
30
31 /* Based on camellia.c ver 1.2.0, see
32    http://info.isl.ntt.co.jp/crypt/eng/camellia/dl/camellia-LGPL-1.2.0.tar.gz.
33  */
34
35 #ifndef NETTLE_CAMELLIA_INTERNAL_H_INCLUDED
36 #define NETTLE_CAMELLIA_INTERNAL_H_INCLUDED
37
38 #include "camellia.h"
39
40 /* Name mangling */
41 #define _camellia_crypt _nettle_camellia_crypt
42 #define _camellia_table _nettle_camellia_table
43
44 /*
45  *  macros
46  */
47
48 /* Rotation of 32-bit values. */
49 #define ROL32(bits, x) (((x) << (bits)) | ((x) >> (32 - (bits))))
50
51 /* Destructive rotation of 128 bit values. */
52 #define ROL128(bits, xl, xr) do {               \
53     uint64_t __rol128_t = (xl);                      \
54     (xl) = ((xl) << (bits)) | ((xr) >> (64 - (bits)));     \
55     (xr) = ((xr) << (bits)) | (__rol128_t >> (64 - (bits)));    \
56   } while (0)
57
58 struct camellia_table
59 {
60   uint32_t sp1110[256];
61   uint32_t sp0222[256];
62   uint32_t sp3033[256];
63   uint32_t sp4404[256];
64 };
65
66 void
67 _camellia_crypt(const struct camellia_ctx *ctx,
68                 const struct camellia_table *T,
69                 unsigned length, uint8_t *dst,
70                 const uint8_t *src);
71
72 extern const struct camellia_table _camellia_table;
73
74 #endif /* NETTLE_CAMELLIA_INTERNAL_H_INCLUDED */