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 int delayed_compress_in;
00062 int delayed_compress_out;
00063 void *compress_out_ctx;
00064 void *compress_in_ctx;
00065 };
00066
00067 struct crypto_struct {
00068 const char *name;
00069 unsigned int blocksize;
00070 unsigned int keylen;
00071 #ifdef HAVE_LIBGCRYPT
00072 gcry_cipher_hd_t *key;
00073 #elif defined HAVE_LIBCRYPTO
00074 void *key;
00075 #endif
00076 unsigned int keysize;
00077 #ifdef HAVE_LIBGCRYPT
00078
00079 int (*set_encrypt_key)(struct crypto_struct *cipher, void *key, void *IV);
00080 int (*set_decrypt_key)(struct crypto_struct *cipher, void *key, void *IV);
00081 void (*cbc_encrypt)(struct crypto_struct *cipher, void *in, void *out,
00082 unsigned long len);
00083 void (*cbc_decrypt)(struct crypto_struct *cipher, void *in, void *out,
00084 unsigned long len);
00085 #elif defined HAVE_LIBCRYPTO
00086
00087 int (*set_encrypt_key)(struct crypto_struct *cipher, void *key);
00088 int (*set_decrypt_key)(struct crypto_struct *cipher, void *key);
00089 void (*cbc_encrypt)(struct crypto_struct *cipher, void *in, void *out,
00090 unsigned long len, void *IV);
00091 void (*cbc_decrypt)(struct crypto_struct *cipher, void *in, void *out,
00092 unsigned long len, void *IV);
00093 #endif
00094 };
00095
00096
00097 #endif