aep.h 6.5 KB

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