comparison ecdsa.c @ 1129:45830474d83c coverity

merge up to date, attempt to fix travis.yml
author Matt Johnston <matt@ucc.asn.au>
date Fri, 12 Jun 2015 23:02:15 +0800
parents aaf576b27a10
children 2bb4c662d1c2
comparison
equal deleted inserted replaced
1077:26c1f9b8f82e 1129:45830474d83c
81 buffer *q_buf = NULL; 81 buffer *q_buf = NULL;
82 struct dropbear_ecc_curve **curve; 82 struct dropbear_ecc_curve **curve;
83 ecc_key *new_key = NULL; 83 ecc_key *new_key = NULL;
84 84
85 /* string "ecdsa-sha2-[identifier]" */ 85 /* string "ecdsa-sha2-[identifier]" */
86 key_ident = buf_getstring(buf, &key_ident_len); 86 key_ident = (unsigned char*)buf_getstring(buf, &key_ident_len);
87 /* string "[identifier]" */ 87 /* string "[identifier]" */
88 identifier = buf_getstring(buf, &identifier_len); 88 identifier = (unsigned char*)buf_getstring(buf, &identifier_len);
89 89
90 if (key_ident_len != identifier_len + strlen("ecdsa-sha2-")) { 90 if (key_ident_len != identifier_len + strlen("ecdsa-sha2-")) {
91 TRACE(("Bad identifier lengths")) 91 TRACE(("Bad identifier lengths"))
92 goto out; 92 goto out;
93 } 93 }
138 return new_key; 138 return new_key;
139 } 139 }
140 140
141 void buf_put_ecdsa_pub_key(buffer *buf, ecc_key *key) { 141 void buf_put_ecdsa_pub_key(buffer *buf, ecc_key *key) {
142 struct dropbear_ecc_curve *curve = NULL; 142 struct dropbear_ecc_curve *curve = NULL;
143 unsigned char key_ident[30]; 143 char key_ident[30];
144 144
145 curve = curve_for_dp(key->dp); 145 curve = curve_for_dp(key->dp);
146 snprintf((char*)key_ident, sizeof(key_ident), "ecdsa-sha2-%s", curve->name); 146 snprintf(key_ident, sizeof(key_ident), "ecdsa-sha2-%s", curve->name);
147 buf_putstring(buf, key_ident, strlen(key_ident)); 147 buf_putstring(buf, key_ident, strlen(key_ident));
148 buf_putstring(buf, curve->name, strlen(curve->name)); 148 buf_putstring(buf, curve->name, strlen(curve->name));
149 buf_put_ecc_raw_pubkey_string(buf, key); 149 buf_put_ecc_raw_pubkey_string(buf, key);
150 } 150 }
151 151
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];
163 void *e = NULL, *p = NULL, *s = NULL, *r; 163 void *e = NULL, *p = NULL, *s = NULL, *r;
164 unsigned char key_ident[30]; 164 char key_ident[30];
165 buffer *sigbuf = NULL; 165 buffer *sigbuf = NULL;
166 166
167 TRACE(("buf_put_ecdsa_sign")) 167 TRACE(("buf_put_ecdsa_sign"))
168 curve = curve_for_dp(key->dp); 168 curve = curve_for_dp(key->dp);
169 169
220 if (ltc_mp.compare_d(s, 0) != LTC_MP_EQ) { 220 if (ltc_mp.compare_d(s, 0) != LTC_MP_EQ) {
221 break; 221 break;
222 } 222 }
223 } 223 }
224 224
225 snprintf((char*)key_ident, sizeof(key_ident), "ecdsa-sha2-%s", curve->name); 225 snprintf(key_ident, sizeof(key_ident), "ecdsa-sha2-%s", curve->name);
226 buf_putstring(buf, key_ident, strlen(key_ident)); 226 buf_putstring(buf, key_ident, strlen(key_ident));
227 /* enough for nistp521 */ 227 /* enough for nistp521 */
228 sigbuf = buf_new(200); 228 sigbuf = buf_new(200);
229 buf_putmpint(sigbuf, (mp_int*)r); 229 buf_putmpint(sigbuf, (mp_int*)r);
230 buf_putmpint(sigbuf, (mp_int*)s); 230 buf_putmpint(sigbuf, (mp_int*)s);