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