libssh  0.7.2
include/libssh/wrapper.h
00001 /*
00002  * This file is part of the SSH Library
00003  *
00004  * Copyright (c) 2009 by Aris Adamantiadis
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 
00021 #ifndef WRAPPER_H_
00022 #define WRAPPER_H_
00023 
00024 #include "config.h"
00025 #include "libssh/libssh.h"
00026 #include "libssh/libcrypto.h"
00027 #include "libssh/libgcrypt.h"
00028 
00029 enum ssh_mac_e {
00030   SSH_MAC_SHA1=1,
00031   SSH_MAC_SHA256,
00032   SSH_MAC_SHA384,
00033   SSH_MAC_SHA512
00034 };
00035 
00036 enum ssh_hmac_e {
00037   SSH_HMAC_SHA1 = 1,
00038   SSH_HMAC_SHA256,
00039   SSH_HMAC_SHA384,
00040   SSH_HMAC_SHA512,
00041   SSH_HMAC_MD5
00042 };
00043 
00044 enum ssh_des_e {
00045   SSH_3DES,
00046   SSH_DES
00047 };
00048 
00049 struct ssh_hmac_struct {
00050   const char* name;
00051   enum ssh_hmac_e hmac_type;
00052 };
00053 
00054 typedef struct ssh_mac_ctx_struct *ssh_mac_ctx;
00055 MD5CTX md5_init(void);
00056 void md5_update(MD5CTX c, const void *data, unsigned long len);
00057 void md5_final(unsigned char *md,MD5CTX c);
00058 
00059 SHACTX sha1_init(void);
00060 void sha1_update(SHACTX c, const void *data, unsigned long len);
00061 void sha1_final(unsigned char *md,SHACTX c);
00062 void sha1(unsigned char *digest,int len,unsigned char *hash);
00063 
00064 SHA256CTX sha256_init(void);
00065 void sha256_update(SHA256CTX c, const void *data, unsigned long len);
00066 void sha256_final(unsigned char *md,SHA256CTX c);
00067 void sha256(unsigned char *digest, int len, unsigned char *hash);
00068 
00069 SHA384CTX sha384_init(void);
00070 void sha384_update(SHA384CTX c, const void *data, unsigned long len);
00071 void sha384_final(unsigned char *md,SHA384CTX c);
00072 void sha384(unsigned char *digest, int len, unsigned char *hash);
00073 
00074 SHA512CTX sha512_init(void);
00075 void sha512_update(SHA512CTX c, const void *data, unsigned long len);
00076 void sha512_final(unsigned char *md,SHA512CTX c);
00077 void sha512(unsigned char *digest, int len, unsigned char *hash);
00078 
00079 void evp(int nid, unsigned char *digest, int len, unsigned char *hash, unsigned int *hlen);
00080 EVPCTX evp_init(int nid);
00081 void evp_update(EVPCTX ctx, const void *data, unsigned long len);
00082 void evp_final(EVPCTX ctx, unsigned char *md, unsigned int *mdlen);
00083 
00084 ssh_mac_ctx ssh_mac_ctx_init(enum ssh_mac_e type);
00085 void ssh_mac_update(ssh_mac_ctx ctx, const void *data, unsigned long len);
00086 void ssh_mac_final(unsigned char *md, ssh_mac_ctx ctx);
00087 
00088 HMACCTX hmac_init(const void *key,int len, enum ssh_hmac_e type);
00089 void hmac_update(HMACCTX c, const void *data, unsigned long len);
00090 void hmac_final(HMACCTX ctx,unsigned char *hashmacbuf,unsigned int *len);
00091 size_t hmac_digest_len(enum ssh_hmac_e type);
00092 
00093 int crypt_set_algorithms(ssh_session session, enum ssh_des_e des_type);
00094 int crypt_set_algorithms_server(ssh_session session);
00095 struct ssh_crypto_struct *crypto_new(void);
00096 void crypto_free(struct ssh_crypto_struct *crypto);
00097 
00098 void ssh_reseed(void);
00099 
00100 void ssh_cipher_clear(struct ssh_cipher_struct *cipher);
00101 struct ssh_hmac_struct *ssh_get_hmactab(void);
00102 const char *ssh_hmac_type_to_string(enum ssh_hmac_e hmac_type);
00103 
00104 #endif /* WRAPPER_H_ */