Remove building with NOCRYPTO option
[minix.git] / crypto / external / bsd / openssl / dist / engines / vendor_defns / sureware.h
blobb1423e19797d78b937e1cb5593fae712553fedab
1 /*-
2 * Written by Corinne Dive-Reclus(cdive@baltimore.com)
4 * Copyright@2001 Baltimore Technologies Ltd.
6 * THIS FILE IS PROVIDED BY BALTIMORE TECHNOLOGIES ``AS IS'' AND
7 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9 * ARE DISCLAIMED. IN NO EVENT SHALL BALTIMORE TECHNOLOGIES BE LIABLE
10 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
11 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
12 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
14 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
15 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
16 * SUCH DAMAGE.
19 #ifdef WIN32
20 # define SW_EXPORT __declspec ( dllexport )
21 #else
22 # define SW_EXPORT
23 #endif
26 * List of exposed SureWare errors
28 #define SUREWAREHOOK_ERROR_FAILED -1
29 #define SUREWAREHOOK_ERROR_FALLBACK -2
30 #define SUREWAREHOOK_ERROR_UNIT_FAILURE -3
31 #define SUREWAREHOOK_ERROR_DATA_SIZE -4
32 #define SUREWAREHOOK_ERROR_INVALID_PAD -5
33 /*-
34 * -----------------WARNING-----------------------------------
35 * In all the following functions:
36 * msg is a string with at least 24 bytes free.
37 * A 24 bytes string will be concatenated to the existing content of msg.
39 /*-
40 * SureWare Initialisation function
41 * in param threadsafe, if !=0, thread safe enabled
42 * return SureWareHOOK_ERROR_UNIT_FAILURE if failure, 1 if success
44 typedef int SureWareHook_Init_t(char *const msg, int threadsafe);
45 extern SW_EXPORT SureWareHook_Init_t SureWareHook_Init;
46 /*-
47 * SureWare Finish function
49 typedef void SureWareHook_Finish_t(void);
50 extern SW_EXPORT SureWareHook_Finish_t SureWareHook_Finish;
51 /*-
52 * PRE_CONDITION:
53 * DO NOT CALL ANY OF THE FOLLOWING FUNCTIONS IN CASE OF INIT FAILURE
55 /*-
56 * SureWare RAND Bytes function
57 * In case of failure, the content of buf is unpredictable.
58 * return 1 if success
59 * SureWareHOOK_ERROR_FALLBACK if function not available in hardware
60 * SureWareHOOK_ERROR_FAILED if error while processing
61 * SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
62 * SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
64 * in/out param buf : a num bytes long buffer where random bytes will be put
65 * in param num : the number of bytes into buf
67 typedef int SureWareHook_Rand_Bytes_t(char *const msg, unsigned char *buf,
68 int num);
69 extern SW_EXPORT SureWareHook_Rand_Bytes_t SureWareHook_Rand_Bytes;
71 /*-
72 * SureWare RAND Seed function
73 * Adds some seed to the Hardware Random Number Generator
74 * return 1 if success
75 * SureWareHOOK_ERROR_FALLBACK if function not available in hardware
76 * SureWareHOOK_ERROR_FAILED if error while processing
77 * SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
78 * SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
80 * in param buf : the seed to add into the HRNG
81 * in param num : the number of bytes into buf
83 typedef int SureWareHook_Rand_Seed_t(char *const msg, const void *buf,
84 int num);
85 extern SW_EXPORT SureWareHook_Rand_Seed_t SureWareHook_Rand_Seed;
87 /*-
88 * SureWare Load Private Key function
89 * return 1 if success
90 * SureWareHOOK_ERROR_FAILED if error while processing
91 * No hardware is contact for this function.
93 * in param key_id :the name of the private protected key file without the extension
94 ".sws"
95 * out param hptr : a pointer to a buffer allocated by SureWare_Hook
96 * out param num: the effective key length in bytes
97 * out param keytype: 1 if RSA 2 if DSA
99 typedef int SureWareHook_Load_Privkey_t(char *const msg, const char *key_id,
100 char **hptr, unsigned long *num,
101 char *keytype);
102 extern SW_EXPORT SureWareHook_Load_Privkey_t SureWareHook_Load_Privkey;
105 * SureWare Info Public Key function
106 * return 1 if success
107 * SureWareHOOK_ERROR_FAILED if error while processing
108 * No hardware is contact for this function.
110 * in param key_id :the name of the private protected key file without the extension
111 ".swp"
112 * out param hptr : a pointer to a buffer allocated by SureWare_Hook
113 * out param num: the effective key length in bytes
114 * out param keytype: 1 if RSA 2 if DSA
116 typedef int SureWareHook_Info_Pubkey_t(char *const msg, const char *key_id,
117 unsigned long *num, char *keytype);
118 extern SW_EXPORT SureWareHook_Info_Pubkey_t SureWareHook_Info_Pubkey;
121 * SureWare Load Public Key function
122 * return 1 if success
123 * SureWareHOOK_ERROR_FAILED if error while processing
124 * No hardware is contact for this function.
126 * in param key_id :the name of the public protected key file without the extension
127 ".swp"
128 * in param num : the bytes size of n and e
129 * out param n: where to write modulus in bn format
130 * out param e: where to write exponent in bn format
132 typedef int SureWareHook_Load_Rsa_Pubkey_t(char *const msg,
133 const char *key_id,
134 unsigned long num,
135 unsigned long *n,
136 unsigned long *e);
137 extern SW_EXPORT SureWareHook_Load_Rsa_Pubkey_t SureWareHook_Load_Rsa_Pubkey;
140 * SureWare Load DSA Public Key function
141 * return 1 if success
142 * SureWareHOOK_ERROR_FAILED if error while processing
143 * No hardware is contact for this function.
145 * in param key_id :the name of the public protected key file without the extension
146 ".swp"
147 * in param num : the bytes size of n and e
148 * out param pub: where to write pub key in bn format
149 * out param p: where to write prime in bn format
150 * out param q: where to write sunprime (length 20 bytes) in bn format
151 * out param g: where to write base in bn format
153 typedef int SureWareHook_Load_Dsa_Pubkey_t(char *const msg,
154 const char *key_id,
155 unsigned long num,
156 unsigned long *pub,
157 unsigned long *p, unsigned long *q,
158 unsigned long *g);
159 extern SW_EXPORT SureWareHook_Load_Dsa_Pubkey_t SureWareHook_Load_Dsa_Pubkey;
162 * SureWare Free function
163 * Destroy the key into the hardware if destroy==1
165 typedef void SureWareHook_Free_t(char *p, int destroy);
166 extern SW_EXPORT SureWareHook_Free_t SureWareHook_Free;
168 #define SUREWARE_PKCS1_PAD 1
169 #define SUREWARE_ISO9796_PAD 2
170 #define SUREWARE_NO_PAD 0
172 * SureWare RSA Private Decryption
173 * return 1 if success
174 * SureWareHOOK_ERROR_FAILED if error while processing
175 * SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
176 * SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
178 * in param flen : byte size of from and to
179 * in param from : encrypted data buffer, should be a not-null valid pointer
180 * out param tlen: byte size of decrypted data, if error, unexpected value
181 * out param to : decrypted data buffer, should be a not-null valid pointer
182 * in param prsa: a protected key pointer, should be a not-null valid pointer
183 * int padding: padding id as follow
184 * SUREWARE_PKCS1_PAD
185 * SUREWARE_NO_PAD
188 typedef int SureWareHook_Rsa_Priv_Dec_t(char *const msg, int flen,
189 unsigned char *from, int *tlen,
190 unsigned char *to, char *prsa,
191 int padding);
192 extern SW_EXPORT SureWareHook_Rsa_Priv_Dec_t SureWareHook_Rsa_Priv_Dec;
194 * SureWare RSA Signature
195 * return 1 if success
196 * SureWareHOOK_ERROR_FAILED if error while processing
197 * SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
198 * SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
200 * in param flen : byte size of from and to
201 * in param from : encrypted data buffer, should be a not-null valid pointer
202 * out param tlen: byte size of decrypted data, if error, unexpected value
203 * out param to : decrypted data buffer, should be a not-null valid pointer
204 * in param prsa: a protected key pointer, should be a not-null valid pointer
205 * int padding: padding id as follow
206 * SUREWARE_PKCS1_PAD
207 * SUREWARE_ISO9796_PAD
210 typedef int SureWareHook_Rsa_Sign_t(char *const msg, int flen,
211 unsigned char *from, int *tlen,
212 unsigned char *to, char *prsa,
213 int padding);
214 extern SW_EXPORT SureWareHook_Rsa_Sign_t SureWareHook_Rsa_Sign;
216 * SureWare DSA Signature
217 * return 1 if success
218 * SureWareHOOK_ERROR_FAILED if error while processing
219 * SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
220 * SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
222 * in param flen : byte size of from and to
223 * in param from : encrypted data buffer, should be a not-null valid pointer
224 * out param to : decrypted data buffer, should be a 40bytes valid pointer
225 * in param pdsa: a protected key pointer, should be a not-null valid pointer
228 typedef int SureWareHook_Dsa_Sign_t(char *const msg, int flen,
229 const unsigned char *from,
230 unsigned long *r, unsigned long *s,
231 char *pdsa);
232 extern SW_EXPORT SureWareHook_Dsa_Sign_t SureWareHook_Dsa_Sign;
235 * SureWare Mod Exp
236 * return 1 if success
237 * SureWareHOOK_ERROR_FAILED if error while processing
238 * SureWareHOOK_ERROR_UNIT_FAILURE if hardware failure
239 * SUREWAREHOOK_ERROR_DATA_SIZE wrong size for buf
241 * mod and res are mlen bytes long.
242 * exp is elen bytes long
243 * data is dlen bytes long
244 * mlen,elen and dlen are all multiple of sizeof(unsigned long)
246 typedef int SureWareHook_Mod_Exp_t(char *const msg, int mlen,
247 const unsigned long *mod, int elen,
248 const unsigned long *exponent, int dlen,
249 unsigned long *data, unsigned long *res);
250 extern SW_EXPORT SureWareHook_Mod_Exp_t SureWareHook_Mod_Exp;