annotate common-kex.c @ 57:3b2a5a1c4347 authpam

svr-authpam code merged and works. needs tidying a log
author Matt Johnston <matt@ucc.asn.au>
date Sun, 08 Aug 2004 16:57:37 +0000
parents a600c015562d
children e3adf4cf5465
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 /*
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 * Dropbear - a SSH2 server
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 * SSH client implementation
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 * This code is copied from the larger file "kex.c"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 * some functions are verbatim, others are generalized --mihnea
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 *
33
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
8 * Copyright (c) 2002-2004 Matt Johnston
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 * Portions Copyright (c) 2004 by Mihnea Stoenescu
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 * All rights reserved.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 * Permission is hereby granted, free of charge, to any person obtaining a copy
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 * of this software and associated documentation files (the "Software"), to deal
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 * in the Software without restriction, including without limitation the rights
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 * copies of the Software, and to permit persons to whom the Software is
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 * furnished to do so, subject to the following conditions:
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 * The above copyright notice and this permission notice shall be included in
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 * all copies or substantial portions of the Software.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
28 * SOFTWARE. */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
30 #include "includes.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
31 #include "dbutil.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
32 #include "algo.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
33 #include "buffer.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
34 #include "session.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
35 #include "kex.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
36 #include "ssh.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
37 #include "packet.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
38 #include "bignum.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
39 #include "random.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
40
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
41 /* diffie-hellman-group1-sha1 value for p */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
42 const unsigned char dh_p_val[] = {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
43 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
44 0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
45 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
46 0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
47 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
48 0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
49 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
50 0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
51 0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
52 0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE6, 0x53, 0x81,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
53 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
54
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
55 const int DH_G_VAL = 2;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
56
33
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
57 static void kexinitialise();
35
0ad5fb979f42 set the isserver flag (oops)
Matt Johnston <matt@ucc.asn.au>
parents: 34
diff changeset
58 void gen_new_keys();
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
59 #ifndef DISABLE_ZLIB
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
60 static void gen_new_zstreams();
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
61 #endif
33
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
62 static void read_kex_algos();
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
63 /* helper function for gen_new_keys */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
64 static void hashkeys(unsigned char *out, int outlen,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
65 const hash_state * hs, unsigned const char X);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
66
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
67
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
68 /* Send our list of algorithms we can use */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
69 void send_msg_kexinit() {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
70
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
71 CHECKCLEARTOWRITE();
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
72 buf_putbyte(ses.writepayload, SSH_MSG_KEXINIT);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
73
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
74 /* cookie */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
75 genrandom(buf_getwriteptr(ses.writepayload, 16), 16);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
76 buf_incrwritepos(ses.writepayload, 16);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
77
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
78 /* kex algos */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
79 buf_put_algolist(ses.writepayload, sshkex);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
80
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
81 /* server_host_key_algorithms */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
82 buf_put_algolist(ses.writepayload, sshhostkey);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
83
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
84 /* encryption_algorithms_client_to_server */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
85 buf_put_algolist(ses.writepayload, sshciphers);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
86
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
87 /* encryption_algorithms_server_to_client */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
88 buf_put_algolist(ses.writepayload, sshciphers);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
89
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
90 /* mac_algorithms_client_to_server */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
91 buf_put_algolist(ses.writepayload, sshhashes);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
92
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
93 /* mac_algorithms_server_to_client */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
94 buf_put_algolist(ses.writepayload, sshhashes);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
95
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
96 /* compression_algorithms_client_to_server */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
97 buf_put_algolist(ses.writepayload, sshcompress);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
98
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
99 /* compression_algorithms_server_to_client */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
100 buf_put_algolist(ses.writepayload, sshcompress);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
101
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
102 /* languages_client_to_server */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
103 buf_putstring(ses.writepayload, "", 0);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
104
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
105 /* languages_server_to_client */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
106 buf_putstring(ses.writepayload, "", 0);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
107
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
108 /* first_kex_packet_follows - unimplemented for now */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
109 buf_putbyte(ses.writepayload, 0x00);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
110
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
111 /* reserved unit32 */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
112 buf_putint(ses.writepayload, 0);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
113
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
114 /* set up transmitted kex packet buffer for hashing.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
115 * This is freed after the end of the kex */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
116 ses.transkexinit = buf_newcopy(ses.writepayload);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
117
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
118 encrypt_packet();
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
119 ses.dataallowed = 0; /* don't send other packets during kex */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
120
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
121 TRACE(("DATAALLOWED=0"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
122 TRACE(("-> KEXINIT"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
123 ses.kexstate.sentkexinit = 1;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
124 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
125
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
126 /* *** NOTE regarding (send|recv)_msg_newkeys ***
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
127 * Changed by mihnea from the original kex.c to set dataallowed after a
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
128 * completed key exchange, no matter the order in which it was performed.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
129 * This enables client mode without affecting server functionality.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
130 */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
131
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
132 /* Bring new keys into use after a key exchange, and let the client know*/
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
133 void send_msg_newkeys() {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
134
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
135 TRACE(("enter send_msg_newkeys"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
136
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
137 /* generate the kexinit request */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
138 CHECKCLEARTOWRITE();
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
139 buf_putbyte(ses.writepayload, SSH_MSG_NEWKEYS);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
140 encrypt_packet();
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
141
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
142
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
143 /* set up our state */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
144 if (ses.kexstate.recvnewkeys) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
145 TRACE(("while RECVNEWKEYS=1"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
146 gen_new_keys();
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
147 kexinitialise(); /* we've finished with this kex */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
148 TRACE((" -> DATAALLOWED=1"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
149 ses.dataallowed = 1; /* we can send other packets again now */
33
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
150 ses.kexstate.donefirstkex = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
151 } else {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
152 ses.kexstate.sentnewkeys = 1;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
153 TRACE(("SENTNEWKEYS=1"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
154 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
155
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
156 TRACE(("-> MSG_NEWKEYS"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
157 TRACE(("leave send_msg_newkeys"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
158 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
159
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
160 /* Bring the new keys into use after a key exchange */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
161 void recv_msg_newkeys() {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
162
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
163 TRACE(("<- MSG_NEWKEYS"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
164 TRACE(("enter recv_msg_newkeys"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
165
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
166 /* simply check if we've sent SSH_MSG_NEWKEYS, and if so,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
167 * switch to the new keys */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
168 if (ses.kexstate.sentnewkeys) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
169 TRACE(("while SENTNEWKEYS=1"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
170 gen_new_keys();
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
171 kexinitialise(); /* we've finished with this kex */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
172 TRACE((" -> DATAALLOWED=1"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
173 ses.dataallowed = 1; /* we can send other packets again now */
33
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
174 ses.kexstate.donefirstkex = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
175 } else {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
176 TRACE(("RECVNEWKEYS=1"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
177 ses.kexstate.recvnewkeys = 1;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
178 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
179
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
180 TRACE(("leave recv_msg_newkeys"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
181 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
182
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
183
33
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
184 /* Set up the kex for the first time */
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
185 void kexfirstinitialise() {
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
186
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
187 ses.kexstate.donefirstkex = 0;
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
188 kexinitialise();
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
189 }
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
190
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
191 /* Reset the kex state, ready for a new negotiation */
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
192 static void kexinitialise() {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
193
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
194 struct timeval tv;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
195
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
196 TRACE(("kexinitialise()"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
197
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
198 /* sent/recv'd MSG_KEXINIT */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
199 ses.kexstate.sentkexinit = 0;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
200 ses.kexstate.recvkexinit = 0;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
201
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
202 /* sent/recv'd MSG_NEWKEYS */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
203 ses.kexstate.recvnewkeys = 0;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
204 ses.kexstate.sentnewkeys = 0;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
205
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
206 /* first_packet_follows */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
207 ses.kexstate.firstfollows = 0;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
208
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
209 ses.kexstate.datatrans = 0;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
210 ses.kexstate.datarecv = 0;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
211
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
212 if (gettimeofday(&tv, 0) < 0) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
213 dropbear_exit("Error getting time");
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
214 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
215 ses.kexstate.lastkextime = tv.tv_sec;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
216
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
217 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
218
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
219 /* Helper function for gen_new_keys, creates a hash. It makes a copy of the
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
220 * already initialised hash_state hs, which should already have processed
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
221 * the dh_K and hash, since these are common. X is the letter 'A', 'B' etc.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
222 * out must have at least min(SHA1_HASH_SIZE, outlen) bytes allocated.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
223 * The output will only be expanded once, since that is all that is required
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
224 * (for 3DES and SHA, with 24 and 20 bytes respectively).
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
225 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
226 * See Section 5.2 of the IETF secsh Transport Draft for details */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
227
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
228 /* Duplicated verbatim from kex.c --mihnea */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
229 static void hashkeys(unsigned char *out, int outlen,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
230 const hash_state * hs, const unsigned char X) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
231
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
232 hash_state hs2;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
233 unsigned char k2[SHA1_HASH_SIZE]; /* used to extending */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
234
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
235 memcpy(&hs2, hs, sizeof(hash_state));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
236 sha1_process(&hs2, &X, 1);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
237 sha1_process(&hs2, ses.session_id, SHA1_HASH_SIZE);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
238 sha1_done(&hs2, out);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
239 if (SHA1_HASH_SIZE < outlen) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
240 /* need to extend */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
241 memcpy(&hs2, hs, sizeof(hash_state));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
242 sha1_process(&hs2, out, SHA1_HASH_SIZE);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
243 sha1_done(&hs2, k2);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
244 memcpy(&out[SHA1_HASH_SIZE], k2, outlen - SHA1_HASH_SIZE);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
245 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
246 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
247
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
248 /* Generate the actual encryption/integrity keys, using the results of the
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
249 * key exchange, as specified in section 5.2 of the IETF secsh-transport
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
250 * draft. This occurs after the DH key-exchange.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
251 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
252 * ses.newkeys is the new set of keys which are generated, these are only
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
253 * taken into use after both sides have sent a newkeys message */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
254
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
255 /* Originally from kex.c, generalized for cli/svr mode --mihnea */
35
0ad5fb979f42 set the isserver flag (oops)
Matt Johnston <matt@ucc.asn.au>
parents: 34
diff changeset
256 void gen_new_keys() {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
257
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
258 unsigned char C2S_IV[MAX_IV_LEN];
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
259 unsigned char C2S_key[MAX_KEY_LEN];
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
260 unsigned char S2C_IV[MAX_IV_LEN];
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
261 unsigned char S2C_key[MAX_KEY_LEN];
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
262 /* unsigned char key[MAX_KEY_LEN]; */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
263 unsigned char *trans_IV, *trans_key, *recv_IV, *recv_key;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
264
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
265 hash_state hs;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
266 unsigned int C2S_keysize, S2C_keysize;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
267 char mactransletter, macrecvletter; /* Client or server specific */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
268
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
269 TRACE(("enter gen_new_keys"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
270 /* the dh_K and hash are the start of all hashes, we make use of that */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
271
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
272 sha1_init(&hs);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
273 sha1_process_mp(&hs, ses.dh_K);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
274 mp_clear(ses.dh_K);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
275 m_free(ses.dh_K);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
276 sha1_process(&hs, ses.hash, SHA1_HASH_SIZE);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
277 m_burn(ses.hash, SHA1_HASH_SIZE);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
278
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
279 if (IS_DROPBEAR_CLIENT) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
280 trans_IV = C2S_IV;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
281 recv_IV = S2C_IV;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
282 trans_key = C2S_key;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
283 recv_key = S2C_key;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
284 C2S_keysize = ses.newkeys->trans_algo_crypt->keysize;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
285 S2C_keysize = ses.newkeys->recv_algo_crypt->keysize;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
286 mactransletter = 'E';
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
287 macrecvletter = 'F';
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
288 } else {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
289 trans_IV = S2C_IV;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
290 recv_IV = C2S_IV;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
291 trans_key = S2C_key;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
292 recv_key = C2S_key;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
293 C2S_keysize = ses.newkeys->recv_algo_crypt->keysize;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
294 S2C_keysize = ses.newkeys->trans_algo_crypt->keysize;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
295 mactransletter = 'F';
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
296 macrecvletter = 'E';
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
297 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
298
35
0ad5fb979f42 set the isserver flag (oops)
Matt Johnston <matt@ucc.asn.au>
parents: 34
diff changeset
299 hashkeys(C2S_IV, SHA1_HASH_SIZE, &hs, 'A');
0ad5fb979f42 set the isserver flag (oops)
Matt Johnston <matt@ucc.asn.au>
parents: 34
diff changeset
300 hashkeys(S2C_IV, SHA1_HASH_SIZE, &hs, 'B');
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
301 hashkeys(C2S_key, C2S_keysize, &hs, 'C');
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
302 hashkeys(S2C_key, S2C_keysize, &hs, 'D');
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
303
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
304 if (cbc_start(
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
305 find_cipher(ses.newkeys->recv_algo_crypt->cipherdesc->name),
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
306 recv_IV, recv_key,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
307 ses.newkeys->recv_algo_crypt->keysize, 0,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
308 &ses.newkeys->recv_symmetric_struct) != CRYPT_OK) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
309 dropbear_exit("crypto error");
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
310 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
311
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
312 if (cbc_start(
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
313 find_cipher(ses.newkeys->trans_algo_crypt->cipherdesc->name),
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
314 trans_IV, trans_key,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
315 ses.newkeys->trans_algo_crypt->keysize, 0,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
316 &ses.newkeys->trans_symmetric_struct) != CRYPT_OK) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
317 dropbear_exit("crypto error");
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
318 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
319
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
320 /* MAC keys */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
321 hashkeys(ses.newkeys->transmackey,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
322 ses.newkeys->trans_algo_mac->keysize, &hs, mactransletter);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
323 hashkeys(ses.newkeys->recvmackey,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
324 ses.newkeys->recv_algo_mac->keysize, &hs, macrecvletter);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
325
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
326 #ifndef DISABLE_ZLIB
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
327 gen_new_zstreams();
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
328 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
329
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
330 /* Switch over to the new keys */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
331 m_burn(ses.keys, sizeof(struct key_context));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
332 m_free(ses.keys);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
333 ses.keys = ses.newkeys;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
334 ses.newkeys = NULL;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
335
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
336 TRACE(("leave gen_new_keys"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
337 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
338
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
339 #ifndef DISABLE_ZLIB
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
340 /* Set up new zlib compression streams, close the old ones. Only
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
341 * called from gen_new_keys() */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
342 static void gen_new_zstreams() {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
343
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
344 /* create new zstreams */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
345 if (ses.newkeys->recv_algo_comp == DROPBEAR_COMP_ZLIB) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
346 ses.newkeys->recv_zstream = (z_streamp)m_malloc(sizeof(z_stream));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
347 ses.newkeys->recv_zstream->zalloc = Z_NULL;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
348 ses.newkeys->recv_zstream->zfree = Z_NULL;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
349
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
350 if (inflateInit(ses.newkeys->recv_zstream) != Z_OK) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
351 dropbear_exit("zlib error");
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
352 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
353 } else {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
354 ses.newkeys->recv_zstream = NULL;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
355 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
356
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
357 if (ses.newkeys->trans_algo_comp == DROPBEAR_COMP_ZLIB) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
358 ses.newkeys->trans_zstream = (z_streamp)m_malloc(sizeof(z_stream));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
359 ses.newkeys->trans_zstream->zalloc = Z_NULL;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
360 ses.newkeys->trans_zstream->zfree = Z_NULL;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
361
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
362 if (deflateInit(ses.newkeys->trans_zstream, Z_DEFAULT_COMPRESSION)
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
363 != Z_OK) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
364 dropbear_exit("zlib error");
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
365 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
366 } else {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
367 ses.newkeys->trans_zstream = NULL;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
368 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
369
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
370 /* clean up old keys */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
371 if (ses.keys->recv_zstream != NULL) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
372 if (inflateEnd(ses.keys->recv_zstream) == Z_STREAM_ERROR) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
373 /* Z_DATA_ERROR is ok, just means that stream isn't ended */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
374 dropbear_exit("crypto error");
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
375 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
376 m_free(ses.keys->recv_zstream);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
377 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
378 if (ses.keys->trans_zstream != NULL) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
379 if (deflateEnd(ses.keys->trans_zstream) == Z_STREAM_ERROR) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
380 /* Z_DATA_ERROR is ok, just means that stream isn't ended */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
381 dropbear_exit("crypto error");
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
382 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
383 m_free(ses.keys->trans_zstream);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
384 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
385 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
386 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
387
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
388
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
389 /* Executed upon receiving a kexinit message from the client to initiate
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
390 * key exchange. If we haven't already done so, we send the list of our
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
391 * preferred algorithms. The client's requested algorithms are processed,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
392 * and we calculate the first portion of the key-exchange-hash for used
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
393 * later in the key exchange. No response is sent, as the client should
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
394 * initiate the diffie-hellman key exchange */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
395
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
396 /* Originally from kex.c, generalized for cli/svr mode --mihnea */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
397 /* Belongs in common_kex.c where it should be moved after review */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
398 void recv_msg_kexinit() {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
399
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
400 TRACE(("<- KEXINIT"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
401 TRACE(("enter recv_msg_kexinit"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
402
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
403 /* start the kex hash */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
404 ses.kexhashbuf = buf_new(MAX_KEXHASHBUF);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
405
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
406 if (!ses.kexstate.sentkexinit) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
407 /* we need to send a kex packet */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
408 send_msg_kexinit();
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
409 TRACE(("continue recv_msg_kexinit: sent kexinit"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
410 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
411
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
412
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
413 if (IS_DROPBEAR_CLIENT) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
414
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
415 /* read the peer's choice of algos */
33
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
416 read_kex_algos();
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
417
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
418 /* V_C, the client's version string (CR and NL excluded) */
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
419 buf_putstring(ses.kexhashbuf,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
420 (unsigned char*)LOCAL_IDENT, strlen(LOCAL_IDENT));
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
421 /* V_S, the server's version string (CR and NL excluded) */
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
422 buf_putstring(ses.kexhashbuf,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
423 ses.remoteident, strlen((char*)ses.remoteident));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
424
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
425 /* I_C, the payload of the client's SSH_MSG_KEXINIT */
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
426 buf_putstring(ses.kexhashbuf,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
427 buf_getptr(ses.transkexinit, ses.transkexinit->len),
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
428 ses.transkexinit->len);
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
429 /* I_S, the payload of the server's SSH_MSG_KEXINIT */
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
430 buf_setpos(ses.payload, 0);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
431 buf_putstring(ses.kexhashbuf,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
432 buf_getptr(ses.payload, ses.payload->len),
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
433 ses.payload->len);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
434
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
435 } else {
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
436 /* SERVER */
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
437
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
438 /* read the peer's choice of algos */
33
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
439 read_kex_algos();
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
440 /* V_C, the client's version string (CR and NL excluded) */
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
441 buf_putstring(ses.kexhashbuf,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
442 ses.remoteident, strlen((char*)ses.remoteident));
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
443 /* V_S, the server's version string (CR and NL excluded) */
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
444 buf_putstring(ses.kexhashbuf,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
445 (unsigned char*)LOCAL_IDENT, strlen(LOCAL_IDENT));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
446
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
447 /* I_C, the payload of the client's SSH_MSG_KEXINIT */
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
448 buf_setpos(ses.payload, 0);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
449 buf_putstring(ses.kexhashbuf,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
450 buf_getptr(ses.payload, ses.payload->len),
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
451 ses.payload->len);
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
452 /* I_S, the payload of the server's SSH_MSG_KEXINIT */
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
453 buf_putstring(ses.kexhashbuf,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
454 buf_getptr(ses.transkexinit, ses.transkexinit->len),
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
455 ses.transkexinit->len);
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
456 ses.requirenext = SSH_MSG_KEXDH_INIT;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
457 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
458
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
459 buf_free(ses.transkexinit);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
460 ses.transkexinit = NULL;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
461 /* the rest of ses.kexhashbuf will be done after DH exchange */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
462
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
463 ses.kexstate.recvkexinit = 1;
22
c1e5d9195402 merge of abac2150ee4f4031a98016241fbd136d24fed127
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
464 // ses.expecting = 0; // client matt
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
465
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
466 TRACE(("leave recv_msg_kexinit"));
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
467 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
468
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
469 /* Initialises and generate one side of the diffie-hellman key exchange values.
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
470 * See the ietf-secsh-transport draft, section 6, for details */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
471 void gen_kexdh_vals(mp_int *dh_pub, mp_int *dh_priv) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
472
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
473 mp_int dh_p, dh_q, dh_g;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
474 unsigned char randbuf[DH_P_LEN];
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
475 int dh_q_len;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
476
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
477 TRACE(("enter send_msg_kexdh_reply"));
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
478
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
479 m_mp_init_multi(&dh_g, &dh_p, &dh_q, dh_priv, dh_pub, NULL);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
480
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
481 /* read the prime and generator*/
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
482 if (mp_read_unsigned_bin(&dh_p, (unsigned char*)dh_p_val, DH_P_LEN)
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
483 != MP_OKAY) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
484 dropbear_exit("Diffie-Hellman error");
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
485 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
486
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
487 if (mp_set_int(&dh_g, DH_G_VAL) != MP_OKAY) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
488 dropbear_exit("Diffie-Hellman error");
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
489 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
490
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
491 /* calculate q = (p-1)/2 */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
492 /* dh_priv is just a temp var here */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
493 if (mp_sub_d(&dh_p, 1, dh_priv) != MP_OKAY) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
494 dropbear_exit("Diffie-Hellman error");
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
495 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
496 if (mp_div_2(dh_priv, &dh_q) != MP_OKAY) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
497 dropbear_exit("Diffie-Hellman error");
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
498 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
499
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
500 dh_q_len = mp_unsigned_bin_size(&dh_q);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
501
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
502 /* calculate our random value dh_y */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
503 do {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
504 assert((unsigned int)dh_q_len <= sizeof(randbuf));
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
505 genrandom(randbuf, dh_q_len);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
506 if (mp_read_unsigned_bin(dh_priv, randbuf, dh_q_len) != MP_OKAY) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
507 dropbear_exit("Diffie-Hellman error");
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
508 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
509 } while (mp_cmp(dh_priv, &dh_q) == MP_GT || mp_cmp_d(dh_priv, 0) != MP_GT);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
510
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
511 /* f = g^y mod p */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
512 if (mp_exptmod(&dh_g, dh_priv, &dh_p, dh_pub) != MP_OKAY) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
513 dropbear_exit("Diffie-Hellman error");
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
514 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
515 mp_clear_multi(&dh_g, &dh_p, &dh_q, NULL);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
516 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
517
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
518 /* This function is fairly common between client/server, with some substitution
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
519 * of dh_e/dh_f etc. Hence these arguments:
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
520 * dh_pub_us is 'e' for the client, 'f' for the server. dh_pub_them is
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
521 * vice-versa. dh_priv is the x/y value corresponding to dh_pub_us */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
522 void kexdh_comb_key(mp_int *dh_pub_us, mp_int *dh_priv, mp_int *dh_pub_them,
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
523 sign_key *hostkey) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
524
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
525 mp_int dh_p;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
526 mp_int *dh_e = NULL, *dh_f = NULL;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
527 hash_state hs;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
528
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
529 /* read the prime and generator*/
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
530 mp_init(&dh_p);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
531 if (mp_read_unsigned_bin(&dh_p, (unsigned char*)dh_p_val, DH_P_LEN)
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
532 != MP_OKAY) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
533 dropbear_exit("Diffie-Hellman error");
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
534 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
535
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
536 /* Check that dh_pub_them (dh_e or dh_f) is in the range [1, p-1] */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
537 if (mp_cmp(dh_pub_them, &dh_p) != MP_LT
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
538 || mp_cmp_d(dh_pub_them, 0) != MP_GT) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
539 dropbear_exit("Diffie-Hellman error");
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
540 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
541
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
542 /* K = e^y mod p = f^x mod p */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
543 ses.dh_K = (mp_int*)m_malloc(sizeof(mp_int));
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
544 m_mp_init(ses.dh_K);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
545 if (mp_exptmod(dh_pub_them, dh_priv, &dh_p, ses.dh_K) != MP_OKAY) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
546 dropbear_exit("Diffie-Hellman error");
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
547 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
548
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
549 /* clear no longer needed vars */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
550 mp_clear_multi(&dh_p, NULL);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
551
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
552 /* From here on, the code needs to work with the _same_ vars on each side,
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
553 * not vice-versaing for client/server */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
554 if (IS_DROPBEAR_CLIENT) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
555 dh_e = dh_pub_us;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
556 dh_f = dh_pub_them;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
557 } else {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
558 dh_e = dh_pub_them;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
559 dh_f = dh_pub_us;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
560 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
561
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
562 /* Create the remainder of the hash buffer, to generate the exchange hash */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
563 /* K_S, the host key */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
564 buf_put_pub_key(ses.kexhashbuf, hostkey, ses.newkeys->algo_hostkey);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
565 /* e, exchange value sent by the client */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
566 buf_putmpint(ses.kexhashbuf, dh_e);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
567 /* f, exchange value sent by the server */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
568 buf_putmpint(ses.kexhashbuf, dh_f);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
569 /* K, the shared secret */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
570 buf_putmpint(ses.kexhashbuf, ses.dh_K);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
571
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
572 /* calculate the hash H to sign */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
573 sha1_init(&hs);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
574 buf_setpos(ses.kexhashbuf, 0);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
575 sha1_process(&hs, buf_getptr(ses.kexhashbuf, ses.kexhashbuf->len),
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
576 ses.kexhashbuf->len);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
577 sha1_done(&hs, ses.hash);
35
0ad5fb979f42 set the isserver flag (oops)
Matt Johnston <matt@ucc.asn.au>
parents: 34
diff changeset
578
0ad5fb979f42 set the isserver flag (oops)
Matt Johnston <matt@ucc.asn.au>
parents: 34
diff changeset
579 buf_burn(ses.kexhashbuf);
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
580 buf_free(ses.kexhashbuf);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
581 ses.kexhashbuf = NULL;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
582
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
583 /* first time around, we set the session_id to H */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
584 if (ses.session_id == NULL) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
585 /* create the session_id, this never needs freeing */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
586 ses.session_id = (unsigned char*)m_malloc(SHA1_HASH_SIZE);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
587 memcpy(ses.session_id, ses.hash, SHA1_HASH_SIZE);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
588 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
589 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
590
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
591 /* read the other side's algo list. buf_match_algo is a callback to match
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
592 * algos for the client or server. */
33
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
593 static void read_kex_algos() {
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
594
36
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
595 /* for asymmetry */
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
596 algo_type * c2s_hash_algo = NULL;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
597 algo_type * s2c_hash_algo = NULL;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
598 algo_type * c2s_cipher_algo = NULL;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
599 algo_type * s2c_cipher_algo = NULL;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
600 algo_type * c2s_comp_algo = NULL;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
601 algo_type * s2c_comp_algo = NULL;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
602 /* the generic one */
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
603 algo_type * algo = NULL;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
604
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
605 /* which algo couldn't match */
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
606 char * erralgo = NULL;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
607
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
608 int goodguess = 0;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
609 int allgood = 1; /* we AND this with each goodguess and see if its still
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
610 true after */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
611
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
612 buf_incrpos(ses.payload, 16); /* start after the cookie */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
613
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
614 ses.newkeys = (struct key_context*)m_malloc(sizeof(struct key_context));
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
615
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
616 /* kex_algorithms */
33
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
617 algo = ses.buf_match_algo(ses.payload, sshkex, &goodguess);
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
618 allgood &= goodguess;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
619 if (algo == NULL) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
620 erralgo = "kex";
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
621 goto error;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
622 }
34
e2a1eaa19f22 Client mostly works up to password auth
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
623 TRACE(("kex algo %s", algo->name));
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
624 ses.newkeys->algo_kex = algo->val;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
625
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
626 /* server_host_key_algorithms */
33
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 26
diff changeset
627 algo = ses.buf_match_algo(ses.payload, sshhostkey, &goodguess);
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
628 allgood &= goodguess;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
629 if (algo == NULL) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
630 erralgo = "hostkey";
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
631 goto error;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
632 }
34
e2a1eaa19f22 Client mostly works up to password auth
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
633 TRACE(("hostkey algo %s", algo->name));
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
634 ses.newkeys->algo_hostkey = algo->val;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
635
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
636 /* encryption_algorithms_client_to_server */
36
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
637 c2s_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, &goodguess);
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
638 if (algo == NULL) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
639 erralgo = "enc c->s";
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
640 goto error;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
641 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
642
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
643 /* encryption_algorithms_server_to_client */
36
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
644 s2c_cipher_algo = ses.buf_match_algo(ses.payload, sshciphers, &goodguess);
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
645 if (algo == NULL) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
646 erralgo = "enc s->c";
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
647 goto error;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
648 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
649
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
650 /* mac_algorithms_client_to_server */
36
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
651 c2s_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, &goodguess);
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
652 if (algo == NULL) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
653 erralgo = "mac c->s";
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
654 goto error;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
655 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
656
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
657 /* mac_algorithms_server_to_client */
36
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
658 s2c_hash_algo = ses.buf_match_algo(ses.payload, sshhashes, &goodguess);
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
659 if (algo == NULL) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
660 erralgo = "mac s->c";
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
661 goto error;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
662 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
663
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
664 /* compression_algorithms_client_to_server */
36
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
665 c2s_comp_algo = ses.buf_match_algo(ses.payload, sshcompress, &goodguess);
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
666 if (algo == NULL) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
667 erralgo = "comp c->s";
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
668 goto error;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
669 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
670
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
671 /* compression_algorithms_server_to_client */
36
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
672 s2c_comp_algo = ses.buf_match_algo(ses.payload, sshcompress, &goodguess);
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
673 if (algo == NULL) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
674 erralgo = "comp s->c";
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
675 goto error;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
676 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
677
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
678 /* languages_client_to_server */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
679 buf_eatstring(ses.payload);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
680
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
681 /* languages_server_to_client */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
682 buf_eatstring(ses.payload);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
683
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
684 /* first_kex_packet_follows */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
685 if (buf_getbyte(ses.payload)) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
686 ses.kexstate.firstfollows = 1;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
687 /* if the guess wasn't good, we ignore the packet sent */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
688 if (!allgood) {
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
689 ses.ignorenext = 1;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
690 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
691 }
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
692
36
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
693 /* Handle the asymmetry */
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
694 if (IS_DROPBEAR_CLIENT) {
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
695 ses.newkeys->recv_algo_crypt =
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
696 (struct dropbear_cipher*)s2c_cipher_algo->data;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
697 ses.newkeys->trans_algo_crypt =
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
698 (struct dropbear_cipher*)c2s_cipher_algo->data;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
699 ses.newkeys->recv_algo_mac =
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
700 (struct dropbear_hash*)s2c_hash_algo->data;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
701 ses.newkeys->trans_algo_mac =
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
702 (struct dropbear_hash*)c2s_hash_algo->data;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
703 ses.newkeys->recv_algo_comp = s2c_comp_algo->val;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
704 ses.newkeys->trans_algo_comp = c2s_comp_algo->val;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
705 } else {
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
706 /* SERVER */
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
707 ses.newkeys->recv_algo_crypt =
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
708 (struct dropbear_cipher*)c2s_cipher_algo->data;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
709 ses.newkeys->trans_algo_crypt =
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
710 (struct dropbear_cipher*)s2c_cipher_algo->data;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
711 ses.newkeys->recv_algo_mac =
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
712 (struct dropbear_hash*)c2s_hash_algo->data;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
713 ses.newkeys->trans_algo_mac =
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
714 (struct dropbear_hash*)s2c_hash_algo->data;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
715 ses.newkeys->recv_algo_comp = c2s_comp_algo->val;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
716 ses.newkeys->trans_algo_comp = s2c_comp_algo->val;
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
717 }
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
718
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
719 TRACE(("enc algo recv %s", algo->name));
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
720 TRACE(("enc algo trans %s", algo->name));
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
721 TRACE(("mac algo recv %s", algo->name));
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
722 TRACE(("mac algo trans %s", algo->name));
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
723 TRACE(("comp algo recv %s", algo->name));
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
724 TRACE(("comp algo trans %s", algo->name));
a600c015562d Handle differing c2s and s2c algorithms properly
Matt Johnston <matt@ucc.asn.au>
parents: 35
diff changeset
725
26
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
726 /* reserved for future extensions */
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
727 buf_getint(ses.payload);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
728 return;
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
729
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
730 error:
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
731 dropbear_exit("no matching algo %s", erralgo);
0969767bca0d snapshot of stuff
Matt Johnston <matt@ucc.asn.au>
parents: 22
diff changeset
732 }