Mercurial > dropbear
comparison src/headers/tomcrypt_cipher.h @ 380:d5faf4814ddb libtomcrypt-orig libtomcrypt-1.16
Update to LibTomCrypt 1.16
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 11 Jan 2007 02:22:00 +0000 |
parents | 59400faa4b44 |
children |
comparison
equal
deleted
inserted
replaced
280:59400faa4b44 | 380:d5faf4814ddb |
---|---|
32 | 32 |
33 #ifdef RIJNDAEL | 33 #ifdef RIJNDAEL |
34 struct rijndael_key { | 34 struct rijndael_key { |
35 ulong32 eK[60], dK[60]; | 35 ulong32 eK[60], dK[60]; |
36 int Nr; | 36 int Nr; |
37 }; | |
38 #endif | |
39 | |
40 #ifdef KSEED | |
41 struct kseed_key { | |
42 ulong32 K[32], dK[32]; | |
43 }; | |
44 #endif | |
45 | |
46 #ifdef LTC_KASUMI | |
47 struct kasumi_key { | |
48 ulong32 KLi1[8], KLi2[8], | |
49 KOi1[8], KOi2[8], KOi3[8], | |
50 KIi1[8], KIi2[8], KIi3[8]; | |
37 }; | 51 }; |
38 #endif | 52 #endif |
39 | 53 |
40 #ifdef XTEA | 54 #ifdef XTEA |
41 struct xtea_key { | 55 struct xtea_key { |
162 struct khazad_key khazad; | 176 struct khazad_key khazad; |
163 #endif | 177 #endif |
164 #ifdef ANUBIS | 178 #ifdef ANUBIS |
165 struct anubis_key anubis; | 179 struct anubis_key anubis; |
166 #endif | 180 #endif |
181 #ifdef KSEED | |
182 struct kseed_key kseed; | |
183 #endif | |
184 #ifdef LTC_KASUMI | |
185 struct kasumi_key kasumi; | |
186 #endif | |
167 void *data; | 187 void *data; |
168 } symmetric_key; | 188 } symmetric_key; |
169 | 189 |
170 /* A block cipher ECB structure */ | 190 #ifdef LTC_ECB_MODE |
191 /** A block cipher ECB structure */ | |
171 typedef struct { | 192 typedef struct { |
172 /** The index of the cipher chosen */ | 193 /** The index of the cipher chosen */ |
173 int cipher, | 194 int cipher, |
174 /** The block size of the given cipher */ | 195 /** The block size of the given cipher */ |
175 blocklen; | 196 blocklen; |
176 /** The scheduled key */ | 197 /** The scheduled key */ |
177 symmetric_key key; | 198 symmetric_key key; |
178 } symmetric_ECB; | 199 } symmetric_ECB; |
179 | 200 #endif |
180 /* A block cipher CFB structure */ | 201 |
202 #ifdef LTC_CFB_MODE | |
203 /** A block cipher CFB structure */ | |
181 typedef struct { | 204 typedef struct { |
182 /** The index of the cipher chosen */ | 205 /** The index of the cipher chosen */ |
183 int cipher, | 206 int cipher, |
184 /** The block size of the given cipher */ | 207 /** The block size of the given cipher */ |
185 blocklen, | 208 blocklen, |
190 /** The pad used to encrypt/decrypt */ | 213 /** The pad used to encrypt/decrypt */ |
191 pad[MAXBLOCKSIZE]; | 214 pad[MAXBLOCKSIZE]; |
192 /** The scheduled key */ | 215 /** The scheduled key */ |
193 symmetric_key key; | 216 symmetric_key key; |
194 } symmetric_CFB; | 217 } symmetric_CFB; |
195 | 218 #endif |
196 /* A block cipher OFB structure */ | 219 |
220 #ifdef LTC_OFB_MODE | |
221 /** A block cipher OFB structure */ | |
197 typedef struct { | 222 typedef struct { |
198 /** The index of the cipher chosen */ | 223 /** The index of the cipher chosen */ |
199 int cipher, | 224 int cipher, |
200 /** The block size of the given cipher */ | 225 /** The block size of the given cipher */ |
201 blocklen, | 226 blocklen, |
204 /** The current IV */ | 229 /** The current IV */ |
205 unsigned char IV[MAXBLOCKSIZE]; | 230 unsigned char IV[MAXBLOCKSIZE]; |
206 /** The scheduled key */ | 231 /** The scheduled key */ |
207 symmetric_key key; | 232 symmetric_key key; |
208 } symmetric_OFB; | 233 } symmetric_OFB; |
209 | 234 #endif |
210 /* A block cipher CBC structure */ | 235 |
236 #ifdef LTC_CBC_MODE | |
237 /** A block cipher CBC structure */ | |
211 typedef struct { | 238 typedef struct { |
212 /** The index of the cipher chosen */ | 239 /** The index of the cipher chosen */ |
213 int cipher, | 240 int cipher, |
214 /** The block size of the given cipher */ | 241 /** The block size of the given cipher */ |
215 blocklen; | 242 blocklen; |
216 /** The current IV */ | 243 /** The current IV */ |
217 unsigned char IV[MAXBLOCKSIZE]; | 244 unsigned char IV[MAXBLOCKSIZE]; |
218 /** The scheduled key */ | 245 /** The scheduled key */ |
219 symmetric_key key; | 246 symmetric_key key; |
220 } symmetric_CBC; | 247 } symmetric_CBC; |
221 | 248 #endif |
222 /* A block cipher CTR structure */ | 249 |
250 | |
251 #ifdef LTC_CTR_MODE | |
252 /** A block cipher CTR structure */ | |
223 typedef struct { | 253 typedef struct { |
224 /** The index of the cipher chosen */ | 254 /** The index of the cipher chosen */ |
225 int cipher, | 255 int cipher, |
226 /** The block size of the given cipher */ | 256 /** The block size of the given cipher */ |
227 blocklen, | 257 blocklen, |
234 /** The pad used to encrypt/decrypt */ | 264 /** The pad used to encrypt/decrypt */ |
235 pad[MAXBLOCKSIZE]; | 265 pad[MAXBLOCKSIZE]; |
236 /** The scheduled key */ | 266 /** The scheduled key */ |
237 symmetric_key key; | 267 symmetric_key key; |
238 } symmetric_CTR; | 268 } symmetric_CTR; |
239 | 269 #endif |
240 /* cipher descriptor table, last entry has "name == NULL" to mark the end of table */ | 270 |
271 | |
272 #ifdef LTC_LRW_MODE | |
273 /** A LRW structure */ | |
274 typedef struct { | |
275 /** The index of the cipher chosen (must be a 128-bit block cipher) */ | |
276 int cipher; | |
277 | |
278 /** The current IV */ | |
279 unsigned char IV[16], | |
280 | |
281 /** the tweak key */ | |
282 tweak[16], | |
283 | |
284 /** The current pad, it's the product of the first 15 bytes against the tweak key */ | |
285 pad[16]; | |
286 | |
287 /** The scheduled symmetric key */ | |
288 symmetric_key key; | |
289 | |
290 #ifdef LRW_TABLES | |
291 /** The pre-computed multiplication table */ | |
292 unsigned char PC[16][256][16]; | |
293 #endif | |
294 } symmetric_LRW; | |
295 #endif | |
296 | |
297 #ifdef LTC_F8_MODE | |
298 /** A block cipher F8 structure */ | |
299 typedef struct { | |
300 /** The index of the cipher chosen */ | |
301 int cipher, | |
302 /** The block size of the given cipher */ | |
303 blocklen, | |
304 /** The padding offset */ | |
305 padlen; | |
306 /** The current IV */ | |
307 unsigned char IV[MAXBLOCKSIZE], | |
308 MIV[MAXBLOCKSIZE]; | |
309 /** Current block count */ | |
310 ulong32 blockcnt; | |
311 /** The scheduled key */ | |
312 symmetric_key key; | |
313 } symmetric_F8; | |
314 #endif | |
315 | |
316 | |
317 /** cipher descriptor table, last entry has "name == NULL" to mark the end of table */ | |
241 extern struct ltc_cipher_descriptor { | 318 extern struct ltc_cipher_descriptor { |
242 /** name of cipher */ | 319 /** name of cipher */ |
243 char *name; | 320 char *name; |
244 /** internal ID */ | 321 /** internal ID */ |
245 unsigned char ID; | 322 unsigned char ID; |
261 int (*setup)(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 338 int (*setup)(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); |
262 /** Encrypt a block | 339 /** Encrypt a block |
263 @param pt The plaintext | 340 @param pt The plaintext |
264 @param ct [out] The ciphertext | 341 @param ct [out] The ciphertext |
265 @param skey The scheduled key | 342 @param skey The scheduled key |
266 */ | 343 @return CRYPT_OK if successful |
267 void (*ecb_encrypt)(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); | 344 */ |
345 int (*ecb_encrypt)(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); | |
268 /** Decrypt a block | 346 /** Decrypt a block |
269 @param ct The ciphertext | 347 @param ct The ciphertext |
270 @param pt [out] The plaintext | 348 @param pt [out] The plaintext |
271 @param skey The scheduled key | 349 @param skey The scheduled key |
272 */ | 350 @return CRYPT_OK if successful |
273 void (*ecb_decrypt)(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); | 351 */ |
352 int (*ecb_decrypt)(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); | |
274 /** Test the block cipher | 353 /** Test the block cipher |
275 @return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled | 354 @return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled |
276 */ | 355 */ |
277 int (*test)(void); | 356 int (*test)(void); |
278 | 357 |
291 /** Accelerated ECB encryption | 370 /** Accelerated ECB encryption |
292 @param pt Plaintext | 371 @param pt Plaintext |
293 @param ct Ciphertext | 372 @param ct Ciphertext |
294 @param blocks The number of complete blocks to process | 373 @param blocks The number of complete blocks to process |
295 @param skey The scheduled key context | 374 @param skey The scheduled key context |
296 */ | 375 @return CRYPT_OK if successful |
297 void (*accel_ecb_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, symmetric_key *skey); | 376 */ |
377 int (*accel_ecb_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, symmetric_key *skey); | |
298 | 378 |
299 /** Accelerated ECB decryption | 379 /** Accelerated ECB decryption |
300 @param pt Plaintext | 380 @param pt Plaintext |
301 @param ct Ciphertext | 381 @param ct Ciphertext |
302 @param blocks The number of complete blocks to process | 382 @param blocks The number of complete blocks to process |
303 @param skey The scheduled key context | 383 @param skey The scheduled key context |
304 */ | 384 @return CRYPT_OK if successful |
305 void (*accel_ecb_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, symmetric_key *skey); | 385 */ |
386 int (*accel_ecb_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, symmetric_key *skey); | |
306 | 387 |
307 /** Accelerated CBC encryption | 388 /** Accelerated CBC encryption |
308 @param pt Plaintext | 389 @param pt Plaintext |
309 @param ct Ciphertext | 390 @param ct Ciphertext |
310 @param blocks The number of complete blocks to process | 391 @param blocks The number of complete blocks to process |
311 @param IV The initial value (input/output) | 392 @param IV The initial value (input/output) |
312 @param skey The scheduled key context | 393 @param skey The scheduled key context |
313 */ | 394 @return CRYPT_OK if successful |
314 void (*accel_cbc_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, symmetric_key *skey); | 395 */ |
396 int (*accel_cbc_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, symmetric_key *skey); | |
315 | 397 |
316 /** Accelerated CBC decryption | 398 /** Accelerated CBC decryption |
317 @param pt Plaintext | 399 @param pt Plaintext |
318 @param ct Ciphertext | 400 @param ct Ciphertext |
319 @param blocks The number of complete blocks to process | 401 @param blocks The number of complete blocks to process |
320 @param IV The initial value (input/output) | 402 @param IV The initial value (input/output) |
321 @param skey The scheduled key context | 403 @param skey The scheduled key context |
322 */ | 404 @return CRYPT_OK if successful |
323 void (*accel_cbc_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, symmetric_key *skey); | 405 */ |
406 int (*accel_cbc_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, symmetric_key *skey); | |
324 | 407 |
325 /** Accelerated CTR encryption | 408 /** Accelerated CTR encryption |
326 @param pt Plaintext | 409 @param pt Plaintext |
327 @param ct Ciphertext | 410 @param ct Ciphertext |
328 @param blocks The number of complete blocks to process | 411 @param blocks The number of complete blocks to process |
329 @param IV The initial value (input/output) | 412 @param IV The initial value (input/output) |
330 @param mode little or big endian counter (mode=0 or mode=1) | 413 @param mode little or big endian counter (mode=0 or mode=1) |
331 @param skey The scheduled key context | 414 @param skey The scheduled key context |
332 */ | 415 @return CRYPT_OK if successful |
333 void (*accel_ctr_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, int mode, symmetric_key *skey); | 416 */ |
417 int (*accel_ctr_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, int mode, symmetric_key *skey); | |
418 | |
419 /** Accelerated LRW | |
420 @param pt Plaintext | |
421 @param ct Ciphertext | |
422 @param blocks The number of complete blocks to process | |
423 @param IV The initial value (input/output) | |
424 @param tweak The LRW tweak | |
425 @param skey The scheduled key context | |
426 @return CRYPT_OK if successful | |
427 */ | |
428 int (*accel_lrw_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey); | |
429 | |
430 /** Accelerated LRW | |
431 @param ct Ciphertext | |
432 @param pt Plaintext | |
433 @param blocks The number of complete blocks to process | |
434 @param IV The initial value (input/output) | |
435 @param tweak The LRW tweak | |
436 @param skey The scheduled key context | |
437 @return CRYPT_OK if successful | |
438 */ | |
439 int (*accel_lrw_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey); | |
334 | 440 |
335 /** Accelerated CCM packet (one-shot) | 441 /** Accelerated CCM packet (one-shot) |
336 @param key The secret key to use | 442 @param key The secret key to use |
337 @param keylen The length of the secret key (octets) | 443 @param keylen The length of the secret key (octets) |
444 @param uskey A previously scheduled key [optional can be NULL] | |
338 @param nonce The session nonce [use once] | 445 @param nonce The session nonce [use once] |
339 @param noncelen The length of the nonce | 446 @param noncelen The length of the nonce |
340 @param header The header for the session | 447 @param header The header for the session |
341 @param headerlen The length of the header (octets) | 448 @param headerlen The length of the header (octets) |
342 @param pt [out] The plaintext | 449 @param pt [out] The plaintext |
345 @param tag [out] The destination tag | 452 @param tag [out] The destination tag |
346 @param taglen [in/out] The max size and resulting size of the authentication tag | 453 @param taglen [in/out] The max size and resulting size of the authentication tag |
347 @param direction Encrypt or Decrypt direction (0 or 1) | 454 @param direction Encrypt or Decrypt direction (0 or 1) |
348 @return CRYPT_OK if successful | 455 @return CRYPT_OK if successful |
349 */ | 456 */ |
350 void (*accel_ccm_memory)( | 457 int (*accel_ccm_memory)( |
351 const unsigned char *key, unsigned long keylen, | 458 const unsigned char *key, unsigned long keylen, |
459 symmetric_key *uskey, | |
352 const unsigned char *nonce, unsigned long noncelen, | 460 const unsigned char *nonce, unsigned long noncelen, |
353 const unsigned char *header, unsigned long headerlen, | 461 const unsigned char *header, unsigned long headerlen, |
354 unsigned char *pt, unsigned long ptlen, | 462 unsigned char *pt, unsigned long ptlen, |
355 unsigned char *ct, | 463 unsigned char *ct, |
356 unsigned char *tag, unsigned long *taglen, | 464 unsigned char *tag, unsigned long *taglen, |
357 int direction); | 465 int direction); |
358 | 466 |
359 /** Accelerated GCM packet (one shot) | 467 /** Accelerated GCM packet (one shot) |
360 @param key The secret key | 468 @param key The secret key |
361 @param keylen The length of the secret key | 469 @param keylen The length of the secret key |
362 @param IV The initial vector | 470 @param IV The initial vector |
363 @param IVlen The length of the initial vector | 471 @param IVlen The length of the initial vector |
364 @param adata The additional authentication data (header) | 472 @param adata The additional authentication data (header) |
365 @param adatalen The length of the adata | 473 @param adatalen The length of the adata |
366 @param pt The plaintext | 474 @param pt The plaintext |
367 @param ptlen The length of the plaintext (ciphertext length is the same) | 475 @param ptlen The length of the plaintext (ciphertext length is the same) |
368 @param ct The ciphertext | 476 @param ct The ciphertext |
369 @param tag [out] The MAC tag | 477 @param tag [out] The MAC tag |
370 @param taglen [in/out] The MAC tag length | 478 @param taglen [in/out] The MAC tag length |
371 @param direction Encrypt or Decrypt mode (GCM_ENCRYPT or GCM_DECRYPT) | 479 @param direction Encrypt or Decrypt mode (GCM_ENCRYPT or GCM_DECRYPT) |
372 */ | 480 @return CRYPT_OK on success |
373 void (*accel_gcm_memory)( | 481 */ |
482 int (*accel_gcm_memory)( | |
374 const unsigned char *key, unsigned long keylen, | 483 const unsigned char *key, unsigned long keylen, |
375 const unsigned char *IV, unsigned long IVlen, | 484 const unsigned char *IV, unsigned long IVlen, |
376 const unsigned char *adata, unsigned long adatalen, | 485 const unsigned char *adata, unsigned long adatalen, |
377 unsigned char *pt, unsigned long ptlen, | 486 unsigned char *pt, unsigned long ptlen, |
378 unsigned char *ct, | 487 unsigned char *ct, |
379 unsigned char *tag, unsigned long *taglen, | 488 unsigned char *tag, unsigned long *taglen, |
380 int direction); | 489 int direction); |
490 | |
491 /** Accelerated one shot OMAC | |
492 @param key The secret key | |
493 @param keylen The key length (octets) | |
494 @param in The message | |
495 @param inlen Length of message (octets) | |
496 @param out [out] Destination for tag | |
497 @param outlen [in/out] Initial and final size of out | |
498 @return CRYPT_OK on success | |
499 */ | |
500 int (*omac_memory)( | |
501 const unsigned char *key, unsigned long keylen, | |
502 const unsigned char *in, unsigned long inlen, | |
503 unsigned char *out, unsigned long *outlen); | |
504 | |
505 /** Accelerated one shot XCBC | |
506 @param key The secret key | |
507 @param keylen The key length (octets) | |
508 @param in The message | |
509 @param inlen Length of message (octets) | |
510 @param out [out] Destination for tag | |
511 @param outlen [in/out] Initial and final size of out | |
512 @return CRYPT_OK on success | |
513 */ | |
514 int (*xcbc_memory)( | |
515 const unsigned char *key, unsigned long keylen, | |
516 const unsigned char *in, unsigned long inlen, | |
517 unsigned char *out, unsigned long *outlen); | |
518 | |
519 /** Accelerated one shot F9 | |
520 @param key The secret key | |
521 @param keylen The key length (octets) | |
522 @param in The message | |
523 @param inlen Length of message (octets) | |
524 @param out [out] Destination for tag | |
525 @param outlen [in/out] Initial and final size of out | |
526 @return CRYPT_OK on success | |
527 @remark Requires manual padding | |
528 */ | |
529 int (*f9_memory)( | |
530 const unsigned char *key, unsigned long keylen, | |
531 const unsigned char *in, unsigned long inlen, | |
532 unsigned char *out, unsigned long *outlen); | |
381 } cipher_descriptor[]; | 533 } cipher_descriptor[]; |
382 | 534 |
383 #ifdef BLOWFISH | 535 #ifdef BLOWFISH |
384 int blowfish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 536 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); | 537 int 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); | 538 int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
387 int blowfish_test(void); | 539 int blowfish_test(void); |
388 void blowfish_done(symmetric_key *skey); | 540 void blowfish_done(symmetric_key *skey); |
389 int blowfish_keysize(int *keysize); | 541 int blowfish_keysize(int *keysize); |
390 extern const struct ltc_cipher_descriptor blowfish_desc; | 542 extern const struct ltc_cipher_descriptor blowfish_desc; |
391 #endif | 543 #endif |
392 | 544 |
393 #ifdef RC5 | 545 #ifdef RC5 |
394 int rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 546 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); | 547 int 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); | 548 int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
397 int rc5_test(void); | 549 int rc5_test(void); |
398 void rc5_done(symmetric_key *skey); | 550 void rc5_done(symmetric_key *skey); |
399 int rc5_keysize(int *keysize); | 551 int rc5_keysize(int *keysize); |
400 extern const struct ltc_cipher_descriptor rc5_desc; | 552 extern const struct ltc_cipher_descriptor rc5_desc; |
401 #endif | 553 #endif |
402 | 554 |
403 #ifdef RC6 | 555 #ifdef RC6 |
404 int rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 556 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); | 557 int 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); | 558 int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
407 int rc6_test(void); | 559 int rc6_test(void); |
408 void rc6_done(symmetric_key *skey); | 560 void rc6_done(symmetric_key *skey); |
409 int rc6_keysize(int *keysize); | 561 int rc6_keysize(int *keysize); |
410 extern const struct ltc_cipher_descriptor rc6_desc; | 562 extern const struct ltc_cipher_descriptor rc6_desc; |
411 #endif | 563 #endif |
412 | 564 |
413 #ifdef RC2 | 565 #ifdef RC2 |
414 int rc2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 566 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); | 567 int 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); | 568 int rc2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
417 int rc2_test(void); | 569 int rc2_test(void); |
418 void rc2_done(symmetric_key *skey); | 570 void rc2_done(symmetric_key *skey); |
419 int rc2_keysize(int *keysize); | 571 int rc2_keysize(int *keysize); |
420 extern const struct ltc_cipher_descriptor rc2_desc; | 572 extern const struct ltc_cipher_descriptor rc2_desc; |
421 #endif | 573 #endif |
422 | 574 |
423 #ifdef SAFERP | 575 #ifdef SAFERP |
424 int saferp_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 576 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); | 577 int 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); | 578 int saferp_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
427 int saferp_test(void); | 579 int saferp_test(void); |
428 void saferp_done(symmetric_key *skey); | 580 void saferp_done(symmetric_key *skey); |
429 int saferp_keysize(int *keysize); | 581 int saferp_keysize(int *keysize); |
430 extern const struct ltc_cipher_descriptor saferp_desc; | 582 extern const struct ltc_cipher_descriptor saferp_desc; |
431 #endif | 583 #endif |
433 #ifdef SAFER | 585 #ifdef SAFER |
434 int safer_k64_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 586 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); | 587 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); | 588 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); | 589 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); | 590 int 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); | 591 int safer_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *key); |
440 int safer_k64_test(void); | 592 int safer_k64_test(void); |
441 int safer_sk64_test(void); | 593 int safer_sk64_test(void); |
442 int safer_sk128_test(void); | 594 int safer_sk128_test(void); |
443 void safer_done(symmetric_key *skey); | 595 void safer_done(symmetric_key *skey); |
444 int safer_64_keysize(int *keysize); | 596 int safer_64_keysize(int *keysize); |
459 #define aes_enc_setup rijndael_enc_setup | 611 #define aes_enc_setup rijndael_enc_setup |
460 #define aes_enc_ecb_encrypt rijndael_enc_ecb_encrypt | 612 #define aes_enc_ecb_encrypt rijndael_enc_ecb_encrypt |
461 #define aes_enc_keysize rijndael_enc_keysize | 613 #define aes_enc_keysize rijndael_enc_keysize |
462 | 614 |
463 int rijndael_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 615 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); | 616 int 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); | 617 int rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
466 int rijndael_test(void); | 618 int rijndael_test(void); |
467 void rijndael_done(symmetric_key *skey); | 619 void rijndael_done(symmetric_key *skey); |
468 int rijndael_keysize(int *keysize); | 620 int rijndael_keysize(int *keysize); |
469 int rijndael_enc_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 621 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); | 622 int rijndael_enc_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); |
471 void rijndael_enc_done(symmetric_key *skey); | 623 void rijndael_enc_done(symmetric_key *skey); |
472 int rijndael_enc_keysize(int *keysize); | 624 int rijndael_enc_keysize(int *keysize); |
473 extern const struct ltc_cipher_descriptor rijndael_desc, aes_desc; | 625 extern const struct ltc_cipher_descriptor rijndael_desc, aes_desc; |
474 extern const struct ltc_cipher_descriptor rijndael_enc_desc, aes_enc_desc; | 626 extern const struct ltc_cipher_descriptor rijndael_enc_desc, aes_enc_desc; |
475 #endif | 627 #endif |
476 | 628 |
477 #ifdef XTEA | 629 #ifdef XTEA |
478 int xtea_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 630 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); | 631 int 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); | 632 int xtea_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
481 int xtea_test(void); | 633 int xtea_test(void); |
482 void xtea_done(symmetric_key *skey); | 634 void xtea_done(symmetric_key *skey); |
483 int xtea_keysize(int *keysize); | 635 int xtea_keysize(int *keysize); |
484 extern const struct ltc_cipher_descriptor xtea_desc; | 636 extern const struct ltc_cipher_descriptor xtea_desc; |
485 #endif | 637 #endif |
486 | 638 |
487 #ifdef TWOFISH | 639 #ifdef TWOFISH |
488 int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 640 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); | 641 int 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); | 642 int twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
491 int twofish_test(void); | 643 int twofish_test(void); |
492 void twofish_done(symmetric_key *skey); | 644 void twofish_done(symmetric_key *skey); |
493 int twofish_keysize(int *keysize); | 645 int twofish_keysize(int *keysize); |
494 extern const struct ltc_cipher_descriptor twofish_desc; | 646 extern const struct ltc_cipher_descriptor twofish_desc; |
495 #endif | 647 #endif |
496 | 648 |
497 #ifdef DES | 649 #ifdef DES |
498 int des_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 650 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); | 651 int 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); | 652 int des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
501 int des_test(void); | 653 int des_test(void); |
502 void des_done(symmetric_key *skey); | 654 void des_done(symmetric_key *skey); |
503 int des_keysize(int *keysize); | 655 int des_keysize(int *keysize); |
504 int des3_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 656 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); | 657 int 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); | 658 int des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
507 int des3_test(void); | 659 int des3_test(void); |
508 void des3_done(symmetric_key *skey); | 660 void des3_done(symmetric_key *skey); |
509 int des3_keysize(int *keysize); | 661 int des3_keysize(int *keysize); |
510 extern const struct ltc_cipher_descriptor des_desc, des3_desc; | 662 extern const struct ltc_cipher_descriptor des_desc, des3_desc; |
511 #endif | 663 #endif |
512 | 664 |
513 #ifdef CAST5 | 665 #ifdef CAST5 |
514 int cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 666 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); | 667 int 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); | 668 int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
517 int cast5_test(void); | 669 int cast5_test(void); |
518 void cast5_done(symmetric_key *skey); | 670 void cast5_done(symmetric_key *skey); |
519 int cast5_keysize(int *keysize); | 671 int cast5_keysize(int *keysize); |
520 extern const struct ltc_cipher_descriptor cast5_desc; | 672 extern const struct ltc_cipher_descriptor cast5_desc; |
521 #endif | 673 #endif |
522 | 674 |
523 #ifdef NOEKEON | 675 #ifdef NOEKEON |
524 int noekeon_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 676 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); | 677 int 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); | 678 int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
527 int noekeon_test(void); | 679 int noekeon_test(void); |
528 void noekeon_done(symmetric_key *skey); | 680 void noekeon_done(symmetric_key *skey); |
529 int noekeon_keysize(int *keysize); | 681 int noekeon_keysize(int *keysize); |
530 extern const struct ltc_cipher_descriptor noekeon_desc; | 682 extern const struct ltc_cipher_descriptor noekeon_desc; |
531 #endif | 683 #endif |
532 | 684 |
533 #ifdef SKIPJACK | 685 #ifdef SKIPJACK |
534 int skipjack_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 686 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); | 687 int 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); | 688 int skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
537 int skipjack_test(void); | 689 int skipjack_test(void); |
538 void skipjack_done(symmetric_key *skey); | 690 void skipjack_done(symmetric_key *skey); |
539 int skipjack_keysize(int *keysize); | 691 int skipjack_keysize(int *keysize); |
540 extern const struct ltc_cipher_descriptor skipjack_desc; | 692 extern const struct ltc_cipher_descriptor skipjack_desc; |
541 #endif | 693 #endif |
542 | 694 |
543 #ifdef KHAZAD | 695 #ifdef KHAZAD |
544 int khazad_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 696 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); | 697 int 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); | 698 int khazad_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
547 int khazad_test(void); | 699 int khazad_test(void); |
548 void khazad_done(symmetric_key *skey); | 700 void khazad_done(symmetric_key *skey); |
549 int khazad_keysize(int *keysize); | 701 int khazad_keysize(int *keysize); |
550 extern const struct ltc_cipher_descriptor khazad_desc; | 702 extern const struct ltc_cipher_descriptor khazad_desc; |
551 #endif | 703 #endif |
552 | 704 |
553 #ifdef ANUBIS | 705 #ifdef ANUBIS |
554 int anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | 706 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); | 707 int 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); | 708 int anubis_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); |
557 int anubis_test(void); | 709 int anubis_test(void); |
558 void anubis_done(symmetric_key *skey); | 710 void anubis_done(symmetric_key *skey); |
559 int anubis_keysize(int *keysize); | 711 int anubis_keysize(int *keysize); |
560 extern const struct ltc_cipher_descriptor anubis_desc; | 712 extern const struct ltc_cipher_descriptor anubis_desc; |
561 #endif | 713 #endif |
562 | 714 |
563 #ifdef ECB | 715 #ifdef KSEED |
716 int kseed_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | |
717 int kseed_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); | |
718 int kseed_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); | |
719 int kseed_test(void); | |
720 void kseed_done(symmetric_key *skey); | |
721 int kseed_keysize(int *keysize); | |
722 extern const struct ltc_cipher_descriptor kseed_desc; | |
723 #endif | |
724 | |
725 #ifdef LTC_KASUMI | |
726 int kasumi_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey); | |
727 int kasumi_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey); | |
728 int kasumi_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey); | |
729 int kasumi_test(void); | |
730 void kasumi_done(symmetric_key *skey); | |
731 int kasumi_keysize(int *keysize); | |
732 extern const struct ltc_cipher_descriptor kasumi_desc; | |
733 #endif | |
734 | |
735 #ifdef LTC_ECB_MODE | |
564 int ecb_start(int cipher, const unsigned char *key, | 736 int ecb_start(int cipher, const unsigned char *key, |
565 int keylen, int num_rounds, symmetric_ECB *ecb); | 737 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); | 738 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); | 739 int ecb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_ECB *ecb); |
568 int ecb_done(symmetric_ECB *ecb); | 740 int ecb_done(symmetric_ECB *ecb); |
569 #endif | 741 #endif |
570 | 742 |
571 #ifdef CFB | 743 #ifdef LTC_CFB_MODE |
572 int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key, | 744 int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key, |
573 int keylen, int num_rounds, symmetric_CFB *cfb); | 745 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); | 746 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); | 747 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); | 748 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); | 749 int cfb_setiv(const unsigned char *IV, unsigned long len, symmetric_CFB *cfb); |
578 int cfb_done(symmetric_CFB *cfb); | 750 int cfb_done(symmetric_CFB *cfb); |
579 #endif | 751 #endif |
580 | 752 |
581 #ifdef OFB | 753 #ifdef LTC_OFB_MODE |
582 int ofb_start(int cipher, const unsigned char *IV, const unsigned char *key, | 754 int ofb_start(int cipher, const unsigned char *IV, const unsigned char *key, |
583 int keylen, int num_rounds, symmetric_OFB *ofb); | 755 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); | 756 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); | 757 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); | 758 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); | 759 int ofb_setiv(const unsigned char *IV, unsigned long len, symmetric_OFB *ofb); |
588 int ofb_done(symmetric_OFB *ofb); | 760 int ofb_done(symmetric_OFB *ofb); |
589 #endif | 761 #endif |
590 | 762 |
591 #ifdef CBC | 763 #ifdef LTC_CBC_MODE |
592 int cbc_start(int cipher, const unsigned char *IV, const unsigned char *key, | 764 int cbc_start(int cipher, const unsigned char *IV, const unsigned char *key, |
593 int keylen, int num_rounds, symmetric_CBC *cbc); | 765 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); | 766 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); | 767 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); | 768 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); | 769 int cbc_setiv(const unsigned char *IV, unsigned long len, symmetric_CBC *cbc); |
598 int cbc_done(symmetric_CBC *cbc); | 770 int cbc_done(symmetric_CBC *cbc); |
599 #endif | 771 #endif |
600 | 772 |
601 #ifdef CTR | 773 #ifdef LTC_CTR_MODE |
602 | 774 |
603 #define CTR_COUNTER_LITTLE_ENDIAN 0 | 775 #define CTR_COUNTER_LITTLE_ENDIAN 0 |
604 #define CTR_COUNTER_BIG_ENDIAN 1 | 776 #define CTR_COUNTER_BIG_ENDIAN 1 |
777 #define LTC_CTR_RFC3686 2 | |
605 | 778 |
606 int ctr_start( int cipher, | 779 int ctr_start( int cipher, |
607 const unsigned char *IV, | 780 const unsigned char *IV, |
608 const unsigned char *key, int keylen, | 781 const unsigned char *key, int keylen, |
609 int num_rounds, int ctr_mode, | 782 int num_rounds, int ctr_mode, |
611 int ctr_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CTR *ctr); | 784 int ctr_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CTR *ctr); |
612 int ctr_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CTR *ctr); | 785 int ctr_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CTR *ctr); |
613 int ctr_getiv(unsigned char *IV, unsigned long *len, symmetric_CTR *ctr); | 786 int ctr_getiv(unsigned char *IV, unsigned long *len, symmetric_CTR *ctr); |
614 int ctr_setiv(const unsigned char *IV, unsigned long len, symmetric_CTR *ctr); | 787 int ctr_setiv(const unsigned char *IV, unsigned long len, symmetric_CTR *ctr); |
615 int ctr_done(symmetric_CTR *ctr); | 788 int ctr_done(symmetric_CTR *ctr); |
616 #endif | 789 int ctr_test(void); |
617 | 790 #endif |
791 | |
792 #ifdef LTC_LRW_MODE | |
793 | |
794 #define LRW_ENCRYPT 0 | |
795 #define LRW_DECRYPT 1 | |
796 | |
797 int lrw_start( int cipher, | |
798 const unsigned char *IV, | |
799 const unsigned char *key, int keylen, | |
800 const unsigned char *tweak, | |
801 int num_rounds, | |
802 symmetric_LRW *lrw); | |
803 int lrw_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_LRW *lrw); | |
804 int lrw_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_LRW *lrw); | |
805 int lrw_getiv(unsigned char *IV, unsigned long *len, symmetric_LRW *lrw); | |
806 int lrw_setiv(const unsigned char *IV, unsigned long len, symmetric_LRW *lrw); | |
807 int lrw_done(symmetric_LRW *lrw); | |
808 int lrw_test(void); | |
809 | |
810 /* don't call */ | |
811 int lrw_process(const unsigned char *pt, unsigned char *ct, unsigned long len, int mode, symmetric_LRW *lrw); | |
812 #endif | |
813 | |
814 #ifdef LTC_F8_MODE | |
815 int f8_start( int cipher, const unsigned char *IV, | |
816 const unsigned char *key, int keylen, | |
817 const unsigned char *salt_key, int skeylen, | |
818 int num_rounds, symmetric_F8 *f8); | |
819 int f8_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_F8 *f8); | |
820 int f8_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_F8 *f8); | |
821 int f8_getiv(unsigned char *IV, unsigned long *len, symmetric_F8 *f8); | |
822 int f8_setiv(const unsigned char *IV, unsigned long len, symmetric_F8 *f8); | |
823 int f8_done(symmetric_F8 *f8); | |
824 int f8_test_mode(void); | |
825 #endif | |
826 | |
827 | |
618 int find_cipher(const char *name); | 828 int find_cipher(const char *name); |
619 int find_cipher_any(const char *name, int blocklen, int keylen); | 829 int find_cipher_any(const char *name, int blocklen, int keylen); |
620 int find_cipher_id(unsigned char ID); | 830 int find_cipher_id(unsigned char ID); |
621 int register_cipher(const struct ltc_cipher_descriptor *cipher); | 831 int register_cipher(const struct ltc_cipher_descriptor *cipher); |
622 int unregister_cipher(const struct ltc_cipher_descriptor *cipher); | 832 int unregister_cipher(const struct ltc_cipher_descriptor *cipher); |
623 int cipher_is_valid(int idx); | 833 int cipher_is_valid(int idx); |
624 | 834 |
625 LTC_MUTEX_PROTO(ltc_cipher_mutex); | 835 LTC_MUTEX_PROTO(ltc_cipher_mutex) |
626 | 836 |
627 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_cipher.h,v $ */ | 837 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_cipher.h,v $ */ |
628 /* $Revision: 1.16 $ */ | 838 /* $Revision: 1.46 $ */ |
629 /* $Date: 2005/06/19 18:00:28 $ */ | 839 /* $Date: 2006/11/13 23:09:38 $ */ |