| 1 | /* -*-c-*- |
| 2 | * |
| 3 | * $Id: serpent.h,v 1.2 2000/10/08 15:48:58 mdw Exp $ |
| 4 | * |
| 5 | * The Serpent 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: serpent.h,v $ |
| 33 | * Revision 1.2 2000/10/08 15:48:58 mdw |
| 34 | * Update comments now that AES has been chosen. |
| 35 | * |
| 36 | * Revision 1.1 2000/06/17 12:08:43 mdw |
| 37 | * New cipher. |
| 38 | * |
| 39 | */ |
| 40 | |
| 41 | /*----- Notes on the Serpent block cipher ---------------------------------* |
| 42 | * |
| 43 | * Serpent was designed and proposed for the AES contest by Ross Anderson, |
| 44 | * Eli Biham and Lars Knudsen. It's not particularly quick, but is |
| 45 | * stunningly secure. The best differential and linear attacks are |
| 46 | * speculated to require %$2^{256}$% texts (it's a 128-bit block cipher). |
| 47 | * The designers originally intended to file a patent, but failed to persue |
| 48 | * it. Use of the algorithm is completely unencumbered. |
| 49 | */ |
| 50 | |
| 51 | #ifndef CATACOMB_SERPENT_H |
| 52 | #define CATACOMB_SERPENT_H |
| 53 | |
| 54 | #ifdef __cplusplus |
| 55 | extern "C" { |
| 56 | #endif |
| 57 | |
| 58 | /*----- Header files ------------------------------------------------------*/ |
| 59 | |
| 60 | #include <stddef.h> |
| 61 | |
| 62 | #include <mLib/bits.h> |
| 63 | |
| 64 | /*----- Magic numbers -----------------------------------------------------*/ |
| 65 | |
| 66 | #define SERPENT_BLKSZ 16 |
| 67 | #define SERPENT_KEYSZ 32 |
| 68 | #define SERPENT_CLASS (N, L, 128) |
| 69 | |
| 70 | extern const octet serpent_keysz[]; |
| 71 | |
| 72 | /*----- Data structures ---------------------------------------------------*/ |
| 73 | |
| 74 | typedef struct serpent_ctx { |
| 75 | uint32 k[4 * 33]; |
| 76 | } serpent_ctx; |
| 77 | |
| 78 | /*----- Functions provided ------------------------------------------------*/ |
| 79 | |
| 80 | /* --- @serpent_init@ --- * |
| 81 | * |
| 82 | * Arguments: @serpent_ctx *k@ = pointer to context block to initialize |
| 83 | * @const void *buf@ = pointer to input buffer |
| 84 | * @size_t sz@ = size of input buffer |
| 85 | * |
| 86 | * Returns: --- |
| 87 | * |
| 88 | * Use: Initializes a Serpent context. The key may be any length of |
| 89 | * up to 32 bytes (256 bits). |
| 90 | */ |
| 91 | |
| 92 | extern void serpent_init(serpent_ctx */*k*/, |
| 93 | const void */*buf*/, size_t /*sz*/); |
| 94 | |
| 95 | /* --- @serpent_eblk@, @serpent_dblk@ --- * |
| 96 | * |
| 97 | * Arguments: @const serpent_ctx *k@ = pointer to key context |
| 98 | * @const uint32 s[4]@ = pointer to source block |
| 99 | * @uint32 d[4]@ = pointer to destination block |
| 100 | * |
| 101 | * Returns: --- |
| 102 | * |
| 103 | * Use: Low-level block encryption. |
| 104 | */ |
| 105 | |
| 106 | extern void serpent_eblk(const serpent_ctx */*k*/, |
| 107 | const uint32 */*s*/, uint32 */*d*/); |
| 108 | extern void serpent_dblk(const serpent_ctx */*k*/, |
| 109 | const uint32 */*s*/, uint32 */*d*/); |
| 110 | |
| 111 | /*----- That's all, folks -------------------------------------------------*/ |
| 112 | |
| 113 | #ifdef __cplusplus |
| 114 | } |
| 115 | #endif |
| 116 | |
| 117 | #endif |