08e7f9359fbe4bc6eea731d8492d124300d729f6
[become] / src / idea.h
1 /* -*-c-*-
2 *
3 * $Id: idea.h,v 1.2 1997/08/04 10:24:22 mdw Exp $
4 *
5 * IDEA encryption routines
6 * Based on Straylight ARM assembler routines
7 *
8 * (c) 1996, 1997 Mark Wooding
9 */
10
11 /*----- Licensing notice --------------------------------------------------*
12 *
13 * This file is part of `become'
14 *
15 * `Become' is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * `Become' is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with `become'; if not, write to the Free Software Foundation,
27 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 */
29
30 /*----- Revision history --------------------------------------------------*
31 *
32 * $Log: idea.h,v $
33 * Revision 1.2 1997/08/04 10:24:22 mdw
34 * Sources placed under CVS control.
35 *
36 * Revision 1.1 1997/07/21 13:47:48 mdw
37 * Initial revision
38 *
39 */
40
41 #ifndef IDEA_H
42 #define IDEA_H
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 /*----- Required headers --------------------------------------------------*/
49
50 #ifndef CONFIG_H
51 # include "config.h"
52 #endif
53
54 /*----- Useful constants --------------------------------------------------*/
55
56 #define IDEA_BLKSIZE (8u) /* Number of bytes in IDEA block */
57 #define IDEA_KEYSIZE (16u) /* Number of bytes in IDEA key */
58 #define IDEA_EXPKEYSIZE (52u) /* Number of ints in expanded key */
59
60 /*----- Type definitions --------------------------------------------------*/
61
62 typedef struct idea_key {
63 int k[IDEA_EXPKEYSIZE]; /* Subkey array */
64 } idea_key;
65
66 /*----- Functions provided ------------------------------------------------*/
67
68 /* --- @idea_ekeys@ --- *
69 *
70 * Arguments: @idea_key *k@ = the expanded key buffer
71 * @const unsigned char *key@ = the user's key encryption key
72 *
73 * Returns: ---
74 *
75 * Use: Unpacks an encryption key.
76 */
77
78 extern void idea_ekeys(idea_key */*k*/, const unsigned char */*key*/);
79
80 /* --- @idea_invertKey@ --- *
81 *
82 * Arguments: @const idea_key *in@ = pointer to input expanded key buffer
83 * @idea_key *out@ = pointer to output expanded key buffer
84 *
85 * Returns: ---
86 *
87 * Use: Computes the inverse (decryption) key given an expanded
88 * IDEA encryption key.
89 */
90
91 extern void idea_invertKey(const idea_key */*in*/, idea_key */*out*/);
92
93 /* --- @idea_dkeys@ --- *
94 *
95 * Arguments: @idea_key *k@ = the expanded key buffer
96 * @const unsigned char *key@ = the user's key encryption key
97 *
98 * Returns: ---
99 *
100 * Use: Unpacks a decryption key.
101 */
102
103 extern void idea_dkeys(idea_key */*k*/, const unsigned char */*key*/);
104
105 /* --- @idea_encrypt@ --- *
106 *
107 * Arguments: @const idea_key *k@ = key to use
108 * @const void *src@ = block to encrypt
109 * @void *dest@ = where to store the result
110 *
111 *
112 * Returns: ---
113 *
114 * Use: Encrypts (or decrypts) a block, using the IDEA cryptosystem.
115 * Since the decryption operation is the same as encryption
116 * except that a different key buffer is used, this is all we
117 * need to complete the simple bits.
118 */
119
120 extern void idea_encrypt(const idea_key */*k*/,
121 const void */*src*/, void */*dest*/);
122
123 /*----- That's all, folks -------------------------------------------------*/
124
125 #ifdef __cplusplus
126 }
127 #endif
128
129 #endif