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 #define DIGEST_MAX_LEN 64 51 enum ssh_key_exchange_e {
53 SSH_KEX_DH_GROUP1_SHA1=1,
55 SSH_KEX_DH_GROUP14_SHA1,
57 SSH_KEX_ECDH_SHA2_NISTP256,
59 SSH_KEX_ECDH_SHA2_NISTP384,
61 SSH_KEX_ECDH_SHA2_NISTP521,
63 SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG
80 struct ssh_crypto_struct {
83 #ifdef HAVE_OPENSSL_ECC 85 #elif defined HAVE_GCRYPT_ECC 86 gcry_sexp_t ecdh_privkey;
88 ssh_string ecdh_client_pubkey;
89 ssh_string ecdh_server_pubkey;
91 #ifdef HAVE_CURVE25519 92 ssh_curve25519_privkey curve25519_privkey;
93 ssh_curve25519_pubkey curve25519_client_pubkey;
94 ssh_curve25519_pubkey curve25519_server_pubkey;
96 ssh_string dh_server_signature;
98 unsigned char *session_id;
99 unsigned char *secret_hash;
100 unsigned char *encryptIV;
101 unsigned char *decryptIV;
102 unsigned char *decryptkey;
103 unsigned char *encryptkey;
104 unsigned char *encryptMAC;
105 unsigned char *decryptMAC;
106 unsigned char hmacbuf[DIGEST_MAX_LEN];
107 struct ssh_cipher_struct *in_cipher, *out_cipher;
108 enum ssh_hmac_e in_hmac, out_hmac;
110 ssh_string server_pubkey;
111 const char *server_pubkey_type;
114 int delayed_compress_in;
115 int delayed_compress_out;
116 void *compress_out_ctx;
117 void *compress_in_ctx;
119 struct ssh_kex_struct server_kex;
120 struct ssh_kex_struct client_kex;
121 char *kex_methods[SSH_KEX_METHODS];
122 enum ssh_key_exchange_e kex_type;
123 enum ssh_mac_e mac_type;
126 struct ssh_cipher_struct {
128 unsigned int blocksize;
129 enum ssh_cipher_e ciphertype;
130 #ifdef HAVE_LIBGCRYPT 132 gcry_cipher_hd_t *key;
133 #elif defined HAVE_LIBCRYPTO 134 struct ssh_3des_key_schedule *des3_key;
135 struct ssh_aes_key_schedule *aes_key;
136 const EVP_CIPHER *cipher;
139 unsigned int keysize;
141 int (*set_encrypt_key)(
struct ssh_cipher_struct *cipher,
void *key,
void *IV);
142 int (*set_decrypt_key)(
struct ssh_cipher_struct *cipher,
void *key,
void *IV);
143 void (*encrypt)(
struct ssh_cipher_struct *cipher,
void *in,
void *out,
145 void (*decrypt)(
struct ssh_cipher_struct *cipher,
void *in,
void *out,
147 void (*cleanup)(
struct ssh_cipher_struct *cipher);