]> git.ipfire.org Git - thirdparty/nettle.git/blame - serpent-internal.h
Avoid warnings for assert_maybe.
[thirdparty/nettle.git] / serpent-internal.h
CommitLineData
00a6c2d1 1/* serpent-internal-h
90112edb
NM
2
3 The serpent block cipher.
4
5 For more details on this algorithm, see the Serpent website at
6 http://www.cl.cam.ac.uk/~rja14/serpent.html
7
8 Copyright (C) 2011 Niels Möller
9 Copyright (C) 2010, 2011 Simon Josefsson
10 Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
11
12 This file is part of GNU Nettle.
13
14 GNU Nettle is free software: you can redistribute it and/or
15 modify it under the terms of either:
16
17 * the GNU Lesser General Public License as published by the Free
18 Software Foundation; either version 3 of the License, or (at your
19 option) any later version.
20
21 or
22
23 * the GNU General Public License as published by the Free
24 Software Foundation; either version 2 of the License, or (at your
25 option) any later version.
26
27 or both in parallel, as here.
28
29 GNU Nettle is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
32 General Public License for more details.
33
34 You should have received copies of the GNU General Public License and
35 the GNU Lesser General Public License along with this program. If
36 not, see http://www.gnu.org/licenses/.
37*/
00a6c2d1
NM
38
39/* This file is derived from cipher/serpent.c in Libgcrypt v1.4.6.
40 The adaption to Nettle was made by Simon Josefsson on 2010-12-07
41 with final touches on 2011-05-30. Changes include replacing
42 libgcrypt with nettle in the license template, renaming
43 serpent_context to serpent_ctx, renaming u32 to uint32_t, removing
44 libgcrypt stubs and selftests, modifying entry function prototypes,
45 using FOR_BLOCKS to iterate through data in encrypt/decrypt, using
46 LE_READ_UINT32 and LE_WRITE_UINT32 to access data in
47 encrypt/decrypt, and running indent on the code. */
48
49#ifndef NETTLE_SERPENT_INTERNAL_H_INCLUDED
50#define NETTLE_SERPENT_INTERNAL_H_INCLUDED
51
00a6c2d1
NM
52#define KEYXOR(x0,x1,x2,x3, subkey) \
53 do { \
54 (x0) ^= (subkey)[0]; \
55 (x1) ^= (subkey)[1]; \
56 (x2) ^= (subkey)[2]; \
57 (x3) ^= (subkey)[3]; \
58 } while (0)
59
60#if HAVE_NATIVE_64_BIT
61/* Operate independently on both halves of a 64-bit word. */
d20990fd 62#define DROTL32(n,x) \
40d9583f
NM
63 (((x) << (n) & ~((((uint64_t) 1 << (n))-1) << 32)) \
64 |(((x) >> (32-(n))) & ~((((uint64_t) 1 << (32-(n)))-1) << (n))))
00a6c2d1
NM
65
66#define KEYXOR64(x0,x1,x2,x3, subkey) \
67 do { \
68 uint64_t _sk; \
69 _sk = (subkey)[0]; _sk |= _sk << 32; (x0) ^= _sk; \
70 _sk = (subkey)[1]; _sk |= _sk << 32; (x1) ^= _sk; \
71 _sk = (subkey)[2]; _sk |= _sk << 32; (x2) ^= _sk; \
72 _sk = (subkey)[3]; _sk |= _sk << 32; (x3) ^= _sk; \
73 } while (0)
74
d20990fd 75#define DRSHIFT32(n,x) \
40d9583f 76 ( ((x) << (n)) & ~((((uint64_t) 1 << (n)) - 1) << 32))
00a6c2d1
NM
77#endif /* HAVE_NATIVE_64_BIT */
78
79#endif /* NETTLE_SERPENT_INTERNAL_H_INCLUDED */
80