dropbear: update to 2013.62
[tomato.git] / release / src / router / dropbear / kex.h
blob144df5973f1041cb6f9edc5f804ff7f920fd99e8
1 /*
2 * Dropbear - a SSH2 server
3 *
4 * Copyright (c) 2002,2003 Matt Johnston
5 * All rights reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE. */
25 #ifndef _KEX_H_
26 #define _KEX_H_
28 #include "includes.h"
29 #include "algo.h"
30 #include "signkey.h"
32 void send_msg_kexinit();
33 void recv_msg_kexinit();
34 void send_msg_newkeys();
35 void recv_msg_newkeys();
36 void kexfirstinitialise();
38 struct kex_dh_param *gen_kexdh_param();
39 void free_kexdh_param(struct kex_dh_param *param);
40 void kexdh_comb_key(struct kex_dh_param *param, mp_int *dh_pub_them,
41 sign_key *hostkey);
43 #ifdef DROPBEAR_ECDH
44 struct kex_ecdh_param *gen_kexecdh_param();
45 void free_kexecdh_param(struct kex_ecdh_param *param);
46 void kexecdh_comb_key(struct kex_ecdh_param *param, buffer *pub_them,
47 sign_key *hostkey);
48 #endif
50 #ifdef DROPBEAR_CURVE25519
51 struct kex_curve25519_param *gen_kexcurve25519_param();
52 void free_kexcurve25519_param(struct kex_curve25519_param *param);
53 void kexcurve25519_comb_key(struct kex_curve25519_param *param, buffer *pub_them,
54 sign_key *hostkey);
55 #endif
57 #ifndef DISABLE_ZLIB
58 int is_compress_trans();
59 int is_compress_recv();
60 #endif
62 void recv_msg_kexdh_init(); /* server */
64 void send_msg_kexdh_init(); /* client */
65 void recv_msg_kexdh_reply(); /* client */
67 struct KEXState {
69 unsigned sentkexinit : 1; /*set when we've sent/recv kexinit packet */
70 unsigned recvkexinit : 1;
71 unsigned them_firstfollows : 1; /* true when first_kex_packet_follows is set */
72 unsigned sentnewkeys : 1; /* set once we've send MSG_NEWKEYS (will be cleared once we have also received */
73 unsigned recvnewkeys : 1; /* set once we've received MSG_NEWKEYS (cleared once we have also sent */
75 unsigned donefirstkex : 1; /* Set to 1 after the first kex has completed,
76 ie the transport layer has been set up */
78 unsigned our_first_follows_matches : 1;
80 time_t lastkextime; /* time of the last kex */
81 unsigned int datatrans; /* data transmitted since last kex */
82 unsigned int datarecv; /* data received since last kex */
86 #define DH_P_1_LEN 128
87 extern const unsigned char dh_p_1[DH_P_1_LEN];
88 #define DH_P_14_LEN 256
89 extern const unsigned char dh_p_14[DH_P_14_LEN];
91 struct kex_dh_param {
92 mp_int pub; /* e */
93 mp_int priv; /* x */
96 #ifdef DROPBEAR_ECDH
97 struct kex_ecdh_param {
98 ecc_key key;
100 #endif
102 #ifdef DROPBEAR_CURVE25519
103 #define CURVE25519_LEN 32
104 struct kex_curve25519_param {
105 unsigned char priv[CURVE25519_LEN];
106 unsigned char pub[CURVE25519_LEN];
109 /* No header file for curve25519_donna */
110 int curve25519_donna(unsigned char *out, const unsigned char *secret, const unsigned char *other);
111 #endif
114 #define MAX_KEXHASHBUF 2000
116 #endif /* _KEX_H_ */