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-128 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-128, defined in RFC2144, is a particular instance of the CAST design
36 * procedure, The cipher seems strong and fairly quick. The design procedure
37 * itself is patented, although the cipher CAST-128 is free to use.
39 * Although CAST ciphers are resistant to differential and linear
40 * cryptanalysis, some instances have been broken by more advanced techniques
41 * -- the CAST procedure does not guarantee a strong cipher. However,
42 * CAST-128 has so far resisted all attacks against it, and has now been
43 * accepted by the Canadian government for protection of all `Designated'
47 #ifndef CATACOMB_CAST128_H
48 #define CATACOMB_CAST128_H
54 /*----- Header files ------------------------------------------------------*/
56 #include <mLib/bits.h>
58 /*----- Magic numbers -----------------------------------------------------*/
60 #define CAST128_BLKSZ 8
61 #define CAST128_KEYSZ 16
62 #define CAST128_CLASS (N, B, 64)
64 extern const octet cast128_keysz[];
66 /*----- Data structures ---------------------------------------------------*/
68 typedef struct cast128_ctx {
74 /*----- Functions provided ------------------------------------------------*/
76 /* --- @cast128_init@ --- *
78 * Arguments: @cast128_ctx *k@ = pointer to key block to fill in
79 * @const void *buf@ = pointer to buffer of key material
80 * @size_t sz@ = size of key material
84 * Use: Initializes a CAST-128 key buffer. CAST-128 accepts
85 * 128-bit keys or shorter.
88 extern void cast128_init(cast128_ctx */*k*/,
89 const void */*buf*/, size_t /*sz*/);
91 /* --- @cast128_eblk@, @cast128_dblk@ --- *
93 * Arguments: @const cast128_ctx *k@ = pointer to key block
94 * @const uint32 s[2]@ = pointer to source block
95 * @uint32 d[2]@ = pointer to destination block
99 * Use: Low-level block encryption and decryption.
102 extern void cast128_eblk(const cast128_ctx */*k*/,
103 const uint32 */*s*/, uint32 */*d*/);
105 extern void cast128_dblk(const cast128_ctx */*k*/,
106 const uint32 */*s*/, uint32 */*d*/);
108 /*----- That's all, folks -------------------------------------------------*/