comparison ecc.c @ 763:f744321ac048 ecc

ecdh works against OpenSSH
author Matt Johnston <matt@ucc.asn.au>
date Mon, 08 Apr 2013 23:12:20 +0800
parents a78a38e402d1
children 5503e05ab3a4
comparison
equal deleted inserted replaced
762:a78a38e402d1 763:f744321ac048
179 179
180 if (private_key->dp != public_key->dp) { 180 if (private_key->dp != public_key->dp) {
181 goto done; 181 goto done;
182 } 182 }
183 183
184 #if 0
185 // XXX - possibly not neccessary tests?
186 if (ltc_ecc_is_valid_idx(private_key->idx) == 0 || ltc_ecc_is_valid_idx(public_key->idx) == 0) {
187 goto done;
188 }
189
190 if (XSTRCMP(private_key->dp->name, public_key->dp->name) != 0) {
191 goto done;
192 }
193 #endif
194
195 /* make new point */ 184 /* make new point */
196 result = ltc_ecc_new_point(); 185 result = ltc_ecc_new_point();
197 if (result == NULL) { 186 if (result == NULL) {
198 goto done; 187 goto done;
199 } 188 }
209 } 198 }
210 199
211 err = DROPBEAR_SUCCESS; 200 err = DROPBEAR_SUCCESS;
212 done: 201 done:
213 if (err == DROPBEAR_SUCCESS) { 202 if (err == DROPBEAR_SUCCESS) {
214 shared_secret = prime; 203 shared_secret = m_malloc(sizeof(*shared_secret));
215 prime = NULL; 204 m_mp_init(shared_secret);
205 mp_copy(result->x, shared_secret);
216 } 206 }
217 207
218 if (prime) { 208 if (prime) {
219 mp_clear(prime); 209 mp_clear(prime);
220 m_free(prime); 210 m_free(prime);
221 } 211 }
222 ltc_ecc_del_point(result); 212 if (result)
213 {
214 ltc_ecc_del_point(result);
215 }
223 216
224 if (err == DROPBEAR_FAILURE) { 217 if (err == DROPBEAR_FAILURE) {
225 dropbear_exit("ECC error"); 218 dropbear_exit("ECC error");
226 } 219 }
227
228 return shared_secret; 220 return shared_secret;
229 } 221 }
230 222
231 #endif 223 #endif