libssh  0.10.90
The SSH library
Loading...
Searching...
No Matches
dh.h
1/*
2 * This file is part of the SSH Library
3 *
4 * Copyright (c) 2009 by Aris Adamantiadis
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef DH_H_
22#define DH_H_
23
24#include "config.h"
25
26#include "libssh/crypto.h"
27
28struct dh_ctx;
29
30#define DH_CLIENT_KEYPAIR 0
31#define DH_SERVER_KEYPAIR 1
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37/* functions implemented by crypto backends */
38int ssh_dh_init_common(struct ssh_crypto_struct *crypto);
39void ssh_dh_cleanup(struct ssh_crypto_struct *crypto);
40
41#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
42int ssh_dh_get_parameters(struct dh_ctx *ctx,
43 const_bignum *modulus, const_bignum *generator);
44#else
45int ssh_dh_get_parameters(struct dh_ctx *ctx,
46 bignum *modulus, bignum *generator);
47#endif /* OPENSSL_VERSION_NUMBER */
48int ssh_dh_set_parameters(struct dh_ctx *ctx,
49 const bignum modulus, const bignum generator);
50
51int ssh_dh_keypair_gen_keys(struct dh_ctx *ctx, int peer);
52#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
53int ssh_dh_keypair_get_keys(struct dh_ctx *ctx, int peer,
54 const_bignum *priv, const_bignum *pub);
55#else
56int ssh_dh_keypair_get_keys(struct dh_ctx *ctx, int peer,
57 bignum *priv, bignum *pub);
58#endif /* OPENSSL_VERSION_NUMBER */
59int ssh_dh_keypair_set_keys(struct dh_ctx *ctx, int peer,
60 bignum priv, bignum pub);
61
62int ssh_dh_compute_shared_secret(struct dh_ctx *ctx, int local, int remote,
63 bignum *dest);
64
65void ssh_dh_debug_crypto(struct ssh_crypto_struct *c);
66
67/* common functions */
68int ssh_dh_init(void);
69void ssh_dh_finalize(void);
70
71int ssh_dh_import_next_pubkey_blob(ssh_session session,
72 ssh_string pubkey_blob);
73
74ssh_key ssh_dh_get_current_server_publickey(ssh_session session);
75int ssh_dh_get_current_server_publickey_blob(ssh_session session,
76 ssh_string *pubkey_blob);
77ssh_key ssh_dh_get_next_server_publickey(ssh_session session);
78int ssh_dh_get_next_server_publickey_blob(ssh_session session,
79 ssh_string *pubkey_blob);
80int dh_handshake(ssh_session session);
81
82int ssh_client_dh_init(ssh_session session);
83void ssh_client_dh_remove_callbacks(ssh_session session);
84#ifdef WITH_SERVER
85void ssh_server_dh_init(ssh_session session);
86#endif /* WITH_SERVER */
87int ssh_server_dh_process_init(ssh_session session, ssh_buffer packet);
88int ssh_fallback_group(uint32_t pmax, bignum *p, bignum *g);
89bool ssh_dh_is_known_group(bignum modulus, bignum generator);
90
91#ifdef __cplusplus
92}
93#endif
94
95#endif /* DH_H_ */