]> git.ipfire.org Git - thirdparty/openssl.git/blame - engines/vendor_defns/sureware.h
Run util/openssl-format-source -v -c .
[thirdparty/openssl.git] / engines / vendor_defns / sureware.h
CommitLineData
6977c7e2
TH
1/*-
2 * Written by Corinne Dive-Reclus(cdive@baltimore.com)
3 *
4 * Copyright@2001 Baltimore Technologies Ltd.
5 *
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.
17 */
18
2eaabb71 19#ifdef WIN32
ae5c8664 20# define SW_EXPORT __declspec ( dllexport )
2eaabb71 21#else
ae5c8664 22# define SW_EXPORT
2eaabb71
RL
23#endif
24
25/*
ae5c8664
MC
26 * List of exposed SureWare errors
27 */
28#define SUREWAREHOOK_ERROR_FAILED -1
29#define SUREWAREHOOK_ERROR_FALLBACK -2
2eaabb71
RL
30#define SUREWAREHOOK_ERROR_UNIT_FAILURE -3
31#define SUREWAREHOOK_ERROR_DATA_SIZE -4
32#define SUREWAREHOOK_ERROR_INVALID_PAD -5
6977c7e2 33/*-
2eaabb71
RL
34* -----------------WARNING-----------------------------------
35* In all the following functions:
36* msg is a string with at least 24 bytes free.
ae5c8664 37* A 24 bytes string will be concatenated to the existing content of msg.
2eaabb71 38*/
6977c7e2 39/*-
ae5c8664
MC
40* SureWare Initialisation function
41* in param threadsafe, if !=0, thread safe enabled
42* return SureWareHOOK_ERROR_UNIT_FAILURE if failure, 1 if success
2eaabb71 43*/
ae5c8664 44typedef int SureWareHook_Init_t(char *const msg, int threadsafe);
2eaabb71 45extern SW_EXPORT SureWareHook_Init_t SureWareHook_Init;
6977c7e2 46/*-
ae5c8664 47* SureWare Finish function
2eaabb71 48*/
41a15c4f 49typedef void SureWareHook_Finish_t(void);
2eaabb71 50extern SW_EXPORT SureWareHook_Finish_t SureWareHook_Finish;
6977c7e2 51/*-
ae5c8664
MC
52* PRE_CONDITION:
53* DO NOT CALL ANY OF THE FOLLOWING FUNCTIONS IN CASE OF INIT FAILURE
2eaabb71 54*/
6977c7e2 55/*-
ae5c8664
MC
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
2eaabb71 63*
ae5c8664
MC
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
2eaabb71 66*/
ae5c8664
MC
67typedef int SureWareHook_Rand_Bytes_t(char *const msg, unsigned char *buf,
68 int num);
2eaabb71
RL
69extern SW_EXPORT SureWareHook_Rand_Bytes_t SureWareHook_Rand_Bytes;
70
6977c7e2 71/*-
ae5c8664
MC
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
2eaabb71 79*
ae5c8664
MC
80* in param buf : the seed to add into the HRNG
81* in param num : the number of bytes into buf
2eaabb71 82*/
ae5c8664
MC
83typedef int SureWareHook_Rand_Seed_t(char *const msg, const void *buf,
84 int num);
2eaabb71
RL
85extern SW_EXPORT SureWareHook_Rand_Seed_t SureWareHook_Rand_Seed;
86
6977c7e2 87/*-
ae5c8664
MC
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.
2eaabb71 92*
ae5c8664
MC
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
98*/
99typedef int SureWareHook_Load_Privkey_t(char *const msg, const char *key_id,
100 char **hptr, unsigned long *num,
101 char *keytype);
2eaabb71
RL
102extern SW_EXPORT SureWareHook_Load_Privkey_t SureWareHook_Load_Privkey;
103
6977c7e2 104/*-
ae5c8664
MC
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.
2eaabb71 109*
ae5c8664
MC
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
115*/
116typedef int SureWareHook_Info_Pubkey_t(char *const msg, const char *key_id,
117 unsigned long *num, char *keytype);
2eaabb71
RL
118extern SW_EXPORT SureWareHook_Info_Pubkey_t SureWareHook_Info_Pubkey;
119
6977c7e2 120/*-
ae5c8664
MC
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.
2eaabb71 125*
ae5c8664
MC
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
131*/
132typedef 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);
2eaabb71
RL
137extern SW_EXPORT SureWareHook_Load_Rsa_Pubkey_t SureWareHook_Load_Rsa_Pubkey;
138
6977c7e2 139/*-
ae5c8664
MC
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.
2eaabb71 144*
ae5c8664
MC
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
152*/
153typedef 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);
2eaabb71
RL
159extern SW_EXPORT SureWareHook_Load_Dsa_Pubkey_t SureWareHook_Load_Dsa_Pubkey;
160
6977c7e2 161/*-
ae5c8664
MC
162* SureWare Free function
163* Destroy the key into the hardware if destroy==1
2eaabb71 164*/
ae5c8664 165typedef void SureWareHook_Free_t(char *p, int destroy);
2eaabb71
RL
166extern SW_EXPORT SureWareHook_Free_t SureWareHook_Free;
167
168#define SUREWARE_PKCS1_PAD 1
169#define SUREWARE_ISO9796_PAD 2
170#define SUREWARE_NO_PAD 0
6977c7e2 171/*-
2eaabb71
RL
172* SureWare RSA Private Decryption
173* return 1 if success
ae5c8664
MC
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
2eaabb71 177*
ae5c8664
MC
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
2eaabb71
RL
182* in param prsa: a protected key pointer, should be a not-null valid pointer
183* int padding: padding id as follow
ae5c8664
MC
184* SUREWARE_PKCS1_PAD
185* SUREWARE_NO_PAD
2eaabb71
RL
186*
187*/
ae5c8664
MC
188typedef 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);
2eaabb71 192extern SW_EXPORT SureWareHook_Rsa_Priv_Dec_t SureWareHook_Rsa_Priv_Dec;
6977c7e2 193/*-
2eaabb71
RL
194* SureWare RSA Signature
195* return 1 if success
ae5c8664
MC
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
2eaabb71 199*
ae5c8664
MC
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
2eaabb71
RL
204* in param prsa: a protected key pointer, should be a not-null valid pointer
205* int padding: padding id as follow
ae5c8664
MC
206* SUREWARE_PKCS1_PAD
207* SUREWARE_ISO9796_PAD
2eaabb71
RL
208*
209*/
ae5c8664
MC
210typedef 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);
2eaabb71 214extern SW_EXPORT SureWareHook_Rsa_Sign_t SureWareHook_Rsa_Sign;
6977c7e2 215/*-
2eaabb71
RL
216* SureWare DSA Signature
217* return 1 if success
ae5c8664
MC
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
2eaabb71 221*
ae5c8664
MC
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
2eaabb71
RL
225* in param pdsa: a protected key pointer, should be a not-null valid pointer
226*
227*/
ae5c8664
MC
228typedef 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);
2eaabb71
RL
232extern SW_EXPORT SureWareHook_Dsa_Sign_t SureWareHook_Dsa_Sign;
233
6977c7e2 234/*-
2eaabb71
RL
235* SureWare Mod Exp
236* return 1 if success
ae5c8664
MC
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
2eaabb71 240*
ae5c8664
MC
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)
245*/
246typedef 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);
2eaabb71 250extern SW_EXPORT SureWareHook_Mod_Exp_t SureWareHook_Mod_Exp;