33 #include "libssh/wrapper.h"
42 #ifdef HAVE_OPENSSL_ECDH_H
43 #include <openssl/ecdh.h>
45 #include "libssh/ecdh.h"
46 #include "libssh/kex.h"
47 #include "libssh/curve25519.h"
49 enum ssh_key_exchange_e {
51 SSH_KEX_DH_GROUP1_SHA1=1,
53 SSH_KEX_DH_GROUP14_SHA1,
55 SSH_KEX_ECDH_SHA2_NISTP256,
57 SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG
60 struct ssh_crypto_struct {
64 ssh_string ecdh_client_pubkey;
65 ssh_string ecdh_server_pubkey;
67 #ifdef HAVE_CURVE25519
68 ssh_curve25519_privkey curve25519_privkey;
69 ssh_curve25519_pubkey curve25519_client_pubkey;
70 ssh_curve25519_pubkey curve25519_server_pubkey;
72 ssh_string dh_server_signature;
74 unsigned char *session_id;
75 unsigned char *secret_hash;
76 unsigned char *encryptIV;
77 unsigned char *decryptIV;
78 unsigned char *decryptkey;
79 unsigned char *encryptkey;
80 unsigned char *encryptMAC;
81 unsigned char *decryptMAC;
82 unsigned char hmacbuf[EVP_MAX_MD_SIZE];
83 struct ssh_cipher_struct *in_cipher, *out_cipher;
84 ssh_string server_pubkey;
85 const char *server_pubkey_type;
88 int delayed_compress_in;
89 int delayed_compress_out;
90 void *compress_out_ctx;
91 void *compress_in_ctx;
93 struct ssh_kex_struct server_kex;
94 struct ssh_kex_struct client_kex;
95 char *kex_methods[SSH_KEX_METHODS];
96 enum ssh_key_exchange_e kex_type;
97 enum ssh_mac_e mac_type;
100 struct ssh_cipher_struct {
102 unsigned int blocksize;
104 #ifdef HAVE_LIBGCRYPT
105 gcry_cipher_hd_t *key;
106 #elif defined HAVE_LIBCRYPTO
110 unsigned int keysize;
112 int (*set_encrypt_key)(
struct ssh_cipher_struct *cipher,
void *key,
void *IV);
113 int (*set_decrypt_key)(
struct ssh_cipher_struct *cipher,
void *key,
void *IV);
114 void (*cbc_encrypt)(
struct ssh_cipher_struct *cipher,
void *in,
void *out,
116 void (*cbc_decrypt)(
struct ssh_cipher_struct *cipher,
void *in,
void *out,