comparison cli-kex.c @ 761:ac2158e3e403 ecc

ecc kind of works, needs fixing/testing
author Matt Johnston <matt@ucc.asn.au>
date Sun, 07 Apr 2013 01:36:42 +0800
parents 76fba0856749
children 5503e05ab3a4
comparison
equal deleted inserted replaced
760:f336d232fc63 761:ac2158e3e403
34 #include "packet.h" 34 #include "packet.h"
35 #include "bignum.h" 35 #include "bignum.h"
36 #include "random.h" 36 #include "random.h"
37 #include "runopts.h" 37 #include "runopts.h"
38 #include "signkey.h" 38 #include "signkey.h"
39 #include "ecc.h"
39 40
40 41
41 static void checkhostkey(unsigned char* keyblob, unsigned int keybloblen); 42 static void checkhostkey(unsigned char* keyblob, unsigned int keybloblen);
42 #define MAX_KNOWNHOSTS_LINE 4500 43 #define MAX_KNOWNHOSTS_LINE 4500
43 44
48 cli_ses.dh_param = gen_kexdh_param(); 49 cli_ses.dh_param = gen_kexdh_param();
49 buf_putmpint(ses.writepayload, &cli_ses.dh_param->pub); 50 buf_putmpint(ses.writepayload, &cli_ses.dh_param->pub);
50 } else { 51 } else {
51 #ifdef DROPBEAR_ECDH 52 #ifdef DROPBEAR_ECDH
52 cli_ses.ecdh_param = gen_kexecdh_param(); 53 cli_ses.ecdh_param = gen_kexecdh_param();
54 buf_put_ecc_pubkey_string(ses.writepayload, &cli_ses.ecdh_param->key);
53 #endif 55 #endif
54 } 56 }
55 encrypt_packet(); 57 encrypt_packet();
56 ses.requirenext = SSH_MSG_KEXDH_REPLY; 58 ses.requirenext = SSH_MSG_KEXDH_REPLY;
57 } 59 }
97 kexdh_comb_key(cli_ses.dh_param, &dh_f, hostkey); 99 kexdh_comb_key(cli_ses.dh_param, &dh_f, hostkey);
98 mp_clear(&dh_f); 100 mp_clear(&dh_f);
99 } else { 101 } else {
100 #ifdef DROPBEAR_ECDH 102 #ifdef DROPBEAR_ECDH
101 buffer *ecdh_qs = buf_getstringbuf(ses.payload); 103 buffer *ecdh_qs = buf_getstringbuf(ses.payload);
102 kexecdh_comb_key(cli_ses.dh_param, ecdh_qs, hostkey); 104 kexecdh_comb_key(cli_ses.ecdh_param, ecdh_qs, hostkey);
103 buf_free(ecdh_qs); 105 buf_free(ecdh_qs);
104 #endif 106 #endif
105 } 107 }
106 free_kexdh_param(cli_ses.dh_param); 108 free_kexdh_param(cli_ses.dh_param);
107 cli_ses.dh_param = NULL; 109 cli_ses.dh_param = NULL;
108 110
109 if (buf_verify(ses.payload, hostkey, ses.hash, SHA1_HASH_SIZE) 111 if (buf_verify(ses.payload, hostkey, ses.hash)
110 != DROPBEAR_SUCCESS) { 112 != DROPBEAR_SUCCESS) {
111 dropbear_exit("Bad hostkey signature"); 113 dropbear_exit("Bad hostkey signature");
112 } 114 }
113 115
114 sign_key_free(hostkey); 116 sign_key_free(hostkey);