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