9810d749 |
1 | /* -*-c-*- |
2 | * |
3 | * $Id: cast256.h,v 1.1 2000/06/17 10:49:14 mdw Exp $ |
4 | * |
5 | * The CAST-128 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: cast256.h,v $ |
33 | * Revision 1.1 2000/06/17 10:49:14 mdw |
34 | * New cipher. |
35 | * |
36 | */ |
37 | |
38 | /*----- Notes on the CAST-256 block cipher --------------------------------* |
39 | * |
40 | * CAST, designed by Carlisle Adams and Stafford Tavares, is a method for |
41 | * designing block ciphers, based around the concept of `bent functions'. It |
42 | * is described in the paper `Constructing Symmetric Ciphers using the CAST |
43 | * Design Procedure' by Carlisle Adams. |
44 | * |
45 | * CAST-256, defined in RFC2612, is a particular instance of the CAST design |
46 | * procedure. It is an `incomplete' Feistel network. It uses the same |
47 | * S-boxes and round functions as CAST-128. |
48 | * |
49 | * CAST-256 was submitted to the AES contest, but was not selected as one of |
50 | * the five `finalist' algorithms. |
51 | */ |
52 | |
53 | #ifndef CATACOMB_CAST256_H |
54 | #define CATACOMB_CAST256_H |
55 | |
56 | #ifdef __cplusplus |
57 | extern "C" { |
58 | #endif |
59 | |
60 | /*----- Header files ------------------------------------------------------*/ |
61 | |
62 | #include <mLib/bits.h> |
63 | |
64 | /*----- Magic numbers -----------------------------------------------------*/ |
65 | |
66 | #define CAST256_BLKSZ 16 |
67 | #define CAST256_KEYSZ 32 |
68 | #define CAST256_CLASS (N, B, 128) |
69 | |
70 | extern const octet cast256_keysz[]; |
71 | |
72 | /*----- Data structures ---------------------------------------------------*/ |
73 | |
74 | typedef struct cast256_ctx { |
75 | uint32 km[48]; |
76 | octet kr[48]; |
77 | } cast256_ctx; |
78 | |
79 | /*----- Functions provided ------------------------------------------------*/ |
80 | |
81 | /* --- @cast256_init@ --- * |
82 | * |
83 | * Arguments: @cast256_ctx *k@ = pointer to key block to fill in |
84 | * @const void *buf@ = pointer to buffer of key material |
85 | * @size_t sz@ = size of key material |
86 | * |
87 | * Returns: --- |
88 | * |
89 | * Use: Initializes a CAST-256 key buffer. CAST-256 accepts |
90 | * 256-bit keys or shorter. |
91 | */ |
92 | |
93 | extern void cast256_init(cast256_ctx */*k*/, |
94 | const void */*buf*/, size_t /*sz*/); |
95 | |
96 | /* --- @cast256_eblk@, @cast256_dblk@ --- * |
97 | * |
98 | * Arguments: @const cast256_ctx *k@ = pointer to key block |
99 | * @const uint32 s[2]@ = pointer to source block |
100 | * @uint32 d[2]@ = pointer to destination block |
101 | * |
102 | * Returns: --- |
103 | * |
104 | * Use: Low-level block encryption and decryption. |
105 | */ |
106 | |
107 | extern void cast256_eblk(const cast256_ctx */*k*/, |
108 | const uint32 */*s*/, uint32 */*d*/); |
109 | |
110 | extern void cast256_dblk(const cast256_ctx */*k*/, |
111 | const uint32 */*s*/, uint32 */*d*/); |
112 | |
113 | /*----- That's all, folks -------------------------------------------------*/ |
114 | |
115 | #ifdef __cplusplus |
116 | } |
117 | #endif |
118 | |
119 | #endif |