📄 tomcrypt_cipher.h
字号:
/* ---- SYMMETRIC KEY STUFF ----- * * We put each of the ciphers scheduled keys in their own structs then we put all of * the key formats in one union. This makes the function prototypes easier to use. */#ifdef LTC_BLOWFISHstruct blowfish_key { ulong32 S[4][256]; ulong32 K[18];};#endif#ifdef LTC_RC5struct rc5_key { int rounds; ulong32 K[50];};#endif#ifdef LTC_RC6struct rc6_key { ulong32 K[44];};#endif#ifdef LTC_SAFERPstruct saferp_key { unsigned char K[33][16]; long rounds;};#endif#ifdef LTC_RIJNDAELstruct rijndael_key { ulong32 eK[60], dK[60]; int Nr;};#endif#ifdef LTC_KSEEDstruct kseed_key { ulong32 K[32], dK[32];};#endif#ifdef LTC_KASUMIstruct kasumi_key { ulong32 KLi1[8], KLi2[8], KOi1[8], KOi2[8], KOi3[8], KIi1[8], KIi2[8], KIi3[8];};#endif#ifdef LTC_XTEAstruct xtea_key { unsigned long A[32], B[32];};#endif#ifdef LTC_TWOFISH#ifndef LTC_TWOFISH_SMALL struct twofish_key { ulong32 S[4][256], K[40]; };#else struct twofish_key { ulong32 K[40]; unsigned char S[32], start; };#endif#endif#ifdef LTC_SAFER#define LTC_SAFER_K64_DEFAULT_NOF_ROUNDS 6#define LTC_SAFER_K128_DEFAULT_NOF_ROUNDS 10#define LTC_SAFER_SK64_DEFAULT_NOF_ROUNDS 8#define LTC_SAFER_SK128_DEFAULT_NOF_ROUNDS 10#define LTC_SAFER_MAX_NOF_ROUNDS 13#define LTC_SAFER_BLOCK_LEN 8#define LTC_SAFER_KEY_LEN (1 + LTC_SAFER_BLOCK_LEN * (1 + 2 * LTC_SAFER_MAX_NOF_ROUNDS))typedef unsigned char safer_block_t[LTC_SAFER_BLOCK_LEN];typedef unsigned char safer_key_t[LTC_SAFER_KEY_LEN];struct safer_key { safer_key_t key; };#endif#ifdef LTC_RC2struct rc2_key { unsigned xkey[64]; };#endif#ifdef LTC_DESstruct des_key { ulong32 ek[32], dk[32];};struct des3_key { ulong32 ek[3][32], dk[3][32];};#endif#ifdef LTC_CAST5struct cast5_key { ulong32 K[32], keylen;};#endif#ifdef LTC_NOEKEONstruct noekeon_key { ulong32 K[4], dK[4];};#endif#ifdef LTC_SKIPJACK struct skipjack_key { unsigned char key[10];};#endif#ifdef LTC_KHAZADstruct khazad_key { ulong64 roundKeyEnc[8 + 1]; ulong64 roundKeyDec[8 + 1]; };#endif#ifdef LTC_ANUBISstruct anubis_key { int keyBits; int R; ulong32 roundKeyEnc[18 + 1][4]; ulong32 roundKeyDec[18 + 1][4]; }; #endif#ifdef LTC_MULTI2struct multi2_key { int N; ulong32 uk[8];};#endiftypedef union Symmetric_key {#ifdef LTC_DES struct des_key des; struct des3_key des3;#endif#ifdef LTC_RC2 struct rc2_key rc2;#endif#ifdef LTC_SAFER struct safer_key safer;#endif#ifdef LTC_TWOFISH struct twofish_key twofish;#endif#ifdef LTC_BLOWFISH struct blowfish_key blowfish;#endif#ifdef LTC_RC5 struct rc5_key rc5;#endif#ifdef LTC_RC6 struct rc6_key rc6;#endif#ifdef LTC_SAFERP struct saferp_key saferp;#endif#ifdef LTC_RIJNDAEL struct rijndael_key rijndael;#endif#ifdef LTC_XTEA struct xtea_key xtea;#endif#ifdef LTC_CAST5 struct cast5_key cast5;#endif#ifdef LTC_NOEKEON struct noekeon_key noekeon;#endif #ifdef LTC_SKIPJACK struct skipjack_key skipjack;#endif#ifdef LTC_KHAZAD struct khazad_key khazad;#endif#ifdef LTC_ANUBIS struct anubis_key anubis;#endif#ifdef LTC_KSEED struct kseed_key kseed;#endif#ifdef LTC_KASUMI struct kasumi_key kasumi;#endif #ifdef LTC_MULTI2 struct multi2_key multi2;#endif void *data;} symmetric_key;#ifdef LTC_ECB_MODE/** A block cipher ECB structure */typedef struct { /** The index of the cipher chosen */ int cipher, /** The block size of the given cipher */ blocklen; /** The scheduled key */ symmetric_key key;} symmetric_ECB;#endif#ifdef LTC_CFB_MODE/** A block cipher CFB structure */typedef struct { /** The index of the cipher chosen */ int cipher, /** The block size of the given cipher */ blocklen, /** The padding offset */ padlen; /** The current IV */ unsigned char IV[MAXBLOCKSIZE], /** The pad used to encrypt/decrypt */ pad[MAXBLOCKSIZE]; /** The scheduled key */ symmetric_key key;} symmetric_CFB;#endif#ifdef LTC_OFB_MODE/** A block cipher OFB structure */typedef struct { /** The index of the cipher chosen */ int cipher, /** The block size of the given cipher */ blocklen, /** The padding offset */ padlen; /** The current IV */ unsigned char IV[MAXBLOCKSIZE]; /** The scheduled key */ symmetric_key key;} symmetric_OFB;#endif#ifdef LTC_CBC_MODE/** A block cipher CBC structure */typedef struct { /** The index of the cipher chosen */ int cipher, /** The block size of the given cipher */ blocklen; /** The current IV */ unsigned char IV[MAXBLOCKSIZE]; /** The scheduled key */ symmetric_key key;} symmetric_CBC;#endif#ifdef LTC_CTR_MODE/** A block cipher CTR structure */typedef struct { /** The index of the cipher chosen */ int cipher, /** The block size of the given cipher */ blocklen, /** The padding offset */ padlen, /** The mode (endianess) of the CTR, 0==little, 1==big */ mode, /** counter width */ ctrlen; /** The counter */ unsigned char ctr[MAXBLOCKSIZE], /** The pad used to encrypt/decrypt */ pad[MAXBLOCKSIZE]; /** The scheduled key */ symmetric_key key;} symmetric_CTR;#endif#ifdef LTC_LRW_MODE/** A LRW structure */typedef struct { /** The index of the cipher chosen (must be a 128-bit block cipher) */ int cipher; /** The current IV */ unsigned char IV[16], /** the tweak key */ tweak[16], /** The current pad, it's the product of the first 15 bytes against the tweak key */ pad[16];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -