3 * $Id: cast256.h,v 1.2 2004/04/08 01:36:15 mdw Exp $
5 * The CAST-128 block cipher
7 * (c) 2000 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
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.
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.
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,
30 /*----- Notes on the CAST-256 block cipher --------------------------------*
32 * CAST, designed by Carlisle Adams and Stafford Tavares, is a method for
33 * designing block ciphers, based around the concept of `bent functions'. It
34 * is described in the paper `Constructing Symmetric Ciphers using the CAST
35 * Design Procedure' by Carlisle Adams.
37 * CAST-256, defined in RFC2612, is a particular instance of the CAST design
38 * procedure. It is an `incomplete' Feistel network. It uses the same
39 * S-boxes and round functions as CAST-128.
41 * CAST-256 was submitted to the AES contest, but was not selected as one of
42 * the five `finalist' algorithms.
45 #ifndef CATACOMB_CAST256_H
46 #define CATACOMB_CAST256_H
52 /*----- Header files ------------------------------------------------------*/
54 #include <mLib/bits.h>
56 /*----- Magic numbers -----------------------------------------------------*/
58 #define CAST256_BLKSZ 16
59 #define CAST256_KEYSZ 32
60 #define CAST256_CLASS (N, B, 128)
62 extern const octet cast256_keysz
[];
64 /*----- Data structures ---------------------------------------------------*/
66 typedef struct cast256_ctx
{
71 /*----- Functions provided ------------------------------------------------*/
73 /* --- @cast256_init@ --- *
75 * Arguments: @cast256_ctx *k@ = pointer to key block to fill in
76 * @const void *buf@ = pointer to buffer of key material
77 * @size_t sz@ = size of key material
81 * Use: Initializes a CAST-256 key buffer. CAST-256 accepts
82 * 256-bit keys or shorter.
85 extern void cast256_init(cast256_ctx */
*k*/
,
86 const void */
*buf*/
, size_t /*sz*/);
88 /* --- @cast256_eblk@, @cast256_dblk@ --- *
90 * Arguments: @const cast256_ctx *k@ = pointer to key block
91 * @const uint32 s[2]@ = pointer to source block
92 * @uint32 d[2]@ = pointer to destination block
96 * Use: Low-level block encryption and decryption.
99 extern void cast256_eblk(const cast256_ctx */
*k*/
,
100 const uint32 */
*s*/
, uint32 */
*d*/
);
102 extern void cast256_dblk(const cast256_ctx */
*k*/
,
103 const uint32 */
*s*/
, uint32 */
*d*/
);
105 /*----- That's all, folks -------------------------------------------------*/