blob: 7e5c67024bff2f2676cd3ab403d369199c883feb [file] [log] [blame]
Damien Miller33b13562000-04-04 14:38:59 +10001/*
2 * Copyright (c) 2000 Markus Friedl. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. All advertising materials mentioning features or use of this software
13 * must display the following acknowledgement:
14 * This product includes software developed by Markus Friedl.
15 * 4. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29#ifndef KEX_H
30#define KEX_H
31
Damien Miller33b13562000-04-04 14:38:59 +100032#define KEX_DH1 "diffie-hellman-group1-sha1"
33#define KEX_DSS "ssh-dss"
34
35enum kex_init_proposals {
36 PROPOSAL_KEX_ALGS,
37 PROPOSAL_SERVER_HOST_KEY_ALGS,
38 PROPOSAL_ENC_ALGS_CTOS,
39 PROPOSAL_ENC_ALGS_STOC,
40 PROPOSAL_MAC_ALGS_CTOS,
41 PROPOSAL_MAC_ALGS_STOC,
42 PROPOSAL_COMP_ALGS_CTOS,
43 PROPOSAL_COMP_ALGS_STOC,
44 PROPOSAL_LANG_CTOS,
45 PROPOSAL_LANG_STOC,
46 PROPOSAL_MAX
47};
48
49enum kex_modes {
50 MODE_IN,
51 MODE_OUT,
52 MODE_MAX
53};
54
55typedef struct Kex Kex;
56typedef struct Mac Mac;
57typedef struct Comp Comp;
58typedef struct Enc Enc;
59
60struct Enc {
61 int type;
62 int enabled;
63 int block_size;
64 unsigned char *key;
65 unsigned char *iv;
66 int key_len;
67 int iv_len;
68 char *name;
69};
70struct Mac {
71 EVP_MD *md;
72 int enabled;
73 int mac_len;
74 unsigned char *key;
75 int key_len;
76 char *name;
77};
78struct Comp {
79 int type;
80 int enabled;
81 char *name;
82};
83struct Kex {
84 Enc enc [MODE_MAX];
85 Mac mac [MODE_MAX];
86 Comp comp[MODE_MAX];
87 int we_need;
88 int server;
89 char *name;
90 char *hostkeyalg;
91};
92
93Buffer *kex_init(char *myproposal[PROPOSAL_MAX]);
Damien Millerb1715dc2000-05-30 13:44:51 +100094void
95kex_exchange_kexinit(
96 Buffer *my_kexinit, Buffer *peer_kexint,
97 char *peer_proposal[PROPOSAL_MAX]);
98Kex *
99kex_choose_conf(char *cprop[PROPOSAL_MAX],
100 char *sprop[PROPOSAL_MAX], int server);
101int kex_derive_keys(Kex *k, unsigned char *hash, BIGNUM *shared_secret);
102void packet_set_kex(Kex *k);
Damien Miller78928792000-04-12 20:17:38 +1000103int dh_pub_is_valid(DH *dh, BIGNUM *dh_pub);
104DH *dh_new_group1();
Damien Miller33b13562000-04-04 14:38:59 +1000105
106unsigned char *
107kex_hash(
108 char *client_version_string,
109 char *server_version_string,
110 char *ckexinit, int ckexinitlen,
111 char *skexinit, int skexinitlen,
112 char *serverhostkeyblob, int sbloblen,
113 BIGNUM *client_dh_pub,
114 BIGNUM *server_dh_pub,
115 BIGNUM *shared_secret);
116
117#endif