3 * The serpent block cipher.
6 /* nettle, low-level cryptographics library
8 * Copyright (C) 2001 Niels Möller
10 * The nettle library is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or (at your
13 * option) any later version.
15 * The nettle library is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with the nettle library; see the file COPYING.LIB. If not, write to
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 /* Serpent is a 128-bit block cipher that accepts a key size of 256
27 * bits, designed by Ross Anderson, Eli Biham, and Lars Knudsen. See
28 * http://www.cl.cam.ac.uk/~rja14/serpent.html for details.
31 #ifndef NETTLE_SERPENT_H_INCLUDED
32 #define NETTLE_SERPENT_H_INCLUDED
34 #include "nettle-types.h"
41 #define serpent_set_key nettle_serpent_set_key
42 #define serpent_encrypt nettle_serpent_encrypt
43 #define serpent_decrypt nettle_serpent_decrypt
45 #define SERPENT_BLOCK_SIZE 16
47 /* Other key lengths are possible, but the design of Serpent makes
48 * smaller key lengths quite pointless; they cheated with the AES
49 * requirements, using a 256-bit key length exclusively and just
50 * padding it out if the desired key length was less, so there really
51 * is no advantage to using key lengths less than 256 bits. */
52 #define SERPENT_KEY_SIZE 32
54 /* Allow keys of size 128 <= bits <= 256 */
56 #define SERPENT_MIN_KEY_SIZE 16
57 #define SERPENT_MAX_KEY_SIZE 32
61 uint32_t keys
[33][4]; /* key schedule */
65 serpent_set_key(struct serpent_ctx
*ctx
,
66 unsigned length
, const uint8_t *key
);
69 serpent_encrypt(const struct serpent_ctx
*ctx
,
70 unsigned length
, uint8_t *dst
,
73 serpent_decrypt(const struct serpent_ctx
*ctx
,
74 unsigned length
, uint8_t *dst
,
81 #endif /* NETTLE_SERPENT_H_INCLUDED */