📄 typhoon.h
字号:
the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. *//************************************************************************* ** Copyright: Corrent Corporation (c) 2001 ** ** Filename: typhoon.h ** Created By: Kapil Sood ** Created On: April 26, 2001 ** Description: This is the main header file of the typhoon ** software library. This file contains all ** function declarations, data structures, type ** definitions, and data declarations that will ** be used in the typhoon software library. ** ** *************************************************************************//* Revision * $Id: typhoon.h,v 1.2 2002/10/25 14:54:33 dsr-oss Exp $ */#ifndef TYPHOON_H#define TYPHOON_H#ifdef __cplusplusextern "C" {#endif#include <stdio.h>/* Define Error and Warning file names */#ifdef _UNIX#define ERROR_FILE_NAME "/tmp/error.dat"#define WARNING_FILE_NAME "/tmp/warning.dat"#endif /* Define typedefs for data types used */typedef unsigned char BYTE ; /* 8-bit byte */typedef unsigned short INT16 ; /* 16-bit integer */typedef unsigned int INT32 ; /* 32-bit integer *//* Define Endian-ness of the library */typedef enum cr_endian_enum { CR_BIG_ENDIAN=0, CR_LITTLE_ENDIAN, CR_NETWORK_ENDIAN, /* Add all values above this */ CR_MAX_ENDIAN } CR_ENDIAN ;CR_ENDIAN cr_lib_endian ;/* Define Return Code values */typedef enum RC_enum { SUCCESS = 0, FAILURE = 1, /* Add all values above this */ MAX_RC } RC ;/* Define Crypto Algorithm Code */typedef enum op_code_enum { CR_NULL_CRYPTO=0, CR_MOD_EXP, CR_MOD_EXP_CRT, CR_RSA_OP, CR_RSA_CRT_OP, CR_DSA_OP, CR_DES_CBC_ENC_OP, CR_DES_CBC_DEC_OP, CR_DES_ECB_ENC_OP, CR_DES_ECB_DEC_OP, CR_TDES_CBC_EDE_ENC_OP, CR_TDES_CBC_EDE_DEC_OP, CR_TDES_ECB_EDE_ENC_OP, CR_TDES_ECB_EDE_DEC_OP, CR_ARCFOUR_ENC_OP, CR_ARCFOUR_DEC_OP, CR_AES128_CBC_ENC_OP, CR_AES128_CBC_DEC_OP, CR_AES192_CBC_ENC_OP, CR_AES192_CBC_DEC_OP, CR_AES256_CBC_ENC_OP, CR_AES256_CBC_DEC_OP, CR_AES128_ECB_ENC_OP, CR_AES128_ECB_DEC_OP, CR_AES192_ECB_ENC_OP, CR_AES192_ECB_DEC_OP, CR_AES256_ECB_ENC_OP, CR_AES256_ECB_DEC_OP, CR_AUTHENTICATE_OP, /* For all HMAC operations */ /* Add all values above this */ CR_MAX_OP_CODE } CR_OP_CODE ;typedef enum authenticate_code_enum { CR_NULL_AUTH=0, CR_SHA1, /* Perform SHA-1 hash */ CR_HMAC_SHA1, /* Perform HMAC_SHA-1 */ CR_HMAC_SHA1_96, /* Perform HMAC_SHA-1-96 */ CR_MD5, /* Perform MD5 hash */ CR_HMAC_MD5, /* Perform HMAC_MD5 hash */ CR_HMAC_MD5_96, /* Perform HMAC_MD5-96 */ CR_MD5_SHA1, /* Perform MD5 and SHA1 hashes separately */ CR_DBL_SHA1, /* Perform SHA1 twice */ CR_DBL_MD5, /* Perform MD5 twice */ CR_DBL_SHA1_MD5, /* Perform MD5 inside and SHA-1 outside */ CR_DBL_MD5_SHA1, /* Perform SHA-1 inside and MD5 outside */ CR_PRF, /* Perform PRF */ /* Add all values above this */ CR_MAX_AUTH_CODE } CR_AUTH_CODE ;/* Define the RSA padding/encryption type */typedef enum rsa_type_enum { CR_NULL_RSA = 0, CR_PKCS1_1_5 = 1, /* Perform PKCS1_1.5 used in SSLv3/TLS1.0 */ /* Add all values above this */ CR_MAX_RSA_TYPE } CR_RSA_TYPE ;/* Define typedefs for complex data structures used */typedef struct token_struct { BYTE *p_data ; /* The pointer to actual data */ INT32 data_size ; /* The length (in bytes) of the data */ } token ;typedef struct rsa_key_struct { token *modulus ; /* 'n' */ token *exponent ; /* Can be 'e' or 'd' */ } rsa_key ;typedef struct rsa_crt_key_struct { token *prime_p ; token *prime_q ; token *dmp1 ; /* 'd mod (p-1)' value */ token *dmq1 ; /* 'd mod (q-1)' value */ token *iqmp ; /* 'inv(q) mod p' value */ } rsa_crt_key ;typedef struct dsa_sign_key_struct { token *r ; token *s ; } dsa_sign_key ;typedef struct dsa_key_struct { token *p ; token *q ; token *g ; token *key ; /* sign: server private key(x); verify: client public key(y) */ } dsa_key ;/* The following struct is used as a general purpose structure for DES encryption/decryption operations. Each of the DES keys are 56-bit long, as per DES specifications. However, the last bit of each byte is used for parity checking. Therefore, the total key size for each key is 64-bit. If single/double keys are used, then unused keys must be NULL, and NULL keys must follow the valid keys. The Initialization Vector (iv) is also 64-bit long. */typedef struct des_key_struct { token *iv ; token *key1 ; token *key2 ; token *key3 ; } des_key ;/* The following struct is used as the key for ARCFOUR. The length of the key * may be between 1 and 256 bytes. However, SSLv3 and TLS1.0 use ARC4 with 128bit * (16 Bytes) key length. Use either the static key, or key token. */typedef struct arcfour_key_struct { token *key ; unsigned char state[256] ; unsigned char state_x ; unsigned char state_y ; } arcfour_key ;/* The following struct is used as a key for AES. The length of the key must be 128/192/256 bits for AES128/AES192/AES256 respectively. The iv must also be of appropriate sizes */typedef struct aes_key_struct { token *key ; token *iv ; } aes_key ;/* The following struct is used for defining secret key components for HMAC algorithms. The size of i/odigest component will be 16/20 Bytes, depending on the hash algorithm MD5/SHA1. The I/ODigest values are the 64B extention of the secret key, XORed with ipad/opad, and then hash operated. Alternatively, the application could send the secret into the library, and the Typhoon device will handle the entire computation. If an ordinary MD5 or SHA1 hashing operation is required, there is no need to use this structure. */typedef struct hmac_key_struct { token *secret ; token *idigest ; token *odigest ; } hmac_key ;/* The following struct is used for defining secret keys for TLS1.0 PRF algorithms. The PRF key components will be either the secret, or the I/ODigest for HMAC_MD5 and HMAC_SHA1. If the secret is NULL, then all other components must contain valid values. If secret is not NULL, then the secret will be used by the library. If the secret is not NULL, then other components must be NULL or will be ignored. */typedef struct prf_key_struct { token *secret ; BYTE *idigest_md5 ; BYTE *odigest_md5 ; BYTE *idigest_sha1 ; BYTE *odigest_sha1 ; } prf_key ;/* The following structure will be used for passing SSLv3 and TLS1.0 security parameters into the library. These security parameters will be unique for every SSL/TLS connection and direction. The tls_mac_key must be used for TLS1.0 only, and the sslv3_tls_mac_secret for SSLv3. The symmetric keys will either be DES/3DES or ARC4. */typedef struct sslv3_tls_key_struct { CR_AUTH_CODE auth_code ; CR_OP_CODE crypto_code ; hmac_key *tls_hmac_key ; token *sslv3_mac_secret ; union { des_key *des_sym_key ; arcfour_key *arcfour_sym_key ; } sym_key ; } sslv3_tls_key ;/* The following are the SA flags that will be used with IPSEC processing. * CR_AH_ADDPAD * CR_AH_NEXT_HDR_STRIP - If set for ESP inbound packets the next header byte * will be removed from the packet after decryption. * CR_IV_STRIP - If set for ESP inbound packets the IV is removed * from the IPsec header. * CR_OHDR_STRIP - If set then all bytes up to the data are removed. * CR_MIN_PADEN - If set for outbound packets then the packet is * padded to the multiple of the cipher block size. * For NULL cipher the packet is padded to a multiple * of 4 bytes. * CR_ENCRYPT - Set for outbound ESP packets. Cleared for inbound. */#define CR_AH_ADDPAD 0x00000001#define CR_NEXT_HDR_STRIP 0x00000002#define CR_IV_STRIP 0x00000004#define CR_OHDR_STRIP 0x00000008#define CR_MIN_PADEN 0x00000010#define CR_ENCRYPT 0x00000020/* Data structure for storing key information for IPsec AH & ESP packets. * auth_code - Authentication type. Must be set for AH. Can be NULL for ESP. * crypto_code - Cipher type for ESP packets. Must be CR_AUTHENTICATE_OP for * AH. * sa_flags - Flags to set in the SA from the list above. * hmac_key - Mac Secret for authentication. Can be NULL if no auth. * sym_key - Union of DES and AES key pointers. crypto_code is checked * to determine which key to use if any. Ignored for AH mode. * NOTE: auth_code and crypto_code cannot both be NULL. */typedef struct ipsec_key_struct
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -