annotate ecc.c @ 757:230666086711 ecc

ecc key import function
author Matt Johnston <matt@ucc.asn.au>
date Wed, 27 Mar 2013 23:50:52 +0800
parents bf9dc2d9c2b1
children 76fba0856749
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
1 #include "includes.h"
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
2 #include "options.h"
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
3 #include "ecc.h"
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
4
755
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 #ifdef DROPBEAR_ECC
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6
757
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
7 // TODO: use raw bytes for the dp rather than the hex strings in libtomcrypt's ecc.c
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
8
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
9 #ifdef DROPBEAR_ECC_256
757
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
10 const struct dropbear_ecc_curve ecc_curve_secp256r1 {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
11 .dp = &ltc_ecc_sets[0],
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
12 .hash_desc = sha256_desc,
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
13 .name = "secp256r1"
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
14 };
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
15 #endif
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
16
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
17
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
18 #ifdef DROPBEAR_ECC_384
757
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
19 const struct dropbear_ecc_curve ecc_curve_secp384r1 {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
20 .dp = &ltc_ecc_sets[1],
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
21 .hash_desc = sha384_desc,
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
22 .name = "secp384r1"
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
23 };
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
24 #endif
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
25
757
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
26 #ifdef DROPBEAR_ECC_521
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
27 const struct dropbear_ecc_curve ecc_curve_secp521r1 {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
28 .dp = &ltc_ecc_sets[2],
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
29 .hash_desc = sha521_desc,
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
30 .name = "secp521r1"
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
31 };
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
32 #endif
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
33
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
34
757
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
35 void buf_put_ecc_pubkey_string(buffer *buf, ecc_key *key) {
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
36 // XXX point compression
755
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
37 int len = key->dp->size*2 + 1;
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
38 buf_putint(len);
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
39 int err = ecc_ansi_x963_export(key, buf_getwriteptr(buf, len), &len);
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
40 if (err != CRYPT_OK) {
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
41 dropbear_exit("ECC error");
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
42 }
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
43 buf_incrwritepos(buf, len);
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
44 }
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
45
757
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
46 ecc_key * buf_get_ecc_key_string(buffer *buf, const struct dropbear_ecc_curve *curve) {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
47 ecc_key *key = NULL;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
48 int ret = DROPBEAR_FAILURE;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
49 const int size = curve->dp->size;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
50 unsigned int len = buf_get_string(buf);
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
51 unsigned char first = buf_get_char(buf);
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
52 if (first == 2 || first == 3) {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
53 dropbear_log("Dropbear doesn't support ECC point compression");
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
54 return NULL;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
55 }
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
56 if (first != 4 || len != 1+2*size) {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
57 return NULL;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
58 }
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
59
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
60 key = m_malloc(sizeof(*key));
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
61 m_mp_init_multi(&key->pubkey.x, &key->pubkey.y, &key->pubkey.z, &key->k, NULL);
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
62
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
63 if (mp_read_unsigned_bin(&key->pubkey.x, buf_getptr(buf, size), size) != MP_OKAY) {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
64 goto out;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
65 }
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
66 buf_incrpos(buf, size);
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
67
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
68 if (mp_read_unsigned_bin(&key->pubkey.y, buf_getptr(buf, size), size) != MP_OKAY) {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
69 goto out;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
70 }
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
71 buf_incrpos(buf, size);
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
72
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
73 if (mp_set(key->pubkey.z, 1) != MP_OKAY) {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
74 goto out;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
75 }
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
76
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
77 if (is_point(key) != CRYPT_OK) {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
78 goto out;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
79 }
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
80
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
81 // SEC1 3.2.3.1 Check that Q != 0
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
82 if (mp_cmp_d(key->pubkey.x, 0) == LTC_MP_EQ) {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
83 goto out;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
84 }
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
85 if (mp_cmp_d(key->pubkey.y, 0) == LTC_MP_EQ) {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
86 goto out;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
87 }
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
88
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
89 ret = DROPBEAR_SUCCESS;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
90
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
91 out:
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
92 if (ret == DROPBEAR_FAILURE) {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
93 if (key) {
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
94 mp_free_multi(&key->pubkey.x, &key->pubkey.y, &key->pubkey.z, &key->k, NULL);
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
95 m_free(key);
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
96 key = NULL;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
97 }
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
98 }
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
99
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
100 return key;
230666086711 ecc key import function
Matt Johnston <matt@ucc.asn.au>
parents: 756
diff changeset
101
755
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
102 }
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
103
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
104 // a modified version of libtomcrypt's "ecc_shared_secret" to output
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
105 // a mp_int instead.
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
106 mp_int * dropbear_ecc_shared_secret(ecc_key *public_key, ecc_key *private_key)
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
107 {
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
108 ecc_point *result = NULL
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
109 mp_int *prime = NULL, *shared_secret = NULL;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
110 int ret = DROPBEAR_FAILURE;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
111
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
112 /* type valid? */
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
113 if (private_key->type != PK_PRIVATE) {
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
114 goto done;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
115 }
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
116
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
117 if (private_key->dp != public_key->dp) {
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
118 goto done;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
119 }
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
120
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
121 #if 0
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
122 // XXX - possibly not neccessary tests?
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
123 if (ltc_ecc_is_valid_idx(private_key->idx) == 0 || ltc_ecc_is_valid_idx(public_key->idx) == 0) {
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
124 goto done;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
125 }
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
126
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
127 if (XSTRCMP(private_key->dp->name, public_key->dp->name) != 0) {
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
128 goto done;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
129 }
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
130 #endif
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
131
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
132 /* make new point */
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
133 result = ltc_ecc_new_point();
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
134 if (result == NULL) {
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
135 goto done;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
136 }
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
137
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
138 prime = m_malloc(sizeof(*prime));
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
139 m_mp_init(prime);
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
140
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
141 if (mp_read_radix(prime, (char *)private_key->dp->prime, 16) != CRYPT_OK) {
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
142 goto done;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
143 }
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
144 if (ltc_mp.ecc_ptmul(private_key->k, &public_key->pubkey, result, prime, 1) != CRYPT_OK) {
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
145 goto done;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
146 }
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
147
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
148 err = DROPBEAR_SUCCESS;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
149 done:
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
150 if (err == DROPBEAR_SUCCESS) {
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
151 shared_secret = prime;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
152 prime = NULL;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
153 }
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
154
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
155 if (prime) {
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
156 mp_clear(prime);
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
157 m_free(prime);
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
158 }
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
159 ltc_ecc_del_point(result);
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
160
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
161 if (err == DROPBEAR_FAILURE) {
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
162 dropbear_exit("ECC error");
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
163 }
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
164
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
165 return shared_secret;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
166 return err;
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
167 }
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
168
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
169 }
755
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
170
b07eb3dc23ec refactor kexdh code a bit, start working on ecdh etc
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
171 #endif