libssh  0.8.5
The SSH library
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/libssh.h"
26#include "libssh/libcrypto.h"
27#include "libssh/libgcrypt.h"
28#include "libssh/libmbedcrypto.h"
29
30enum ssh_digest_e {
31 SSH_DIGEST_AUTO=0,
32 SSH_DIGEST_SHA1=1,
33 SSH_DIGEST_SHA256,
34 SSH_DIGEST_SHA512
35};
36
37enum ssh_mac_e {
38 SSH_MAC_SHA1=1,
39 SSH_MAC_SHA256,
40 SSH_MAC_SHA384,
41 SSH_MAC_SHA512
42};
43
44enum ssh_hmac_e {
45 SSH_HMAC_SHA1 = 1,
46 SSH_HMAC_SHA256,
47 SSH_HMAC_SHA384,
48 SSH_HMAC_SHA512,
49 SSH_HMAC_MD5,
50 SSH_HMAC_AEAD_POLY1305
51};
52
53enum ssh_des_e {
54 SSH_3DES,
55 SSH_DES
56};
57
59 const char* name;
60 enum ssh_hmac_e hmac_type;
61};
62
64
65typedef struct ssh_mac_ctx_struct *ssh_mac_ctx;
66MD5CTX md5_init(void);
67void md5_update(MD5CTX c, const void *data, unsigned long len);
68void md5_final(unsigned char *md,MD5CTX c);
69
70SHACTX sha1_init(void);
71void sha1_update(SHACTX c, const void *data, unsigned long len);
72void sha1_final(unsigned char *md,SHACTX c);
73void sha1(unsigned char *digest,int len,unsigned char *hash);
74
75SHA256CTX sha256_init(void);
76void sha256_update(SHA256CTX c, const void *data, unsigned long len);
77void sha256_final(unsigned char *md,SHA256CTX c);
78void sha256(unsigned char *digest, int len, unsigned char *hash);
79
80SHA384CTX sha384_init(void);
81void sha384_update(SHA384CTX c, const void *data, unsigned long len);
82void sha384_final(unsigned char *md,SHA384CTX c);
83void sha384(unsigned char *digest, int len, unsigned char *hash);
84
85SHA512CTX sha512_init(void);
86void sha512_update(SHA512CTX c, const void *data, unsigned long len);
87void sha512_final(unsigned char *md,SHA512CTX c);
88void sha512(unsigned char *digest, int len, unsigned char *hash);
89
90void evp(int nid, unsigned char *digest, int len, unsigned char *hash, unsigned int *hlen);
91EVPCTX evp_init(int nid);
92void evp_update(EVPCTX ctx, const void *data, unsigned long len);
93void evp_final(EVPCTX ctx, unsigned char *md, unsigned int *mdlen);
94
95ssh_mac_ctx ssh_mac_ctx_init(enum ssh_mac_e type);
96void ssh_mac_update(ssh_mac_ctx ctx, const void *data, unsigned long len);
97void ssh_mac_final(unsigned char *md, ssh_mac_ctx ctx);
98
99HMACCTX hmac_init(const void *key,int len, enum ssh_hmac_e type);
100void hmac_update(HMACCTX c, const void *data, unsigned long len);
101void hmac_final(HMACCTX ctx,unsigned char *hashmacbuf,unsigned int *len);
102size_t hmac_digest_len(enum ssh_hmac_e type);
103
104int crypt_set_algorithms_client(ssh_session session);
105int crypt_set_algorithms_server(ssh_session session);
106struct ssh_crypto_struct *crypto_new(void);
107void crypto_free(struct ssh_crypto_struct *crypto);
108
109void ssh_reseed(void);
110int ssh_crypto_init(void);
111void ssh_crypto_finalize(void);
112
113void ssh_cipher_clear(struct ssh_cipher_struct *cipher);
114struct ssh_hmac_struct *ssh_get_hmactab(void);
115struct ssh_cipher_struct *ssh_get_ciphertab(void);
116const char *ssh_hmac_type_to_string(enum ssh_hmac_e hmac_type);
117
118#endif /* WRAPPER_H_ */
Definition: crypto.h:131
Definition: crypto.h:84
Definition: wrapper.h:58
Definition: session.h:102