Rearrange the file tree.
[u/mdw/catacomb] / symm / desx.h
1 /* -*-c-*-
2 *
3 * The DESX algorithm
4 *
5 * (c) 2001 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 DESX -----------------------------------------------------*
29 *
30 * DESX was designed by Ron Rivest in 1986 as a simple and cheap way to
31 * strengthen DES against exhaustive search. It also increases the
32 * difficulty of differential and linear attacks.
33 */
34
35 #ifndef CATACOMB_DESX_H
36 #define CATACOMB_DESX_H
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 /*----- Header files ------------------------------------------------------*/
43
44 #include <stddef.h>
45
46 #include <mLib/bits.h>
47
48 #ifndef CATACOMB_DES_H
49 # include "des.h"
50 #endif
51
52 /*----- Magical numbers ---------------------------------------------------*/
53
54 #define DESX_BLKSZ 8
55 #define DESX_KEYSZ 23
56 #define DESX_CLASS (N, B, 64)
57
58 extern const octet desx_keysz[];
59
60 /*----- Data structures ---------------------------------------------------*/
61
62 typedef struct desx_ctx {
63 des_ctx k;
64 uint32 prea, preb;
65 uint32 posta, postb;
66 } desx_ctx;
67
68 /*----- Functions provided ------------------------------------------------*/
69
70 /* --- @desx_init@ --- *
71 *
72 * Arguments: @desx_ctx *k@ = pointer to key block
73 * @const void *buf@ = pointer to key buffer
74 * @size_t sz@ = size of key material
75 *
76 * Returns: ---
77 *
78 * Use: Initializes a DESX key buffer. The key buffer contains, in
79 * order, an optional 8-byte pre-whitening key, a single-DES key
80 * (either 7 or 8 bytes), and an optional 8-byte port-whitening
81 * key. If no whitening keys are specified, the algorithm
82 * becomes the same as single-DES.
83 */
84
85 extern void desx_init(desx_ctx */*k*/, const void */*buf*/, size_t /*sz*/);
86
87 /* --- @desx_eblk@, @desx_dblk@ --- *
88 *
89 * Arguments: @const desx_ctx *k@ = pointer to key block
90 * @const uint32 s[2]@ = pointer to source block
91 * @uint32 d[2]@ = pointer to destination block
92 *
93 * Returns: ---
94 *
95 * Use: Low-level block encryption and decryption.
96 */
97
98 extern void desx_eblk(const desx_ctx */*k*/,
99 const uint32 */*s*/, uint32 */*d*/);
100 extern void desx_dblk(const desx_ctx */*k*/,
101 const uint32 */*s*/, uint32 */*d*/);
102
103 /*----- That's all, folks -------------------------------------------------*/
104
105 #ifdef __cplusplus
106 }
107 #endif
108
109 #endif