79ca601bb0ebafcf1df0ef78968b8ac37dc7f309
3 * $Id: idea.h,v 1.1 1997/07/21 13:47:48 mdw Exp $
5 * IDEA encryption routines
6 * Based on Straylight ARM assembler routines
8 * (c) 1996, 1997 Mark Wooding
11 /*----- Licencing 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
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 /*----- Revision history --------------------------------------------------*
33 * Revision 1.1 1997/07/21 13:47:48 mdw
45 /*----- Required headers --------------------------------------------------*/
51 /*----- Useful constants --------------------------------------------------*/
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 */
57 /*----- Type definitions --------------------------------------------------*/
59 typedef struct idea_key
{
60 int k
[IDEA_EXPKEYSIZE
]; /* Subkey array */
63 /*----- Functions provided ------------------------------------------------*/
65 /* --- @idea_ekeys@ --- *
67 * Arguments: @idea_key *k@ = the expanded key buffer
68 * @const unsigned char *key@ = the user's key encryption key
72 * Use: Unpacks an encryption key.
75 extern void idea_ekeys(idea_key */
*k*/
, const unsigned char */
*key*/
);
77 /* --- @idea_invertKey@ --- *
79 * Arguments: @const idea_key *in@ = pointer to input expanded key buffer
80 * @idea_key *out@ = pointer to output expanded key buffer
84 * Use: Computes the inverse (decryption) key given an expanded
85 * IDEA encryption key.
88 extern void idea_invertKey(const idea_key */
*in*/
, idea_key */
*out*/
);
90 /* --- @idea_dkeys@ --- *
92 * Arguments: @idea_key *k@ = the expanded key buffer
93 * @const unsigned char *key@ = the user's key encryption key
97 * Use: Unpacks a decryption key.
100 extern void idea_dkeys(idea_key */
*k*/
, const unsigned char */
*key*/
);
102 /* --- @idea_encrypt@ --- *
104 * Arguments: @const idea_key *k@ = key to use
105 * @const void *src@ = block to encrypt
106 * @void *dest@ = where to store the result
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.
117 extern void idea_encrypt(const idea_key */
*k*/
,
118 const void */
*src*/
, void */
*dest*/
);
120 /*----- That's all, folks -------------------------------------------------*/