64 #define HASH EVP_sha()
69 #define HASH EVP_sha1()
74 #ifndef OPENSSL_NO_SHA
85 #include <openssl/fips.h>
89 const unsigned char *seed_in,
int seed_len,
90 int *counter_ret,
unsigned long *h_ret,
BN_GENCB *
cb)
102 counter_ret, h_ret, cb);
106 return FIPS_dsa_generate_parameters_ex(ret, bits,
108 counter_ret, h_ret, cb);
114 size_t qbits = bits >= 2048 ? 256 : 160;
128 seed_in, seed_len, NULL, counter_ret, h_ret, cb);
133 const EVP_MD *evpmd,
const unsigned char *seed_in,
size_t seed_len,
134 unsigned char *seed_out,
135 int *counter_ret,
unsigned long *h_ret,
BN_GENCB *
cb)
144 int i,
k, n=0, m=0, qsize = qbits >> 3;
162 bits = (bits+63)/64*64;
167 if (seed_len && (seed_len < (
size_t)qsize))
169 if (seed_len > (
size_t)qsize)
173 memcpy(seed, seed_in, seed_len);
214 memcpy(buf , seed, qsize);
215 memcpy(buf2, seed, qsize);
217 for (i = qsize-1; i >= 0; i--)
225 if (!
EVP_Digest(seed, qsize, md, NULL, evpmd, NULL))
227 if (!
EVP_Digest(buf, qsize, buf2, NULL, evpmd, NULL))
229 for (i = 0; i < qsize; i++)
270 for (i = qsize-1; i >= 0; i--)
284 if (!
BN_lshift(r0,r0,(qsize << 3)*k))
goto err;
285 if (!
BN_add(W,W,r0))
goto err;
291 if (!
BN_add(X,X,test))
goto err;
295 if (!
BN_mod(c,X,r0,ctx))
goto err;
297 if (!
BN_sub(p,X,r0))
goto err;
316 if (counter >= 4096)
break;
326 if (!
BN_div(r0,NULL,test,q,ctx))
goto err;
353 if (ret->
p == NULL || ret->
q == NULL || ret->
g == NULL)
358 if (counter_ret != NULL) *counter_ret=counter;
359 if (h_ret != NULL) *h_ret=
h;
361 memcpy(seed_out, seed, qsize);