Mercurial > dropbear
comparison common-kex.c @ 398:59c7938af2bd
merge of '1250b8af44b62d8f4fe0f8d9fc7e7a1cc34e7e1c'
and '7f8670ac3bb975f40967f3979d09d2199b7e90c8'
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 03 Feb 2007 08:20:30 +0000 |
parents | 3e098639b05f |
children | e66eec4dcba7 b895f91c2ee6 |
comparison
equal
deleted
inserted
replaced
396:e7c1a77d2921 | 398:59c7938af2bd |
---|---|
260 unsigned char *trans_IV, *trans_key, *recv_IV, *recv_key; | 260 unsigned char *trans_IV, *trans_key, *recv_IV, *recv_key; |
261 | 261 |
262 hash_state hs; | 262 hash_state hs; |
263 unsigned int C2S_keysize, S2C_keysize; | 263 unsigned int C2S_keysize, S2C_keysize; |
264 char mactransletter, macrecvletter; /* Client or server specific */ | 264 char mactransletter, macrecvletter; /* Client or server specific */ |
265 int recv_cipher = 0, trans_cipher = 0; | |
265 | 266 |
266 TRACE(("enter gen_new_keys")) | 267 TRACE(("enter gen_new_keys")) |
267 /* the dh_K and hash are the start of all hashes, we make use of that */ | 268 /* the dh_K and hash are the start of all hashes, we make use of that */ |
268 | 269 |
269 sha1_init(&hs); | 270 sha1_init(&hs); |
296 hashkeys(C2S_IV, SHA1_HASH_SIZE, &hs, 'A'); | 297 hashkeys(C2S_IV, SHA1_HASH_SIZE, &hs, 'A'); |
297 hashkeys(S2C_IV, SHA1_HASH_SIZE, &hs, 'B'); | 298 hashkeys(S2C_IV, SHA1_HASH_SIZE, &hs, 'B'); |
298 hashkeys(C2S_key, C2S_keysize, &hs, 'C'); | 299 hashkeys(C2S_key, C2S_keysize, &hs, 'C'); |
299 hashkeys(S2C_key, S2C_keysize, &hs, 'D'); | 300 hashkeys(S2C_key, S2C_keysize, &hs, 'D'); |
300 | 301 |
301 if (cbc_start( | 302 recv_cipher = find_cipher(ses.newkeys->recv_algo_crypt->cipherdesc->name); |
302 find_cipher(ses.newkeys->recv_algo_crypt->cipherdesc->name), | 303 if (recv_cipher < 0) |
303 recv_IV, recv_key, | 304 dropbear_exit("crypto error"); |
305 | |
306 if (cbc_start(recv_cipher, recv_IV, recv_key, | |
304 ses.newkeys->recv_algo_crypt->keysize, 0, | 307 ses.newkeys->recv_algo_crypt->keysize, 0, |
305 &ses.newkeys->recv_symmetric_struct) != CRYPT_OK) { | 308 &ses.newkeys->recv_symmetric_struct) != CRYPT_OK) { |
306 dropbear_exit("crypto error"); | 309 dropbear_exit("crypto error"); |
307 } | 310 } |
308 | 311 trans_cipher = find_cipher(ses.newkeys->trans_algo_crypt->cipherdesc->name); |
309 if (cbc_start( | 312 if (trans_cipher < 0) |
310 find_cipher(ses.newkeys->trans_algo_crypt->cipherdesc->name), | 313 dropbear_exit("crypto error"); |
311 trans_IV, trans_key, | 314 |
315 if (cbc_start(trans_cipher, trans_IV, trans_key, | |
312 ses.newkeys->trans_algo_crypt->keysize, 0, | 316 ses.newkeys->trans_algo_crypt->keysize, 0, |
313 &ses.newkeys->trans_symmetric_struct) != CRYPT_OK) { | 317 &ses.newkeys->trans_symmetric_struct) != CRYPT_OK) { |
314 dropbear_exit("crypto error"); | 318 dropbear_exit("crypto error"); |
315 } | 319 } |
316 | 320 |
515 mp_int dh_p; | 519 mp_int dh_p; |
516 mp_int *dh_e = NULL, *dh_f = NULL; | 520 mp_int *dh_e = NULL, *dh_f = NULL; |
517 hash_state hs; | 521 hash_state hs; |
518 | 522 |
519 /* read the prime and generator*/ | 523 /* read the prime and generator*/ |
520 mp_init(&dh_p); | 524 m_mp_init(&dh_p); |
521 bytes_to_mp(&dh_p, dh_p_val, DH_P_LEN); | 525 bytes_to_mp(&dh_p, dh_p_val, DH_P_LEN); |
522 | 526 |
523 /* Check that dh_pub_them (dh_e or dh_f) is in the range [1, p-1] */ | 527 /* Check that dh_pub_them (dh_e or dh_f) is in the range [1, p-1] */ |
524 if (mp_cmp(dh_pub_them, &dh_p) != MP_LT | 528 if (mp_cmp(dh_pub_them, &dh_p) != MP_LT |
525 || mp_cmp_d(dh_pub_them, 0) != MP_GT) { | 529 || mp_cmp_d(dh_pub_them, 0) != MP_GT) { |