libssh  0.10.0
The SSH library
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/* functions implemented by crypto backends */
34int ssh_dh_init_common(struct ssh_crypto_struct *crypto);
35void ssh_dh_cleanup(struct ssh_crypto_struct *crypto);
36
37#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
38int ssh_dh_get_parameters(struct dh_ctx *ctx,
39 const_bignum *modulus, const_bignum *generator);
40#else
41int ssh_dh_get_parameters(struct dh_ctx *ctx,
42 bignum *modulus, bignum *generator);
43#endif /* OPENSSL_VERSION_NUMBER */
44int ssh_dh_set_parameters(struct dh_ctx *ctx,
45 const bignum modulus, const bignum generator);
46
47int ssh_dh_keypair_gen_keys(struct dh_ctx *ctx, int peer);
48#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
49int ssh_dh_keypair_get_keys(struct dh_ctx *ctx, int peer,
50 const_bignum *priv, const_bignum *pub);
51#else
52int ssh_dh_keypair_get_keys(struct dh_ctx *ctx, int peer,
53 bignum *priv, bignum *pub);
54#endif /* OPENSSL_VERSION_NUMBER */
55int ssh_dh_keypair_set_keys(struct dh_ctx *ctx, int peer,
56 const bignum priv, const bignum pub);
57
58int ssh_dh_compute_shared_secret(struct dh_ctx *ctx, int local, int remote,
59 bignum *dest);
60
61void ssh_dh_debug_crypto(struct ssh_crypto_struct *c);
62
63/* common functions */
64int ssh_dh_init(void);
65void ssh_dh_finalize(void);
66
67int ssh_dh_import_next_pubkey_blob(ssh_session session,
68 ssh_string pubkey_blob);
69
70ssh_key ssh_dh_get_current_server_publickey(ssh_session session);
71int ssh_dh_get_current_server_publickey_blob(ssh_session session,
72 ssh_string *pubkey_blob);
73ssh_key ssh_dh_get_next_server_publickey(ssh_session session);
74int ssh_dh_get_next_server_publickey_blob(ssh_session session,
75 ssh_string *pubkey_blob);
76
77int ssh_client_dh_init(ssh_session session);
78#ifdef WITH_SERVER
79void ssh_server_dh_init(ssh_session session);
80#endif /* WITH_SERVER */
81int ssh_server_dh_process_init(ssh_session session, ssh_buffer packet);
82int ssh_fallback_group(uint32_t pmax, bignum *p, bignum *g);
83bool ssh_dh_is_known_group(bignum modulus, bignum generator);
84
85#endif /* DH_H_ */
Definition: dh_crypto.c:47
Definition: buffer.c:47
Definition: crypto.h:106
Definition: pki.h:54
Definition: session.h:110
Definition: string.h:29