blob: 58733b0475b0d28ef021fc264b0f6fc887d784fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#ifndef SSH_DH_H
#define SSH_DH_H
#include <openssl/bn.h>
#include <openssl/sha.h>
#include <openssl/evp.h>
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && \
!defined(LIBRESSL_VERSION_NUMBER)
#define ssh_md_ctx_new EVP_MD_CTX_new
#define ssh_md_ctx_free EVP_MD_CTX_free
#else
#define ssh_md_ctx_new EVP_MD_CTX_create
#define ssh_md_ctx_free EVP_MD_CTX_destroy
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned char* (*hash_t)(const unsigned char *, size_t, unsigned char *);
typedef struct
{
EVP_MD_CTX *mdctx;
const EVP_MD *md;
unsigned int hashlen;
} evp_md_t;
typedef struct ssh_diffie_hellman
{
BIGNUM *g; // generator
BIGNUM *p; // prime
BIGNUM *bn_x; /* random number */
int e_len;
unsigned char *mpint_e; /* g^x mod p */
int secret_len;
unsigned char *secret;
BN_CTX *ctx;
evp_md_t digest;
} SSH_DH;
void ssh_dh_free(SSH_DH*);
void ssh_dh_hash(SSH_DH*, const unsigned char* data, unsigned char*, size_t len);
int ssh_dh_compute_secret(SSH_DH*, const unsigned char *, int);
typedef SSH_DH*(*NEW_DH)(void);
extern const char all_dh_list[];
NEW_DH search_dh(const char *s);
#ifdef __cplusplus
}
#endif
#endif
|