comparison ecc.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
7 #ifdef DROPBEAR_ECC 7 #ifdef DROPBEAR_ECC
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 32, /* .ltc_size */
13 .hash_desc = &sha256_desc, 13 NULL, /* .dp */
14 .name = "nistp256" 14 &sha256_desc, /* .hash_desc */
15 "nistp256" /* .name */
15 }; 16 };
16 #endif 17 #endif
17 #ifdef DROPBEAR_ECC_384 18 #ifdef DROPBEAR_ECC_384
18 struct dropbear_ecc_curve ecc_curve_nistp384 = { 19 struct dropbear_ecc_curve ecc_curve_nistp384 = {
19 .ltc_size = 48, 20 48, /* .ltc_size */
20 .hash_desc = &sha384_desc, 21 NULL, /* .dp */
21 .name = "nistp384" 22 &sha384_desc, /* .hash_desc */
23 "nistp384" /* .name */
22 }; 24 };
23 #endif 25 #endif
24 #ifdef DROPBEAR_ECC_521 26 #ifdef DROPBEAR_ECC_521
25 struct dropbear_ecc_curve ecc_curve_nistp521 = { 27 struct dropbear_ecc_curve ecc_curve_nistp521 = {
26 .ltc_size = 66, 28 66, /* .ltc_size */
27 .hash_desc = &sha512_desc, 29 NULL, /* .dp */
28 .name = "nistp521" 30 &sha512_desc, /* .hash_desc */
31 "nistp521" /* .name */
29 }; 32 };
30 #endif 33 #endif
31 34
32 struct dropbear_ecc_curve *dropbear_ecc_curves[] = { 35 struct dropbear_ecc_curve *dropbear_ecc_curves[] = {
33 #ifdef DROPBEAR_ECC_256 36 #ifdef DROPBEAR_ECC_256
135 } 138 }
136 139
137 /* For the "ephemeral public key octet string" in ECDH (rfc5656 section 4) */ 140 /* For the "ephemeral public key octet string" in ECDH (rfc5656 section 4) */
138 void buf_put_ecc_raw_pubkey_string(buffer *buf, ecc_key *key) { 141 void buf_put_ecc_raw_pubkey_string(buffer *buf, ecc_key *key) {
139 unsigned long len = key->dp->size*2 + 1; 142 unsigned long len = key->dp->size*2 + 1;
143 int err;
140 buf_putint(buf, len); 144 buf_putint(buf, len);
141 int err = ecc_ansi_x963_export(key, buf_getwriteptr(buf, len), &len); 145 err = ecc_ansi_x963_export(key, buf_getwriteptr(buf, len), &len);
142 if (err != CRYPT_OK) { 146 if (err != CRYPT_OK) {
143 dropbear_exit("ECC error"); 147 dropbear_exit("ECC error");
144 } 148 }
145 buf_incrwritepos(buf, len); 149 buf_incrwritepos(buf, len);
146 } 150 }