gdsa: Include "dsa.h" for dsa_h2n.
[u/mdw/catacomb] / serpent.h
CommitLineData
8dd8c294 1/* -*-c-*-
2 *
b817bfc6 3 * $Id: serpent.h,v 1.3 2004/04/08 01:36:15 mdw Exp $
8dd8c294 4 *
5 * The Serpent block cipher
6 *
7 * (c) 2000 Straylight/Edgeware
8 */
9
45c0fd36 10/*----- Licensing notice --------------------------------------------------*
8dd8c294 11 *
12 * This file is part of Catacomb.
13 *
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
45c0fd36 18 *
8dd8c294 19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
45c0fd36 23 *
8dd8c294 24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 * MA 02111-1307, USA.
28 */
29
8dd8c294 30/*----- Notes on the Serpent block cipher ---------------------------------*
31 *
fbac94e6 32 * Serpent was designed and proposed for the AES contest by Ross Anderson,
8dd8c294 33 * Eli Biham and Lars Knudsen. It's not particularly quick, but is
34 * stunningly secure. The best differential and linear attacks are
35 * speculated to require %$2^{256}$% texts (it's a 128-bit block cipher).
36 * The designers originally intended to file a patent, but failed to persue
37 * it. Use of the algorithm is completely unencumbered.
38 */
39
40#ifndef CATACOMB_SERPENT_H
41#define CATACOMB_SERPENT_H
42
43#ifdef __cplusplus
44 extern "C" {
45#endif
46
47/*----- Header files ------------------------------------------------------*/
48
49#include <stddef.h>
50
51#include <mLib/bits.h>
52
53/*----- Magic numbers -----------------------------------------------------*/
54
55#define SERPENT_BLKSZ 16
56#define SERPENT_KEYSZ 32
57#define SERPENT_CLASS (N, L, 128)
58
59extern const octet serpent_keysz[];
60
61/*----- Data structures ---------------------------------------------------*/
62
63typedef struct serpent_ctx {
64 uint32 k[4 * 33];
65} serpent_ctx;
66
67/*----- Functions provided ------------------------------------------------*/
68
69/* --- @serpent_init@ --- *
70 *
71 * Arguments: @serpent_ctx *k@ = pointer to context block to initialize
72 * @const void *buf@ = pointer to input buffer
73 * @size_t sz@ = size of input buffer
74 *
75 * Returns: ---
76 *
77 * Use: Initializes a Serpent context. The key may be any length of
78 * up to 32 bytes (256 bits).
79 */
80
81extern void serpent_init(serpent_ctx */*k*/,
82 const void */*buf*/, size_t /*sz*/);
83
84/* --- @serpent_eblk@, @serpent_dblk@ --- *
85 *
86 * Arguments: @const serpent_ctx *k@ = pointer to key context
87 * @const uint32 s[4]@ = pointer to source block
88 * @uint32 d[4]@ = pointer to destination block
89 *
90 * Returns: ---
91 *
92 * Use: Low-level block encryption.
93 */
94
95extern void serpent_eblk(const serpent_ctx */*k*/,
96 const uint32 */*s*/, uint32 */*d*/);
97extern void serpent_dblk(const serpent_ctx */*k*/,
98 const uint32 */*s*/, uint32 */*d*/);
99
100/*----- That's all, folks -------------------------------------------------*/
101
102#ifdef __cplusplus
103 }
104#endif
105
106#endif