comparison src/pk/dsa/dsa_make_key.c @ 209:39d5d58461d6 libtomcrypt-orig LTC_1.05

Import of libtomcrypt 1.05
author Matt Johnston <matt@ucc.asn.au>
date Wed, 06 Jul 2005 03:53:40 +0000
parents 1c15b283127b
children
comparison
equal deleted inserted replaced
191:1c15b283127b 209:39d5d58461d6
68 err = CRYPT_ERROR_READPRNG; 68 err = CRYPT_ERROR_READPRNG;
69 goto LBL_ERR; 69 goto LBL_ERR;
70 } 70 }
71 71
72 /* force magnitude */ 72 /* force magnitude */
73 buf[0] = 1; 73 buf[0] |= 0xC0;
74 74
75 /* force even */ 75 /* force even */
76 buf[modulus_size - group_size] &= ~1; 76 buf[modulus_size - group_size - 1] &= ~1;
77 77
78 if ((err = mp_read_unsigned_bin(&tmp2, buf, modulus_size - group_size+1)) != MP_OKAY) { goto error; } 78 if ((err = mp_read_unsigned_bin(&tmp2, buf, modulus_size - group_size)) != MP_OKAY) { goto error; }
79 if ((err = mp_mul(&key->q, &tmp2, &key->p)) != MP_OKAY) { goto error; } 79 if ((err = mp_mul(&key->q, &tmp2, &key->p)) != MP_OKAY) { goto error; }
80 if ((err = mp_add_d(&key->p, 1, &key->p)) != MP_OKAY) { goto error; } 80 if ((err = mp_add_d(&key->p, 1, &key->p)) != MP_OKAY) { goto error; }
81 81
82 /* now loop until p is prime */ 82 /* now loop until p is prime */
83 for (;;) { 83 for (;;) {
84 if ((err = is_prime(&key->p, &res)) != CRYPT_OK) { goto LBL_ERR; } 84 if ((err = is_prime(&key->p, &res)) != CRYPT_OK) { goto LBL_ERR; }
85 if (res == MP_YES) break; 85 if (res == MP_YES) break;
86 86
138 XFREE(buf); 138 XFREE(buf);
139 return err; 139 return err;
140 } 140 }
141 141
142 #endif 142 #endif
143
144 /* $Source: /cvs/libtom/libtomcrypt/src/pk/dsa/dsa_make_key.c,v $ */
145 /* $Revision: 1.4 $ */
146 /* $Date: 2005/06/11 05:45:35 $ */