Added cipher acceleration to SILC Accelerator. Added cipher softacc.
[crypto.git] / lib / silcacc / softacc_i.h
1 /*
2
3   softacc_i.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2008 Pekka Riikonen
8
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.
12
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.
17
18 */
19
20 #ifndef SOFTACC_I_H
21 #define SOFTACC_I_H
22
23 #if SILC_SOFTACC_DEBUG_ON == 1
24 #define SILC_SOFTACC_DEBUG(fmt) SILC_LOG_DEBUG(fmt)
25 #else
26 #define SILC_SOFTACC_DEBUG(fmt)
27 #endif /* SILC_SOFTACC_DEBUG_ON == 1 */
28
29 /* Defaults */
30 #define SILC_SOFTACC_MIN_THREADS 0
31 #define SILC_SOFTACC_MAX_THREADS 4
32 #define SILC_SOFTACC_CIPHER_THREADS 2
33 #define SILC_SOFTACC_CIPHER_BLOCKS 4096
34 #define SILC_SOFTACC_CIPHER_STREAMS (SILC_SOFTACC_CIPHER_THREADS * 2)
35
36 /* Software accelerator context */
37 typedef struct {
38   SilcSchedule schedule;                 /* Scheduler */
39   SilcThreadPool tp;                     /* The thread pool */
40
41   /* Options */
42   SilcUInt32 min_threads;
43   SilcUInt32 max_threads;
44   SilcUInt32 cipher_threads;
45   SilcUInt32 cipher_blocks;
46   SilcUInt32 cipher_streams;
47 } *SilcSoftacc;
48
49 /* Accelerator API */
50 SilcBool silc_softacc_init(SilcSchedule schedule, va_list va);
51 SilcBool silc_softacc_uninit(void);
52
53 #ifdef SILC_DIST_SOFTACC_PKCS
54 extern const SilcPKCSAlgorithm softacc_pkcs[];
55
56 SILC_PKCS_ALG_IMPORT_PUBLIC_KEY(silc_softacc_acc_public_key);
57 SILC_PKCS_ALG_PUBLIC_KEY_FREE(silc_softacc_free_public_key);
58 SILC_PKCS_ALG_IMPORT_PRIVATE_KEY(silc_softacc_acc_private_key);
59 SILC_PKCS_ALG_PRIVATE_KEY_FREE(silc_softacc_free_private_key);
60 SILC_PKCS_ALG_ENCRYPT(silc_softacc_encrypt);
61 SILC_PKCS_ALG_DECRYPT(silc_softacc_decrypt);
62 SILC_PKCS_ALG_SIGN(silc_softacc_sign);
63 SILC_PKCS_ALG_VERIFY(silc_softacc_verify);
64 #endif /* SILC_DIST_SOFTACC_PKCS */
65
66 #ifdef SILC_DIST_SOFTACC_CIPHER
67 extern const SilcCipherObject softacc_cipher[];
68
69 SILC_CIPHER_API_SET_KEY(softacc_cipher_aes);
70 SILC_CIPHER_API_ENCRYPT(softacc_cipher_aes);
71 SILC_CIPHER_API_SET_IV(softacc_cipher_aes);
72
73 SILC_CIPHER_API_SET_KEY(softacc_cipher);
74 SILC_CIPHER_API_SET_IV(softacc_cipher);
75 SILC_CIPHER_API_ENCRYPT(softacc_cipher);
76 SILC_CIPHER_API_INIT(softacc_cipher);
77 SILC_CIPHER_API_UNINIT(softacc_cipher);
78 #endif /* SILC_DIST_SOFTACC_CIPHER */
79
80 #endif /* SOFTACC_I_H */