1*0a6a1f1dSLionel Sambuc /* 2*0a6a1f1dSLionel Sambuc * This header declares the necessary definitions for using the 3*0a6a1f1dSLionel Sambuc * exponentiation acceleration capabilities, and rnd number generation of the 4*0a6a1f1dSLionel Sambuc * AEP card. 5ebfedea0SLionel Sambuc */ 6ebfedea0SLionel Sambuc 7ebfedea0SLionel Sambuc /* 8ebfedea0SLionel Sambuc * 9ebfedea0SLionel Sambuc * Some AEP defines 10ebfedea0SLionel Sambuc * 11ebfedea0SLionel Sambuc */ 12ebfedea0SLionel Sambuc 13*0a6a1f1dSLionel Sambuc /* 14*0a6a1f1dSLionel Sambuc * Successful return value 15*0a6a1f1dSLionel Sambuc */ 16ebfedea0SLionel Sambuc #define AEP_R_OK 0x00000000 17ebfedea0SLionel Sambuc 18*0a6a1f1dSLionel Sambuc /* 19*0a6a1f1dSLionel Sambuc * Miscelleanous unsuccessful return value 20*0a6a1f1dSLionel Sambuc */ 21ebfedea0SLionel Sambuc #define AEP_R_GENERAL_ERROR 0x10000001 22ebfedea0SLionel Sambuc 23*0a6a1f1dSLionel Sambuc /* 24*0a6a1f1dSLionel Sambuc * Insufficient host memory 25*0a6a1f1dSLionel Sambuc */ 26ebfedea0SLionel Sambuc #define AEP_R_HOST_MEMORY 0x10000002 27ebfedea0SLionel Sambuc 28ebfedea0SLionel Sambuc #define AEP_R_FUNCTION_FAILED 0x10000006 29ebfedea0SLionel Sambuc 30*0a6a1f1dSLionel Sambuc /* 31*0a6a1f1dSLionel Sambuc * Invalid arguments in function call 32*0a6a1f1dSLionel Sambuc */ 33ebfedea0SLionel Sambuc #define AEP_R_ARGUMENTS_BAD 0x10020000 34ebfedea0SLionel Sambuc 35ebfedea0SLionel Sambuc #define AEP_R_NO_TARGET_RESOURCES 0x10030000 36ebfedea0SLionel Sambuc 37*0a6a1f1dSLionel Sambuc /* 38*0a6a1f1dSLionel Sambuc * Error occuring on socket operation 39*0a6a1f1dSLionel Sambuc */ 40ebfedea0SLionel Sambuc #define AEP_R_SOCKERROR 0x10000010 41ebfedea0SLionel Sambuc 42*0a6a1f1dSLionel Sambuc /* 43*0a6a1f1dSLionel Sambuc * Socket has been closed from the other end 44*0a6a1f1dSLionel Sambuc */ 45ebfedea0SLionel Sambuc #define AEP_R_SOCKEOF 0x10000011 46ebfedea0SLionel Sambuc 47*0a6a1f1dSLionel Sambuc /* 48*0a6a1f1dSLionel Sambuc * Invalid handles 49*0a6a1f1dSLionel Sambuc */ 50ebfedea0SLionel Sambuc #define AEP_R_CONNECTION_HANDLE_INVALID 0x100000B3 51ebfedea0SLionel Sambuc 52ebfedea0SLionel Sambuc #define AEP_R_TRANSACTION_HANDLE_INVALID 0x10040000 53ebfedea0SLionel Sambuc 54*0a6a1f1dSLionel Sambuc /* 55*0a6a1f1dSLionel Sambuc * Transaction has not yet returned from accelerator 56*0a6a1f1dSLionel Sambuc */ 57ebfedea0SLionel Sambuc #define AEP_R_TRANSACTION_NOT_READY 0x00010000 58ebfedea0SLionel Sambuc 59*0a6a1f1dSLionel Sambuc /* 60*0a6a1f1dSLionel Sambuc * There is already a thread waiting on this transaction 61*0a6a1f1dSLionel Sambuc */ 62ebfedea0SLionel Sambuc #define AEP_R_TRANSACTION_CLAIMED 0x10050000 63ebfedea0SLionel Sambuc 64*0a6a1f1dSLionel Sambuc /* 65*0a6a1f1dSLionel Sambuc * The transaction timed out 66*0a6a1f1dSLionel Sambuc */ 67ebfedea0SLionel Sambuc #define AEP_R_TIMED_OUT 0x10060000 68ebfedea0SLionel Sambuc 69ebfedea0SLionel Sambuc #define AEP_R_FXN_NOT_IMPLEMENTED 0x10070000 70ebfedea0SLionel Sambuc 71ebfedea0SLionel Sambuc #define AEP_R_TARGET_ERROR 0x10080000 72ebfedea0SLionel Sambuc 73*0a6a1f1dSLionel Sambuc /* 74*0a6a1f1dSLionel Sambuc * Error in the AEP daemon process 75*0a6a1f1dSLionel Sambuc */ 76ebfedea0SLionel Sambuc #define AEP_R_DAEMON_ERROR 0x10090000 77ebfedea0SLionel Sambuc 78*0a6a1f1dSLionel Sambuc /* 79*0a6a1f1dSLionel Sambuc * Invalid ctx id 80*0a6a1f1dSLionel Sambuc */ 81ebfedea0SLionel Sambuc #define AEP_R_INVALID_CTX_ID 0x10009000 82ebfedea0SLionel Sambuc 83ebfedea0SLionel Sambuc #define AEP_R_NO_KEY_MANAGER 0x1000a000 84ebfedea0SLionel Sambuc 85*0a6a1f1dSLionel Sambuc /* 86*0a6a1f1dSLionel Sambuc * Error obtaining a mutex 87*0a6a1f1dSLionel Sambuc */ 88ebfedea0SLionel Sambuc #define AEP_R_MUTEX_BAD 0x000001A0 89ebfedea0SLionel Sambuc 90*0a6a1f1dSLionel Sambuc /* 91*0a6a1f1dSLionel Sambuc * Fxn call before AEP_Initialise ot after AEP_Finialise 92*0a6a1f1dSLionel Sambuc */ 93ebfedea0SLionel Sambuc #define AEP_R_AEPAPI_NOT_INITIALIZED 0x10000190 94ebfedea0SLionel Sambuc 95*0a6a1f1dSLionel Sambuc /* 96*0a6a1f1dSLionel Sambuc * AEP_Initialise has already been called 97*0a6a1f1dSLionel Sambuc */ 98ebfedea0SLionel Sambuc #define AEP_R_AEPAPI_ALREADY_INITIALIZED 0x10000191 99ebfedea0SLionel Sambuc 100*0a6a1f1dSLionel Sambuc /* 101*0a6a1f1dSLionel Sambuc * Maximum number of connections to daemon reached 102*0a6a1f1dSLionel Sambuc */ 103ebfedea0SLionel Sambuc #define AEP_R_NO_MORE_CONNECTION_HNDLS 0x10000200 104ebfedea0SLionel Sambuc 105ebfedea0SLionel Sambuc /* 106ebfedea0SLionel Sambuc * 107ebfedea0SLionel Sambuc * Some AEP Type definitions 108ebfedea0SLionel Sambuc * 109ebfedea0SLionel Sambuc */ 110ebfedea0SLionel Sambuc 111ebfedea0SLionel Sambuc /* an unsigned 8-bit value */ 112ebfedea0SLionel Sambuc typedef unsigned char AEP_U8; 113ebfedea0SLionel Sambuc 114ebfedea0SLionel Sambuc /* an unsigned 8-bit character */ 115ebfedea0SLionel Sambuc typedef char AEP_CHAR; 116ebfedea0SLionel Sambuc 117ebfedea0SLionel Sambuc /* a BYTE-sized Boolean flag */ 118ebfedea0SLionel Sambuc typedef AEP_U8 AEP_BBOOL; 119ebfedea0SLionel Sambuc 120*0a6a1f1dSLionel Sambuc /* 121*0a6a1f1dSLionel Sambuc * Unsigned value, at least 16 bits long 122*0a6a1f1dSLionel Sambuc */ 123ebfedea0SLionel Sambuc typedef unsigned short AEP_U16; 124ebfedea0SLionel Sambuc 125ebfedea0SLionel Sambuc /* an unsigned value, at least 32 bits long */ 126ebfedea0SLionel Sambuc #ifdef SIXTY_FOUR_BIT_LONG 127ebfedea0SLionel Sambuc typedef unsigned int AEP_U32; 128ebfedea0SLionel Sambuc #else 129ebfedea0SLionel Sambuc typedef unsigned long AEP_U32; 130ebfedea0SLionel Sambuc #endif 131ebfedea0SLionel Sambuc 132ebfedea0SLionel Sambuc #ifdef SIXTY_FOUR_BIT_LONG 133ebfedea0SLionel Sambuc typedef unsigned long AEP_U64; 134ebfedea0SLionel Sambuc #else 135*0a6a1f1dSLionel Sambuc typedef struct { 136*0a6a1f1dSLionel Sambuc unsigned long l1, l2; 137*0a6a1f1dSLionel Sambuc } AEP_U64; 138ebfedea0SLionel Sambuc #endif 139ebfedea0SLionel Sambuc 140ebfedea0SLionel Sambuc /* at least 32 bits; each bit is a Boolean flag */ 141ebfedea0SLionel Sambuc typedef AEP_U32 AEP_FLAGS; 142ebfedea0SLionel Sambuc 143ebfedea0SLionel Sambuc typedef AEP_U8 *AEP_U8_PTR; 144ebfedea0SLionel Sambuc typedef AEP_CHAR *AEP_CHAR_PTR; 145ebfedea0SLionel Sambuc typedef AEP_U32 *AEP_U32_PTR; 146ebfedea0SLionel Sambuc typedef AEP_U64 *AEP_U64_PTR; 147ebfedea0SLionel Sambuc typedef void *AEP_VOID_PTR; 148ebfedea0SLionel Sambuc 149ebfedea0SLionel Sambuc /* Pointer to a AEP_VOID_PTR-- i.e., pointer to pointer to void */ 150ebfedea0SLionel Sambuc typedef AEP_VOID_PTR *AEP_VOID_PTR_PTR; 151ebfedea0SLionel Sambuc 152*0a6a1f1dSLionel Sambuc /* 153*0a6a1f1dSLionel Sambuc * Used to identify an AEP connection handle 154*0a6a1f1dSLionel Sambuc */ 155ebfedea0SLionel Sambuc typedef AEP_U32 AEP_CONNECTION_HNDL; 156ebfedea0SLionel Sambuc 157*0a6a1f1dSLionel Sambuc /* 158*0a6a1f1dSLionel Sambuc * Pointer to an AEP connection handle 159*0a6a1f1dSLionel Sambuc */ 160ebfedea0SLionel Sambuc typedef AEP_CONNECTION_HNDL *AEP_CONNECTION_HNDL_PTR; 161ebfedea0SLionel Sambuc 162*0a6a1f1dSLionel Sambuc /* 163*0a6a1f1dSLionel Sambuc * Used by an application (in conjunction with the apps process id) to 164*0a6a1f1dSLionel Sambuc * identify an individual transaction 165*0a6a1f1dSLionel Sambuc */ 166ebfedea0SLionel Sambuc typedef AEP_U32 AEP_TRANSACTION_ID; 167ebfedea0SLionel Sambuc 168*0a6a1f1dSLionel Sambuc /* 169*0a6a1f1dSLionel Sambuc * Pointer to an applications transaction identifier 170*0a6a1f1dSLionel Sambuc */ 171ebfedea0SLionel Sambuc typedef AEP_TRANSACTION_ID *AEP_TRANSACTION_ID_PTR; 172ebfedea0SLionel Sambuc 173*0a6a1f1dSLionel Sambuc /* 174*0a6a1f1dSLionel Sambuc * Return value type 175*0a6a1f1dSLionel Sambuc */ 176ebfedea0SLionel Sambuc typedef AEP_U32 AEP_RV; 177ebfedea0SLionel Sambuc 178ebfedea0SLionel Sambuc #define MAX_PROCESS_CONNECTIONS 256 179ebfedea0SLionel Sambuc 180ebfedea0SLionel Sambuc #define RAND_BLK_SIZE 1024 181ebfedea0SLionel Sambuc 182ebfedea0SLionel Sambuc typedef enum { 183ebfedea0SLionel Sambuc NotConnected = 0, 184ebfedea0SLionel Sambuc Connected = 1, 185ebfedea0SLionel Sambuc InUse = 2 186ebfedea0SLionel Sambuc } AEP_CONNECTION_STATE; 187ebfedea0SLionel Sambuc 188ebfedea0SLionel Sambuc typedef struct AEP_CONNECTION_ENTRY { 189ebfedea0SLionel Sambuc AEP_CONNECTION_STATE conn_state; 190ebfedea0SLionel Sambuc AEP_CONNECTION_HNDL conn_hndl; 191ebfedea0SLionel Sambuc } AEP_CONNECTION_ENTRY; 192ebfedea0SLionel Sambuc 193ebfedea0SLionel Sambuc typedef AEP_RV t_AEP_OpenConnection(AEP_CONNECTION_HNDL_PTR phConnection); 194ebfedea0SLionel Sambuc typedef AEP_RV t_AEP_CloseConnection(AEP_CONNECTION_HNDL hConnection); 195ebfedea0SLionel Sambuc 196ebfedea0SLionel Sambuc typedef AEP_RV t_AEP_ModExp(AEP_CONNECTION_HNDL hConnection, 197ebfedea0SLionel Sambuc AEP_VOID_PTR pA, AEP_VOID_PTR pP, 198ebfedea0SLionel Sambuc AEP_VOID_PTR pN, 199ebfedea0SLionel Sambuc AEP_VOID_PTR pResult, 200ebfedea0SLionel Sambuc AEP_TRANSACTION_ID *pidTransID); 201ebfedea0SLionel Sambuc 202ebfedea0SLionel Sambuc typedef AEP_RV t_AEP_ModExpCrt(AEP_CONNECTION_HNDL hConnection, 203ebfedea0SLionel Sambuc AEP_VOID_PTR pA, AEP_VOID_PTR pP, 204ebfedea0SLionel Sambuc AEP_VOID_PTR pQ, 205ebfedea0SLionel Sambuc AEP_VOID_PTR pDmp1, AEP_VOID_PTR pDmq1, 206ebfedea0SLionel Sambuc AEP_VOID_PTR pIqmp, 207ebfedea0SLionel Sambuc AEP_VOID_PTR pResult, 208ebfedea0SLionel Sambuc AEP_TRANSACTION_ID *pidTransID); 209ebfedea0SLionel Sambuc 210ebfedea0SLionel Sambuc #ifdef AEPRAND 211ebfedea0SLionel Sambuc typedef AEP_RV t_AEP_GenRandom(AEP_CONNECTION_HNDL hConnection, 212ebfedea0SLionel Sambuc AEP_U32 Len, 213ebfedea0SLionel Sambuc AEP_U32 Type, 214ebfedea0SLionel Sambuc AEP_VOID_PTR pResult, 215ebfedea0SLionel Sambuc AEP_TRANSACTION_ID *pidTransID); 216ebfedea0SLionel Sambuc #endif 217ebfedea0SLionel Sambuc 218ebfedea0SLionel Sambuc typedef AEP_RV t_AEP_Initialize(AEP_VOID_PTR pInitArgs); 219ebfedea0SLionel Sambuc typedef AEP_RV t_AEP_Finalize(void); 220*0a6a1f1dSLionel Sambuc typedef AEP_RV t_AEP_SetBNCallBacks(AEP_RV (*GetBigNumSizeFunc) 221*0a6a1f1dSLionel Sambuc (AEP_VOID_PTR ArbBigNum, 222*0a6a1f1dSLionel Sambuc AEP_U32 *BigNumSize), 223*0a6a1f1dSLionel Sambuc AEP_RV (*MakeAEPBigNumFunc) (AEP_VOID_PTR 224*0a6a1f1dSLionel Sambuc ArbBigNum, 225*0a6a1f1dSLionel Sambuc AEP_U32 226*0a6a1f1dSLionel Sambuc BigNumSize, 227*0a6a1f1dSLionel Sambuc unsigned char 228*0a6a1f1dSLionel Sambuc *AEP_BigNum), 229*0a6a1f1dSLionel Sambuc AEP_RV (*ConverAEPBigNumFunc) (void 230*0a6a1f1dSLionel Sambuc *ArbBigNum, 231*0a6a1f1dSLionel Sambuc AEP_U32 232*0a6a1f1dSLionel Sambuc BigNumSize, 233*0a6a1f1dSLionel Sambuc unsigned 234*0a6a1f1dSLionel Sambuc char 235*0a6a1f1dSLionel Sambuc *AEP_BigNum)); 236