Use the shiny new `mLib' warning-control macros.
[u/mdw/catacomb] / symm / idea.h
CommitLineData
d03ab969 1/* -*-c-*-
2 *
d03ab969 3 * Implementation of the IDEA cipher
4 *
5 * (c) 1999 Straylight/Edgeware
6 */
7
45c0fd36 8/*----- Licensing notice --------------------------------------------------*
d03ab969 9 *
10 * This file is part of Catacomb.
11 *
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
45c0fd36 16 *
d03ab969 17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
45c0fd36 21 *
d03ab969 22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 * MA 02111-1307, USA.
26 */
27
d03ab969 28/*----- Notes on the IDEA block cipher ------------------------------------*
29 *
30 * IDEA was invented by James Massey and Xuejia Lai. The fundamental idea
31 * underlying the cipher is combining incompatible group operations. The
32 * algorithm's main claim to fame is that it is the symmetric cipher in PGP
33 * version 2.
34 *
35 * The IDEA algorithm is allegedly patented by Ascom Tech A.G., even in the
36 * UK and Europe. Ascom are willing to grant licences for use in software
37 * which forbids commercial use, but this is not compatible with Free
38 * Software Foundation ideology. The author recommends against the use of
39 * the IDEA cipher entirely. Blowfish is conceptually simpler, appears more
40 * concervative, offers a larger keyspace, runs faster, and is in the public
41 * domain.
42 */
43
b3f05084 44#ifndef CATACOMB_IDEA_H
45#define CATACOMB_IDEA_H
d03ab969 46
47#ifdef __cplusplus
48 extern "C" {
49#endif
50
51/*----- Header files ------------------------------------------------------*/
52
53#include <stddef.h>
54
55#include <mLib/bits.h>
56
57/*----- Magical numbers ---------------------------------------------------*/
58
59#define IDEA_BLKSZ 8
60#define IDEA_KEYSZ 16
61#define IDEA_CLASS (N, B, 64)
62
6ced98bd 63extern const octet idea_keysz[];
64
d03ab969 65/*----- Data structures ---------------------------------------------------*/
66
67typedef struct idea_ctx {
68 uint16 e[52];
69 uint16 d[52];
70} idea_ctx;
71
72/*----- Functions provided ------------------------------------------------*/
73
74/* --- @idea_init@ --- *
75 *
76 * Arguments: @idea_ctx *k@ = pointer to key block
77 * @const void *buf@ = pointer to key buffer
78 * @size_t sz@ = size of key material
79 *
80 * Returns: ---
81 *
82 * Use: Initializes an IDEA key buffer. The buffer must be exactly
83 * 16 bytes in size, because IDEA is only defined with a key
84 * size of 128 bits.
85 */
86
87extern void idea_init(idea_ctx */*k*/, const void */*buf*/, size_t /*sz*/);
88
89/* --- @idea_eblk@, @idea_dblk@ --- *
90 *
91 * Arguments: @const idea_ctx *k@ = pointer to a key block
92 * @const uint32 s[2]@ = pointer to source block
93 * @uint32 d[2]@ = pointer to destination block
94 *
95 * Returns: ---
96 *
97 * Use: Low-level block encryption and decryption.
98 */
99
100extern void idea_eblk(const idea_ctx */*k*/,
101 const uint32 */*s*/, uint32 */*d*/);
102extern void idea_dblk(const idea_ctx */*k*/,
103 const uint32 */*s*/, uint32 */*d*/);
104
105/*----- That's all, folks -------------------------------------------------*/
106
107#ifdef __cplusplus
108 }
109#endif
110
111#endif