comparison common-kex.c @ 681:a4b7627b3157 insecure-nocrypto

Update insecure-nocrypto to current head
author Matt Johnston <matt@ucc.asn.au>
date Wed, 16 May 2012 22:54:51 +0800
parents 03073a27abb3 0129fd8ccc71
children c37857676924
comparison
equal deleted inserted replaced
680:bd4b5d7886e5 681:a4b7627b3157
291 unsigned char *trans_IV, *trans_key, *recv_IV, *recv_key; 291 unsigned char *trans_IV, *trans_key, *recv_IV, *recv_key;
292 292
293 hash_state hs; 293 hash_state hs;
294 unsigned int C2S_keysize, S2C_keysize; 294 unsigned int C2S_keysize, S2C_keysize;
295 char mactransletter, macrecvletter; /* Client or server specific */ 295 char mactransletter, macrecvletter; /* Client or server specific */
296 int recv_cipher = 0, trans_cipher = 0;
297 296
298 TRACE(("enter gen_new_keys")) 297 TRACE(("enter gen_new_keys"))
299 /* the dh_K and hash are the start of all hashes, we make use of that */ 298 /* the dh_K and hash are the start of all hashes, we make use of that */
300 299
301 sha1_init(&hs); 300 sha1_init(&hs);
328 hashkeys(C2S_IV, SHA1_HASH_SIZE, &hs, 'A'); 327 hashkeys(C2S_IV, SHA1_HASH_SIZE, &hs, 'A');
329 hashkeys(S2C_IV, SHA1_HASH_SIZE, &hs, 'B'); 328 hashkeys(S2C_IV, SHA1_HASH_SIZE, &hs, 'B');
330 hashkeys(C2S_key, C2S_keysize, &hs, 'C'); 329 hashkeys(C2S_key, C2S_keysize, &hs, 'C');
331 hashkeys(S2C_key, S2C_keysize, &hs, 'D'); 330 hashkeys(S2C_key, S2C_keysize, &hs, 'D');
332 331
333 recv_cipher = find_cipher(ses.newkeys->recv.algo_crypt->cipherdesc->name); 332 if (ses.newkeys->recv.algo_crypt->cipherdesc != NULL) {
334 if (recv_cipher < 0) 333 int recv_cipher = find_cipher(ses.newkeys->recv.algo_crypt->cipherdesc->name);
335 dropbear_exit("Crypto error"); 334 if (recv_cipher < 0)
336 if (ses.newkeys->recv.crypt_mode->start(recv_cipher, 335 dropbear_exit("Crypto error");
337 recv_IV, recv_key, 336 if (ses.newkeys->recv.crypt_mode->start(recv_cipher,
338 ses.newkeys->recv.algo_crypt->keysize, 0, 337 recv_IV, recv_key,
339 &ses.newkeys->recv.cipher_state) != CRYPT_OK) { 338 ses.newkeys->recv.algo_crypt->keysize, 0,
340 dropbear_exit("Crypto error"); 339 &ses.newkeys->recv.cipher_state) != CRYPT_OK) {
341 } 340 dropbear_exit("Crypto error");
342 341 }
343 trans_cipher = find_cipher(ses.newkeys->trans.algo_crypt->cipherdesc->name); 342 }
344 if (trans_cipher < 0) 343
345 dropbear_exit("Crypto error"); 344 if (ses.newkeys->trans.algo_crypt->cipherdesc != NULL) {
346 if (ses.newkeys->trans.crypt_mode->start(trans_cipher, 345 int trans_cipher = find_cipher(ses.newkeys->trans.algo_crypt->cipherdesc->name);
347 trans_IV, trans_key, 346 if (trans_cipher < 0)
348 ses.newkeys->trans.algo_crypt->keysize, 0, 347 dropbear_exit("Crypto error");
349 &ses.newkeys->trans.cipher_state) != CRYPT_OK) { 348 if (ses.newkeys->trans.crypt_mode->start(trans_cipher,
350 dropbear_exit("Crypto error"); 349 trans_IV, trans_key,
351 } 350 ses.newkeys->trans.algo_crypt->keysize, 0,
352 351 &ses.newkeys->trans.cipher_state) != CRYPT_OK) {
352 dropbear_exit("Crypto error");
353 }
354 }
355
353 /* MAC keys */ 356 /* MAC keys */
354 hashkeys(ses.newkeys->trans.mackey, 357 if (ses.newkeys->trans.algo_mac->hashdesc != NULL) {
355 ses.newkeys->trans.algo_mac->keysize, &hs, mactransletter); 358 hashkeys(ses.newkeys->trans.mackey,
356 hashkeys(ses.newkeys->recv.mackey, 359 ses.newkeys->trans.algo_mac->keysize, &hs, mactransletter);
357 ses.newkeys->recv.algo_mac->keysize, &hs, macrecvletter); 360 }
361 if (ses.newkeys->recv.algo_mac->hashdesc != NULL) {
362 hashkeys(ses.newkeys->recv.mackey,
363 ses.newkeys->recv.algo_mac->keysize, &hs, macrecvletter);
364 }
358 ses.newkeys->trans.hash_index = find_hash(ses.newkeys->trans.algo_mac->hashdesc->name), 365 ses.newkeys->trans.hash_index = find_hash(ses.newkeys->trans.algo_mac->hashdesc->name),
359 ses.newkeys->recv.hash_index = find_hash(ses.newkeys->recv.algo_mac->hashdesc->name), 366 ses.newkeys->recv.hash_index = find_hash(ses.newkeys->recv.algo_mac->hashdesc->name),
360 367
361 #ifndef DISABLE_ZLIB 368 #ifndef DISABLE_ZLIB
362 gen_new_zstreams(); 369 gen_new_zstreams();