libssh: /build/libssh/src/libssh-0.9.3/include/libssh/dh.h Source File

libssh 0.9.3 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
28 struct dh_ctx;
29
30 #define DH_CLIENT_KEYPAIR 0
31 #define DH_SERVER_KEYPAIR 1
32
33 /* functions implemented by crypto backends */
34 int ssh_dh_init_common(struct ssh_crypto_struct *crypto);
35 void ssh_dh_cleanup(struct ssh_crypto_struct *crypto);
36
37 int ssh_dh_get_parameters(struct dh_ctx *ctx,
38 const_bignum *modulus, const_bignum *generator);
39 int ssh_dh_set_parameters(struct dh_ctx *ctx,
40 const bignum modulus, const bignum generator);
41
42 int ssh_dh_keypair_gen_keys(struct dh_ctx *ctx, int peer);
43 int ssh_dh_keypair_get_keys(struct dh_ctx *ctx, int peer,
44 const_bignum *priv, const_bignum *pub);
45 int ssh_dh_keypair_set_keys(struct dh_ctx *ctx, int peer,
46 const bignum priv, const bignum pub);
47
48 int ssh_dh_compute_shared_secret(struct dh_ctx *ctx, int local, int remote,
49 bignum *dest);
50
51 void ssh_dh_debug_crypto(struct ssh_crypto_struct *c);
52
53 /* common functions */
54 int ssh_dh_init(void);
55 void ssh_dh_finalize(void);
56
57 int ssh_dh_import_next_pubkey_blob(ssh_session session,
58 ssh_string pubkey_blob);
59
60 ssh_key ssh_dh_get_current_server_publickey(ssh_session session);
61 int ssh_dh_get_current_server_publickey_blob(ssh_session session,
62 ssh_string *pubkey_blob);
63 ssh_key ssh_dh_get_next_server_publickey(ssh_session session);
64 int ssh_dh_get_next_server_publickey_blob(ssh_session session,
65 ssh_string *pubkey_blob);
66
67 int ssh_client_dh_init(ssh_session session);
68 #ifdef WITH_SERVER
69 void ssh_server_dh_init(ssh_session session);
70 #endif /* WITH_SERVER */
71 int ssh_server_dh_process_init(ssh_session session, ssh_buffer packet);
72 int ssh_fallback_group(uint32_t pmax, bignum *p, bignum *g);
73 bool ssh_dh_is_known_group(bignum modulus, bignum generator);
74
75 #endif /* DH_H_ */
ssh_key_struct
Definition: pki.h:50
ssh_crypto_struct
Definition: crypto.h:104
ssh_buffer_struct
Definition: buffer.c:47
ssh_session_struct
Definition: session.h:109
dh_ctx
Definition: dh_crypto.c:40
ssh_string_struct
Definition: string.h:29