comparison rsa.c @ 34:e2a1eaa19f22

Client mostly works up to password auth Need to rework algo-choosing etc, since server is now broken.
author Matt Johnston <matt@ucc.asn.au>
date Wed, 28 Jul 2004 16:44:16 +0000
parents fe6bca95afa7
children b0316ce64e4b
comparison
equal deleted inserted replaced
33:f789045062e6 34:e2a1eaa19f22
203 unsigned int slen; 203 unsigned int slen;
204 mp_int rsa_s, rsa_mdash; 204 mp_int rsa_s, rsa_mdash;
205 mp_int *rsa_em = NULL; 205 mp_int *rsa_em = NULL;
206 int ret = DROPBEAR_FAILURE; 206 int ret = DROPBEAR_FAILURE;
207 207
208 TRACE(("enter buf_rsa_verify"));
209
208 assert(key != NULL); 210 assert(key != NULL);
209 211
210 m_mp_init_multi(&rsa_mdash, &rsa_s, NULL); 212 m_mp_init_multi(&rsa_mdash, &rsa_s, NULL);
211 213
212 slen = buf_getint(buf); 214 slen = buf_getint(buf);
215 goto out; 217 goto out;
216 } 218 }
217 219
218 if (mp_read_unsigned_bin(&rsa_s, buf_getptr(buf, buf->len - buf->pos), 220 if (mp_read_unsigned_bin(&rsa_s, buf_getptr(buf, buf->len - buf->pos),
219 buf->len - buf->pos) != MP_OKAY) { 221 buf->len - buf->pos) != MP_OKAY) {
222 TRACE(("failed reading rsa_s"));
220 goto out; 223 goto out;
221 } 224 }
222 225
223 /* check that s <= n-1 */ 226 /* check that s <= n-1 */
224 if (mp_cmp(&rsa_s, key->n) != MP_LT) { 227 if (mp_cmp(&rsa_s, key->n) != MP_LT) {
228 231
229 /* create the magic PKCS padded value */ 232 /* create the magic PKCS padded value */
230 rsa_em = rsa_pad_em(key, data, len); 233 rsa_em = rsa_pad_em(key, data, len);
231 234
232 if (mp_exptmod(&rsa_s, key->e, key->n, &rsa_mdash) != MP_OKAY) { 235 if (mp_exptmod(&rsa_s, key->e, key->n, &rsa_mdash) != MP_OKAY) {
236 TRACE(("failed exptmod rsa_s"));
233 goto out; 237 goto out;
234 } 238 }
235 239
236 if (mp_cmp(rsa_em, &rsa_mdash) == MP_EQ) { 240 if (mp_cmp(rsa_em, &rsa_mdash) == MP_EQ) {
237 /* signature is valid */ 241 /* signature is valid */
242 TRACE(("success!"));
238 ret = DROPBEAR_SUCCESS; 243 ret = DROPBEAR_SUCCESS;
239 } 244 }
240 245
241 out: 246 out:
242 mp_clear_multi(rsa_em, &rsa_mdash, &rsa_s, NULL); 247 mp_clear_multi(rsa_em, &rsa_mdash, &rsa_s, NULL);
243 m_free(rsa_em); 248 m_free(rsa_em);
249 TRACE(("leave buf_rsa_verify: ret %d", ret));
244 return ret; 250 return ret;
245 251
246 } 252 }
247 #endif /* DROPBEAR_SIGNKEY_VERIFY */ 253 #endif /* DROPBEAR_SIGNKEY_VERIFY */
248 254