Lines Matching refs:dsa
31 static int dsa_keygen(DSA *dsa);
33 int DSA_generate_key(DSA *dsa) in DSA_generate_key() argument
36 if (dsa->meth->dsa_keygen != NULL) in DSA_generate_key()
37 return dsa->meth->dsa_keygen(dsa); in DSA_generate_key()
39 return dsa_keygen(dsa); in DSA_generate_key()
42 int ossl_dsa_generate_public_key(BN_CTX *ctx, const DSA *dsa, in ossl_dsa_generate_public_key() argument
53 if (!BN_mod_exp(pub_key, dsa->params.g, prk, dsa->params.p, ctx)) in ossl_dsa_generate_public_key()
75 static int dsa_keygen_knownanswer_test(DSA *dsa, BN_CTX *ctx, in dsa_keygen_knownanswer_test() argument
93 if (!ossl_dsa_generate_public_key(ctx, dsa, dsa->priv_key, pub_key2)) in dsa_keygen_knownanswer_test()
101 ret = !BN_cmp(dsa->pub_key, pub_key2); in dsa_keygen_knownanswer_test()
114 static int dsa_keygen_pairwise_test(DSA *dsa, OSSL_CALLBACK *cb, void *cbarg) in dsa_keygen_pairwise_test() argument
129 sig = DSA_do_sign(dgst, (int)dgst_len, dsa); in dsa_keygen_pairwise_test()
135 if (DSA_do_verify(dgst, dgst_len, sig, dsa) != 1) in dsa_keygen_pairwise_test()
147 static int dsa_keygen(DSA *dsa) in dsa_keygen() argument
153 if ((ctx = BN_CTX_new_ex(dsa->libctx)) == NULL) in dsa_keygen()
156 if (dsa->priv_key == NULL) { in dsa_keygen()
160 priv_key = dsa->priv_key; in dsa_keygen()
164 if (!ossl_ffc_params_simple_validate(dsa->libctx, &dsa->params, in dsa_keygen()
173 if (!ossl_ffc_generate_private_key(ctx, &dsa->params, in dsa_keygen()
174 BN_num_bits(dsa->params.q), in dsa_keygen()
178 if (dsa->pub_key == NULL) { in dsa_keygen()
182 pub_key = dsa->pub_key; in dsa_keygen()
185 if (!ossl_dsa_generate_public_key(ctx, dsa, priv_key, pub_key)) in dsa_keygen()
188 dsa->priv_key = priv_key; in dsa_keygen()
189 dsa->pub_key = pub_key; in dsa_keygen()
197 OSSL_SELF_TEST_get_callback(dsa->libctx, &cb, &cbarg); in dsa_keygen()
198 ok = dsa_keygen_pairwise_test(dsa, cb, cbarg) in dsa_keygen()
199 && dsa_keygen_knownanswer_test(dsa, ctx, cb, cbarg); in dsa_keygen()
202 BN_free(dsa->pub_key); in dsa_keygen()
203 BN_clear_free(dsa->priv_key); in dsa_keygen()
204 dsa->pub_key = NULL; in dsa_keygen()
205 dsa->priv_key = NULL; in dsa_keygen()
211 dsa->dirty_cnt++; in dsa_keygen()
214 if (pub_key != dsa->pub_key) in dsa_keygen()
216 if (priv_key != dsa->priv_key) in dsa_keygen()