ubsec.h
来自「这个linux源代码是很全面的~基本完整了~使用c编译的~由于时间问题我没有亲自」· C头文件 代码 · 共 711 行 · 第 1/2 页
H
711 行
/* * 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 *//* * ubsec.h: Interface functions and defintions for the ubsec Software Reference * library. * * This file should be included by any files using the UBSEC 5501 SRL *//* * Revision History: * * Oct 99 SOR Created. * Sep 00 SOR 5820 Support Added. * Jul 01 RJT 5821 Support Added (1.2a) * Oct 01 SRM 64 bit port. */#ifndef _UBSEC_H_#define _UBSEC_H_#include "ubslinux.h"/* * Device_Context is handle for all ubsec device operations. It * is assigned at initialization time. */typedef void *ubsec_DeviceContext_t, **ubsec_DeviceContext_pt;#ifdef PAD_ALIGN64_APP32#define PADIT(name,size) char name[size];#else#define PADIT(name,size)#endif#include "ubssys.h"/* * List of Vendor/Device IDs supported by the library. */#define BROADCOM_VENDOR_ID 0x14e4 /* Broadcom vendor ID */#define BROADCOM_DEVICE_ID_5801 0x5801 /* Release board. */#define BROADCOM_DEVICE_ID_5802 0x5802 /* Release board. */#define BROADCOM_DEVICE_ID_5805 0x5805 /* Release board */#define BROADCOM_DEVICE_ID_5820 0x5820 /* Release board */#define BROADCOM_DEVICE_ID_5821 0x5821 /* Release board */#define BROADCOM_DEVICE_ID_5822 0x5822 /* Release board *//* Macro to determine device type based on deviceID */#define UBSEC_IS_CRYPTO_DEVICEID(DeviceID) ((DeviceID) == BROADCOM_DEVICE_ID_5801)/* * Version of the SRL. */#define UBSEC_VERSION_MAJOR 0x1#define UBSEC_VERSION_MINOR 0x4#define UBSEC_VERSION_REV ' ' /* Single alphanumeric character, start with blank, then a,b,c... *//* * Cryptographic parameter definitions */#define UBSEC_DES_KEY_LENGTH 2 /* long */#define UBSEC_3DES_KEY_LENGTH 6 /* long */#define UBSEC_MAX_CRYPT_KEY_LENGTH UBSEC_3DES_KEY_LENGTH#define UBSEC_IV_LENGTH 2 /* long */#define UBSEC_IV_LENGTH_BYTES 8#define UBSEC_MAC_KEY_LENGTH 64 /* Bytes */#define UBSEC_MD5_LENGTH 16 /* Bytes */#define UBSEC_SHA1_LENGTH 20 /* Bytes */#define UBSEC_HMAC_LENGTH 20 /* Max of MD5/SHA1 *//* * HMAC State type defines the current (inner/outer) * Hash state values. */typedef struct ubsec_HMAC_State_s { unsigned char InnerState[UBSEC_HMAC_LENGTH]; unsigned char OuterState[UBSEC_HMAC_LENGTH];} ubsec_HMAC_State_t, *ubsec_HMAC_State_pt;typedef unsigned char* ubsec_MemAddress_t;/* * Generic Fragment information type. Length * and physical address of fragment defined * here. */typedef struct ubsec_FragmentInfo_s { int FragmentLength; /* Length of the fragment. */ PADIT(FragmentAddress_pad,8) ubsec_MemAddress_t FragmentAddress; /* Virtual or Physical address */} ubsec_FragmentInfo_t, *ubsec_FragmentInfo_pt;/* * HMAC Block type. Used to generate a HMAC state which is * passed to the API. */typedef unsigned char ubsec_HMAC_Block_t[UBSEC_MAC_KEY_LENGTH],*ubsec_HMAC_Block_pt;/* * HMAC Block type. Used to generate a HMAC state which is * passed to the API. */typedef unsigned char ubsec_HMAC_Key_t[UBSEC_MAC_KEY_LENGTH],*ubsec_HMAC_Key_pt;/* * Initial Vector type for CBC operations. */typedef long ubsec_IV_t[UBSEC_IV_LENGTH], *ubsec_IV_pt;/* * DES Key type definitions. *//* Single DES Crypt key type. 3DES operation used 3 of these. */typedef long ubsec_CryptKey_t[UBSEC_DES_KEY_LENGTH], *ubsec_CryptKey_pt;/* Cipher command type defines Cipher/Authentication operation. */typedef long ubsec_CipherCommand_t;/* Status code is used by the SRL to indicate status */typedef long ubsec_Status_t;/* * Cipher command struture defines the parameters of a cipher * command, its input and output data areas along with the * context. */typedef struct ubsec_CipherCommandInfo_s { ubsec_CipherCommand_t Command; /* Operation(s) to perform */ ubsec_IV_pt InitialVector; /* IV for CBC operation. */ ubsec_CryptKey_pt CryptKey; /* For CBC operation. */ ubsec_HMAC_State_pt HMACState; /* Initialized HMAC state for authentication. */ unsigned NumSource; /* Number of source fragments. */ ubsec_FragmentInfo_pt SourceFragments; /* Source fragment list */ UBS_UINT32 NumDestination; /* Number of Destination fragments. */ ubsec_FragmentInfo_pt DestinationFragments; /* Destination fragment list */ ubsec_FragmentInfo_t AuthenticationInfo; /* Authentication output location . */ unsigned short CryptHeaderSkip; /* Size of crypt header to skip. */ void(*CompletionCallback)(unsigned long Context,ubsec_Status_t Result); /* Callback routine on completion. */ unsigned long CommandContext; /* Context (ID) of this command). */ } ubsec_CipherCommandInfo_t,*ubsec_CipherCommandInfo_pt;/* * Cipher Command subtype flags. */#define UBSEC_ENCODE 1#define UBSEC_DECODE 2#define UBSEC_3DES 4#define UBSEC_DES 8#define UBSEC_MAC_MD5 16#define UBSEC_MAC_SHA1 32/* * Command field definitions. */#define UBSEC_ENCODE_3DES (UBSEC_ENCODE+UBSEC_3DES)#define UBSEC_DECODE_3DES (UBSEC_DECODE+UBSEC_3DES)#define UBSEC_ENCODE_DES (UBSEC_ENCODE+UBSEC_DES)#define UBSEC_DECODE_DES (UBSEC_DECODE+UBSEC_DES)#define UBSEC_ENCODE_3DES_MD5 (UBSEC_ENCODE_3DES+UBSEC_MAC_MD5)#define UBSEC_DECODE_3DES_MD5 (UBSEC_DECODE_3DES+UBSEC_MAC_MD5)#define UBSEC_ENCODE_3DES_SHA1 (UBSEC_ENCODE_3DES+UBSEC_MAC_SHA1)#define UBSEC_DECODE_3DES_SHA1 (UBSEC_DECODE_3DES+UBSEC_MAC_SHA1)#define UBSEC_ENCODE_DES_MD5 (UBSEC_ENCODE_DES+UBSEC_MAC_MD5)#define UBSEC_DECODE_DES_MD5 (UBSEC_DECODE_DES+UBSEC_MAC_MD5)#define UBSEC_ENCODE_DES_SHA1 (UBSEC_ENCODE_DES+UBSEC_MAC_SHA1)#define UBSEC_DECODE_DES_SHA1 (UBSEC_DECODE_DES+UBSEC_MAC_SHA1)#define UBSEC_USING_CRYPT(f) ( (f) & (UBSEC_3DES | UBSEC_DES) )#define UBSEC_USING_MAC(f) ( (f) & (UBSEC_MAC_MD5 | UBSEC_MAC_SHA1) )/* * Status codes */#define UBSEC_STATUS_SUCCESS 0#define UBSEC_STATUS_NO_DEVICE -1#define UBSEC_STATUS_TIMEOUT -2#define UBSEC_STATUS_INVALID_PARAMETER -3#define UBSEC_STATUS_DEVICE_FAILED -4#define UBSEC_STATUS_DEVICE_BUSY -5#define UBSEC_STATUS_NO_RESOURCE -6#define UBSEC_STATUS_CANCELLED -7 /* * SRL API function prototypes. */#ifndef OS_DeviceInfo_t#define OS_DeviceInfo_t void *#endif#ifndef OS_MemHandle_t#define OS_MemHandle_t void *#endif#ifndef UBSECAPI#define UBSECAPI#endif /* Initialize the device */UBSECAPI ubsec_Status_tubsec_InitDevice(unsigned short DeviceID, unsigned long BaseAddress, unsigned int irq, unsigned int CipherPipeLineDepth, unsigned int KeyPipeLineDepth, ubsec_DeviceContext_pt Context, OS_DeviceInfo_t OSContext);/* * Perform self test of device. */UBSECAPI ubsec_Status_tubsec_TestCryptoDevice(ubsec_DeviceContext_t Context,void(*CompletionCallback)(unsigned long PacketContext,ubsec_Status_t Result),unsigned long CompletionContext);UBSECAPI ubsec_Status_tubsec_TestKeyDevice(ubsec_DeviceContext_t Context,void(*CompletionCallback)(unsigned long PacketContext,ubsec_Status_t Result),unsigned long CompletionContext); /* Reset the device */UBSECAPI ubsec_Status_tubsec_ResetDevice( ubsec_DeviceContext_t Context); /* Shutdown the device. */UBSECAPI ubsec_Status_tubsec_ShutdownDevice( ubsec_DeviceContext_t Context); /* Enable device interrupts */ubsec_Status_tubsec_EnableInterrupt( ubsec_DeviceContext_t Context); /* Disable device interrupts */unsigned longubsec_DisableInterrupt( ubsec_DeviceContext_t Context); /* Poll device for completion of commands */ubsec_Status_tubsec_PollDevice( ubsec_DeviceContext_t Context); /* Cipher command execute function. */UBSECAPI ubsec_Status_tubsec_CipherCommand(ubsec_DeviceContext_t Context, ubsec_CipherCommandInfo_pt command, int *NumCommands); /* Initialize HMAC state */UBSECAPI ubsec_Status_tubsec_InitHMACState(ubsec_HMAC_State_pt HMAC_State, ubsec_CipherCommand_t type, ubsec_HMAC_Key_pt Key) ;/* ISR functions are here to allow direct call by the wrapper. */UBSECAPI long ubsec_ISR(ubsec_DeviceContext_t Context);UBSECAPI void ubsec_ISRCallback(ubsec_DeviceContext_t Context);/* * * Public key operational definitions. * *//* * The long key type is used as a generic type to hold public * key information. * KeyValue points to an array of 32-bit integers. The convention of these keys * is such that element[0] of this array holds the least significant part of * the total "key" (multi-precision integer). * Keylength holds the number of significant bits in the key, i.e. the bit * position of the most significant "1" bit, plus 1. * For example, the multi-precision integer ("key") * 0x0102030405060708090A0B0C0D0E0F00 * has 121 significant bits (KeyLength), and would be arranged in the N-element * array (pointed to by KeyLength) of 32-bit integers as * array[0] = 0x0D0E0F00 * array[1] = 0x090A0B0C * array[2] = 0x05060708 * array[3] = 0x01020304 * array[4] = 0x00000000 * ... * array[N-1] = 0x00000000 */typedef struct ubsec_LongKey_s { UBS_UINT32 KeyLength; /* length in bits */ PADIT(KeyValue_pad,8) OS_MemHandle_t KeyValue; /* pointer to 32-bit integer "key" array */} ubsec_LongKey_t,*ubsec_LongKey_pt;/* * Diffie-Hellman parameter type definition. */typedef struct ubsec_DH_Params_t { ubsec_LongKey_t Y; /* Public value, in (UBSEC_DH_SHARED), out (UBSEC_DH_PUBLIC) */ ubsec_LongKey_t X; /* Secret value, in (UBSEC_DH_SHARED), out (UBSEC_DH_PUBLIC) */ ubsec_LongKey_t K; /* Shared secret value, out (UBSEC_DH_SHARED) */ ubsec_LongKey_t N; /* Modulus, in (UBSEC_DH_SHARED), out (UBSEC_DH_PUBLIC) */ ubsec_LongKey_t G; /* Generator, in (UBSEC_DH_PUBLIC) */ ubsec_LongKey_t UserX; /* Optional user supplied secret value, in (UBSEC_DH_PUBLIC) */ unsigned short RandomKeyLen; /* Random key length*/ unsigned short RNGEnable; /* Generate random secret value if set, ignore user supplied. */} ubsec_DH_Params_t,*ubsec_DH_Params_pt;/* * RSA parameter type definition. */typedef struct ubsec_RSA_Params_t { ubsec_LongKey_t OutputKeyInfo; /* Output data. */ ubsec_LongKey_t InputKeyInfo; /* Input data. */ ubsec_LongKey_t ModN; /* Modulo N value to be applied */ ubsec_LongKey_t ExpE; /* BaseG value to be applied. */ ubsec_LongKey_t PrimeP; /* Prime P value */ ubsec_LongKey_t PrimeQ; /* Prime Q value */ ubsec_LongKey_t PrimeEdp; /* Private exponent edp. */ ubsec_LongKey_t PrimeEdq; /* Private exponent edq. */ ubsec_LongKey_t Pinv; /* Pinv value. */} ubsec_RSA_Params_t,*ubsec_RSA_Params_pt;/* * DSA parameter type definition.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?