00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _CRYPTO_H_
00027 #define _CRYPTO_H_
00028
00029 #include "config.h"
00030
00031 #ifdef HAVE_LIBGCRYPT
00032 #include <gcrypt.h>
00033 #endif
00034 #include "libssh/wrapper.h"
00035
00036 #ifdef cbc_encrypt
00037 #undef cbc_encrypt
00038 #endif
00039 #ifdef cbc_decrypt
00040 #undef cbc_decrypt
00041 #endif
00042
00043 struct ssh_crypto_struct {
00044 bignum e,f,x,k,y;
00045 unsigned char session_id[SHA_DIGEST_LEN];
00046
00047 unsigned char encryptIV[SHA_DIGEST_LEN*2];
00048 unsigned char decryptIV[SHA_DIGEST_LEN*2];
00049
00050 unsigned char decryptkey[SHA_DIGEST_LEN*2];
00051 unsigned char encryptkey[SHA_DIGEST_LEN*2];
00052
00053 unsigned char encryptMAC[SHA_DIGEST_LEN];
00054 unsigned char decryptMAC[SHA_DIGEST_LEN];
00055 unsigned char hmacbuf[EVP_MAX_MD_SIZE];
00056 struct crypto_struct *in_cipher, *out_cipher;
00057 ssh_string server_pubkey;
00058 const char *server_pubkey_type;
00059 int do_compress_out;
00060 int do_compress_in;
00061 void *compress_out_ctx;
00062 void *compress_in_ctx;
00063 };
00064
00065 struct crypto_struct {
00066 const char *name;
00067 unsigned int blocksize;
00068 unsigned int keylen;
00069 #ifdef HAVE_LIBGCRYPT
00070 gcry_cipher_hd_t *key;
00071 #elif defined HAVE_LIBCRYPTO
00072 void *key;
00073 #endif
00074 unsigned int keysize;
00075 #ifdef HAVE_LIBGCRYPT
00076
00077 int (*set_encrypt_key)(struct crypto_struct *cipher, void *key, void *IV);
00078 int (*set_decrypt_key)(struct crypto_struct *cipher, void *key, void *IV);
00079 void (*cbc_encrypt)(struct crypto_struct *cipher, void *in, void *out,
00080 unsigned long len);
00081 void (*cbc_decrypt)(struct crypto_struct *cipher, void *in, void *out,
00082 unsigned long len);
00083 #elif defined HAVE_LIBCRYPTO
00084
00085 int (*set_encrypt_key)(struct crypto_struct *cipher, void *key);
00086 int (*set_decrypt_key)(struct crypto_struct *cipher, void *key);
00087 void (*cbc_encrypt)(struct crypto_struct *cipher, void *in, void *out,
00088 unsigned long len, void *IV);
00089 void (*cbc_decrypt)(struct crypto_struct *cipher, void *in, void *out,
00090 unsigned long len, void *IV);
00091 #endif
00092 };
00093
00094
00095 #endif