]> andersk Git - gssapi-openssh.git/blame - openssh/kex.h
merged OpenSSH 5.3p1 to trunk
[gssapi-openssh.git] / openssh / kex.h
CommitLineData
b5afdff5 1/* $OpenBSD: kex.h,v 1.47 2009/05/27 06:34:36 andreas Exp $ */
3c0ef626 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
30460aeb 29#include <signal.h>
3c0ef626 30#include <openssl/evp.h>
fa0f0f45 31#include <openssl/hmac.h>
3c0ef626 32
b5afdff5 33#define KEX_COOKIE_LEN 16
34
08822d99 35#define KEX_DH1 "diffie-hellman-group1-sha1"
36#define KEX_DH14 "diffie-hellman-group14-sha1"
37#define KEX_DHGEX_SHA1 "diffie-hellman-group-exchange-sha1"
30460aeb 38#define KEX_DHGEX_SHA256 "diffie-hellman-group-exchange-sha256"
3c0ef626 39
2ce0bfe4 40#define COMP_NONE 0
41#define COMP_ZLIB 1
42#define COMP_DELAYED 2
43
3c0ef626 44enum kex_init_proposals {
45 PROPOSAL_KEX_ALGS,
46 PROPOSAL_SERVER_HOST_KEY_ALGS,
47 PROPOSAL_ENC_ALGS_CTOS,
48 PROPOSAL_ENC_ALGS_STOC,
49 PROPOSAL_MAC_ALGS_CTOS,
50 PROPOSAL_MAC_ALGS_STOC,
51 PROPOSAL_COMP_ALGS_CTOS,
52 PROPOSAL_COMP_ALGS_STOC,
53 PROPOSAL_LANG_CTOS,
54 PROPOSAL_LANG_STOC,
55 PROPOSAL_MAX
56};
57
58enum kex_modes {
59 MODE_IN,
60 MODE_OUT,
61 MODE_MAX
62};
63
64enum kex_exchange {
8afc6a66 65 KEX_DH_GRP1_SHA1,
7e82606e 66 KEX_DH_GRP14_SHA1,
8afc6a66 67 KEX_DH_GEX_SHA1,
f713db99 68 KEX_DH_GEX_SHA256,
8afc6a66 69 KEX_GSS_GRP1_SHA1,
f713db99 70 KEX_GSS_GRP14_SHA1,
fe4ad273 71 KEX_GSS_GEX_SHA1,
8afc6a66 72 KEX_MAX
3c0ef626 73};
74
75#define KEX_INIT_SENT 0x0001
76
77typedef struct Kex Kex;
78typedef struct Mac Mac;
79typedef struct Comp Comp;
80typedef struct Enc Enc;
81typedef struct Newkeys Newkeys;
82
83struct Enc {
84 char *name;
85 Cipher *cipher;
86 int enabled;
e9702f7d 87 u_int key_len;
88 u_int block_size;
3c0ef626 89 u_char *key;
90 u_char *iv;
91};
92struct Mac {
93 char *name;
94 int enabled;
2ce0bfe4 95 u_int mac_len;
3c0ef626 96 u_char *key;
2ce0bfe4 97 u_int key_len;
fa0f0f45 98 int type;
99 const EVP_MD *evp_md;
100 HMAC_CTX evp_ctx;
101 struct umac_ctx *umac_ctx;
3c0ef626 102};
103struct Comp {
104 int type;
105 int enabled;
106 char *name;
107};
108struct Newkeys {
109 Enc enc;
110 Mac mac;
111 Comp comp;
112};
5598e598 113
3c0ef626 114struct Kex {
115 u_char *session_id;
d03f4262 116 u_int session_id_len;
3c0ef626 117 Newkeys *newkeys[MODE_MAX];
2ce0bfe4 118 u_int we_need;
3c0ef626 119 int server;
120 char *name;
121 int hostkey_type;
122 int kex_type;
123 Buffer my;
124 Buffer peer;
30460aeb 125 sig_atomic_t done;
3c0ef626 126 int flags;
08822d99 127 const EVP_MD *evp_md;
fe4ad273 128#ifdef GSSAPI
c06c9ae8 129 int gss_deleg_creds;
fe4ad273 130 int gss_trust_dns;
131 char *gss_host;
f97edba6 132 char *gss_client;
fe4ad273 133#endif
3c0ef626 134 char *client_version_string;
135 char *server_version_string;
136 int (*verify_host_key)(Key *);
137 Key *(*load_host_key)(int);
350391c5 138 int (*host_key_index)(Key *);
8afc6a66 139 void (*kex[KEX_MAX])(Kex *);
3c0ef626 140};
141
473db5ab 142void kex_prop2buf(Buffer *, char *proposal[PROPOSAL_MAX]);
143
3c0ef626 144Kex *kex_setup(char *[PROPOSAL_MAX]);
145void kex_finish(Kex *);
146
147void kex_send_kexinit(Kex *);
e9702f7d 148void kex_input_kexinit(int, u_int32_t, void *);
08822d99 149void kex_derive_keys(Kex *, u_char *, u_int, BIGNUM *);
3c0ef626 150
8afc6a66 151Newkeys *kex_get_newkeys(int);
152
153void kexdh_client(Kex *);
154void kexdh_server(Kex *);
155void kexgex_client(Kex *);
156void kexgex_server(Kex *);
fe4ad273 157
b2b34e95 158#ifdef GSSAPI
fe4ad273 159void kexgss_client(Kex *);
160void kexgss_server(Kex *);
b2b34e95 161#endif
905081a4 162
08822d99 163void
8afc6a66 164kex_dh_hash(char *, char *, char *, int, char *, int, u_char *, int,
08822d99 165 BIGNUM *, BIGNUM *, BIGNUM *, u_char **, u_int *);
166void
167kexgex_hash(const EVP_MD *, char *, char *, char *, int, char *,
30460aeb 168 int, u_char *, int, int, int, int, BIGNUM *, BIGNUM *, BIGNUM *,
08822d99 169 BIGNUM *, BIGNUM *, u_char **, u_int *);
3c0ef626 170
7e82606e 171void
172derive_ssh1_session_id(BIGNUM *, BIGNUM *, u_int8_t[8], u_int8_t[16]);
173
3c0ef626 174#if defined(DEBUG_KEX) || defined(DEBUG_KEXDH)
175void dump_digest(char *, u_char *, int);
176#endif
177
178#endif
This page took 0.095994 seconds and 5 git commands to generate.