comparison svr-kex.c @ 852:7540c0822374 ecc

Various cleanups and fixes for warnings
author Matt Johnston <matt@ucc.asn.au>
date Tue, 12 Nov 2013 23:02:32 +0800
parents 7507b174bba0
children 220f55d540ae
comparison
equal deleted inserted replaced
851:c1c1b43f78c2 852:7540c0822374
62 break; 62 break;
63 case DROPBEAR_KEX_ECDH: 63 case DROPBEAR_KEX_ECDH:
64 case DROPBEAR_KEX_CURVE25519: 64 case DROPBEAR_KEX_CURVE25519:
65 #if defined(DROPBEAR_ECDH) || defined(DROPBEAR_CURVE25519) 65 #if defined(DROPBEAR_ECDH) || defined(DROPBEAR_CURVE25519)
66 ecdh_qs = buf_getstringbuf(ses.payload); 66 ecdh_qs = buf_getstringbuf(ses.payload);
67 if (ses.payload->pos != ses.payload->len) { 67 #endif
68 dropbear_exit("Bad kex value"); 68 break;
69 } 69 }
70 #endif 70 if (ses.payload->pos != ses.payload->len) {
71 break; 71 dropbear_exit("Bad kex value");
72 } 72 }
73 73
74 send_msg_kexdh_reply(&dh_e, ecdh_qs); 74 send_msg_kexdh_reply(&dh_e, ecdh_qs);
75 75
76 mp_clear(&dh_e); 76 mp_clear(&dh_e);
77 if (ecdh_qs) { 77 if (ecdh_qs) {
78 buf_free(ecdh_qs); 78 buf_free(ecdh_qs);
79 ecdh_qs = NULL;
79 } 80 }
80 81
81 send_msg_newkeys(); 82 send_msg_newkeys();
82 ses.requirenext[0] = SSH_MSG_NEWKEYS; 83 ses.requirenext[0] = SSH_MSG_NEWKEYS;
83 ses.requirenext[1] = 0; 84 ses.requirenext[1] = 0;
130 if (signkey_generate(type, 0, fn_temp) == DROPBEAR_FAILURE) { 131 if (signkey_generate(type, 0, fn_temp) == DROPBEAR_FAILURE) {
131 goto out; 132 goto out;
132 } 133 }
133 134
134 if (link(fn_temp, fn) < 0) { 135 if (link(fn_temp, fn) < 0) {
136 /* It's OK to get EEXIST - we probably just lost a race
137 with another connection to generate the key */
135 if (errno != EEXIST) { 138 if (errno != EEXIST) {
136 dropbear_log(LOG_ERR, "Failed moving key file to %s", fn); 139 dropbear_log(LOG_ERR, "Failed moving key file to %s: %s", fn,
140 strerror(errno));
137 /* XXX fallback to non-atomic copy for some filesystems? */ 141 /* XXX fallback to non-atomic copy for some filesystems? */
138 goto out; 142 goto out;
139 } 143 }
140 } 144 }
141 145
149 153
150 if (ret == DROPBEAR_FAILURE) 154 if (ret == DROPBEAR_FAILURE)
151 { 155 {
152 dropbear_exit("Couldn't read or generate hostkey %s", fn); 156 dropbear_exit("Couldn't read or generate hostkey %s", fn);
153 } 157 }
154
155 // directory for keys.
156
157 // Create lockfile first, or wait if it exists. PID!
158 // Generate key
159 // write it, load to memory
160 // atomic rename, done.
161
162 } 158 }
163 #endif 159 #endif
164 160
165 /* Generate our side of the diffie-hellman key exchange value (dh_f), and 161 /* Generate our side of the diffie-hellman key exchange value (dh_f), and
166 * calculate the session key using the diffie-hellman algorithm. Following 162 * calculate the session key using the diffie-hellman algorithm. Following