]> andersk Git - openssh.git/blob - kex.h
doc
[openssh.git] / kex.h
1 /*
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
32 #include "config.h"
33
34 #ifdef HAVE_OPENSSL
35 # include <openssl/bn.h>
36 # include <openssl/evp.h>
37 #endif
38 #ifdef HAVE_SSL
39 # include <ssl/bn.h>
40 # include <ssl/evp.h>
41 #endif
42
43 #define KEX_DH1 "diffie-hellman-group1-sha1"
44 #define KEX_DSS "ssh-dss"
45
46 enum kex_init_proposals {
47         PROPOSAL_KEX_ALGS,
48         PROPOSAL_SERVER_HOST_KEY_ALGS,
49         PROPOSAL_ENC_ALGS_CTOS,
50         PROPOSAL_ENC_ALGS_STOC,
51         PROPOSAL_MAC_ALGS_CTOS,
52         PROPOSAL_MAC_ALGS_STOC,
53         PROPOSAL_COMP_ALGS_CTOS,
54         PROPOSAL_COMP_ALGS_STOC,
55         PROPOSAL_LANG_CTOS,
56         PROPOSAL_LANG_STOC,
57         PROPOSAL_MAX
58 };
59
60 enum kex_modes {
61         MODE_IN,
62         MODE_OUT,
63         MODE_MAX
64 };
65
66 typedef struct Kex Kex;
67 typedef struct Mac Mac;
68 typedef struct Comp Comp;
69 typedef struct Enc Enc;
70
71 struct Enc {
72         int             type;
73         int             enabled;
74         int             block_size;
75         unsigned char   *key;
76         unsigned char   *iv;
77         int             key_len;
78         int             iv_len;
79         char            *name;
80 };
81 struct Mac {
82         EVP_MD          *md;
83         int             enabled;
84         int             mac_len;
85         unsigned char   *key;
86         int             key_len;
87         char            *name;
88 };
89 struct Comp {
90         int             type;
91         int             enabled;
92         char            *name;
93 };
94 struct Kex {
95         Enc             enc [MODE_MAX];
96         Mac             mac [MODE_MAX];
97         Comp            comp[MODE_MAX];
98         int             we_need;
99         int             server;
100         char            *name;
101         char            *hostkeyalg;
102 };
103
104 Buffer  *kex_init(char *myproposal[PROPOSAL_MAX]);
105 int     dh_pub_is_valid(DH *dh, BIGNUM *dh_pub);
106 DH      *dh_new_group1();
107 Kex     *kex_choose_conf(char *cprop[PROPOSAL_MAX], char *sprop[PROPOSAL_MAX], int server);
108 int     kex_derive_keys(Kex *k, unsigned char *hash, BIGNUM *shared_secret);
109 void    bignum_print(BIGNUM *b);
110 void    packet_set_kex(Kex *k);
111
112 unsigned char *
113 kex_hash(
114     char *client_version_string,
115     char *server_version_string,
116     char *ckexinit, int ckexinitlen,
117     char *skexinit, int skexinitlen,
118     char *serverhostkeyblob, int sbloblen,
119     BIGNUM *client_dh_pub,
120     BIGNUM *server_dh_pub,
121     BIGNUM *shared_secret);
122
123 #endif
This page took 0.047566 seconds and 5 git commands to generate.