comparison common-kex.c @ 855:04ede40a529a

- Some fixes for old compilers like tru64 v4 from Daniel Richard G. - Don't warn about blocking random device for prngd
author Matt Johnston <matt@ucc.asn.au>
date Thu, 14 Nov 2013 21:36:45 +0800
parents 7540c0822374
children c19acba28590
comparison
equal deleted inserted replaced
854:ccc76acaf4c7 855:04ede40a529a
284 const hash_state * hs, const unsigned char X) { 284 const hash_state * hs, const unsigned char X) {
285 285
286 const struct ltc_hash_descriptor *hash_desc = ses.newkeys->algo_kex->hash_desc; 286 const struct ltc_hash_descriptor *hash_desc = ses.newkeys->algo_kex->hash_desc;
287 hash_state hs2; 287 hash_state hs2;
288 unsigned int offset; 288 unsigned int offset;
289 unsigned char tmpout[hash_desc->hashsize]; 289 unsigned char tmpout[MAX_HASH_SIZE];
290 290
291 memcpy(&hs2, hs, sizeof(hash_state)); 291 memcpy(&hs2, hs, sizeof(hash_state));
292 hash_desc->process(&hs2, &X, 1); 292 hash_desc->process(&hs2, &X, 1);
293 hash_desc->process(&hs2, ses.session_id->data, ses.session_id->len); 293 hash_desc->process(&hs2, ses.session_id->data, ses.session_id->len);
294 hash_desc->done(&hs2, tmpout); 294 hash_desc->done(&hs2, tmpout);
301 memcpy(&hs2, hs, sizeof(hash_state)); 301 memcpy(&hs2, hs, sizeof(hash_state));
302 hash_desc->process(&hs2, out, offset); 302 hash_desc->process(&hs2, out, offset);
303 hash_desc->done(&hs2, tmpout); 303 hash_desc->done(&hs2, tmpout);
304 memcpy(&out[offset], tmpout, MIN(outlen - offset, hash_desc->hashsize)); 304 memcpy(&out[offset], tmpout, MIN(outlen - offset, hash_desc->hashsize));
305 } 305 }
306
306 } 307 }
307 308
308 /* Generate the actual encryption/integrity keys, using the results of the 309 /* Generate the actual encryption/integrity keys, using the results of the
309 * key exchange, as specified in section 7.2 of the transport rfc 4253. 310 * key exchange, as specified in section 7.2 of the transport rfc 4253.
310 * This occurs after the DH key-exchange. 311 * This occurs after the DH key-exchange.
567 568
568 /* Initialises and generate one side of the diffie-hellman key exchange values. 569 /* Initialises and generate one side of the diffie-hellman key exchange values.
569 * See the transport rfc 4253 section 8 for details */ 570 * See the transport rfc 4253 section 8 for details */
570 /* dh_pub and dh_priv MUST be already initialised */ 571 /* dh_pub and dh_priv MUST be already initialised */
571 struct kex_dh_param *gen_kexdh_param() { 572 struct kex_dh_param *gen_kexdh_param() {
573 struct kex_dh_param *param = NULL;
572 574
573 DEF_MP_INT(dh_p); 575 DEF_MP_INT(dh_p);
574 DEF_MP_INT(dh_q); 576 DEF_MP_INT(dh_q);
575 DEF_MP_INT(dh_g); 577 DEF_MP_INT(dh_g);
576 578
577 TRACE(("enter gen_kexdh_vals")) 579 TRACE(("enter gen_kexdh_vals"))
578 580
579 struct kex_dh_param *param = m_malloc(sizeof(*param)); 581 param = m_malloc(sizeof(*param));
580 m_mp_init_multi(&param->pub, &param->priv, &dh_g, &dh_p, &dh_q, NULL); 582 m_mp_init_multi(&param->pub, &param->priv, &dh_g, &dh_p, &dh_q, NULL);
581 583
582 /* read the prime and generator*/ 584 /* read the prime and generator*/
583 load_dh_p(&dh_p); 585 load_dh_p(&dh_p);
584 586
821 823
822 int goodguess = 0; 824 int goodguess = 0;
823 int allgood = 1; /* we AND this with each goodguess and see if its still 825 int allgood = 1; /* we AND this with each goodguess and see if its still
824 true after */ 826 true after */
825 827
826 buf_incrpos(ses.payload, 16); /* start after the cookie */
827
828 memset(ses.newkeys, 0x0, sizeof(*ses.newkeys));
829
830 #ifdef USE_KEXGUESS2 828 #ifdef USE_KEXGUESS2
831 enum kexguess2_used kexguess2 = KEXGUESS2_LOOK; 829 enum kexguess2_used kexguess2 = KEXGUESS2_LOOK;
832 #else 830 #else
833 enum kexguess2_used kexguess2 = KEXGUESS2_NO; 831 enum kexguess2_used kexguess2 = KEXGUESS2_NO;
834 #endif 832 #endif
833
834 buf_incrpos(ses.payload, 16); /* start after the cookie */
835
836 memset(ses.newkeys, 0x0, sizeof(*ses.newkeys));
835 837
836 /* kex_algorithms */ 838 /* kex_algorithms */
837 algo = buf_match_algo(ses.payload, sshkex, &kexguess2, &goodguess); 839 algo = buf_match_algo(ses.payload, sshkex, &kexguess2, &goodguess);
838 allgood &= goodguess; 840 allgood &= goodguess;
839 if (algo == NULL || algo->val == KEXGUESS2_ALGO_ID) { 841 if (algo == NULL || algo->val == KEXGUESS2_ALGO_ID) {