3 * $Id: icrypt.h,v 1.1 1997/07/21 13:47:49 mdw Exp $
5 * Higher level IDEA encryption
7 * (c) 1997 Mark Wooding
10 /*----- Licencing notice --------------------------------------------------*
12 * This file is part of `become'
14 * `Become' is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * `Become' is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with `become'; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.1 1997/07/21 13:47:49 mdw
44 /*----- Required headers --------------------------------------------------*/
56 /*----- Type definitions --------------------------------------------------*/
58 /* --- @icrypt_job@ --- */
60 typedef struct icrypt_job
{
61 idea_key k
; /* IDEA key for en/decrypting */
62 int i
; /* Index into the IV buffer */
63 char iv
[IDEA_BLKSIZE
]; /* IV bytes for encrypting */
66 /*----- Functions provided ------------------------------------------------*/
68 /* --- @icrypt_init@ --- *
70 * Arguments: @icrypt_job *j@ = pointer to job context block
71 * @unsigned char *k@ = pointer to key data
72 * @const unsigned char *iv@ = pointer to IV
76 * Use: Primes the context block ready for encryption.
79 extern void icrypt_init(icrypt_job */
*j*/
,
81 const unsigned char */
*iv*/
);
83 /* --- @icrypt_encrypt@ --- *
85 * Arguments: @icrypt_job *j@ = job handle
86 * @const void *src@ = pointer to source buffer
87 * @void *dest@ = pointer to destination buffer
88 * @size_t sz@ = size of buffers to handle
92 * Use: Encrypts data from the source to the destination, using the
93 * key attached to the job handle.
96 extern void icrypt_encrypt(icrypt_job */
*j*/
, const void */
*src*/
,
97 void */
*dest*/
, size_t /*sz*/);
99 /* --- @icrypt_decrypt@ --- *
101 * Arguments: @icrypt_job *j@ = job handle
102 * @const void *src@ = pointer to source buffer
103 * @void *dest@ = pointer to destination buffer
104 * @size_t sz@ = size of buffers to handle
108 * Use: Decrypts data from the source to the destination, using
109 * the key attached to the job handle.
112 extern void icrypt_decrypt(icrypt_job */
*j*/
, const void */
*src*/
,
113 void */
*dest*/
, size_t /*sz*/);
115 /* --- @icrypt_reset@ --- *
117 * Arguments: @icrypt_job *j@ = pointer to job context block
118 * @unsigned char *k@ = pointer to key data, or zero for
120 * @const unsigned char *iv@ = pointer to IV, or zero
124 * Use: Alters the context block. This can be used after recovery
125 * of a session key, for example.
128 extern void icrypt_reset(icrypt_job */
*j*/
,
129 unsigned char */
*k*/
,
130 const unsigned char */
*iv*/
);
132 /* --- @icrypt_saveIV@ --- *
134 * Arguments: @icrypt_job *j@ = pointer to job context block
135 * @unsigned char *iv@ = where to store the IV
139 * Use: Writes out the job's IV after munging it a little.
142 extern void icrypt_saveIV(icrypt_job */
*j*/
, unsigned char */
*iv*/
);
144 /*----- That's all, folks -------------------------------------------------*/