meanwhile
1.1.0
Main Page
Related Pages
Data Structures
Files
File List
Globals
src
mw_cipher.h
Go to the documentation of this file.
1
2
/*
3
Meanwhile - Unofficial Lotus Sametime Community Client Library
4
Copyright (C) 2004 Christopher (siege) O'Brien
5
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Library General Public
8
License as published by the Free Software Foundation; either
9
version 2 of the License, or (at your option) any later version.
10
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
15
16
You should have received a copy of the GNU Library General Public
17
License along with this library; if not, write to the Free
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
*/
20
21
#ifndef _MW_CIPHER_H
22
#define _MW_CIPHER_H
23
24
25
#include <glib.h>
26
#include "
mw_common.h
"
27
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
32
33
34
/* place-holders */
35
struct
mwChannel
;
36
struct
mwSession
;
37
38
41
enum
mwCipherType
{
42
mwCipher_RC2_40
= 0x0000,
43
mwCipher_RC2_128
= 0x0001,
44
};
45
46
47
struct
mwCipher
;
48
struct
mwCipherInstance
;
49
50
53
typedef
struct
mwCipherInstance
*(*mwCipherInstantiator)
54
(
struct
mwCipher
*cipher,
struct
mwChannel
*chan);
55
56
61
typedef
int (*
mwCipherProcessor
)
62
(
struct
mwCipherInstance
*ci,
struct
mwOpaque
*
data
);
63
64
70
struct
mwCipher
{
71
74
struct
mwSession
*
session
;
75
76
guint16
type
;
77
const
char
*(*get_name)(void);
78
const
char
*(*get_desc)(void);
82
mwCipherInstantiator
new_instance
;
83
84
void (*
offered
)(
struct
mwCipherInstance
*ci,
struct
mwEncryptItem
*item);
85
struct
mwEncryptItem
*(*offer)(
struct
mwCipherInstance
*ci);
86
void (*
accepted
)(
struct
mwCipherInstance
*ci,
struct
mwEncryptItem
*item);
87
struct
mwEncryptItem
*(*accept)(
struct
mwCipherInstance
*ci);
88
89
mwCipherProcessor
encrypt
;
90
mwCipherProcessor
decrypt
;
94
void (*
clear
)(
struct
mwCipher
*c);
95
98
void (*
clear_instance
)(
struct
mwCipherInstance
*ci);
99
};
100
101
105
struct
mwCipherInstance
{
106
109
struct
mwCipher
*
cipher
;
110
113
struct
mwChannel
*
channel
;
114
};
115
116
117
struct
mwCipher
*
mwCipher_new_RC2_40
(
struct
mwSession
*s);
118
119
120
struct
mwCipher
*
mwCipher_new_RC2_128
(
struct
mwSession
*s);
121
122
123
struct
mwSession
*
mwCipher_getSession
(
struct
mwCipher
*cipher);
124
125
126
guint16
mwCipher_getType
(
struct
mwCipher
*cipher);
127
128
129
const
char
*
mwCipher_getName
(
struct
mwCipher
*cipher);
130
131
132
const
char
*
mwCipher_getDesc
(
struct
mwCipher
*cipher);
133
134
135
struct
mwCipherInstance
*
mwCipher_newInstance
(
struct
mwCipher
*cipher,
136
struct
mwChannel
*
channel
);
137
138
140
void
mwCipher_free
(
struct
mwCipher
* cipher);
141
142
144
struct
mwCipher
*
mwCipherInstance_getCipher
(
struct
mwCipherInstance
*ci);
145
146
148
struct
mwChannel
*
mwCipherInstance_getChannel
(
struct
mwCipherInstance
*ci);
149
150
152
void
mwCipherInstance_offered
(
struct
mwCipherInstance
*ci,
153
struct
mwEncryptItem
*item);
154
155
157
struct
mwEncryptItem
*
158
mwCipherInstance_offer
(
struct
mwCipherInstance
*ci);
159
160
162
void
mwCipherInstance_accepted
(
struct
mwCipherInstance
*ci,
163
struct
mwEncryptItem
*item);
164
165
167
struct
mwEncryptItem
*
168
mwCipherInstance_accept
(
struct
mwCipherInstance
*ci);
169
170
172
int
mwCipherInstance_encrypt
(
struct
mwCipherInstance
*ci,
173
struct
mwOpaque
*data);
174
175
177
int
mwCipherInstance_decrypt
(
struct
mwCipherInstance
*ci,
178
struct
mwOpaque
*data);
179
180
182
void
mwCipherInstance_free
(
struct
mwCipherInstance
*ci);
183
184
191
/* @{ */
192
193
198
void
mwKeyRandom
(guchar *key, gsize keylen);
199
200
202
void
mwIV_init
(guchar *iv);
203
204
207
void
mwKeyExpand
(
int
*ekey,
const
guchar *key, gsize keylen);
208
209
211
void
mwEncryptExpanded
(
const
int
*ekey, guchar *iv,
212
struct
mwOpaque
*in,
213
struct
mwOpaque
*out);
214
215
217
void
mwEncrypt
(
const
guchar *key, gsize keylen, guchar *iv,
218
struct
mwOpaque
*in,
struct
mwOpaque
*out);
219
220
222
void
mwDecryptExpanded
(
const
int
*ekey, guchar *iv,
223
struct
mwOpaque
*in,
224
struct
mwOpaque
*out);
225
226
228
void
mwDecrypt
(
const
guchar *key, gsize keylen, guchar *iv,
229
struct
mwOpaque
*in,
struct
mwOpaque
*out);
230
231
232
/* @} */
233
234
247
/* @{ */
248
249
251
struct
mwMpi
;
252
253
255
struct
mwMpi
*
mwMpi_new
(
void
);
256
257
259
void
mwMpi_free
(
struct
mwMpi
*i);
260
261
263
void
mwMpi_import
(
struct
mwMpi
*i,
struct
mwOpaque
*o);
264
265
267
void
mwMpi_export
(
struct
mwMpi
*i,
struct
mwOpaque
*o);
268
269
271
void
mwMpi_setDHPrime
(
struct
mwMpi
*i);
272
273
275
void
mwMpi_setDHBase
(
struct
mwMpi
*i);
276
277
280
void
mwMpi_randDHKeypair
(
struct
mwMpi
*private_key,
struct
mwMpi
*public_key);
281
282
285
void
mwMpi_calculateDHShared
(
struct
mwMpi
*shared_key,
struct
mwMpi
*remote_key,
286
struct
mwMpi
*private_key);
287
288
289
/* @} */
290
291
292
#ifdef __cplusplus
293
}
294
#endif
295
296
297
#endif
/* _MW_CIPHER_H */
Generated by
1.8.3.1