3 * $Id: idea.h,v 1.2 1997/08/04 10:24:22 mdw Exp $
5 * IDEA encryption routines
6 * Based on Straylight ARM assembler routines
8 * (c) 1996, 1997 Mark Wooding
11 /*----- Licensing notice --------------------------------------------------*
13 * This file is part of `become'
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.
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.
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.
30 /*----- Revision history --------------------------------------------------*
33 * Revision 1.2 1997/08/04 10:24:22 mdw
34 * Sources placed under CVS control.
36 * Revision 1.1 1997/07/21 13:47:48 mdw
48 /*----- Required headers --------------------------------------------------*/
54 /*----- Useful constants --------------------------------------------------*/
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 */
60 /*----- Type definitions --------------------------------------------------*/
62 typedef struct idea_key
{
63 int k
[IDEA_EXPKEYSIZE
]; /* Subkey array */
66 /*----- Functions provided ------------------------------------------------*/
68 /* --- @idea_ekeys@ --- *
70 * Arguments: @idea_key *k@ = the expanded key buffer
71 * @const unsigned char *key@ = the user's key encryption key
75 * Use: Unpacks an encryption key.
78 extern void idea_ekeys(idea_key */
*k*/
, const unsigned char */
*key*/
);
80 /* --- @idea_invertKey@ --- *
82 * Arguments: @const idea_key *in@ = pointer to input expanded key buffer
83 * @idea_key *out@ = pointer to output expanded key buffer
87 * Use: Computes the inverse (decryption) key given an expanded
88 * IDEA encryption key.
91 extern void idea_invertKey(const idea_key */
*in*/
, idea_key */
*out*/
);
93 /* --- @idea_dkeys@ --- *
95 * Arguments: @idea_key *k@ = the expanded key buffer
96 * @const unsigned char *key@ = the user's key encryption key
100 * Use: Unpacks a decryption key.
103 extern void idea_dkeys(idea_key */
*k*/
, const unsigned char */
*key*/
);
105 /* --- @idea_encrypt@ --- *
107 * Arguments: @const idea_key *k@ = key to use
108 * @const void *src@ = block to encrypt
109 * @void *dest@ = where to store the result
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.
120 extern void idea_encrypt(const idea_key */
*k*/
,
121 const void */
*src*/
, void */
*dest*/
);
123 /*----- That's all, folks -------------------------------------------------*/