3 * The Serpent block cipher
5 * (c) 2000 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Catacomb.
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 /*----- Notes on the Serpent block cipher ---------------------------------*
30 * Serpent was designed and proposed for the AES contest by Ross Anderson,
31 * Eli Biham and Lars Knudsen. It's not particularly quick, but is
32 * stunningly secure. The best differential and linear attacks are
33 * speculated to require %$2^{256}$% texts (it's a 128-bit block cipher).
34 * The designers originally intended to file a patent, but failed to persue
35 * it. Use of the algorithm is completely unencumbered.
38 #ifndef CATACOMB_SERPENT_H
39 #define CATACOMB_SERPENT_H
45 /*----- Header files ------------------------------------------------------*/
49 #include <mLib/bits.h>
51 /*----- Magic numbers -----------------------------------------------------*/
53 #define SERPENT_BLKSZ 16
54 #define SERPENT_KEYSZ 32
55 #define SERPENT_CLASS (N, L, 128)
57 extern const octet serpent_keysz[];
59 /*----- Data structures ---------------------------------------------------*/
61 typedef struct serpent_ctx {
65 /*----- Functions provided ------------------------------------------------*/
67 /* --- @serpent_init@ --- *
69 * Arguments: @serpent_ctx *k@ = pointer to context block to initialize
70 * @const void *buf@ = pointer to input buffer
71 * @size_t sz@ = size of input buffer
75 * Use: Initializes a Serpent context. The key may be any length of
76 * up to 32 bytes (256 bits).
79 extern void serpent_init(serpent_ctx */*k*/,
80 const void */*buf*/, size_t /*sz*/);
82 /* --- @serpent_eblk@, @serpent_dblk@ --- *
84 * Arguments: @const serpent_ctx *k@ = pointer to key context
85 * @const uint32 s[4]@ = pointer to source block
86 * @uint32 d[4]@ = pointer to destination block
90 * Use: Low-level block encryption.
93 extern void serpent_eblk(const serpent_ctx */*k*/,
94 const uint32 */*s*/, uint32 */*d*/);
95 extern void serpent_dblk(const serpent_ctx */*k*/,
96 const uint32 */*s*/, uint32 */*d*/);
98 /*----- That's all, folks -------------------------------------------------*/