comparison src/headers/tomcrypt_cipher.h @ 191:1c15b283127b libtomcrypt-orig

Import of libtomcrypt 1.02 with manual path rename rearrangement etc
author Matt Johnston <matt@ucc.asn.au>
date Fri, 06 May 2005 13:23:02 +0000
parents
children 39d5d58461d6
comparison
equal deleted inserted replaced
143:5d99163f7e32 191:1c15b283127b
1 /* ---- SYMMETRIC KEY STUFF -----
2 *
3 * We put each of the ciphers scheduled keys in their own structs then we put all of
4 * the key formats in one union. This makes the function prototypes easier to use.
5 */
6 #ifdef BLOWFISH
7 struct blowfish_key {
8 ulong32 S[4][256];
9 ulong32 K[18];
10 };
11 #endif
12
13 #ifdef RC5
14 struct rc5_key {
15 int rounds;
16 ulong32 K[50];
17 };
18 #endif
19
20 #ifdef RC6
21 struct rc6_key {
22 ulong32 K[44];
23 };
24 #endif
25
26 #ifdef SAFERP
27 struct saferp_key {
28 unsigned char K[33][16];
29 long rounds;
30 };
31 #endif
32
33 #ifdef RIJNDAEL
34 struct rijndael_key {
35 ulong32 eK[64], dK[64];
36 int Nr;
37 };
38 #endif
39
40 #ifdef XTEA
41 struct xtea_key {
42 unsigned long A[32], B[32];
43 };
44 #endif
45
46 #ifdef TWOFISH
47 #ifndef TWOFISH_SMALL
48 struct twofish_key {
49 ulong32 S[4][256], K[40];
50 };
51 #else
52 struct twofish_key {
53 ulong32 K[40];
54 unsigned char S[32], start;
55 };
56 #endif
57 #endif
58
59 #ifdef SAFER
60 #define SAFER_K64_DEFAULT_NOF_ROUNDS 6
61 #define SAFER_K128_DEFAULT_NOF_ROUNDS 10
62 #define SAFER_SK64_DEFAULT_NOF_ROUNDS 8
63 #define SAFER_SK128_DEFAULT_NOF_ROUNDS 10
64 #define SAFER_MAX_NOF_ROUNDS 13
65 #define SAFER_BLOCK_LEN 8
66 #define SAFER_KEY_LEN (1 + SAFER_BLOCK_LEN * (1 + 2 * SAFER_MAX_NOF_ROUNDS))
67 typedef unsigned char safer_block_t[SAFER_BLOCK_LEN];
68 typedef unsigned char safer_key_t[SAFER_KEY_LEN];
69 struct safer_key { safer_key_t key; };
70 #endif
71
72 #ifdef RC2
73 struct rc2_key { unsigned xkey[64]; };
74 #endif
75
76 #ifdef DES
77 struct des_key {
78 ulong32 ek[32], dk[32];
79 };
80
81 struct des3_key {
82 ulong32 ek[3][32], dk[3][32];
83 };
84 #endif
85
86 #ifdef CAST5
87 struct cast5_key {
88 ulong32 K[32], keylen;
89 };
90 #endif
91
92 #ifdef NOEKEON
93 struct noekeon_key {
94 ulong32 K[4], dK[4];
95 };
96 #endif
97
98 #ifdef SKIPJACK
99 struct skipjack_key {
100 unsigned char key[10];
101 };
102 #endif
103
104 #ifdef KHAZAD
105 struct khazad_key {
106 ulong64 roundKeyEnc[8 + 1];
107 ulong64 roundKeyDec[8 + 1];
108 };
109 #endif
110
111 #ifdef ANUBIS
112 struct anubis_key {
113 int keyBits;
114 int R;
115 ulong32 roundKeyEnc[18 + 1][4];
116 ulong32 roundKeyDec[18 + 1][4];
117 };
118 #endif
119
120 typedef union Symmetric_key {
121 #ifdef DES
122 struct des_key des;
123 struct des3_key des3;
124 #endif
125 #ifdef RC2
126 struct rc2_key rc2;
127 #endif
128 #ifdef SAFER
129 struct safer_key safer;
130 #endif
131 #ifdef TWOFISH
132 struct twofish_key twofish;
133 #endif
134 #ifdef BLOWFISH
135 struct blowfish_key blowfish;
136 #endif
137 #ifdef RC5
138 struct rc5_key rc5;
139 #endif
140 #ifdef RC6
141 struct rc6_key rc6;
142 #endif
143 #ifdef SAFERP
144 struct saferp_key saferp;
145 #endif
146 #ifdef RIJNDAEL
147 struct rijndael_key rijndael;
148 #endif
149 #ifdef XTEA
150 struct xtea_key xtea;
151 #endif
152 #ifdef CAST5
153 struct cast5_key cast5;
154 #endif
155 #ifdef NOEKEON
156 struct noekeon_key noekeon;
157 #endif
158 #ifdef SKIPJACK
159 struct skipjack_key skipjack;
160 #endif
161 #ifdef KHAZAD
162 struct khazad_key khazad;
163 #endif
164 #ifdef ANUBIS
165 struct anubis_key anubis;
166 #endif
167 void *data;
168 } symmetric_key;
169
170 /* A block cipher ECB structure */
171 typedef struct {
172 /** The index of the cipher chosen */
173 int cipher,
174 /** The block size of the given cipher */
175 blocklen;
176 /** The scheduled key */
177 symmetric_key key;
178 } symmetric_ECB;
179
180 /* A block cipher CFB structure */
181 typedef struct {
182 /** The index of the cipher chosen */
183 int cipher,
184 /** The block size of the given cipher */
185 blocklen,
186 /** The padding offset */
187 padlen;
188 /** The current IV */
189 unsigned char IV[MAXBLOCKSIZE],
190 /** The pad used to encrypt/decrypt */
191 pad[MAXBLOCKSIZE];
192 /** The scheduled key */
193 symmetric_key key;
194 } symmetric_CFB;
195
196 /* A block cipher OFB structure */
197 typedef struct {
198 /** The index of the cipher chosen */
199 int cipher,
200 /** The block size of the given cipher */
201 blocklen,
202 /** The padding offset */
203 padlen;
204 /** The current IV */
205 unsigned char IV[MAXBLOCKSIZE];
206 /** The scheduled key */
207 symmetric_key key;
208 } symmetric_OFB;
209
210 /* A block cipher CBC structure */
211 typedef struct {
212 /** The index of the cipher chosen */
213 int cipher,
214 /** The block size of the given cipher */
215 blocklen;
216 /** The current IV */
217 unsigned char IV[MAXBLOCKSIZE];
218 /** The scheduled key */
219 symmetric_key key;
220 } symmetric_CBC;
221
222 /* A block cipher CTR structure */
223 typedef struct {
224 /** The index of the cipher chosen */
225 int cipher,
226 /** The block size of the given cipher */
227 blocklen,
228 /** The padding offset */
229 padlen,
230 /** The mode (endianess) of the CTR, 0==little, 1==big */
231 mode;
232 /** The counter */
233 unsigned char ctr[MAXBLOCKSIZE],
234 /** The pad used to encrypt/decrypt */
235 pad[MAXBLOCKSIZE];
236 /** The scheduled key */
237 symmetric_key key;
238 } symmetric_CTR;
239
240 /* cipher descriptor table, last entry has "name == NULL" to mark the end of table */
241 extern struct ltc_cipher_descriptor {
242 /** name of cipher */
243 char *name;
244 /** internal ID */
245 unsigned char ID;
246 /** min keysize (octets) */
247 int min_key_length,
248 /** max keysize (octets) */
249 max_key_length,
250 /** block size (octets) */
251 block_length,
252 /** default number of rounds */
253 default_rounds;
254 /** Setup the cipher
255 @param key The input symmetric key
256 @param keylen The length of the input key (octets)
257 @param num_rounds The requested number of rounds (0==default)
258 @param skey [out] The destination of the scheduled key
259 @return CRYPT_OK if successful
260 */
261 int (*setup)(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
262 /** Encrypt a block
263 @param pt The plaintext
264 @param ct [out] The ciphertext
265 @param skey The scheduled key
266 */
267 void (*ecb_encrypt)(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
268 /** Decrypt a block
269 @param ct The ciphertext
270 @param pt [out] The plaintext
271 @param skey The scheduled key
272 */
273 void (*ecb_decrypt)(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
274 /** Test the block cipher
275 @return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled
276 */
277 int (*test)(void);
278
279 /** Terminate the context
280 @param skey The scheduled key
281 */
282 void (*done)(symmetric_key *skey);
283
284 /** Determine a key size
285 @param keysize [in/out] The size of the key desired and the suggested size
286 @return CRYPT_OK if successful
287 */
288 int (*keysize)(int *keysize);
289
290 /** Accelerators **/
291 /** Accelerated ECB encryption
292 @param pt Plaintext
293 @param ct Ciphertext
294 @param blocks The number of complete blocks to process
295 @param skey The scheduled key context
296 */
297 void (*accel_ecb_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, symmetric_key *skey);
298
299 /** Accelerated ECB decryption
300 @param pt Plaintext
301 @param ct Ciphertext
302 @param blocks The number of complete blocks to process
303 @param skey The scheduled key context
304 */
305 void (*accel_ecb_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, symmetric_key *skey);
306
307 /** Accelerated CBC encryption
308 @param pt Plaintext
309 @param ct Ciphertext
310 @param blocks The number of complete blocks to process
311 @param IV The initial value (input/output)
312 @param skey The scheduled key context
313 */
314 void (*accel_cbc_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, symmetric_key *skey);
315
316 /** Accelerated CBC decryption
317 @param pt Plaintext
318 @param ct Ciphertext
319 @param blocks The number of complete blocks to process
320 @param IV The initial value (input/output)
321 @param skey The scheduled key context
322 */
323 void (*accel_cbc_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, symmetric_key *skey);
324
325 /** Accelerated CTR encryption
326 @param pt Plaintext
327 @param ct Ciphertext
328 @param blocks The number of complete blocks to process
329 @param IV The initial value (input/output)
330 @param mode little or big endian counter (mode=0 or mode=1)
331 @param skey The scheduled key context
332 */
333 void (*accel_ctr_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, int mode, symmetric_key *skey);
334
335 /** Accelerated CCM packet (one-shot)
336 @param key The secret key to use
337 @param keylen The length of the secret key (octets)
338 @param nonce The session nonce [use once]
339 @param noncelen The length of the nonce
340 @param header The header for the session
341 @param headerlen The length of the header (octets)
342 @param pt [out] The plaintext
343 @param ptlen The length of the plaintext (octets)
344 @param ct [out] The ciphertext
345 @param tag [out] The destination tag
346 @param taglen [in/out] The max size and resulting size of the authentication tag
347 @param direction Encrypt or Decrypt direction (0 or 1)
348 @return CRYPT_OK if successful
349 */
350 void (*accel_ccm_memory)(
351 const unsigned char *key, unsigned long keylen,
352 const unsigned char *nonce, unsigned long noncelen,
353 const unsigned char *header, unsigned long headerlen,
354 unsigned char *pt, unsigned long ptlen,
355 unsigned char *ct,
356 unsigned char *tag, unsigned long *taglen,
357 int direction);
358
359 /** Accelerated GCM packet (one shot)
360 @param key The secret key
361 @param keylen The length of the secret key
362 @param IV The initial vector
363 @param IVlen The length of the initial vector
364 @param adata The additional authentication data (header)
365 @param adatalen The length of the adata
366 @param pt The plaintext
367 @param ptlen The length of the plaintext (ciphertext length is the same)
368 @param ct The ciphertext
369 @param tag [out] The MAC tag
370 @param taglen [in/out] The MAC tag length
371 @param direction Encrypt or Decrypt mode (GCM_ENCRYPT or GCM_DECRYPT)
372 */
373 void (*accel_gcm_memory)(
374 const unsigned char *key, unsigned long keylen,
375 const unsigned char *IV, unsigned long IVlen,
376 const unsigned char *adata, unsigned long adatalen,
377 unsigned char *pt, unsigned long ptlen,
378 unsigned char *ct,
379 unsigned char *tag, unsigned long *taglen,
380 int direction);
381 } cipher_descriptor[];
382
383 #ifdef BLOWFISH
384 int blowfish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
385 void blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
386 void blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
387 int blowfish_test(void);
388 void blowfish_done(symmetric_key *skey);
389 int blowfish_keysize(int *keysize);
390 extern const struct ltc_cipher_descriptor blowfish_desc;
391 #endif
392
393 #ifdef RC5
394 int rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
395 void rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
396 void rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
397 int rc5_test(void);
398 void rc5_done(symmetric_key *skey);
399 int rc5_keysize(int *keysize);
400 extern const struct ltc_cipher_descriptor rc5_desc;
401 #endif
402
403 #ifdef RC6
404 int rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
405 void rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
406 void rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
407 int rc6_test(void);
408 void rc6_done(symmetric_key *skey);
409 int rc6_keysize(int *keysize);
410 extern const struct ltc_cipher_descriptor rc6_desc;
411 #endif
412
413 #ifdef RC2
414 int rc2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
415 void rc2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
416 void rc2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
417 int rc2_test(void);
418 void rc2_done(symmetric_key *skey);
419 int rc2_keysize(int *keysize);
420 extern const struct ltc_cipher_descriptor rc2_desc;
421 #endif
422
423 #ifdef SAFERP
424 int saferp_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
425 void saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
426 void saferp_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
427 int saferp_test(void);
428 void saferp_done(symmetric_key *skey);
429 int saferp_keysize(int *keysize);
430 extern const struct ltc_cipher_descriptor saferp_desc;
431 #endif
432
433 #ifdef SAFER
434 int safer_k64_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
435 int safer_sk64_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
436 int safer_k128_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
437 int safer_sk128_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
438 void safer_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *key);
439 void safer_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *key);
440 int safer_k64_test(void);
441 int safer_sk64_test(void);
442 int safer_sk128_test(void);
443 void safer_done(symmetric_key *skey);
444 int safer_64_keysize(int *keysize);
445 int safer_128_keysize(int *keysize);
446 extern const struct ltc_cipher_descriptor safer_k64_desc, safer_k128_desc, safer_sk64_desc, safer_sk128_desc;
447 #endif
448
449 #ifdef RIJNDAEL
450
451 /* make aes an alias */
452 #define aes_setup rijndael_setup
453 #define aes_ecb_encrypt rijndael_ecb_encrypt
454 #define aes_ecb_decrypt rijndael_ecb_decrypt
455 #define aes_test rijndael_test
456 #define aes_done rijndael_done
457 #define aes_keysize rijndael_keysize
458
459 #define aes_enc_setup rijndael_enc_setup
460 #define aes_enc_ecb_encrypt rijndael_enc_ecb_encrypt
461 #define aes_enc_keysize rijndael_enc_keysize
462
463 int rijndael_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
464 void rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
465 void rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
466 int rijndael_test(void);
467 void rijndael_done(symmetric_key *skey);
468 int rijndael_keysize(int *keysize);
469 int rijndael_enc_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
470 void rijndael_enc_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
471 void rijndael_enc_done(symmetric_key *skey);
472 int rijndael_enc_keysize(int *keysize);
473 extern const struct ltc_cipher_descriptor rijndael_desc, aes_desc;
474 extern const struct ltc_cipher_descriptor rijndael_enc_desc, aes_enc_desc;
475 #endif
476
477 #ifdef XTEA
478 int xtea_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
479 void xtea_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
480 void xtea_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
481 int xtea_test(void);
482 void xtea_done(symmetric_key *skey);
483 int xtea_keysize(int *keysize);
484 extern const struct ltc_cipher_descriptor xtea_desc;
485 #endif
486
487 #ifdef TWOFISH
488 int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
489 void twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
490 void twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
491 int twofish_test(void);
492 void twofish_done(symmetric_key *skey);
493 int twofish_keysize(int *keysize);
494 extern const struct ltc_cipher_descriptor twofish_desc;
495 #endif
496
497 #ifdef DES
498 int des_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
499 void des_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
500 void des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
501 int des_test(void);
502 void des_done(symmetric_key *skey);
503 int des_keysize(int *keysize);
504 int des3_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
505 void des3_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
506 void des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
507 int des3_test(void);
508 void des3_done(symmetric_key *skey);
509 int des3_keysize(int *keysize);
510 extern const struct ltc_cipher_descriptor des_desc, des3_desc;
511 #endif
512
513 #ifdef CAST5
514 int cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
515 void cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
516 void cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
517 int cast5_test(void);
518 void cast5_done(symmetric_key *skey);
519 int cast5_keysize(int *keysize);
520 extern const struct ltc_cipher_descriptor cast5_desc;
521 #endif
522
523 #ifdef NOEKEON
524 int noekeon_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
525 void noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
526 void noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
527 int noekeon_test(void);
528 void noekeon_done(symmetric_key *skey);
529 int noekeon_keysize(int *keysize);
530 extern const struct ltc_cipher_descriptor noekeon_desc;
531 #endif
532
533 #ifdef SKIPJACK
534 int skipjack_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
535 void skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
536 void skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
537 int skipjack_test(void);
538 void skipjack_done(symmetric_key *skey);
539 int skipjack_keysize(int *keysize);
540 extern const struct ltc_cipher_descriptor skipjack_desc;
541 #endif
542
543 #ifdef KHAZAD
544 int khazad_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
545 void khazad_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
546 void khazad_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
547 int khazad_test(void);
548 void khazad_done(symmetric_key *skey);
549 int khazad_keysize(int *keysize);
550 extern const struct ltc_cipher_descriptor khazad_desc;
551 #endif
552
553 #ifdef ANUBIS
554 int anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
555 void anubis_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
556 void anubis_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
557 int anubis_test(void);
558 void anubis_done(symmetric_key *skey);
559 int anubis_keysize(int *keysize);
560 extern const struct ltc_cipher_descriptor anubis_desc;
561 #endif
562
563 #ifdef ECB
564 int ecb_start(int cipher, const unsigned char *key,
565 int keylen, int num_rounds, symmetric_ECB *ecb);
566 int ecb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_ECB *ecb);
567 int ecb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_ECB *ecb);
568 int ecb_done(symmetric_ECB *ecb);
569 #endif
570
571 #ifdef CFB
572 int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key,
573 int keylen, int num_rounds, symmetric_CFB *cfb);
574 int cfb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CFB *cfb);
575 int cfb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CFB *cfb);
576 int cfb_getiv(unsigned char *IV, unsigned long *len, symmetric_CFB *cfb);
577 int cfb_setiv(const unsigned char *IV, unsigned long len, symmetric_CFB *cfb);
578 int cfb_done(symmetric_CFB *cfb);
579 #endif
580
581 #ifdef OFB
582 int ofb_start(int cipher, const unsigned char *IV, const unsigned char *key,
583 int keylen, int num_rounds, symmetric_OFB *ofb);
584 int ofb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_OFB *ofb);
585 int ofb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_OFB *ofb);
586 int ofb_getiv(unsigned char *IV, unsigned long *len, symmetric_OFB *ofb);
587 int ofb_setiv(const unsigned char *IV, unsigned long len, symmetric_OFB *ofb);
588 int ofb_done(symmetric_OFB *ofb);
589 #endif
590
591 #ifdef CBC
592 int cbc_start(int cipher, const unsigned char *IV, const unsigned char *key,
593 int keylen, int num_rounds, symmetric_CBC *cbc);
594 int cbc_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CBC *cbc);
595 int cbc_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CBC *cbc);
596 int cbc_getiv(unsigned char *IV, unsigned long *len, symmetric_CBC *cbc);
597 int cbc_setiv(const unsigned char *IV, unsigned long len, symmetric_CBC *cbc);
598 int cbc_done(symmetric_CBC *cbc);
599 #endif
600
601 #ifdef CTR
602 int ctr_start(int cipher, const unsigned char *IV, const unsigned char *key,
603 int keylen, int num_rounds, symmetric_CTR *ctr);
604 int ctr_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CTR *ctr);
605 int ctr_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CTR *ctr);
606 int ctr_getiv(unsigned char *IV, unsigned long *len, symmetric_CTR *ctr);
607 int ctr_setiv(const unsigned char *IV, unsigned long len, symmetric_CTR *ctr);
608 int ctr_done(symmetric_CTR *ctr);
609 #endif
610
611 int find_cipher(const char *name);
612 int find_cipher_any(const char *name, int blocklen, int keylen);
613 int find_cipher_id(unsigned char ID);
614
615 int register_cipher(const struct ltc_cipher_descriptor *cipher);
616 int unregister_cipher(const struct ltc_cipher_descriptor *cipher);
617
618 int cipher_is_valid(int idx);
619