Add an internal-representation no-op function.
[u/mdw/catacomb] / twofish.h
1 /* -*-c-*-
2 *
3 * $Id: twofish.h,v 1.3 2001/04/29 18:12:43 mdw Exp $
4 *
5 * The Twofish block cipher
6 *
7 * (c) 2000 Straylight/Edgeware
8 */
9
10 /*----- Licensing notice --------------------------------------------------*
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.
18 *
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.
23 *
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
30 /*----- Revision history --------------------------------------------------*
31 *
32 * $Log: twofish.h,v $
33 * Revision 1.3 2001/04/29 18:12:43 mdw
34 * Fix formatting.
35 *
36 * Revision 1.2 2000/10/08 15:48:58 mdw
37 * Update comments now that AES has been chosen.
38 *
39 * Revision 1.1 2000/06/17 12:10:17 mdw
40 * New cipher.
41 *
42 */
43
44 /*----- Notes on the Twofish block cipher ---------------------------------*
45 *
46 * Twofish was designed by Bruce Schneier, John Kelsey, Doug Whiting, David
47 * Wagner, Chris Hall and Niels Ferguson. The algorithm is unpatented and
48 * free for anyone to use. It was one of the five AES finalist algorithms.
49 *
50 * Twofish is a complex cipher offering various space and time tradeoffs.
51 * This implementation has a heavy key schedule and fast bulk encryption.
52 */
53
54 #ifndef CATACOMB_TWOFISH_H
55 #define CATACOMB_TWOFISH_H
56
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60
61 /*----- Header files ------------------------------------------------------*/
62
63 #include <stddef.h>
64
65 #include <mLib/bits.h>
66
67 /*----- Magical numbers ---------------------------------------------------*/
68
69 #define TWOFISH_BLKSZ 16
70 #define TWOFISH_KEYSZ 32
71 #define TWOFISH_CLASS (N, L, 128)
72
73 extern const octet twofish_keysz[];
74
75 /*----- Data structures ---------------------------------------------------*/
76
77 typedef struct twofish_ctx {
78 uint32 k[40];
79 uint32 g[4][256];
80 } twofish_ctx;
81
82 /*----- Functions provided ------------------------------------------------*/
83
84 /* --- @twofish_init@ --- *
85 *
86 * Arguments: @twofish_ctx *k@ = pointer to key block to fill in
87 * @const void *buf@ = pointer to buffer of key material
88 * @size_t sz@ = size of key material
89 *
90 * Returns: ---
91 *
92 * Use: Initializes a Twofish key buffer. Twofish accepts keys of up
93 * to 256 bits in length.
94 */
95
96 extern void twofish_init(twofish_ctx */*k*/,
97 const void */*buf*/, size_t /*sz*/);
98
99 /* --- @twofish_eblk@, @twofish_dblk@ --- *
100 *
101 * Arguments: @const twofish_ctx *k@ = pointer to key block
102 * @const uint32 s[4]@ = pointer to source block
103 * @uint32 d[4]@ = pointer to destination block
104 *
105 * Returns: ---
106 *
107 * Use: Low-level block encryption and decryption.
108 */
109
110 extern void twofish_eblk(const twofish_ctx */*k*/,
111 const uint32 */*s*/, uint32 */*d*/);
112
113 extern void twofish_dblk(const twofish_ctx */*k*/,
114 const uint32 */*s*/, uint32 */*d*/);
115
116 /*----- That's all, folks -------------------------------------------------*/
117
118 #ifdef __cplusplus
119 }
120 #endif
121
122 #endif