⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tomcrypt_cipher.h

📁 这是一个用来加解密的算法库
💻 H
📖 第 1 页 / 共 2 页
字号:
/* ---- 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 BLOWFISHstruct blowfish_key {   ulong32 S[4][256];   ulong32 K[18];};#endif#ifdef RC5struct rc5_key {   int rounds;   ulong32 K[50];};#endif#ifdef RC6struct rc6_key {   ulong32 K[44];};#endif#ifdef SAFERPstruct saferp_key {   unsigned char K[33][16];   long rounds;};#endif#ifdef RIJNDAELstruct rijndael_key {   ulong32 eK[64], dK[64];   int Nr;};#endif#ifdef XTEAstruct xtea_key {   unsigned long A[32], B[32];};#endif#ifdef TWOFISH#ifndef 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 SAFER#define SAFER_K64_DEFAULT_NOF_ROUNDS     6#define SAFER_K128_DEFAULT_NOF_ROUNDS   10#define SAFER_SK64_DEFAULT_NOF_ROUNDS    8#define SAFER_SK128_DEFAULT_NOF_ROUNDS  10#define SAFER_MAX_NOF_ROUNDS            13#define SAFER_BLOCK_LEN                  8#define SAFER_KEY_LEN     (1 + SAFER_BLOCK_LEN * (1 + 2 * SAFER_MAX_NOF_ROUNDS))typedef unsigned char safer_block_t[SAFER_BLOCK_LEN];typedef unsigned char safer_key_t[SAFER_KEY_LEN];struct safer_key { safer_key_t key; };#endif#ifdef RC2struct rc2_key { unsigned xkey[64]; };#endif#ifdef DESstruct des_key {    ulong32 ek[32], dk[32];};struct des3_key {    ulong32 ek[3][32], dk[3][32];};#endif#ifdef CAST5struct cast5_key {    ulong32 K[32], keylen;};#endif#ifdef NOEKEONstruct noekeon_key {    ulong32 K[4], dK[4];};#endif#ifdef SKIPJACK struct skipjack_key {    unsigned char key[10];};#endif#ifdef KHAZADstruct khazad_key {   ulong64 roundKeyEnc[8 + 1];    ulong64 roundKeyDec[8 + 1]; };#endif#ifdef ANUBISstruct anubis_key {    int keyBits;    int R;    ulong32 roundKeyEnc[18 + 1][4];    ulong32 roundKeyDec[18 + 1][4]; }; #endiftypedef union Symmetric_key {#ifdef DES   struct des_key des;   struct des3_key des3;#endif#ifdef RC2   struct rc2_key rc2;#endif#ifdef SAFER   struct safer_key safer;#endif#ifdef TWOFISH   struct twofish_key  twofish;#endif#ifdef BLOWFISH   struct blowfish_key blowfish;#endif#ifdef RC5   struct rc5_key      rc5;#endif#ifdef RC6   struct rc6_key      rc6;#endif#ifdef SAFERP   struct saferp_key   saferp;#endif#ifdef RIJNDAEL   struct rijndael_key rijndael;#endif#ifdef XTEA   struct xtea_key     xtea;#endif#ifdef CAST5   struct cast5_key    cast5;#endif#ifdef NOEKEON   struct noekeon_key  noekeon;#endif   #ifdef SKIPJACK   struct skipjack_key skipjack;#endif#ifdef KHAZAD   struct khazad_key   khazad;#endif#ifdef ANUBIS   struct anubis_key   anubis;#endif} symmetric_key;/* 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;/* 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;/* 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;/* 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;/* 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;   /** The counter */                          unsigned char       ctr[MAXBLOCKSIZE],    /** The pad used to encrypt/decrypt */                                              pad[MAXBLOCKSIZE];   /** The scheduled key */   symmetric_key       key;} symmetric_CTR;/* cipher descriptor table, last entry has "name == NULL" to mark the end of table */extern struct ltc_cipher_descriptor {   /** name of cipher */   char *name;   /** internal ID */   unsigned char ID;   /** min keysize (octets) */   int  min_key_length,    /** max keysize (octets) */        max_key_length,    /** block size (octets) */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -