libssh 0.11.1 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
28 struct dh_ctx;
29
30#define DH_CLIENT_KEYPAIR 0
31#define DH_SERVER_KEYPAIR 1
32
33#ifdef __cplusplus
34 extern "C" {
35#endif
36
37/* functions implemented by crypto backends */
38 int ssh_dh_init_common(struct ssh_crypto_struct *crypto);
39 void ssh_dh_cleanup(struct ssh_crypto_struct *crypto);
40
41#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
42 int ssh_dh_get_parameters(struct dh_ctx *ctx,
43 const_bignum *modulus, const_bignum *generator);
44#else
45 int ssh_dh_get_parameters(struct dh_ctx *ctx,
46 bignum *modulus, bignum *generator);
47#endif /* OPENSSL_VERSION_NUMBER */
48 int ssh_dh_set_parameters(struct dh_ctx *ctx,
49 const bignum modulus, const bignum generator);
50
51 int ssh_dh_keypair_gen_keys(struct dh_ctx *ctx, int peer);
52#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
53 int ssh_dh_keypair_get_keys(struct dh_ctx *ctx, int peer,
54 const_bignum *priv, const_bignum *pub);
55#else
56 int ssh_dh_keypair_get_keys(struct dh_ctx *ctx, int peer,
57 bignum *priv, bignum *pub);
58#endif /* OPENSSL_VERSION_NUMBER */
59 int ssh_dh_keypair_set_keys(struct dh_ctx *ctx, int peer,
60 bignum priv, bignum pub);
61
62 int ssh_dh_compute_shared_secret(struct dh_ctx *ctx, int local, int remote,
63 bignum *dest);
64
65 void ssh_dh_debug_crypto(struct ssh_crypto_struct *c);
66
67/* common functions */
68 int ssh_dh_init(void);
69 void ssh_dh_finalize(void);
70
71 int 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);
75 int 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);
78 int ssh_dh_get_next_server_publickey_blob(ssh_session session,
79 ssh_string *pubkey_blob);
80 int dh_handshake(ssh_session session);
81
82 int ssh_client_dh_init(ssh_session session);
83 void ssh_client_dh_remove_callbacks(ssh_session session);
84#ifdef WITH_SERVER
85 void ssh_server_dh_init(ssh_session session);
86#endif /* WITH_SERVER */
87 int ssh_server_dh_process_init(ssh_session session, ssh_buffer packet);
88 int ssh_fallback_group(uint32_t pmax, bignum *p, bignum *g);
89 bool ssh_dh_is_known_group(bignum modulus, bignum generator);
90
91#ifdef __cplusplus
92}
93#endif
94
95#endif /* DH_H_ */