📄 ubscrypt.h
字号:
/* * Broadcom Cryptonet Driver software is distributed as is, without any warranty * of any kind, either express or implied as further specified in the GNU Public * License. This software may be used and distributed according to the terms of * the GNU Public License. * * Cryptonet is a registered trademark of Broadcom Corporation. *//****************************************************************************** * * Copyright 2000 * Broadcom Corporation * 16215 Alton Parkway * PO Box 57013 * Irvine CA 92619-7013 * *****************************************************************************//* * Broadcom Corporation uBSec SDK *//* * ubscrypt.h: This file contains all the structure definitions for the crypto * functions of the BCM58xx chip family. * * This file was previously named ubs5501.h: */ /* * Revision History: * * 09/xx/1999 SOR Created - ubs5501.h. * 12/01/1999 DWP Modified to handle Big Endian devices. Activating SRL for * Big Endian requires defining BIG_ENDIAN, rather than * LITTLE_ENDIAN * 12/03/1999 SOR Modifications to do all static address computations * at init time * 09/14/2000 SOR Added 5820 Support * 09/14/2000 SOR Created register control file and this file. * 04/03/2001 RJT Added support for CryptoNet device big-endian mode * 07/16/2001 RJT Added support for BCM5821 * 10/04/2001 SRM 64bit port */#ifndef _UBSCRYPT_H_#define _UBSCRYPT_H_/* * Device specfic Data Structures. * * These structures are determined by the hardware. * additional fields are added for simplicity. * * BCM - ubs5801 was previously the BSN-ubs5501. * so both definitions may be used in this file. *//* * Packet Context Buffer structure * * Keeps the keys and instructions for a packet. * * CryptoKeys holds the keys for 3DES * HMACInnerState pre-computed HMAC inner state * HMACOuterState pre-computed HMAC outer state * (2x16bit for MD5, 2x20bit for SHA1) * ComputedIV Crypto Initial Vector(from payload, if explicit) * Processing Control Flags: * reserved reserved * uAuthentication MD5/SHA1/None * Inbound Inbound Packet * Crypto 3DES-CBC/None * CryptoOffset Offset to skip authenticated but not encrypted * header words. Goes to start of IV data, in * units of 32-bit words. */typedef struct CipherContext_s {#ifdef UBSEC_582x_CLASS_DEVICE #if (UBS_CRYPTONET_ATTRIBUTE == UBS_LITTLE_ENDIAN) VOLATILE unsigned short CryptoFlag; VOLATILE unsigned short CryptoOffset;#else VOLATILE unsigned short CryptoOffset; VOLATILE unsigned short CryptoFlag;#endif /* UBS_CRYPTONET_ATTRIBUTE conditional */ VOLATILE UBS_UINT32 CryptoKey1[2]; VOLATILE UBS_UINT32 CryptoKey2[2]; VOLATILE UBS_UINT32 CryptoKey3[2]; VOLATILE UBS_UINT32 ComputedIV[2]; VOLATILE UBS_UINT32 HMACInnerState[5]; VOLATILE UBS_UINT32 HMACOuterState[5];#else /* UBSEC_580x */ VOLATILE UBS_UINT32 CryptoKey1[2]; VOLATILE UBS_UINT32 CryptoKey2[2]; VOLATILE UBS_UINT32 CryptoKey3[2]; VOLATILE UBS_UINT32 HMACInnerState[5]; VOLATILE UBS_UINT32 HMACOuterState[5]; VOLATILE UBS_UINT32 ComputedIV[2];#if (UBS_CRYPTONET_ATTRIBUTE == UBS_LITTLE_ENDIAN) VOLATILE unsigned short CryptoFlag; VOLATILE unsigned short CryptoOffset;#else VOLATILE unsigned short CryptoOffset; VOLATILE unsigned short CryptoFlag;#endif /* UBS_CRYPTONET_ATTRIBUTE conditional */#endif /* 5820/21 conditional */} CipherContext_t, *CipherContext_pt;/* * CryptoFlag Settings *//* #ifdef UBS_LITTLE_ENDIAN */#if (UBS_CPU_ATTRIBUTE == UBS_CRYPTONET_ATTRIBUTE)#define CF_ENCODE 0x0000#define CF_DECODE 0x4000#define CF_3DES 0x8000#define CF_MD5 0x1000#define CF_SHA1 0x2000#else#define CF_ENCODE 0x0000#define CF_DECODE 0x0040#define CF_3DES 0x0080#define CF_MD5 0x0010#define CF_SHA1 0x0020#endif#ifdef UBSEC_582x_CLASS_DEVICE /* SSL/TLS/ARC4 are for BCM5820/21 only *//* * SSL MD5/SHA1 context. */#define SSL_HMAC_PAD_VALUE_LONG 0x3636363636363636#define SSL_HMAC_PAD_LENGTH_LONG 12#define SSL_MAC_PAD_VALUE_LONG 0x3636363636363636#define SSL_MAC_PAD_LENGTH_LONG 12typedef struct SSL_HMACContext_s {#if (UBS_CRYPTONET_ATTRIBUTE == UBS_LITTLE_ENDIAN) VOLATILE unsigned short CryptoFlag; VOLATILE unsigned short Reserved;#else VOLATILE unsigned short Reserved; VOLATILE unsigned short CryptoFlag;#endif /* UBS_CRYPTONET_ATTRIBUTE conditional */ VOLATILE unsigned char HMACKey[20]; VOLATILE unsigned char HMACPad[48]; VOLATILE UBS_UINT32 SequenceHigh; VOLATILE UBS_UINT32 SequenceLow;#if (UBS_CRYPTONET_ATTRIBUTE == UBS_LITTLE_ENDIAN) VOLATILE UBS_UINT32 ReservedB : 8; VOLATILE UBS_UINT32 DataLength : 16; VOLATILE UBS_UINT32 ContentType : 8;#else VOLATILE UBS_UINT32 ContentType : 8; VOLATILE UBS_UINT32 DataLength : 16; VOLATILE UBS_UINT32 ReservedB : 8;#endif /* UBS_CRYPTONET_ATTRIBUTE conditional */} SSL_HMACContext_t, *SSL_HMACContext_pt, SSL_MACContext_t, *SSL_MACContext_pt;/* TLS HMAC Context */typedef struct TLS_HMACContext_s {#if (UBS_CRYPTONET_ATTRIBUTE == UBS_LITTLE_ENDIAN) VOLATILE unsigned short CryptoFlag; VOLATILE unsigned short Reserved;#else VOLATILE unsigned short Reserved; VOLATILE unsigned short CryptoFlag;#endif /* UBS_CRYPTONET_ATTRIBUTE conditional */ VOLATILE UBS_UINT32 HMACInnerState[5]; VOLATILE UBS_UINT32 HMACOuterState[5]; VOLATILE UBS_UINT32 SequenceHigh; VOLATILE UBS_UINT32 SequenceLow;#if (UBS_CRYPTONET_ATTRIBUTE == UBS_LITTLE_ENDIAN) VOLATILE UBS_UINT32 DataLengthHi:8; VOLATILE UBS_UINT32 Version:16; VOLATILE UBS_UINT32 ContentType:8; VOLATILE UBS_UINT32 ReservedG2:24; VOLATILE UBS_UINT32 DataLengthLo:8;#else VOLATILE UBS_UINT32 ContentType:8; VOLATILE UBS_UINT32 Version:16; VOLATILE UBS_UINT32 DataLengthHi:8; VOLATILE UBS_UINT32 DataLengthLo:8; VOLATILE UBS_UINT32 ReservedG2:24;#endif /* UBS_CRYPTONET_ATTRIBUTE conditional */} TLS_HMACContext_t, *TLS_HMACContext_pt;/* SSL/TLS DES Context */typedef struct SSL_CryptoContext_s {#if (UBS_CRYPTONET_ATTRIBUTE == UBS_LITTLE_ENDIAN) VOLATILE unsigned short CryptoFlag; VOLATILE unsigned short Reserved;#else VOLATILE unsigned short Reserved; VOLATILE unsigned short CryptoFlag;#endif /* UBS_CRYPTONET_ATTRIBUTE conditional */ VOLATILE UBS_UINT32 CryptoKey1[2]; VOLATILE UBS_UINT32 CryptoKey2[2]; VOLATILE UBS_UINT32 CryptoKey3[2]; VOLATILE UBS_UINT32 ComputedIV[2];} SSL_CryptoContext_t, *SSL_CryptoContext_pt;/* ARC4 DES Context */typedef struct ARC4_CryptoContext_s {#if (UBS_CRYPTONET_ATTRIBUTE == UBS_LITTLE_ENDIAN) VOLATILE unsigned short StateInfo; VOLATILE unsigned short Reserved;#else VOLATILE unsigned short Reserved; VOLATILE unsigned short StateInfo;#endif /* UBS_CRYPTONET_ATTRIBUTE conditional */ VOLATILE unsigned char KeyState[UBSEC_ARC4_KEYSTATE_BYTES];} ARC4_CryptoContext_t, *ARC4_CryptoContext_pt;/* Bit field definitions for state Information */#if (UBS_CPU_ATTRIBUTE == UBS_CRYPTONET_ATTRIBUTE)#define ARC4_STATE_NULL_DATA 0x1000#define ARC4_STATE_WRITEBACK 0x0800#define ARC4_STATE_STATEKEY 0x0400#else#define ARC4_STATE_NULL_DATA 0x0010#define ARC4_STATE_WRITEBACK 0x0008#define ARC4_STATE_STATEKEY 0x0004#endif/* Pure Hash Context */typedef struct Hash_Context_s {#if (UBS_CRYPTONET_ATTRIBUTE == UBS_LITTLE_ENDIAN) VOLATILE unsigned short CryptoFlag; VOLATILE unsigned short Reserved; #else VOLATILE unsigned short Reserved; VOLATILE unsigned short CryptoFlag;#endif /* UBS_CRYPTONET_ATTRIBUTE conditional */} Hash_Context_t, *Hash_Context_pt;#endif /* UBSEC_582x_CLASS_DEVICE *//* * Generic union to encompass all cipher context types */typedef union CryptoContext_u { CipherContext_t Cipher;#ifdef UBSEC_582x_CLASS_DEVICE SSL_HMACContext_t SSL_Mac; TLS_HMACContext_t TLS_HMac; SSL_CryptoContext_t SSL_Crypto; ARC4_CryptoContext_t ARC4_Crypto; Hash_Context_t Hash;#endif} CryptoContext_t, *CryptoContext_pt;typedef struct PacketContextUnaligned_s {#ifdef UBSEC_582x_CLASS_DEVICE#if (UBS_CRYPTONET_ATTRIBUTE == UBS_LITTLE_ENDIAN) VOLATILE unsigned short cmd_structure_length; VOLATILE unsigned short operation_type; #else VOLATILE unsigned short operation_type; VOLATILE unsigned short cmd_structure_length;#endif /* UBS_CRYPTONET_ATTRIBUTE conditional */#endif /* UBSEC_582x_CLASS_DEVICE */ VOLATILE CryptoContext_t Context; VOLATILE UBS_UINT32 PhysicalAddress;} PacketContextUnaligned_t;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -