comparison ecdsa.c @ 854:ccc76acaf4c7

merge ecc again
author Matt Johnston <matt@ucc.asn.au>
date Thu, 14 Nov 2013 20:45:46 +0800
parents 7540c0822374
children 04ede40a529a
comparison
equal deleted inserted replaced
845:774ad9b112ef 854:ccc76acaf4c7
5 #include "ecc.h" 5 #include "ecc.h"
6 #include "ecdsa.h" 6 #include "ecdsa.h"
7 #include "signkey.h" 7 #include "signkey.h"
8 8
9 #ifdef DROPBEAR_ECDSA 9 #ifdef DROPBEAR_ECDSA
10
11 int signkey_is_ecdsa(enum signkey_type type)
12 {
13 return type == DROPBEAR_SIGNKEY_ECDSA_NISTP256
14 || type == DROPBEAR_SIGNKEY_ECDSA_NISTP384
15 || type == DROPBEAR_SIGNKEY_ECDSA_NISTP521;
16 }
10 17
11 enum signkey_type ecdsa_signkey_type(ecc_key * key) { 18 enum signkey_type ecdsa_signkey_type(ecc_key * key) {
12 #ifdef DROPBEAR_ECC_256 19 #ifdef DROPBEAR_ECC_256
13 if (key->dp == ecc_curve_nistp256.dp) { 20 if (key->dp == ecc_curve_nistp256.dp) {
14 return DROPBEAR_SIGNKEY_ECDSA_NISTP256; 21 return DROPBEAR_SIGNKEY_ECDSA_NISTP256;
237 } 244 }
238 } 245 }
239 246
240 // returns values in s and r 247 // returns values in s and r
241 // returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE 248 // returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE
242 static int buf_get_ecdsa_verify_params(buffer *buf, struct dropbear_ecc_curve *curve, 249 static int buf_get_ecdsa_verify_params(buffer *buf,
243 void *r, void* s) { 250 void *r, void* s) {
244 int ret = DROPBEAR_FAILURE; 251 int ret = DROPBEAR_FAILURE;
245 unsigned int sig_len; 252 unsigned int sig_len;
246 unsigned int sig_pos; 253 unsigned int sig_pos;
247 254
248 sig_len = buf_getint(buf); 255 sig_len = buf_getint(buf);
293 || !mG 300 || !mG
294 || !mQ) { 301 || !mQ) {
295 dropbear_exit("ECC error"); 302 dropbear_exit("ECC error");
296 } 303 }
297 304
298 if (buf_get_ecdsa_verify_params(buf, curve, r, s) != DROPBEAR_SUCCESS) { 305 if (buf_get_ecdsa_verify_params(buf, r, s) != DROPBEAR_SUCCESS) {
299 goto out; 306 goto out;
300 } 307 }
301 308
302 curve->hash_desc->init(&hs); 309 curve->hash_desc->init(&hs);
303 curve->hash_desc->process(&hs, data_buf->data, data_buf->len); 310 curve->hash_desc->process(&hs, data_buf->data, data_buf->len);