Tomato 1.26
[tomato.git] / release / src / router / matrixssl / src / crypto / matrixCrypto.h
blob58f45f3df60c9de06cd828b1f6f5fe59de85dac0
1 /*
2 * matrixCrypto.h
3 * Release $Name: MATRIXSSL_1_8_8_OPEN $
5 * Public API set for matrixCrypto
6 */
7 /*
8 * Copyright (c) PeerSec Networks, 2002-2009. All Rights Reserved.
9 * The latest version of this code is available at http://www.matrixssl.org
11 * This software is open source; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This General Public License does NOT permit incorporating this software
17 * into proprietary programs. If you are unable to comply with the GPL, a
18 * commercial license for this software may be purchased from PeerSec Networks
19 * at http://www.peersec.com
21 * This program is distributed in WITHOUT ANY WARRANTY; without even the
22 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 * See the GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 * http://www.gnu.org/copyleft/gpl.html
30 /******************************************************************************/
32 #ifndef _h_MATRIX_CRYPTO
33 #define _h_MATRIX_CRYPTO
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 #include "../../matrixCommon.h"
42 User application. Now include cryptoLayer to get the proper algorithm
43 defines so we know what API set to expose
45 #include "cryptoLayer.h"
47 /******************************************************************************/
50 MATRIXPUBLIC int32 matrixGetRandomBytes(unsigned char *bytes, int32 size);
52 #ifdef USE_ARC4
53 MATRIXPUBLIC void matrixArc4Init(sslCipherContext_t *ctx, unsigned char *key,
54 int32 keylen);
55 MATRIXPUBLIC int32 matrixArc4(sslCipherContext_t *ctx, unsigned char *in,
56 unsigned char *out, int32 len);
57 #endif /* USE_ARC4 */
59 #ifdef USE_3DES
60 MATRIXPUBLIC int32 matrix3desInit(sslCipherContext_t *ctx, unsigned char *IV,
61 unsigned char *key, int32 keylen);
62 MATRIXPUBLIC int32 matrix3desEncrypt(sslCipherContext_t *ctx, unsigned char *pt,
63 unsigned char *ct, int32 len);
64 MATRIXPUBLIC int32 matrix3desDecrypt(sslCipherContext_t *ctx, unsigned char *ct,
65 unsigned char *pt, int32 len);
66 MATRIXPUBLIC void generate3DESKey(unsigned char *pass, int32 passlen,
67 unsigned char *salt, unsigned char *key);
68 #endif /* USE_3DES */
73 HMAC and message digests
75 MATRIXPUBLIC int32 matrixHmacMd5(unsigned char *key, int32 keyLen,
76 const unsigned char *buf, unsigned long len,
77 unsigned char *hash, unsigned char *hmacKey,
78 int32 *hmacKeyLen);
79 MATRIXPUBLIC void matrixHmacMd5Init(sslHmacContext_t *ctx,
80 unsigned char *key, int32 keyLen);
81 MATRIXPUBLIC void matrixHmacMd5Update(sslHmacContext_t *ctx,
82 const unsigned char *buf, unsigned long len);
83 MATRIXPUBLIC int32 matrixHmacMd5Final(sslHmacContext_t *ctx,
84 unsigned char *hash);
86 MATRIXPUBLIC int32 matrixHmacSha1(unsigned char *key, int32 keyLen,
87 const unsigned char *buf, unsigned long len,
88 unsigned char *hash, unsigned char *hmacKey,
89 int32 *hmacKeyLen);
90 MATRIXPUBLIC void matrixHmacSha1Init(sslHmacContext_t *ctx,
91 unsigned char *key, int32 keyLen);
92 MATRIXPUBLIC void matrixHmacSha1Update(sslHmacContext_t *ctx,
93 const unsigned char *buf, unsigned long len);
94 MATRIXPUBLIC int32 matrixHmacSha1Final(sslHmacContext_t *ctx,
95 unsigned char *hash);
97 MATRIXPUBLIC void matrixSha1Init(sslSha1Context_t *ctx);
98 MATRIXPUBLIC void matrixSha1Update(sslSha1Context_t *ctx,
99 const unsigned char *buf, unsigned long len);
100 MATRIXPUBLIC int32 matrixSha1Final(sslSha1Context_t *ctx, unsigned char *hash);
103 MATRIXPUBLIC void matrixMd5Init(sslMd5Context_t *ctx);
104 MATRIXPUBLIC void matrixMd5Update(sslMd5Context_t *ctx,
105 const unsigned char *buf, unsigned long len);
106 MATRIXPUBLIC int32 matrixMd5Final(sslMd5Context_t *ctx, unsigned char *hash);
109 #ifdef USE_MD2
111 MD2 is provided for compatibility with V2 and older X509 certificates,
112 it is known to have security problems and should not be used for any current
113 development.
115 MATRIXPUBLIC void matrixMd2Init(sslMd2Context_t *ctx);
116 MATRIXPUBLIC int32 matrixMd2Update(sslMd2Context_t *ctx,
117 const unsigned char *buf, unsigned long len);
118 MATRIXPUBLIC int32 matrixMd2Final(sslMd2Context_t *ctx, unsigned char *hash);
119 #endif /* USE_MD2 */
124 #ifdef USE_RSA
125 MATRIXPUBLIC int32 matrixRsaEncryptPub(psPool_t *pool, sslRsaKey_t *key,
126 unsigned char *in, int32 inlen,
127 unsigned char *out, int32 outlen);
128 MATRIXPUBLIC int32 matrixRsaDecryptPriv(psPool_t *pool, sslRsaKey_t *key,
129 unsigned char *in, int32 inlen,
130 unsigned char *out, int32 outlen);
131 MATRIXPUBLIC int32 matrixRsaDecryptPub(psPool_t *pool, sslRsaKey_t *key,
132 unsigned char *in, int32 inlen,
133 unsigned char *out, int32 outlen);
134 #endif /* USE_RSA */
139 #ifdef __cplusplus
141 #endif
143 #endif /* _h_MATRIX_CRYPTO */
145 /******************************************************************************/