3 * The CAST-128 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 CAST-256 block cipher --------------------------------*
30 * CAST, designed by Carlisle Adams and Stafford Tavares, is a method for
31 * designing block ciphers, based around the concept of `bent functions'. It
32 * is described in the paper `Constructing Symmetric Ciphers using the CAST
33 * Design Procedure' by Carlisle Adams.
35 * CAST-256, defined in RFC2612, is a particular instance of the CAST design
36 * procedure. It is an `incomplete' Feistel network. It uses the same
37 * S-boxes and round functions as CAST-128.
39 * CAST-256 was submitted to the AES contest, but was not selected as one of
40 * the five `finalist' algorithms.
43 #ifndef CATACOMB_CAST256_H
44 #define CATACOMB_CAST256_H
50 /*----- Header files ------------------------------------------------------*/
52 #include <mLib/bits.h>
54 /*----- Magic numbers -----------------------------------------------------*/
56 #define CAST256_BLKSZ 16
57 #define CAST256_KEYSZ 32
58 #define CAST256_CLASS (N, B, 128)
60 extern const octet cast256_keysz[];
62 /*----- Data structures ---------------------------------------------------*/
64 typedef struct cast256_ctx {
69 /*----- Functions provided ------------------------------------------------*/
71 /* --- @cast256_init@ --- *
73 * Arguments: @cast256_ctx *k@ = pointer to key block to fill in
74 * @const void *buf@ = pointer to buffer of key material
75 * @size_t sz@ = size of key material
79 * Use: Initializes a CAST-256 key buffer. CAST-256 accepts
80 * 256-bit keys or shorter.
83 extern void cast256_init(cast256_ctx */*k*/,
84 const void */*buf*/, size_t /*sz*/);
86 /* --- @cast256_eblk@, @cast256_dblk@ --- *
88 * Arguments: @const cast256_ctx *k@ = pointer to key block
89 * @const uint32 s[2]@ = pointer to source block
90 * @uint32 d[2]@ = pointer to destination block
94 * Use: Low-level block encryption and decryption.
97 extern void cast256_eblk(const cast256_ctx */*k*/,
98 const uint32 */*s*/, uint32 */*d*/);
100 extern void cast256_dblk(const cast256_ctx */*k*/,
101 const uint32 */*s*/, uint32 */*d*/);
103 /*----- That's all, folks -------------------------------------------------*/