comparison ecdsa.c @ 1511:5916af64acd4 fuzz

merge from main
author Matt Johnston <matt@ucc.asn.au>
date Sat, 17 Feb 2018 19:29:51 +0800
parents 06d52bcb8094
children d68d61e7056a
comparison
equal deleted inserted replaced
1457:32f990cc96b1 1511:5916af64acd4
13 return type == DROPBEAR_SIGNKEY_ECDSA_NISTP256 13 return type == DROPBEAR_SIGNKEY_ECDSA_NISTP256
14 || type == DROPBEAR_SIGNKEY_ECDSA_NISTP384 14 || type == DROPBEAR_SIGNKEY_ECDSA_NISTP384
15 || type == DROPBEAR_SIGNKEY_ECDSA_NISTP521; 15 || type == DROPBEAR_SIGNKEY_ECDSA_NISTP521;
16 } 16 }
17 17
18 enum signkey_type ecdsa_signkey_type(ecc_key * key) { 18 enum signkey_type ecdsa_signkey_type(const ecc_key * key) {
19 #if DROPBEAR_ECC_256 19 #if DROPBEAR_ECC_256
20 if (key->dp == ecc_curve_nistp256.dp) { 20 if (key->dp == ecc_curve_nistp256.dp) {
21 return DROPBEAR_SIGNKEY_ECDSA_NISTP256; 21 return DROPBEAR_SIGNKEY_ECDSA_NISTP256;
22 } 22 }
23 #endif 23 #endif
152 void buf_put_ecdsa_priv_key(buffer *buf, ecc_key *key) { 152 void buf_put_ecdsa_priv_key(buffer *buf, ecc_key *key) {
153 buf_put_ecdsa_pub_key(buf, key); 153 buf_put_ecdsa_pub_key(buf, key);
154 buf_putmpint(buf, key->k); 154 buf_putmpint(buf, key->k);
155 } 155 }
156 156
157 void buf_put_ecdsa_sign(buffer *buf, ecc_key *key, buffer *data_buf) { 157 void buf_put_ecdsa_sign(buffer *buf, const ecc_key *key, const buffer *data_buf) {
158 /* Based on libtomcrypt's ecc_sign_hash but without the asn1 */ 158 /* Based on libtomcrypt's ecc_sign_hash but without the asn1 */
159 int err = DROPBEAR_FAILURE; 159 int err = DROPBEAR_FAILURE;
160 struct dropbear_ecc_curve *curve = NULL; 160 struct dropbear_ecc_curve *curve = NULL;
161 hash_state hs; 161 hash_state hs;
162 unsigned char hash[64]; 162 unsigned char hash[64];
270 out: 270 out:
271 return ret; 271 return ret;
272 } 272 }
273 273
274 274
275 int buf_ecdsa_verify(buffer *buf, ecc_key *key, buffer *data_buf) { 275 int buf_ecdsa_verify(buffer *buf, const ecc_key *key, const buffer *data_buf) {
276 /* Based on libtomcrypt's ecc_verify_hash but without the asn1 */ 276 /* Based on libtomcrypt's ecc_verify_hash but without the asn1 */
277 int ret = DROPBEAR_FAILURE; 277 int ret = DROPBEAR_FAILURE;
278 hash_state hs; 278 hash_state hs;
279 struct dropbear_ecc_curve *curve = NULL; 279 struct dropbear_ecc_curve *curve = NULL;
280 unsigned char hash[64]; 280 unsigned char hash[64];