3bef8c14 |
1 | /* -*-c-*- |
3bef8c14 |
2 | * |
3 | * The MARS block cipher |
4 | * |
5 | * (c) 2001 Straylight/Edgeware |
6 | */ |
7 | |
45c0fd36 |
8 | /*----- Licensing notice --------------------------------------------------* |
3bef8c14 |
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. |
45c0fd36 |
16 | * |
3bef8c14 |
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. |
45c0fd36 |
21 | * |
3bef8c14 |
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 | |
3bef8c14 |
28 | /*----- Notes on the MARS block cipher ------------------------------------* |
29 | * |
30 | * MARS was IBM's submission to the AES contest. It was designed by a number |
31 | * of clever people at the T. J. Watson labs, and made it to the second round |
32 | * of the contest. Unfortunately, MARS is rather messy. There are some |
33 | * awkward corner cases in the key schedule algorithm, for example, that show |
34 | * up very rarely. |
35 | */ |
36 | |
37 | #ifndef CATACOMB_MARS_H |
38 | #define CATACOMB_MARS_H |
39 | |
40 | #ifdef __cplusplus |
41 | extern "C" { |
42 | #endif |
43 | |
44 | /*----- Header files ------------------------------------------------------*/ |
45 | |
46 | #include <stddef.h> |
47 | |
48 | #include <mLib/bits.h> |
49 | |
50 | /*----- Magical numbers ---------------------------------------------------*/ |
51 | |
52 | #define MARS_BLKSZ 16 |
53 | #define MARS_KEYSZ 32 |
54 | #define MARS_CLASS (N, L, 128) |
55 | |
56 | extern const octet mars_keysz[]; |
57 | |
58 | /*----- Data structures ---------------------------------------------------*/ |
59 | |
60 | typedef struct mars_ctx { |
61 | uint32 k[40]; |
62 | } mars_ctx; |
63 | |
64 | /*----- Functions provided ------------------------------------------------*/ |
65 | |
66 | /* --- @mars_init@ --- * |
67 | * |
68 | * Arguments: @mars_ctx *k@ = pointer to key block to fill in |
69 | * @const void *buf@ = pointer to buffer of key material |
70 | * @size_t sz@ = size of key material |
71 | * |
72 | * Returns: --- |
73 | * |
74 | * Use: Initializes a MARS key buffer. MARS accepts key sizes |
75 | * between 128 and 448 bits which are a multiple of 32 bits. |
76 | */ |
77 | |
78 | extern void mars_init(mars_ctx */*k*/, |
79 | const void */*buf*/, size_t /*sz*/); |
80 | |
81 | /* --- @mars_eblk@, @mars_dblk@ --- * |
82 | * |
83 | * Arguments: @const mars_ctx *k@ = pointer to key block |
84 | * @const uint32 s[4]@ = pointer to source block |
85 | * @uint32 d[4]@ = pointer to destination block |
86 | * |
87 | * Returns: --- |
88 | * |
89 | * Use: Low-level block encryption and decryption. |
90 | */ |
91 | |
92 | extern void mars_eblk(const mars_ctx */*k*/, |
93 | const uint32 */*s*/, uint32 */*d*/); |
94 | |
95 | extern void mars_dblk(const mars_ctx */*k*/, |
96 | const uint32 */*s*/, uint32 */*d*/); |
97 | |
98 | /*----- That's all, folks -------------------------------------------------*/ |
99 | |
100 | #ifdef __cplusplus |
101 | } |
102 | #endif |
103 | |
104 | #endif |