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