Tomato 1.26
[tomato.git] / release / src / router / matrixssl / src / crypto / cryptoLayer.h
blobb90baaf42bd9dac09233c7866e0e777017963a52
1 /*
2 * cryptoLayer.h
3 * Release $Name: MATRIXSSL_1_8_8_OPEN $
5 * Cryptography provider layered header. This layer decouples
6 * the cryptography implementation from the SSL protocol implementation.
7 * Contributors adding new providers must implement all functions
8 * externed below.
9 */
11 * Copyright (c) PeerSec Networks, 2002-2009. All Rights Reserved.
12 * The latest version of this code is available at http://www.matrixssl.org
14 * This software is open source; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This General Public License does NOT permit incorporating this software
20 * into proprietary programs. If you are unable to comply with the GPL, a
21 * commercial license for this software may be purchased from PeerSec Networks
22 * at http://www.peersec.com
24 * This program is distributed in WITHOUT ANY WARRANTY; without even the
25 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
26 * See the GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 * http://www.gnu.org/copyleft/gpl.html
33 /******************************************************************************/
35 #ifndef _h_CRYPTO_LAYER
36 #define _h_CRYPTO_LAYER
37 #define _h_EXPORT_SYMBOLS
39 /******************************************************************************/
41 Crypto may have some reliance on os layer (psMalloc in particular)
43 #include "../os/osLayer.h"
46 Return the length of padding bytes required for a record of 'LEN' bytes
47 The name Pwr2 indicates that calculations will work with 'BLOCKSIZE'
48 that are powers of 2.
49 Because of the trailing pad length byte, a length that is a multiple
50 of the pad bytes
52 #define sslPadLenPwr2(LEN, BLOCKSIZE) \
53 BLOCKSIZE <= 1 ? (unsigned char)0 : \
54 (unsigned char)(BLOCKSIZE - ((LEN) & (BLOCKSIZE - 1)))
57 Define the default crypto provider here
59 #define USE_PEERSEC_CRYPTO
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
65 #define SSL_MD5_HASH_SIZE 16
66 #define SSL_SHA1_HASH_SIZE 20
68 #define SSL_MAX_MAC_SIZE 20
69 #define SSL_MAX_IV_SIZE 16
70 #define SSL_MAX_BLOCK_SIZE 16
71 #define SSL_MAX_SYM_KEY_SIZE 32
73 #define USE_X509 /* Must define for certificate support */
75 Enable the algorithms used for each cipher suite
78 #ifdef USE_SSL_RSA_WITH_NULL_MD5
79 #define USE_RSA
80 #define USE_MD5_MAC
81 #endif
83 #ifdef USE_SSL_RSA_WITH_NULL_SHA
84 #define USE_RSA
85 #define USE_SHA1_MAC
86 #endif
88 #ifdef USE_SSL_RSA_WITH_RC4_128_SHA
89 #define USE_ARC4
90 #define USE_SHA1_MAC
91 #define USE_RSA
92 #endif
94 #ifdef USE_SSL_RSA_WITH_RC4_128_MD5
95 #define USE_ARC4
96 #define USE_MD5_MAC
97 #define USE_RSA
98 #endif
100 #ifdef USE_SSL_RSA_WITH_3DES_EDE_CBC_SHA
101 #define USE_3DES
102 #define USE_SHA1_MAC
103 #define USE_RSA
104 #endif
107 Support for optionally encrypted private key files. These are
108 usually encrypted with 3DES.
110 #ifdef USE_ENCRYPTED_PRIVATE_KEYS
111 #define USE_3DES
112 #endif
115 Support for client side SSL
117 #ifdef USE_CLIENT_SIDE_SSL
118 #define USE_RSA_PUBLIC_ENCRYPT
119 #endif
122 Support for client authentication
126 Addtional crypt support
128 /* #define USE_MD2 */
131 Now that we've set up the required defines, include the crypto provider
133 #ifdef USE_PEERSEC_CRYPTO
134 #include "peersec/pscrypto.h"
135 #endif
137 /******************************************************************************/
139 Include the public prototypes now. This level of indirection is needed
140 to properly expose the public APIs to DLLs. The circular reference
141 between these two files is avoided with the top level defines and the
142 order in which they are included is the key to making this work so edit
143 with caution.
145 #include "matrixCrypto.h"
148 #ifdef __cplusplus
150 #endif
152 #endif /* _h_CRYPTO_LAYER */
154 /******************************************************************************/