libssh  0.6.3
wrapper.h
1 /*
2  * This file is part of the SSH Library
3  *
4  * Copyright (c) 2009 by Aris Adamantiadis
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef WRAPPER_H_
22 #define WRAPPER_H_
23 
24 #include "config.h"
25 #include "libssh/libcrypto.h"
26 #include "libssh/libgcrypt.h"
27 
28 enum ssh_mac_e {
29  SSH_MAC_SHA1=1,
30  SSH_MAC_SHA256,
31  SSH_MAC_SHA384,
32  SSH_MAC_SHA512
33 };
34 
35 enum ssh_hmac_e {
36  SSH_HMAC_SHA1 = 1,
37  SSH_HMAC_MD5
38 };
39 
40 enum ssh_des_e {
41  SSH_3DES,
42  SSH_DES
43 };
44 
45 typedef struct ssh_mac_ctx_struct *ssh_mac_ctx;
46 MD5CTX md5_init(void);
47 void md5_update(MD5CTX c, const void *data, unsigned long len);
48 void md5_final(unsigned char *md,MD5CTX c);
49 SHACTX sha1_init(void);
50 void sha1_update(SHACTX c, const void *data, unsigned long len);
51 void sha1_final(unsigned char *md,SHACTX c);
52 void sha1(unsigned char *digest,int len,unsigned char *hash);
53 void sha256(unsigned char *digest, int len, unsigned char *hash);
54 
55 void evp(int nid, unsigned char *digest, int len, unsigned char *hash, unsigned int *hlen);
56 EVPCTX evp_init(int nid);
57 void evp_update(EVPCTX ctx, const void *data, unsigned long len);
58 void evp_final(EVPCTX ctx, unsigned char *md, unsigned int *mdlen);
59 
60 ssh_mac_ctx ssh_mac_ctx_init(enum ssh_mac_e type);
61 void ssh_mac_update(ssh_mac_ctx ctx, const void *data, unsigned long len);
62 void ssh_mac_final(unsigned char *md, ssh_mac_ctx ctx);
63 
64 HMACCTX hmac_init(const void *key,int len, enum ssh_hmac_e type);
65 void hmac_update(HMACCTX c, const void *data, unsigned long len);
66 void hmac_final(HMACCTX ctx,unsigned char *hashmacbuf,unsigned int *len);
67 
68 int crypt_set_algorithms(ssh_session session, enum ssh_des_e des_type);
69 int crypt_set_algorithms_server(ssh_session session);
70 struct ssh_crypto_struct *crypto_new(void);
71 void crypto_free(struct ssh_crypto_struct *crypto);
72 
73 void ssh_reseed(void);
74 
75 #endif /* WRAPPER_H_ */