28 unsigned char K[33][16];
49 KOi1[8], KOi2[8], KOi3[8],
50 KIi1[8], KIi2[8], KIi3[8];
56 unsigned long A[32], B[32];
61 #ifndef LTC_TWOFISH_SMALL
68 unsigned char S[32], start;
74 #define LTC_SAFER_K64_DEFAULT_NOF_ROUNDS 6
75 #define LTC_SAFER_K128_DEFAULT_NOF_ROUNDS 10
76 #define LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS 8
77 #define LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS 10
78 #define LTC_SAFER_MAX_NOF_ROUNDS 13
79 #define LTC_SAFER_BLOCK_LEN 8
80 #define LTC_SAFER_KEY_LEN (1 + LTC_SAFER_BLOCK_LEN * (1 + 2 * LTC_SAFER_MAX_NOF_ROUNDS))
81 typedef unsigned char safer_block_t[LTC_SAFER_BLOCK_LEN];
82 typedef unsigned char safer_key_t[LTC_SAFER_KEY_LEN];
83 struct safer_key { safer_key_t key; };
87 struct rc2_key {
unsigned xkey[64]; };
113 struct skipjack_key {
114 unsigned char key[10];
129 ulong32 roundKeyEnc[18 + 1][4];
130 ulong32 roundKeyDec[18 + 1][4];
144 struct des3_key des3;
150 struct safer_key safer;
153 struct twofish_key twofish;
156 struct blowfish_key blowfish;
165 struct saferp_key saferp;
168 struct rijndael_key rijndael;
171 struct xtea_key xtea;
174 struct cast5_key cast5;
177 struct noekeon_key noekeon;
180 struct skipjack_key skipjack;
183 struct khazad_key khazad;
186 struct anubis_key anubis;
189 struct kseed_key kseed;
192 struct kasumi_key kasumi;
195 struct multi2_key multi2;
292 unsigned char IV[16],
305 unsigned char PC[16][256][16];
471 const unsigned char *key,
unsigned long keylen,
473 const unsigned char *nonce,
unsigned long noncelen,
474 const unsigned char *header,
unsigned long headerlen,
475 unsigned char *pt,
unsigned long ptlen,
477 unsigned char *tag,
unsigned long *taglen,
496 const unsigned char *key,
unsigned long keylen,
497 const unsigned char *IV,
unsigned long IVlen,
498 const unsigned char *adata,
unsigned long adatalen,
499 unsigned char *pt,
unsigned long ptlen,
501 unsigned char *tag,
unsigned long *taglen,
514 const unsigned char *key,
unsigned long keylen,
515 const unsigned char *in,
unsigned long inlen,
516 unsigned char *out,
unsigned long *outlen);
528 const unsigned char *key,
unsigned long keylen,
529 const unsigned char *in,
unsigned long inlen,
530 unsigned char *out,
unsigned long *outlen);
543 const unsigned char *key,
unsigned long keylen,
544 const unsigned char *in,
unsigned long inlen,
545 unsigned char *out,
unsigned long *outlen);
549 int blowfish_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
550 int blowfish_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
551 int blowfish_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
552 int blowfish_test(
void);
554 int blowfish_keysize(
int *keysize);
559 int rc5_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
560 int rc5_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
561 int rc5_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
569 int rc6_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
570 int rc6_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
571 int rc6_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
579 int rc2_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
580 int rc2_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
581 int rc2_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
589 int saferp_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
590 int saferp_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
591 int saferp_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
592 int saferp_test(
void);
594 int saferp_keysize(
int *
keysize);
599 int safer_k64_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
600 int safer_sk64_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
601 int safer_k128_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
602 int safer_sk128_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
603 int safer_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *key);
604 int safer_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *key);
605 int safer_k64_test(
void);
606 int safer_sk64_test(
void);
607 int safer_sk128_test(
void);
609 int safer_64_keysize(
int *
keysize);
610 int safer_128_keysize(
int *
keysize);
611 extern const struct ltc_cipher_descriptor safer_k64_desc, safer_k128_desc, safer_sk64_desc, safer_sk128_desc;
617 #define aes_setup rijndael_setup
618 #define aes_ecb_encrypt rijndael_ecb_encrypt
619 #define aes_ecb_decrypt rijndael_ecb_decrypt
620 #define aes_test rijndael_test
621 #define aes_done rijndael_done
622 #define aes_keysize rijndael_keysize
624 #define aes_enc_setup rijndael_enc_setup
625 #define aes_enc_ecb_encrypt rijndael_enc_ecb_encrypt
626 #define aes_enc_keysize rijndael_enc_keysize
628 int rijndael_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
629 int rijndael_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
630 int rijndael_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
631 int rijndael_test(
void);
633 int rijndael_keysize(
int *
keysize);
634 int rijndael_enc_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
635 int rijndael_enc_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
637 int rijndael_enc_keysize(
int *
keysize);
643 int xtea_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
644 int xtea_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
645 int xtea_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
648 int xtea_keysize(
int *
keysize);
653 int twofish_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
654 int twofish_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
655 int twofish_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
656 int twofish_test(
void);
658 int twofish_keysize(
int *
keysize);
663 int des_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
664 int des_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
665 int des_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
669 int des3_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
670 int des3_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
671 int des3_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
674 int des3_keysize(
int *
keysize);
679 int cast5_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
680 int cast5_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
681 int cast5_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
682 int cast5_test(
void);
684 int cast5_keysize(
int *
keysize);
689 int noekeon_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
690 int noekeon_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
691 int noekeon_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
692 int noekeon_test(
void);
694 int noekeon_keysize(
int *
keysize);
699 int skipjack_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
700 int skipjack_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
701 int skipjack_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
702 int skipjack_test(
void);
704 int skipjack_keysize(
int *
keysize);
709 int khazad_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
710 int khazad_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
711 int khazad_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
712 int khazad_test(
void);
714 int khazad_keysize(
int *
keysize);
719 int anubis_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
720 int anubis_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
721 int anubis_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
722 int anubis_test(
void);
724 int anubis_keysize(
int *
keysize);
729 int kseed_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
730 int kseed_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
731 int kseed_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
732 int kseed_test(
void);
734 int kseed_keysize(
int *
keysize);
739 int kasumi_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
740 int kasumi_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
741 int kasumi_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
742 int kasumi_test(
void);
744 int kasumi_keysize(
int *
keysize);
750 int multi2_setup(
const unsigned char *key,
int keylen,
int num_rounds,
symmetric_key *skey);
751 int multi2_ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
symmetric_key *skey);
752 int multi2_ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
symmetric_key *skey);
753 int multi2_test(
void);
755 int multi2_keysize(
int *
keysize);
760 int ecb_start(
int cipher,
const unsigned char *key,
761 int keylen,
int num_rounds, symmetric_ECB *ecb);
762 int ecb_encrypt(
const unsigned char *pt,
unsigned char *ct,
unsigned long len, symmetric_ECB *ecb);
763 int ecb_decrypt(
const unsigned char *ct,
unsigned char *pt,
unsigned long len, symmetric_ECB *ecb);
764 int ecb_done(symmetric_ECB *ecb);
768 int cfb_start(
int cipher,
const unsigned char *IV,
const unsigned char *key,
769 int keylen,
int num_rounds, symmetric_CFB *cfb);
770 int cfb_encrypt(
const unsigned char *pt,
unsigned char *ct,
unsigned long len, symmetric_CFB *cfb);
771 int cfb_decrypt(
const unsigned char *ct,
unsigned char *pt,
unsigned long len, symmetric_CFB *cfb);
772 int cfb_getiv(
unsigned char *IV,
unsigned long *len, symmetric_CFB *cfb);
773 int cfb_setiv(
const unsigned char *IV,
unsigned long len, symmetric_CFB *cfb);
774 int cfb_done(symmetric_CFB *cfb);
778 int ofb_start(
int cipher,
const unsigned char *IV,
const unsigned char *key,
779 int keylen,
int num_rounds, symmetric_OFB *ofb);
780 int ofb_encrypt(
const unsigned char *pt,
unsigned char *ct,
unsigned long len, symmetric_OFB *ofb);
781 int ofb_decrypt(
const unsigned char *ct,
unsigned char *pt,
unsigned long len, symmetric_OFB *ofb);
782 int ofb_getiv(
unsigned char *IV,
unsigned long *len, symmetric_OFB *ofb);
783 int ofb_setiv(
const unsigned char *IV,
unsigned long len, symmetric_OFB *ofb);
784 int ofb_done(symmetric_OFB *ofb);
788 int cbc_start(
int cipher,
const unsigned char *IV,
const unsigned char *key,
789 int keylen,
int num_rounds, symmetric_CBC *cbc);
790 int cbc_encrypt(
const unsigned char *pt,
unsigned char *ct,
unsigned long len, symmetric_CBC *cbc);
791 int cbc_decrypt(
const unsigned char *ct,
unsigned char *pt,
unsigned long len, symmetric_CBC *cbc);
792 int cbc_getiv(
unsigned char *IV,
unsigned long *len, symmetric_CBC *cbc);
793 int cbc_setiv(
const unsigned char *IV,
unsigned long len, symmetric_CBC *cbc);
794 int cbc_done(symmetric_CBC *cbc);
799 #define CTR_COUNTER_LITTLE_ENDIAN 0x0000
800 #define CTR_COUNTER_BIG_ENDIAN 0x1000
801 #define LTC_CTR_RFC3686 0x2000
803 int ctr_start(
int cipher,
804 const unsigned char *IV,
805 const unsigned char *key,
int keylen,
806 int num_rounds,
int ctr_mode,
808 int ctr_encrypt(
const unsigned char *pt,
unsigned char *ct,
unsigned long len, symmetric_CTR *ctr);
809 int ctr_decrypt(
const unsigned char *ct,
unsigned char *pt,
unsigned long len, symmetric_CTR *ctr);
810 int ctr_getiv(
unsigned char *IV,
unsigned long *len, symmetric_CTR *ctr);
811 int ctr_setiv(
const unsigned char *IV,
unsigned long len, symmetric_CTR *ctr);
812 int ctr_done(symmetric_CTR *ctr);
818 #define LRW_ENCRYPT 0
819 #define LRW_DECRYPT 1
821 int lrw_start(
int cipher,
822 const unsigned char *IV,
823 const unsigned char *key,
int keylen,
824 const unsigned char *tweak,
827 int lrw_encrypt(
const unsigned char *pt,
unsigned char *ct,
unsigned long len, symmetric_LRW *lrw);
828 int lrw_decrypt(
const unsigned char *ct,
unsigned char *pt,
unsigned long len, symmetric_LRW *lrw);
829 int lrw_getiv(
unsigned char *IV,
unsigned long *len, symmetric_LRW *lrw);
830 int lrw_setiv(
const unsigned char *IV,
unsigned long len, symmetric_LRW *lrw);
831 int lrw_done(symmetric_LRW *lrw);
835 int lrw_process(
const unsigned char *pt,
unsigned char *ct,
unsigned long len,
int mode, symmetric_LRW *lrw);
839 int f8_start(
int cipher,
const unsigned char *IV,
840 const unsigned char *key,
int keylen,
841 const unsigned char *salt_key,
int skeylen,
842 int num_rounds, symmetric_F8 *f8);
843 int f8_encrypt(
const unsigned char *pt,
unsigned char *ct,
unsigned long len, symmetric_F8 *f8);
844 int f8_decrypt(
const unsigned char *ct,
unsigned char *pt,
unsigned long len, symmetric_F8 *f8);
845 int f8_getiv(
unsigned char *IV,
unsigned long *len, symmetric_F8 *f8);
846 int f8_setiv(
const unsigned char *IV,
unsigned long len, symmetric_F8 *f8);
847 int f8_done(symmetric_F8 *f8);
848 int f8_test_mode(
void);
857 int xts_start(
int cipher,
858 const unsigned char *key1,
859 const unsigned char *key2,
860 unsigned long keylen,
865 const unsigned char *pt,
unsigned long ptlen,
867 const unsigned char *tweak,
870 const unsigned char *ct,
unsigned long ptlen,
872 const unsigned char *tweak,
875 void xts_done(symmetric_xts *xts);
877 void xts_mult_x(
unsigned char *
I);
int(* accel_lrw_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey)
Definition: tomcrypt_cipher.h:441
int(* accel_gcm_memory)(const unsigned char *key, unsigned long keylen, const unsigned char *IV, unsigned long IVlen, const unsigned char *adata, unsigned long adatalen, unsigned char *pt, unsigned long ptlen, unsigned char *ct, unsigned char *tag, unsigned long *taglen, int direction)
Definition: tomcrypt_cipher.h:495
struct ltc_cipher_descriptor cipher_descriptor[]
IntFormatSpec< int, AlignTypeSpec< TYPE_CODE >, Char > pad(int value, unsigned width, Char fill= ' ')
int(* setup)(const unsigned char *key, int keylen, int num_rounds, symmetric_key *skey)
Definition: tomcrypt_cipher.h:351
int(* accel_cbc_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, symmetric_key *skey)
Definition: tomcrypt_cipher.h:419
#define LTC_MUTEX_PROTO(x)
Definition: tomcrypt_custom.h:405
int register_cipher(const struct ltc_cipher_descriptor *cipher)
#define MAXBLOCKSIZE
Definition: tomcrypt.h:23
int(* accel_ctr_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, int mode, symmetric_key *skey)
Definition: tomcrypt_cipher.h:430
int(* accel_ccm_memory)(const unsigned char *key, unsigned long keylen, symmetric_key *uskey, const unsigned char *nonce, unsigned long noncelen, const unsigned char *header, unsigned long headerlen, unsigned char *pt, unsigned long ptlen, unsigned char *ct, unsigned char *tag, unsigned long *taglen, int direction)
Definition: tomcrypt_cipher.h:470
int(* accel_ecb_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, symmetric_key *skey)
Definition: tomcrypt_cipher.h:390
unsigned long ulong32
Definition: tomcrypt_macros.h:16
int find_cipher(const char *name)
unsigned long long ulong64
Definition: tomcrypt_macros.h:7
int(* accel_ecb_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, symmetric_key *skey)
Definition: tomcrypt_cipher.h:399
void * data
Definition: tomcrypt_cipher.h:197
int default_rounds
Definition: tomcrypt_cipher.h:337
int(* xcbc_memory)(const unsigned char *key, unsigned long keylen, const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen)
Definition: tomcrypt_cipher.h:527
int unregister_cipher(const struct ltc_cipher_descriptor *cipher)
int(* ecb_encrypt)(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
Definition: tomcrypt_cipher.h:358
unsigned char ID
Definition: tomcrypt_cipher.h:335
Definition: tomcrypt_cipher.h:331
int max_key_length
Definition: tomcrypt_cipher.h:337
char * name
Definition: tomcrypt_cipher.h:333
int find_cipher_any(const char *name, int blocklen, int keylen)
int find_cipher_id(unsigned char ID)
union Symmetric_key symmetric_key
int(* accel_lrw_decrypt)(const unsigned char *ct, unsigned char *pt, unsigned long blocks, unsigned char *IV, const unsigned char *tweak, symmetric_key *skey)
Definition: tomcrypt_cipher.h:452
int(* ecb_decrypt)(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
Definition: tomcrypt_cipher.h:365
int min_key_length
Definition: tomcrypt_cipher.h:337
Definition: tomcrypt_cipher.h:141
int block_length
Definition: tomcrypt_cipher.h:337
int(* f9_memory)(const unsigned char *key, unsigned long keylen, const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen)
Definition: tomcrypt_cipher.h:542
int(* keysize)(int *keysize)
Definition: tomcrypt_cipher.h:380
int cipher_is_valid(int idx)
int(* omac_memory)(const unsigned char *key, unsigned long keylen, const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen)
Definition: tomcrypt_cipher.h:513
void(* done)(symmetric_key *skey)
Definition: tomcrypt_cipher.h:374
int(* test)(void)
Definition: tomcrypt_cipher.h:369
int(* accel_cbc_encrypt)(const unsigned char *pt, unsigned char *ct, unsigned long blocks, unsigned char *IV, symmetric_key *skey)
Definition: tomcrypt_cipher.h:409