comparison rsa.c @ 346:ed24dfc44904 debug-unrandom

add some debugging of mpints
author Matt Johnston <matt@ucc.asn.au>
date Fri, 04 Aug 2006 17:15:35 +0000
parents 454a34b2dfd1
children
comparison
equal deleted inserted replaced
345:959c66ccf1b5 346:ed24dfc44904
209 209
210 TRACE(("enter buf_rsa_verify")) 210 TRACE(("enter buf_rsa_verify"))
211 211
212 dropbear_assert(key != NULL); 212 dropbear_assert(key != NULL);
213 213
214 printhex("buf_rsa_verify buffer", buf->data, buf->len);
215 print_mp_int("buf_rsa_verify key n", key->n);
216 print_mp_int("buf_rsa_verify key e", key->e);
217
214 m_mp_init_multi(&rsa_mdash, &rsa_s, &rsa_em, NULL); 218 m_mp_init_multi(&rsa_mdash, &rsa_s, &rsa_em, NULL);
215 219
216 slen = buf_getint(buf); 220 slen = buf_getint(buf);
217 if (slen != (unsigned int)mp_unsigned_bin_size(key->n)) { 221 if (slen != (unsigned int)mp_unsigned_bin_size(key->n)) {
218 TRACE(("bad size")) 222 TRACE(("bad size"))
223 buf->len - buf->pos) != MP_OKAY) { 227 buf->len - buf->pos) != MP_OKAY) {
224 TRACE(("failed reading rsa_s")) 228 TRACE(("failed reading rsa_s"))
225 goto out; 229 goto out;
226 } 230 }
227 231
232 print_mp_int("buf_rsa_verify rsa_s", &rsa_s);
233
228 /* check that s <= n-1 */ 234 /* check that s <= n-1 */
229 if (mp_cmp(&rsa_s, key->n) != MP_LT) { 235 if (mp_cmp(&rsa_s, key->n) != MP_LT) {
230 TRACE(("s > n-1")) 236 TRACE(("s > n-1"))
231 goto out; 237 goto out;
232 } 238 }
233 239
234 /* create the magic PKCS padded value */ 240 /* create the magic PKCS padded value */
235 rsa_pad_em(key, data, len, &rsa_em); 241 rsa_pad_em(key, data, len, &rsa_em);
242 print_mp_int("buf_rsa_verify rsa_em", &rsa_em);
236 243
237 if (mp_exptmod(&rsa_s, key->e, key->n, &rsa_mdash) != MP_OKAY) { 244 if (mp_exptmod(&rsa_s, key->e, key->n, &rsa_mdash) != MP_OKAY) {
238 TRACE(("failed exptmod rsa_s")) 245 TRACE(("failed exptmod rsa_s"))
239 goto out; 246 goto out;
240 } 247 }
248 print_mp_int("buf_rsa_verify rsa_mdash", &rsa_mdash);
241 249
242 if (mp_cmp(&rsa_em, &rsa_mdash) == MP_EQ) { 250 if (mp_cmp(&rsa_em, &rsa_mdash) == MP_EQ) {
243 /* signature is valid */ 251 /* signature is valid */
244 TRACE(("success!")) 252 TRACE(("success!"))
245 ret = DROPBEAR_SUCCESS; 253 ret = DROPBEAR_SUCCESS;