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