comparison svr-kex.c @ 1295:750ec4ec4cbe

Convert #ifdef to #if, other build changes
author Matt Johnston <matt@ucc.asn.au>
date Wed, 04 May 2016 15:33:40 +0200
parents 56aba7dedbea
children 185c14fa504d 8747c2b19152
comparison
equal deleted inserted replaced
1294:56aba7dedbea 1295:750ec4ec4cbe
60 if (buf_getmpint(ses.payload, &dh_e) != DROPBEAR_SUCCESS) { 60 if (buf_getmpint(ses.payload, &dh_e) != DROPBEAR_SUCCESS) {
61 dropbear_exit("Bad kex value"); 61 dropbear_exit("Bad kex value");
62 } 62 }
63 break; 63 break;
64 #endif 64 #endif
65 #ifdef DROPBEAR_ECDH 65 #if DROPBEAR_ECDH
66 case DROPBEAR_KEX_ECDH: 66 case DROPBEAR_KEX_ECDH:
67 #endif 67 #endif
68 #ifdef DROPBEAR_CURVE25519 68 #if DROPBEAR_CURVE25519
69 case DROPBEAR_KEX_CURVE25519: 69 case DROPBEAR_KEX_CURVE25519:
70 #endif 70 #endif
71 #if defined(DROPBEAR_ECDH) || defined(DROPBEAR_CURVE25519) 71 #if DROPBEAR_ECDH || DROPBEAR_CURVE25519
72 ecdh_qs = buf_getstringbuf(ses.payload); 72 ecdh_qs = buf_getstringbuf(ses.payload);
73 break; 73 break;
74 #endif 74 #endif
75 } 75 }
76 if (ses.payload->pos != ses.payload->len) { 76 if (ses.payload->pos != ses.payload->len) {
89 ses.requirenext = SSH_MSG_NEWKEYS; 89 ses.requirenext = SSH_MSG_NEWKEYS;
90 TRACE(("leave recv_msg_kexdh_init")) 90 TRACE(("leave recv_msg_kexdh_init"))
91 } 91 }
92 92
93 93
94 #ifdef DROPBEAR_DELAY_HOSTKEY 94 #if DROPBEAR_DELAY_HOSTKEY
95 95
96 static void fsync_parent_dir(const char* fn) { 96 static void fsync_parent_dir(const char* fn) {
97 #ifdef HAVE_LIBGEN_H 97 #ifdef HAVE_LIBGEN_H
98 char *fn_dir = m_strdup(fn); 98 char *fn_dir = m_strdup(fn);
99 char *dir = dirname(fn_dir); 99 char *dir = dirname(fn_dir);
124 return; 124 return;
125 } 125 }
126 126
127 switch (type) 127 switch (type)
128 { 128 {
129 #ifdef DROPBEAR_RSA 129 #if DROPBEAR_RSA
130 case DROPBEAR_SIGNKEY_RSA: 130 case DROPBEAR_SIGNKEY_RSA:
131 fn = RSA_PRIV_FILENAME; 131 fn = RSA_PRIV_FILENAME;
132 break; 132 break;
133 #endif 133 #endif
134 #ifdef DROPBEAR_DSS 134 #if DROPBEAR_DSS
135 case DROPBEAR_SIGNKEY_DSS: 135 case DROPBEAR_SIGNKEY_DSS:
136 fn = DSS_PRIV_FILENAME; 136 fn = DSS_PRIV_FILENAME;
137 break; 137 break;
138 #endif 138 #endif
139 #ifdef DROPBEAR_ECDSA 139 #if DROPBEAR_ECDSA
140 case DROPBEAR_SIGNKEY_ECDSA_NISTP256: 140 case DROPBEAR_SIGNKEY_ECDSA_NISTP256:
141 case DROPBEAR_SIGNKEY_ECDSA_NISTP384: 141 case DROPBEAR_SIGNKEY_ECDSA_NISTP384:
142 case DROPBEAR_SIGNKEY_ECDSA_NISTP521: 142 case DROPBEAR_SIGNKEY_ECDSA_NISTP521:
143 fn = ECDSA_PRIV_FILENAME; 143 fn = ECDSA_PRIV_FILENAME;
144 break; 144 break;
213 TRACE(("enter send_msg_kexdh_reply")) 213 TRACE(("enter send_msg_kexdh_reply"))
214 214
215 /* we can start creating the kexdh_reply packet */ 215 /* we can start creating the kexdh_reply packet */
216 CHECKCLEARTOWRITE(); 216 CHECKCLEARTOWRITE();
217 217
218 #ifdef DROPBEAR_DELAY_HOSTKEY 218 #if DROPBEAR_DELAY_HOSTKEY
219 if (svr_opts.delay_hostkey) 219 if (svr_opts.delay_hostkey)
220 { 220 {
221 svr_ensure_hostkey(); 221 svr_ensure_hostkey();
222 } 222 }
223 #endif 223 #endif
225 buf_putbyte(ses.writepayload, SSH_MSG_KEXDH_REPLY); 225 buf_putbyte(ses.writepayload, SSH_MSG_KEXDH_REPLY);
226 buf_put_pub_key(ses.writepayload, svr_opts.hostkey, 226 buf_put_pub_key(ses.writepayload, svr_opts.hostkey,
227 ses.newkeys->algo_hostkey); 227 ses.newkeys->algo_hostkey);
228 228
229 switch (ses.newkeys->algo_kex->mode) { 229 switch (ses.newkeys->algo_kex->mode) {
230 #ifdef DROPBEAR_NORMAL_DH 230 #if DROPBEAR_NORMAL_DH
231 case DROPBEAR_KEX_NORMAL_DH: 231 case DROPBEAR_KEX_NORMAL_DH:
232 { 232 {
233 struct kex_dh_param * dh_param = gen_kexdh_param(); 233 struct kex_dh_param * dh_param = gen_kexdh_param();
234 kexdh_comb_key(dh_param, dh_e, svr_opts.hostkey); 234 kexdh_comb_key(dh_param, dh_e, svr_opts.hostkey);
235 235
237 buf_putmpint(ses.writepayload, &dh_param->pub); 237 buf_putmpint(ses.writepayload, &dh_param->pub);
238 free_kexdh_param(dh_param); 238 free_kexdh_param(dh_param);
239 } 239 }
240 break; 240 break;
241 #endif 241 #endif
242 #ifdef DROPBEAR_ECDH 242 #if DROPBEAR_ECDH
243 case DROPBEAR_KEX_ECDH: 243 case DROPBEAR_KEX_ECDH:
244 { 244 {
245 struct kex_ecdh_param *ecdh_param = gen_kexecdh_param(); 245 struct kex_ecdh_param *ecdh_param = gen_kexecdh_param();
246 kexecdh_comb_key(ecdh_param, ecdh_qs, svr_opts.hostkey); 246 kexecdh_comb_key(ecdh_param, ecdh_qs, svr_opts.hostkey);
247 247
248 buf_put_ecc_raw_pubkey_string(ses.writepayload, &ecdh_param->key); 248 buf_put_ecc_raw_pubkey_string(ses.writepayload, &ecdh_param->key);
249 free_kexecdh_param(ecdh_param); 249 free_kexecdh_param(ecdh_param);
250 } 250 }
251 break; 251 break;
252 #endif 252 #endif
253 #ifdef DROPBEAR_CURVE25519 253 #if DROPBEAR_CURVE25519
254 case DROPBEAR_KEX_CURVE25519: 254 case DROPBEAR_KEX_CURVE25519:
255 { 255 {
256 struct kex_curve25519_param *param = gen_kexcurve25519_param(); 256 struct kex_curve25519_param *param = gen_kexcurve25519_param();
257 kexcurve25519_comb_key(param, ecdh_qs, svr_opts.hostkey); 257 kexcurve25519_comb_key(param, ecdh_qs, svr_opts.hostkey);
258 buf_putstring(ses.writepayload, (const char*)param->pub, CURVE25519_LEN); 258 buf_putstring(ses.writepayload, (const char*)param->pub, CURVE25519_LEN);