c4f2d992 |
1 | /* -*-c-*- |
2 | * |
03f996bd |
3 | * $Id: icrypt.h,v 1.2 1997/08/04 10:24:22 mdw Exp $ |
c4f2d992 |
4 | * |
5 | * Higher level IDEA encryption |
6 | * |
7 | * (c) 1997 Mark Wooding |
8 | */ |
9 | |
03f996bd |
10 | /*----- Licensing notice --------------------------------------------------* |
c4f2d992 |
11 | * |
12 | * This file is part of `become' |
13 | * |
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. |
18 | * |
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. |
23 | * |
24 | * You should have received a copy of the GNU General Public License |
03f996bd |
25 | * along with `become'; if not, write to the Free Software Foundation, |
26 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
c4f2d992 |
27 | */ |
28 | |
29 | /*----- Revision history --------------------------------------------------* |
30 | * |
31 | * $Log: icrypt.h,v $ |
03f996bd |
32 | * Revision 1.2 1997/08/04 10:24:22 mdw |
33 | * Sources placed under CVS control. |
34 | * |
35 | * Revision 1.1 1997/07/21 13:47:49 mdw |
c4f2d992 |
36 | * Initial revision |
37 | * |
38 | */ |
39 | |
40 | #ifndef ICRYPT_H |
41 | #define ICRYPT_H |
42 | |
43 | #ifdef __cplusplus |
44 | extern "C" { |
45 | #endif |
46 | |
47 | /*----- Required headers --------------------------------------------------*/ |
48 | |
49 | #include <stddef.h> |
50 | |
51 | #ifndef CONFIG_H |
52 | # include "config.h" |
53 | #endif |
54 | |
55 | #ifndef IDEA_H |
56 | # include "idea.h" |
57 | #endif |
58 | |
59 | /*----- Type definitions --------------------------------------------------*/ |
60 | |
61 | /* --- @icrypt_job@ --- */ |
62 | |
63 | typedef struct icrypt_job { |
64 | idea_key k; /* IDEA key for en/decrypting */ |
65 | int i; /* Index into the IV buffer */ |
66 | char iv[IDEA_BLKSIZE]; /* IV bytes for encrypting */ |
67 | } icrypt_job; |
68 | |
69 | /*----- Functions provided ------------------------------------------------*/ |
70 | |
71 | /* --- @icrypt_init@ --- * |
72 | * |
73 | * Arguments: @icrypt_job *j@ = pointer to job context block |
74 | * @unsigned char *k@ = pointer to key data |
75 | * @const unsigned char *iv@ = pointer to IV |
76 | * |
77 | * Returns: --- |
78 | * |
79 | * Use: Primes the context block ready for encryption. |
80 | */ |
81 | |
82 | extern void icrypt_init(icrypt_job */*j*/, |
83 | unsigned char */*k*/, |
84 | const unsigned char */*iv*/); |
85 | |
86 | /* --- @icrypt_encrypt@ --- * |
87 | * |
88 | * Arguments: @icrypt_job *j@ = job handle |
89 | * @const void *src@ = pointer to source buffer |
90 | * @void *dest@ = pointer to destination buffer |
91 | * @size_t sz@ = size of buffers to handle |
92 | * |
93 | * Returns: --- |
94 | * |
95 | * Use: Encrypts data from the source to the destination, using the |
96 | * key attached to the job handle. |
97 | */ |
98 | |
99 | extern void icrypt_encrypt(icrypt_job */*j*/, const void */*src*/, |
100 | void */*dest*/, size_t /*sz*/); |
101 | |
102 | /* --- @icrypt_decrypt@ --- * |
103 | * |
104 | * Arguments: @icrypt_job *j@ = job handle |
105 | * @const void *src@ = pointer to source buffer |
106 | * @void *dest@ = pointer to destination buffer |
107 | * @size_t sz@ = size of buffers to handle |
108 | * |
109 | * Returns: --- |
110 | * |
111 | * Use: Decrypts data from the source to the destination, using |
112 | * the key attached to the job handle. |
113 | */ |
114 | |
115 | extern void icrypt_decrypt(icrypt_job */*j*/, const void */*src*/, |
116 | void */*dest*/, size_t /*sz*/); |
117 | |
118 | /* --- @icrypt_reset@ --- * |
119 | * |
120 | * Arguments: @icrypt_job *j@ = pointer to job context block |
121 | * @unsigned char *k@ = pointer to key data, or zero for |
122 | * no change |
123 | * @const unsigned char *iv@ = pointer to IV, or zero |
124 | * |
125 | * Returns: --- |
126 | * |
127 | * Use: Alters the context block. This can be used after recovery |
128 | * of a session key, for example. |
129 | */ |
130 | |
131 | extern void icrypt_reset(icrypt_job */*j*/, |
132 | unsigned char */*k*/, |
133 | const unsigned char */*iv*/); |
134 | |
135 | /* --- @icrypt_saveIV@ --- * |
136 | * |
137 | * Arguments: @icrypt_job *j@ = pointer to job context block |
138 | * @unsigned char *iv@ = where to store the IV |
139 | * |
140 | * Returns: --- |
141 | * |
142 | * Use: Writes out the job's IV after munging it a little. |
143 | */ |
144 | |
145 | extern void icrypt_saveIV(icrypt_job */*j*/, unsigned char */*iv*/); |
146 | |
147 | /*----- That's all, folks -------------------------------------------------*/ |
148 | |
149 | #ifdef __cplusplus |
150 | } |
151 | #endif |
152 | |
153 | #endif |