comparison ecc.c @ 793:70625eed40c9 ecc

A bit of work on ecdsa for host/auth keys
author Matt Johnston <matt@ucc.asn.au>
date Sun, 14 Apr 2013 00:50:03 +0800
parents 6e6ce39da2fc
children 724c3e0c8734
comparison
equal deleted inserted replaced
768:6e6ce39da2fc 793:70625eed40c9
8 8
9 // .dp members are filled out by dropbear_ecc_fill_dp() at startup 9 // .dp members are filled out by dropbear_ecc_fill_dp() at startup
10 #ifdef DROPBEAR_ECC_256 10 #ifdef DROPBEAR_ECC_256
11 struct dropbear_ecc_curve ecc_curve_nistp256 = { 11 struct dropbear_ecc_curve ecc_curve_nistp256 = {
12 .ltc_size = 32, 12 .ltc_size = 32,
13 .hashdesc = &sha256_desc, 13 .hash_desc = &sha256_desc,
14 .name = "nistp256" 14 .name = "nistp256"
15 }; 15 };
16 #endif 16 #endif
17 #ifdef DROPBEAR_ECC_384 17 #ifdef DROPBEAR_ECC_384
18 struct dropbear_ecc_curve ecc_curve_nistp384 = { 18 struct dropbear_ecc_curve ecc_curve_nistp384 = {
19 .ltc_size = 48, 19 .ltc_size = 48,
20 .hashdesc = &sha384_desc, 20 .hash_desc = &sha384_desc,
21 .name = "nistp384" 21 .name = "nistp384"
22 }; 22 };
23 #endif 23 #endif
24 #ifdef DROPBEAR_ECC_521 24 #ifdef DROPBEAR_ECC_521
25 struct dropbear_ecc_curve ecc_curve_nistp521 = { 25 struct dropbear_ecc_curve ecc_curve_nistp521 = {
26 .ltc_size = 66, 26 .ltc_size = 66,
27 .hashdesc = &sha512_desc, 27 .hash_desc = &sha512_desc,
28 .name = "nistp521" 28 .name = "nistp521"
29 }; 29 };
30 #endif 30 #endif
31 31
32 struct dropbear_ecc_curve *dropbear_ecc_curves[] = { 32 struct dropbear_ecc_curve *dropbear_ecc_curves[] = {
57 dropbear_exit("Missing ECC params %s", (*curve)->name); 57 dropbear_exit("Missing ECC params %s", (*curve)->name);
58 } 58 }
59 } 59 }
60 } 60 }
61 61
62 struct dropbear_ecc_curve* curve_for_dp(const ltc_ecc_set_type *dp) {
63 struct dropbear_ecc_curve **curve = NULL;
64 for (curve = dropbear_ecc_curves; *curve; curve++) {
65 if ((*curve)->dp == dp) {
66 break;
67 }
68 }
69 assert(*curve);
70 return *curve;
71 }
72
62 ecc_key * new_ecc_key(void) { 73 ecc_key * new_ecc_key(void) {
63 ecc_key *key = m_malloc(sizeof(*key)); 74 ecc_key *key = m_malloc(sizeof(*key));
64 key->pubkey.x = m_malloc(sizeof(mp_int)); 75 key->pubkey.x = m_malloc(sizeof(mp_int));
65 key->pubkey.y = m_malloc(sizeof(mp_int)); 76 key->pubkey.y = m_malloc(sizeof(mp_int));
66 key->pubkey.z = m_malloc(sizeof(mp_int)); 77 key->pubkey.z = m_malloc(sizeof(mp_int));