chiark / gitweb /
symm/chacha.c: Set the correct nonce size for `xchachaNN'.
[catacomb] / symm / cast256.h
1 /* -*-c-*-
2  *
3  * The CAST-128 block cipher
4  *
5  * (c) 2000 Straylight/Edgeware
6  */
7
8 /*----- Licensing notice --------------------------------------------------*
9  *
10  * This file is part of Catacomb.
11  *
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.
16  *
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.
21  *
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,
25  * MA 02111-1307, USA.
26  */
27
28 /*----- Notes on the CAST-256 block cipher --------------------------------*
29  *
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.
34  *
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.
38  *
39  * CAST-256 was submitted to the AES contest, but was not selected as one of
40  * the five `finalist' algorithms.
41  */
42
43 #ifndef CATACOMB_CAST256_H
44 #define CATACOMB_CAST256_H
45
46 #ifdef __cplusplus
47   extern "C" {
48 #endif
49
50 /*----- Header files ------------------------------------------------------*/
51
52 #include <mLib/bits.h>
53
54 /*----- Magic numbers -----------------------------------------------------*/
55
56 #define CAST256_BLKSZ 16
57 #define CAST256_KEYSZ 32
58 #define CAST256_CLASS (N, B, 128)
59
60 extern const octet cast256_keysz[];
61
62 /*----- Data structures ---------------------------------------------------*/
63
64 typedef struct cast256_ctx {
65   uint32 km[48];
66   octet kr[48];
67 } cast256_ctx;
68
69 /*----- Functions provided ------------------------------------------------*/
70
71 /* --- @cast256_init@ --- *
72  *
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
76  *
77  * Returns:     ---
78  *
79  * Use:         Initializes a CAST-256 key buffer.  CAST-256 accepts
80  *              256-bit keys or shorter.
81  */
82
83 extern void cast256_init(cast256_ctx */*k*/,
84                          const void */*buf*/, size_t /*sz*/);
85
86 /* --- @cast256_eblk@, @cast256_dblk@ --- *
87  *
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
91  *
92  * Returns:     ---
93  *
94  * Use:         Low-level block encryption and decryption.
95  */
96
97 extern void cast256_eblk(const cast256_ctx */*k*/,
98                          const uint32 */*s*/, uint32 */*d*/);
99
100 extern void cast256_dblk(const cast256_ctx */*k*/,
101                          const uint32 */*s*/, uint32 */*d*/);
102
103 /*----- That's all, folks -------------------------------------------------*/
104
105 #ifdef __cplusplus
106   }
107 #endif
108
109 #endif