]> andersk Git - gssapi-openssh.git/blob - openssh/kex.h
merge OpenSSH 3.9p1 to trunk
[gssapi-openssh.git] / openssh / kex.h
1 /*      $OpenBSD: kex.h,v 1.35 2004/06/13 12:53:24 djm Exp $    */
2
3 /*
4  * Copyright (c) 2000, 2001 Markus Friedl.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 #ifndef KEX_H
27 #define KEX_H
28
29 #include <openssl/evp.h>
30 #include "buffer.h"
31 #include "cipher.h"
32 #include "key.h"
33
34 #define KEX_DH1         "diffie-hellman-group1-sha1"
35 #define KEX_DH14        "diffie-hellman-group14-sha1"
36 #define KEX_DHGEX       "diffie-hellman-group-exchange-sha1"
37
38 enum kex_init_proposals {
39         PROPOSAL_KEX_ALGS,
40         PROPOSAL_SERVER_HOST_KEY_ALGS,
41         PROPOSAL_ENC_ALGS_CTOS,
42         PROPOSAL_ENC_ALGS_STOC,
43         PROPOSAL_MAC_ALGS_CTOS,
44         PROPOSAL_MAC_ALGS_STOC,
45         PROPOSAL_COMP_ALGS_CTOS,
46         PROPOSAL_COMP_ALGS_STOC,
47         PROPOSAL_LANG_CTOS,
48         PROPOSAL_LANG_STOC,
49         PROPOSAL_MAX
50 };
51
52 enum kex_modes {
53         MODE_IN,
54         MODE_OUT,
55         MODE_MAX
56 };
57
58 enum kex_exchange {
59         KEX_DH_GRP1_SHA1,
60         KEX_DH_GRP14_SHA1,
61         KEX_DH_GEX_SHA1,
62         KEX_GSS_GRP1_SHA1,
63         KEX_MAX
64 };
65
66 #define KEX_INIT_SENT   0x0001
67
68 typedef struct Kex Kex;
69 typedef struct Mac Mac;
70 typedef struct Comp Comp;
71 typedef struct Enc Enc;
72 typedef struct Newkeys Newkeys;
73
74 struct Enc {
75         char    *name;
76         Cipher  *cipher;
77         int     enabled;
78         u_int   key_len;
79         u_int   block_size;
80         u_char  *key;
81         u_char  *iv;
82 };
83 struct Mac {
84         char    *name;
85         int     enabled;
86         const EVP_MD    *md;
87         int     mac_len;
88         u_char  *key;
89         int     key_len;
90 };
91 struct Comp {
92         int     type;
93         int     enabled;
94         char    *name;
95 };
96 struct Newkeys {
97         Enc     enc;
98         Mac     mac;
99         Comp    comp;
100 };
101
102 struct KexOptions {
103         int     gss_deleg_creds;
104 };
105
106 struct Kex {
107         u_char  *session_id;
108         u_int   session_id_len;
109         Newkeys *newkeys[MODE_MAX];
110         int     we_need;
111         int     server;
112         char    *name;
113         int     hostkey_type;
114         int     kex_type;
115         Buffer  my;
116         Buffer  peer;
117         int     done;
118         int     flags;
119         char    *client_version_string;
120         char    *server_version_string;
121         struct  KexOptions options;
122         int     (*verify_host_key)(Key *);
123         Key     *(*load_host_key)(int);
124         int     (*host_key_index)(Key *);
125         void    (*kex[KEX_MAX])(Kex *);
126 };
127
128 Kex     *kex_setup(char *[PROPOSAL_MAX]);
129 void     kex_finish(Kex *);
130
131 void     kex_send_kexinit(Kex *);
132 void     kex_input_kexinit(int, u_int32_t, void *);
133 void     kex_derive_keys(Kex *, u_char *, BIGNUM *);
134
135 Newkeys *kex_get_newkeys(int);
136
137 void     kexdh_client(Kex *);
138 void     kexdh_server(Kex *);
139 void     kexgex_client(Kex *);
140 void     kexgex_server(Kex *);
141 #ifdef GSSAPI
142 void     kexgss_client(Kex *);
143 void     kexgss_server(Kex *);
144 #endif
145
146 u_char *
147 kex_dh_hash(char *, char *, char *, int, char *, int, u_char *, int,
148     BIGNUM *, BIGNUM *, BIGNUM *);
149 u_char *
150 kexgex_hash(char *, char *, char *, int, char *, int, u_char *, int,
151     int, int, int, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *);
152
153 void
154 derive_ssh1_session_id(BIGNUM *, BIGNUM *, u_int8_t[8], u_int8_t[16]);
155
156 #if defined(DEBUG_KEX) || defined(DEBUG_KEXDH)
157 void    dump_digest(char *, u_char *, int);
158 #endif
159
160 #endif
This page took 0.05396 seconds and 5 git commands to generate.