d03ab969 |
1 | /* -*-c-*- |
2 | * |
b3f05084 |
3 | * $Id: idea.h,v 1.2 1999/12/10 23:29:48 mdw Exp $ |
d03ab969 |
4 | * |
5 | * Implementation of the IDEA cipher |
6 | * |
7 | * (c) 1999 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: idea.h,v $ |
b3f05084 |
33 | * Revision 1.2 1999/12/10 23:29:48 mdw |
34 | * Change header file guard names. |
35 | * |
d03ab969 |
36 | * Revision 1.1 1999/09/03 08:41:12 mdw |
37 | * Initial import. |
38 | * |
39 | */ |
40 | |
41 | /*----- Notes on the IDEA block cipher ------------------------------------* |
42 | * |
43 | * IDEA was invented by James Massey and Xuejia Lai. The fundamental idea |
44 | * underlying the cipher is combining incompatible group operations. The |
45 | * algorithm's main claim to fame is that it is the symmetric cipher in PGP |
46 | * version 2. |
47 | * |
48 | * The IDEA algorithm is allegedly patented by Ascom Tech A.G., even in the |
49 | * UK and Europe. Ascom are willing to grant licences for use in software |
50 | * which forbids commercial use, but this is not compatible with Free |
51 | * Software Foundation ideology. The author recommends against the use of |
52 | * the IDEA cipher entirely. Blowfish is conceptually simpler, appears more |
53 | * concervative, offers a larger keyspace, runs faster, and is in the public |
54 | * domain. |
55 | */ |
56 | |
b3f05084 |
57 | #ifndef CATACOMB_IDEA_H |
58 | #define CATACOMB_IDEA_H |
d03ab969 |
59 | |
60 | #ifdef __cplusplus |
61 | extern "C" { |
62 | #endif |
63 | |
64 | /*----- Header files ------------------------------------------------------*/ |
65 | |
66 | #include <stddef.h> |
67 | |
68 | #include <mLib/bits.h> |
69 | |
70 | /*----- Magical numbers ---------------------------------------------------*/ |
71 | |
72 | #define IDEA_BLKSZ 8 |
73 | #define IDEA_KEYSZ 16 |
74 | #define IDEA_CLASS (N, B, 64) |
75 | |
76 | /*----- Data structures ---------------------------------------------------*/ |
77 | |
78 | typedef struct idea_ctx { |
79 | uint16 e[52]; |
80 | uint16 d[52]; |
81 | } idea_ctx; |
82 | |
83 | /*----- Functions provided ------------------------------------------------*/ |
84 | |
85 | /* --- @idea_init@ --- * |
86 | * |
87 | * Arguments: @idea_ctx *k@ = pointer to key block |
88 | * @const void *buf@ = pointer to key buffer |
89 | * @size_t sz@ = size of key material |
90 | * |
91 | * Returns: --- |
92 | * |
93 | * Use: Initializes an IDEA key buffer. The buffer must be exactly |
94 | * 16 bytes in size, because IDEA is only defined with a key |
95 | * size of 128 bits. |
96 | */ |
97 | |
98 | extern void idea_init(idea_ctx */*k*/, const void */*buf*/, size_t /*sz*/); |
99 | |
100 | /* --- @idea_eblk@, @idea_dblk@ --- * |
101 | * |
102 | * Arguments: @const idea_ctx *k@ = pointer to a key block |
103 | * @const uint32 s[2]@ = pointer to source block |
104 | * @uint32 d[2]@ = pointer to destination block |
105 | * |
106 | * Returns: --- |
107 | * |
108 | * Use: Low-level block encryption and decryption. |
109 | */ |
110 | |
111 | extern void idea_eblk(const idea_ctx */*k*/, |
112 | const uint32 */*s*/, uint32 */*d*/); |
113 | extern void idea_dblk(const idea_ctx */*k*/, |
114 | const uint32 */*s*/, uint32 */*d*/); |
115 | |
116 | /*----- That's all, folks -------------------------------------------------*/ |
117 | |
118 | #ifdef __cplusplus |
119 | } |
120 | #endif |
121 | |
122 | #endif |