Mercurial > dropbear
comparison ecdsa.c @ 766:d1575fdc29a6 ecc
start on ecdsa keys
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 09 Apr 2013 00:36:04 +0800 |
parents | |
children | e465ed10c51d |
comparison
equal
deleted
inserted
replaced
765:5503e05ab3a4 | 766:d1575fdc29a6 |
---|---|
1 #include "includes.h" | |
2 #include "dbutil.h" | |
3 #include "crypto_desc.h" | |
4 | |
5 #ifdef DROPBEAR_ECDSA | |
6 | |
7 ecc_key *gen_ecdsa_priv_key(unsigned int bit_size) { | |
8 const ltc_ecc_set_type *dp = NULL; // curve domain parameters | |
9 // TODO: use raw bytes for the dp rather than the hex strings in libtomcrypt's ecc.c | |
10 switch (bit_size) { | |
11 #ifdef DROPBEAR_ECC_256 | |
12 case 256: | |
13 dp = <c_ecc_sets[0]; | |
14 break; | |
15 #endif | |
16 #ifdef DROPBEAR_ECC_384 | |
17 case 384: | |
18 dp = <c_ecc_sets[0]; | |
19 break; | |
20 #endif | |
21 #ifdef DROPBEAR_ECC_521 | |
22 case 521: | |
23 dp = <c_ecc_sets[0]; | |
24 break; | |
25 #endif | |
26 } | |
27 if (!dp) { | |
28 dropbear_exit("Key size %d isn't valid. Try " | |
29 #ifdef DROPBEAR_ECC_256 | |
30 "256 " | |
31 #endif | |
32 #ifdef DROPBEAR_ECC_384 | |
33 "384 " | |
34 #endif | |
35 #ifdef DROPBEAR_ECC_521 | |
36 "521 " | |
37 #endif | |
38 , bit_size); | |
39 } | |
40 | |
41 ecc_key *new_key = m_malloc(sizeof(*new_key)); | |
42 if (ecc_make_key_ex(NULL, dropbear_ltc_prng, new_key, dp) != CRYPT_OK) { | |
43 dropbear_exit("ECC error"); | |
44 } | |
45 return new_key; | |
46 } | |
47 | |
48 int buf_get_ecdsa_pub_key(buffer* buf, ecc_key *key) { | |
49 | |
50 } | |
51 | |
52 | |
53 #endif // DROPBEAR_ECDSA |