chiark / gitweb /
Initial revision
[become] / src / idea.h
1 /* -*-c-*-
2  *
3  * $Id: idea.h,v 1.1 1997/07/21 13:47:48 mdw Exp $
4  *
5  * IDEA encryption routines
6  *  Based on Straylight ARM assembler routines
7  *
8  * (c) 1996, 1997 Mark Wooding
9  */
10
11 /*----- Licencing 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
27  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28  */
29
30 /*----- Revision history --------------------------------------------------*
31  *
32  * $Log: idea.h,v $
33  * Revision 1.1  1997/07/21 13:47:48  mdw
34  * Initial revision
35  *
36  */
37
38 #ifndef IDEA_H
39 #define IDEA_H
40
41 #ifdef __cplusplus
42   extern "C" {
43 #endif
44
45 /*----- Required headers --------------------------------------------------*/
46
47 #ifndef CONFIG_H
48 #  include "config.h"
49 #endif
50
51 /*----- Useful constants --------------------------------------------------*/
52
53 #define IDEA_BLKSIZE (8u)               /* Number of bytes in IDEA block */
54 #define IDEA_KEYSIZE (16u)              /* Number of bytes in IDEA key */
55 #define IDEA_EXPKEYSIZE (52u)           /* Number of ints in expanded key */
56
57 /*----- Type definitions --------------------------------------------------*/
58
59 typedef struct idea_key {
60   int k[IDEA_EXPKEYSIZE];               /* Subkey array */
61 } idea_key;
62
63 /*----- Functions provided ------------------------------------------------*/
64
65 /* --- @idea_ekeys@ --- *
66  *
67  * Arguments:   @idea_key *k@ = the expanded key buffer
68  *              @const unsigned char *key@ = the user's key encryption key
69  *
70  * Returns:     ---
71  *
72  * Use:         Unpacks an encryption key.
73  */
74
75 extern void idea_ekeys(idea_key */*k*/, const unsigned char */*key*/);
76
77 /* --- @idea_invertKey@ --- *
78  *
79  * Arguments:   @const idea_key *in@ = pointer to input expanded key buffer
80  *              @idea_key *out@ = pointer to output expanded key buffer
81  *
82  * Returns:     ---
83  *
84  * Use:         Computes the inverse (decryption) key given an expanded
85  *              IDEA encryption key.
86  */
87
88 extern void idea_invertKey(const idea_key */*in*/, idea_key */*out*/);
89
90 /* --- @idea_dkeys@ --- *
91  *
92  * Arguments:   @idea_key *k@ = the expanded key buffer
93  *              @const unsigned char *key@ = the user's key encryption key
94  *
95  * Returns:     ---
96  *
97  * Use:         Unpacks a decryption key.
98  */
99
100 extern void idea_dkeys(idea_key */*k*/, const unsigned char */*key*/);
101
102 /* --- @idea_encrypt@ --- *
103  *
104  * Arguments:   @const idea_key *k@ = key to use
105  *              @const void *src@ = block to encrypt
106  *              @void *dest@ = where to store the result
107  *              
108  *
109  * Returns:     ---
110  *
111  * Use:         Encrypts (or decrypts) a block, using the IDEA cryptosystem.
112  *              Since the decryption operation is the same as encryption
113  *              except that a different key buffer is used, this is all we
114  *              need to complete the simple bits.
115  */
116
117 extern void idea_encrypt(const idea_key */*k*/,
118                          const void */*src*/, void */*dest*/);
119
120 /*----- That's all, folks -------------------------------------------------*/
121
122 #ifdef __cplusplus
123   }
124 #endif
125
126 #endif