5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2007 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
20 /****h* silcskr/SILC Accelerator Interface
29 /****s* silcacc/SilcAccAPI/SilcAccelerator
33 * typedef struct SilcAcceleratorObject { ... }
34 * *SilcAccelerator, SilcAcceleratorStruct;
38 * The accelerator context. This is given as argument to silc_acc_register
39 * when registering new accelerator, and it is given as argument to all
40 * other silc_acc_* functions. Registered accelerator context can be
41 * retrieved by calling silc_acc_find.
44 typedef struct SilcAcceleratorObject {
45 const char *name; /* Accelerator's name */
46 SilcBool (*init)(SilcSchedule schedule,
47 va_list va); /* Initialize accelerator */
48 SilcBool (*uninit)(void); /* Uninitialize accelerator */
49 const SilcPKCSAlgorithm *pkcs; /* Accelerated PKCS algorithms */
51 const SilcDHObject *dh; /* Accelerated Diffie-Hellmans */
52 const SilcCipherObject *cipher; /* Accelerated ciphers */
53 const SilcHashObject *hash; /* Accelerated hashes */
54 const SilcHmacObject *hmac; /* Accelerated HMACs */
55 const SilcRngObject *rng; /* Accelerated RNG's */
57 } *SilcAccelerator, SilcAcceleratorStruct;
59 /****f* silcacc/SilcAccAPI/silc_acc_register
63 * SilcBool silc_acc_register(const SilcAccelerator acc);
67 * Register new accelerator to the accelerator library. The `acc'
68 * is the accelerator context to be registered.
72 * This needs to be called only when adding new accelerator to the
73 * library. The accelerator library has some pre-registered accelerators
74 * that need not be registered with this call.
77 SilcBool silc_acc_register(const SilcAccelerator acc);
79 /****f* silcacc/SilcAccAPI/silc_acc_unregister
83 * void silc_acc_unregister(SilcAccelerator acc);
87 * Unregister the accelerator `acc' from the accelerator library. The
88 * accelerator cannot be used anymore after this call has returned.
91 void silc_acc_unregister(SilcAccelerator acc);
93 /****f* silcacc/SilcAccAPI/silc_acc_find
97 * SilcAccelerator silc_acc_find(const char *name);
101 * Find accelerator by its name indicated by `name'. Returns the
102 * accelerator context or NULL if such accelerator is not registered.
105 SilcAccelerator silc_acc_find(const char *name);
107 /****f* silcacc/SilcAccAPI/silc_acc_init
111 * SilcBool silc_acc_init(SilcAccelerator acc, SilcSchedule schedule, ...);
115 * Initialize accelerator `acc'. Usually accelerator may be initialized
116 * only once and should be done after registering it. The `schedule'
117 * must be given as argument, in case the accelerator needs to do operations
118 * through the scheduler. The variable argument list is optional
119 * accelerator specific initialization arguments. The argument list must
120 * be ended with NULL. Returns FALSE if initialization failed.
124 * silc_acc_init(softacc, "min_threads", 2, "max_threads", 16, NULL);
127 SilcBool silc_acc_init(SilcAccelerator acc, SilcSchedule schedule, ...);
129 /****f* silcacc/SilcAccAPI/silc_acc_uninit
133 * SilcBool silc_acc_uninit(SilcAccelerator acc);
137 * Uninitialize the accelerator `acc'. The accelerator may not be used
138 * after this call has returned. Some accelerators may be re-initialized
139 * by calling silc_acc_init again. Returns FALSE if error occurred
140 * during uninitializing.
143 SilcBool silc_acc_uninit(SilcAccelerator acc);
145 /****f* silcacc/SilcAccAPI/silc_acc_get_supported
149 * SilcDList silc_acc_get_supported(void);
153 * Returns list of registered accelerators. The caller must free the
154 * returned list by calling silc_dlist_uninit.
157 SilcDList silc_acc_get_supported(void);
159 /****f* silcacc/SilcAccAPI/silc_acc_get_name
163 * const char *silc_acc_get_name(SilcAccelerator acc);
167 * Returns the name of the accelerator `acc'.
170 const char *silc_acc_get_name(SilcAccelerator acc);
172 /****f* silcacc/SilcAccAPI/silc_acc_public_key
176 * SilcPublicKey silc_acc_public_key(SilcAccelerator acc,
177 * SilcPublicKey public_key);
181 * Accelerate the public key indicated by `public_key'. Returns new
182 * accelerated SilcPublicKey context. It can be used just as normal
183 * public key and must be freed by calling silc_pkcs_public_key_free.
184 * The associated `public_key' is not freed when the accelerated public
185 * key is freed. The `public_key' must not be freed as long as it is
188 * The associated `public_key' can be retrieved from the returned
189 * public key by calling silc_acc_get_public_key.
192 SilcPublicKey silc_acc_public_key(SilcAccelerator acc,
193 SilcPublicKey public_key);
195 /****f* silcacc/SilcAccAPI/silc_acc_private_key
199 * SilcPrivateKey silc_acc_private_key(SilcAccelerator acc,
200 * SilcPrivateKey private_key);
204 * Accelerate the private key indicated by `private_key'. Returns new
205 * accelerated SilcPrivateKey context. It can be used just as normal
206 * private key and must be freed by calling silc_pkcs_private_key_free.
207 * The associated `private_key' is not freed when the accelerated private
208 * key is freed. The `private_key' must not be freed as long as it is
211 * The associated `private_key' can be retrieved from the returned
212 * private key by calling silc_acc_get_private_key.
215 SilcPrivateKey silc_acc_private_key(SilcAccelerator acc,
216 SilcPrivateKey private_key);
218 /****f* silcacc/SilcAccAPI/silc_acc_get_public_key
222 * SilcPublicKey silc_acc_get_public_key(SilcAccelerator acc,
223 * SilcPublicKey public_key);
227 * Returns the underlaying public key from the accelerated public key
228 * indicated by `public_key'. Returns NULL if `public_key' is not
229 * accelerated public key.
232 SilcPublicKey silc_acc_get_public_key(SilcAccelerator acc,
233 SilcPublicKey public_key);
235 /****f* silcacc/SilcAccAPI/silc_acc_get_private_key
239 * SilcPrivateKey silc_acc_get_private_key(SilcAccelerator acc,
240 * SilcPrivateKey private_key);
244 * Returns the underlaying private key from the accelerated private key
245 * indicated by `private_key'. Returns NULL if `private_key' is not
246 * accelerated private key.
249 SilcPrivateKey silc_acc_get_private_key(SilcAccelerator acc,
250 SilcPrivateKey private_key);
252 #endif /* SILCACC_H */