1 /* ---- SYMMETRIC KEY STUFF -----
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.
28 unsigned char K[33][16];
35 ulong32 eK[60], dK[60];
42 ulong32 K[32], dK[32];
48 ulong32 KLi1[8], KLi2[8],
49 KOi1[8], KOi2[8], KOi3[8],
50 KIi1[8], KIi2[8], KIi3[8];
56 unsigned long A[32], B[32];
63 ulong32 S[4][256], K[40];
68 unsigned char S[32], start;
74 #define SAFER_K64_DEFAULT_NOF_ROUNDS 6
75 #define SAFER_K128_DEFAULT_NOF_ROUNDS 10
76 #define SAFER_SK64_DEFAULT_NOF_ROUNDS 8
77 #define SAFER_SK128_DEFAULT_NOF_ROUNDS 10
78 #define SAFER_MAX_NOF_ROUNDS 13
79 #define SAFER_BLOCK_LEN 8
80 #define SAFER_KEY_LEN (1 + SAFER_BLOCK_LEN * (1 + 2 * SAFER_MAX_NOF_ROUNDS))
81 typedef unsigned char safer_block_t[SAFER_BLOCK_LEN];
82 typedef unsigned char safer_key_t[SAFER_KEY_LEN];
83 struct safer_key { safer_key_t key; };
87 struct rc2_key { unsigned xkey[64]; };
92 ulong32 ek[32], dk[32];
96 ulong32 ek[3][32], dk[3][32];
102 ulong32 K[32], keylen;
113 struct skipjack_key {
114 unsigned char key[10];
120 ulong64 roundKeyEnc[8 + 1];
121 ulong64 roundKeyDec[8 + 1];
129 ulong32 roundKeyEnc[18 + 1][4];
130 ulong32 roundKeyDec[18 + 1][4];
134 typedef union Symmetric_key {
137 struct des3_key des3;
143 struct safer_key safer;
146 struct twofish_key twofish;
149 struct blowfish_key blowfish;
158 struct saferp_key saferp;
161 struct rijndael_key rijndael;
164 struct xtea_key xtea;
167 struct cast5_key cast5;
170 struct noekeon_key noekeon;
173 struct skipjack_key skipjack;
176 struct khazad_key khazad;
179 struct anubis_key anubis;
182 struct kseed_key kseed;
185 struct kasumi_key kasumi;
191 /** A block cipher ECB structure */
193 /** The index of the cipher chosen */
195 /** The block size of the given cipher */
197 /** The scheduled key */
203 /** A block cipher CFB structure */
205 /** The index of the cipher chosen */
207 /** The block size of the given cipher */
209 /** The padding offset */
211 /** The current IV */
212 unsigned char IV[MAXBLOCKSIZE],
213 /** The pad used to encrypt/decrypt */
215 /** The scheduled key */
221 /** A block cipher OFB structure */
223 /** The index of the cipher chosen */
225 /** The block size of the given cipher */
227 /** The padding offset */
229 /** The current IV */
230 unsigned char IV[MAXBLOCKSIZE];
231 /** The scheduled key */
237 /** A block cipher CBC structure */
239 /** The index of the cipher chosen */
241 /** The block size of the given cipher */
243 /** The current IV */
244 unsigned char IV[MAXBLOCKSIZE];
245 /** The scheduled key */
252 /** A block cipher CTR structure */
254 /** The index of the cipher chosen */
256 /** The block size of the given cipher */
258 /** The padding offset */
260 /** The mode (endianess) of the CTR, 0==little, 1==big */
263 unsigned char ctr[MAXBLOCKSIZE],
264 /** The pad used to encrypt/decrypt */
266 /** The scheduled key */
273 /** A LRW structure */
275 /** The index of the cipher chosen (must be a 128-bit block cipher) */
278 /** The current IV */
279 unsigned char IV[16],
284 /** The current pad, it's the product of the first 15 bytes against the tweak key */
287 /** The scheduled symmetric key */
291 /** The pre-computed multiplication table */
292 unsigned char PC[16][256][16];
298 /** A block cipher F8 structure */
300 /** The index of the cipher chosen */
302 /** The block size of the given cipher */
304 /** The padding offset */
306 /** The current IV */
307 unsigned char IV[MAXBLOCKSIZE],
309 /** Current block count */
311 /** The scheduled key */
317 /** cipher descriptor table, last entry has "name == NULL" to mark the end of table */
318 extern struct ltc_cipher_descriptor {
319 /** name of cipher */
323 /** min keysize (octets) */
325 /** max keysize (octets) */
327 /** block size (octets) */
329 /** default number of rounds */
332 @param key The input symmetric key
333 @param keylen The length of the input key (octets)
334 @param num_rounds The requested number of rounds (0==default)
335 @param skey [out] The destination of the scheduled key
336 @return CRYPT_OK if successful
338 int (*setup)(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
340 @param pt The plaintext
341 @param ct [out] The ciphertext
342 @param skey The scheduled key
343 @return CRYPT_OK if successful
345 int (*ecb_encrypt)(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
347 @param ct The ciphertext
348 @param pt [out] The plaintext
349 @param skey The scheduled key
350 @return CRYPT_OK if successful
352 int (*ecb_decrypt)(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
353 /** Test the block cipher
354 @return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled
358 /** Terminate the context
359 @param skey The scheduled key
361 void (*done)(symmetric_key *skey);
363 /** Determine a key size
364 @param keysize [in/out] The size of the key desired and the suggested size
365 @return CRYPT_OK if successful
367 int (*keysize)(int *keysize);
370 /** Accelerated ECB encryption
373 @param blocks The number of complete blocks to process
374 @param skey The scheduled key context
375 @return CRYPT_OK if successful
377 int (*accel_ecb_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, symmetric_key *skey);
379 /** Accelerated ECB decryption
382 @param blocks The number of complete blocks to process
383 @param skey The scheduled key context
384 @return CRYPT_OK if successful
386 int (*accel_ecb_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, symmetric_key *skey);
388 /** Accelerated CBC encryption
391 @param blocks The number of complete blocks to process
392 @param IV The initial value (input/output)
393 @param skey The scheduled key context
394 @return CRYPT_OK if successful
396 int (*accel_cbc_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, symmetric_key *skey);
398 /** Accelerated CBC decryption
401 @param blocks The number of complete blocks to process
402 @param IV The initial value (input/output)
403 @param skey The scheduled key context
404 @return CRYPT_OK if successful
406 int (*accel_cbc_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, symmetric_key *skey);
408 /** Accelerated CTR encryption
411 @param blocks The number of complete blocks to process
412 @param IV The initial value (input/output)
413 @param mode little or big endian counter (mode=0 or mode=1)
414 @param skey The scheduled key context
415 @return CRYPT_OK if successful
417 int (*accel_ctr_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, int mode, symmetric_key *skey);
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
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);
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
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);
441 /** Accelerated CCM packet (one-shot)
442 @param key The secret key to use
443 @param keylen The length of the secret key (octets)
444 @param uskey A previously scheduled key [optional can be NULL]
445 @param nonce The session nonce [use once]
446 @param noncelen The length of the nonce
447 @param header The header for the session
448 @param headerlen The length of the header (octets)
449 @param pt [out] The plaintext
450 @param ptlen The length of the plaintext (octets)
451 @param ct [out] The ciphertext
452 @param tag [out] The destination tag
453 @param taglen [in/out] The max size and resulting size of the authentication tag
454 @param direction Encrypt or Decrypt direction (0 or 1)
455 @return CRYPT_OK if successful
457 int (*accel_ccm_memory)(
458 const unsigned char *key, unsigned long keylen,
459 symmetric_key *uskey,
460 const unsigned char *nonce, unsigned long noncelen,
461 const unsigned char *header, unsigned long headerlen,
462 unsigned char *pt, unsigned long ptlen,
464 unsigned char *tag, unsigned long *taglen,
467 /** Accelerated GCM packet (one shot)
468 @param key The secret key
469 @param keylen The length of the secret key
470 @param IV The initial vector
471 @param IVlen The length of the initial vector
472 @param adata The additional authentication data (header)
473 @param adatalen The length of the adata
474 @param pt The plaintext
475 @param ptlen The length of the plaintext (ciphertext length is the same)
476 @param ct The ciphertext
477 @param tag [out] The MAC tag
478 @param taglen [in/out] The MAC tag length
479 @param direction Encrypt or Decrypt mode (GCM_ENCRYPT or GCM_DECRYPT)
480 @return CRYPT_OK on success
482 int (*accel_gcm_memory)(
483 const unsigned char *key, unsigned long keylen,
484 const unsigned char *IV, unsigned long IVlen,
485 const unsigned char *adata, unsigned long adatalen,
486 unsigned char *pt, unsigned long ptlen,
488 unsigned char *tag, unsigned long *taglen,
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
501 const unsigned char *key, unsigned long keylen,
502 const unsigned char *in, unsigned long inlen,
503 unsigned char *out, unsigned long *outlen);
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
515 const unsigned char *key, unsigned long keylen,
516 const unsigned char *in, unsigned long inlen,
517 unsigned char *out, unsigned long *outlen);
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
530 const unsigned char *key, unsigned long keylen,
531 const unsigned char *in, unsigned long inlen,
532 unsigned char *out, unsigned long *outlen);
533 } cipher_descriptor[];
536 int blowfish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
537 int blowfish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
538 int blowfish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
539 int blowfish_test(void);
540 void blowfish_done(symmetric_key *skey);
541 int blowfish_keysize(int *keysize);
542 extern const struct ltc_cipher_descriptor blowfish_desc;
546 int rc5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
547 int rc5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
548 int rc5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
550 void rc5_done(symmetric_key *skey);
551 int rc5_keysize(int *keysize);
552 extern const struct ltc_cipher_descriptor rc5_desc;
556 int rc6_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
557 int rc6_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
558 int rc6_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
560 void rc6_done(symmetric_key *skey);
561 int rc6_keysize(int *keysize);
562 extern const struct ltc_cipher_descriptor rc6_desc;
566 int rc2_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
567 int rc2_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
568 int rc2_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
570 void rc2_done(symmetric_key *skey);
571 int rc2_keysize(int *keysize);
572 extern const struct ltc_cipher_descriptor rc2_desc;
576 int saferp_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
577 int saferp_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
578 int saferp_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
579 int saferp_test(void);
580 void saferp_done(symmetric_key *skey);
581 int saferp_keysize(int *keysize);
582 extern const struct ltc_cipher_descriptor saferp_desc;
586 int safer_k64_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);
588 int safer_k128_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);
590 int safer_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *key);
591 int safer_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *key);
592 int safer_k64_test(void);
593 int safer_sk64_test(void);
594 int safer_sk128_test(void);
595 void safer_done(symmetric_key *skey);
596 int safer_64_keysize(int *keysize);
597 int safer_128_keysize(int *keysize);
598 extern const struct ltc_cipher_descriptor safer_k64_desc, safer_k128_desc, safer_sk64_desc, safer_sk128_desc;
603 /* make aes an alias */
604 #define aes_setup rijndael_setup
605 #define aes_ecb_encrypt rijndael_ecb_encrypt
606 #define aes_ecb_decrypt rijndael_ecb_decrypt
607 #define aes_test rijndael_test
608 #define aes_done rijndael_done
609 #define aes_keysize rijndael_keysize
611 #define aes_enc_setup rijndael_enc_setup
612 #define aes_enc_ecb_encrypt rijndael_enc_ecb_encrypt
613 #define aes_enc_keysize rijndael_enc_keysize
615 int rijndael_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
616 int rijndael_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
617 int rijndael_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
618 int rijndael_test(void);
619 void rijndael_done(symmetric_key *skey);
620 int rijndael_keysize(int *keysize);
621 int rijndael_enc_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
622 int rijndael_enc_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
623 void rijndael_enc_done(symmetric_key *skey);
624 int rijndael_enc_keysize(int *keysize);
625 extern const struct ltc_cipher_descriptor rijndael_desc, aes_desc;
626 extern const struct ltc_cipher_descriptor rijndael_enc_desc, aes_enc_desc;
630 int xtea_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
631 int xtea_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
632 int xtea_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
634 void xtea_done(symmetric_key *skey);
635 int xtea_keysize(int *keysize);
636 extern const struct ltc_cipher_descriptor xtea_desc;
640 int twofish_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
641 int twofish_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
642 int twofish_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
643 int twofish_test(void);
644 void twofish_done(symmetric_key *skey);
645 int twofish_keysize(int *keysize);
646 extern const struct ltc_cipher_descriptor twofish_desc;
650 int des_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
651 int des_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
652 int des_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
654 void des_done(symmetric_key *skey);
655 int des_keysize(int *keysize);
656 int des3_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
657 int des3_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
658 int des3_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
660 void des3_done(symmetric_key *skey);
661 int des3_keysize(int *keysize);
662 extern const struct ltc_cipher_descriptor des_desc, des3_desc;
666 int cast5_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
667 int cast5_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
668 int cast5_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
669 int cast5_test(void);
670 void cast5_done(symmetric_key *skey);
671 int cast5_keysize(int *keysize);
672 extern const struct ltc_cipher_descriptor cast5_desc;
676 int noekeon_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
677 int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
678 int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
679 int noekeon_test(void);
680 void noekeon_done(symmetric_key *skey);
681 int noekeon_keysize(int *keysize);
682 extern const struct ltc_cipher_descriptor noekeon_desc;
686 int skipjack_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
687 int skipjack_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
688 int skipjack_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
689 int skipjack_test(void);
690 void skipjack_done(symmetric_key *skey);
691 int skipjack_keysize(int *keysize);
692 extern const struct ltc_cipher_descriptor skipjack_desc;
696 int khazad_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
697 int khazad_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
698 int khazad_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
699 int khazad_test(void);
700 void khazad_done(symmetric_key *skey);
701 int khazad_keysize(int *keysize);
702 extern const struct ltc_cipher_descriptor khazad_desc;
706 int anubis_setup(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey);
707 int anubis_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey);
708 int anubis_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey);
709 int anubis_test(void);
710 void anubis_done(symmetric_key *skey);
711 int anubis_keysize(int *keysize);
712 extern const struct ltc_cipher_descriptor anubis_desc;
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;
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;
736 int ecb_start(int cipher, const unsigned char *key,
737 int keylen, int num_rounds, symmetric_ECB *ecb);
738 int ecb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_ECB *ecb);
739 int ecb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_ECB *ecb);
740 int ecb_done(symmetric_ECB *ecb);
744 int cfb_start(int cipher, const unsigned char *IV, const unsigned char *key,
745 int keylen, int num_rounds, symmetric_CFB *cfb);
746 int cfb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CFB *cfb);
747 int cfb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CFB *cfb);
748 int cfb_getiv(unsigned char *IV, unsigned long *len, symmetric_CFB *cfb);
749 int cfb_setiv(const unsigned char *IV, unsigned long len, symmetric_CFB *cfb);
750 int cfb_done(symmetric_CFB *cfb);
754 int ofb_start(int cipher, const unsigned char *IV, const unsigned char *key,
755 int keylen, int num_rounds, symmetric_OFB *ofb);
756 int ofb_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_OFB *ofb);
757 int ofb_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_OFB *ofb);
758 int ofb_getiv(unsigned char *IV, unsigned long *len, symmetric_OFB *ofb);
759 int ofb_setiv(const unsigned char *IV, unsigned long len, symmetric_OFB *ofb);
760 int ofb_done(symmetric_OFB *ofb);
764 int cbc_start(int cipher, const unsigned char *IV, const unsigned char *key,
765 int keylen, int num_rounds, symmetric_CBC *cbc);
766 int cbc_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CBC *cbc);
767 int cbc_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CBC *cbc);
768 int cbc_getiv(unsigned char *IV, unsigned long *len, symmetric_CBC *cbc);
769 int cbc_setiv(const unsigned char *IV, unsigned long len, symmetric_CBC *cbc);
770 int cbc_done(symmetric_CBC *cbc);
775 #define CTR_COUNTER_LITTLE_ENDIAN 0
776 #define CTR_COUNTER_BIG_ENDIAN 1
777 #define LTC_CTR_RFC3686 2
779 int ctr_start( int cipher,
780 const unsigned char *IV,
781 const unsigned char *key, int keylen,
782 int num_rounds, int ctr_mode,
784 int ctr_encrypt(const unsigned char *pt, unsigned char *ct, unsigned long len, symmetric_CTR *ctr);
785 int ctr_decrypt(const unsigned char *ct, unsigned char *pt, unsigned long len, symmetric_CTR *ctr);
786 int ctr_getiv(unsigned char *IV, unsigned long *len, symmetric_CTR *ctr);
787 int ctr_setiv(const unsigned char *IV, unsigned long len, symmetric_CTR *ctr);
788 int ctr_done(symmetric_CTR *ctr);
794 #define LRW_ENCRYPT 0
795 #define LRW_DECRYPT 1
797 int lrw_start( int cipher,
798 const unsigned char *IV,
799 const unsigned char *key, int keylen,
800 const unsigned char *tweak,
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);
811 int lrw_process(const unsigned char *pt, unsigned char *ct, unsigned long len, int mode, symmetric_LRW *lrw);
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);
828 int find_cipher(const char *name);
829 int find_cipher_any(const char *name, int blocklen, int keylen);
830 int find_cipher_id(unsigned char ID);
831 int register_cipher(const struct ltc_cipher_descriptor *cipher);
832 int unregister_cipher(const struct ltc_cipher_descriptor *cipher);
833 int cipher_is_valid(int idx);
835 LTC_MUTEX_PROTO(ltc_cipher_mutex)
837 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_cipher.h,v $ */
838 /* $Revision: 1.46 $ */
839 /* $Date: 2006/11/13 23:09:38 $ */