comparison genrsa.c @ 805:724c3e0c8734 ecc

Add m_mp_alloc_init_multi() helper
author Matt Johnston <matt@ucc.asn.au>
date Thu, 23 May 2013 22:18:16 +0800
parents d386defb5376
children 220f55d540ae
comparison
equal deleted inserted replaced
804:34b73c9d8aa3 805:724c3e0c8734
48 dropbear_exit("Bits must satisfy 512 <= bits <= 4096, and be a" 48 dropbear_exit("Bits must satisfy 512 <= bits <= 4096, and be a"
49 " multiple of 8"); 49 " multiple of 8");
50 } 50 }
51 51
52 key = m_malloc(sizeof(*key)); 52 key = m_malloc(sizeof(*key));
53 53 m_mp_alloc_init_multi(&key->e, &key->n, &key->d, &key->p, &key->q, NULL);
54 key->e = (mp_int*)m_malloc(sizeof(mp_int)); 54 m_mp_init_multi(&pminus, &lcm, &qminus, NULL);
55 key->n = (mp_int*)m_malloc(sizeof(mp_int));
56 key->d = (mp_int*)m_malloc(sizeof(mp_int));
57 key->p = (mp_int*)m_malloc(sizeof(mp_int));
58 key->q = (mp_int*)m_malloc(sizeof(mp_int));
59
60 m_mp_init_multi(key->e, key->n, key->d, key->p, key->q,
61 &pminus, &lcm, &qminus, NULL);
62 55
63 if (mp_set_int(key->e, RSA_E) != MP_OKAY) { 56 if (mp_set_int(key->e, RSA_E) != MP_OKAY) {
64 fprintf(stderr, "RSA generation failed\n"); 57 fprintf(stderr, "RSA generation failed\n");
65 exit(1); 58 exit(1);
66 } 59 }