2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 * Licensed under the OpenSSL licenses, (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
14 * https://www.openssl.org/source/license.html
15 * or in the file LICENSE in the source distribution.
20 #include <openssl/err.h>
22 DSA_METHOD *DSA_meth_new(const char *name, int flags)
24 DSA_METHOD *dsam = OPENSSL_zalloc(sizeof(DSA_METHOD));
27 dsam->name = OPENSSL_strdup(name);
28 if (dsam->name == NULL) {
30 DSAerr(DSA_F_DSA_METH_NEW, ERR_R_MALLOC_FAILURE);
39 void DSA_meth_free(DSA_METHOD *dsam)
42 if (dsam->name != NULL)
43 OPENSSL_free(dsam->name);
48 DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam)
52 ret = OPENSSL_malloc(sizeof(DSA_METHOD));
55 memcpy(ret, dsam, sizeof(*dsam));
56 ret->name = OPENSSL_strdup(dsam->name);
57 if (ret->name == NULL) {
59 DSAerr(DSA_F_DSA_METH_DUP, ERR_R_MALLOC_FAILURE);
67 const char *DSA_meth_get0_name(const DSA_METHOD *dsam)
72 int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name)
76 tmpname = OPENSSL_strdup(name);
77 if (tmpname == NULL) {
78 DSAerr(DSA_F_DSA_METH_SET1_NAME, ERR_R_MALLOC_FAILURE);
82 OPENSSL_free(dsam->name);
88 int DSA_meth_get_flags(DSA_METHOD *dsam)
93 int DSA_meth_set_flags(DSA_METHOD *dsam, int flags)
99 void *DSA_meth_get0_app_data(const DSA_METHOD *dsam)
101 return dsam->app_data;
104 int DSA_meth_set0_app_data(DSA_METHOD *dsam, void *app_data)
106 dsam->app_data = app_data;
110 DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam))
111 (const unsigned char *, int, DSA *)
113 return dsam->dsa_do_sign;
116 int DSA_meth_set_sign(DSA_METHOD *dsam,
117 DSA_SIG *(*sign) (const unsigned char *, int, DSA *))
119 dsam->dsa_do_sign = sign;
123 int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam))
124 (DSA *, BN_CTX *, BIGNUM **, BIGNUM **)
126 return dsam->dsa_sign_setup;
129 int DSA_meth_set_sign_setup(DSA_METHOD *dsam,
130 int (*sign_setup) (DSA *, BN_CTX *, BIGNUM **, BIGNUM **))
132 dsam->dsa_sign_setup = sign_setup;
136 int (*DSA_meth_get_verify(const DSA_METHOD *dsam))
137 (const unsigned char *, int , DSA_SIG *, DSA *)
139 return dsam->dsa_do_verify;
142 int DSA_meth_set_verify(DSA_METHOD *dsam,
143 int (*verify) (const unsigned char *, int, DSA_SIG *, DSA *))
145 dsam->dsa_do_verify = verify;
149 int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))
150 (DSA *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *,
151 BN_CTX *, BN_MONT_CTX *)
153 return dsam->dsa_mod_exp;
156 int DSA_meth_set_mod_exp(DSA_METHOD *dsam,
157 int (*mod_exp) (DSA *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *,
158 BIGNUM *, BN_CTX *, BN_MONT_CTX *))
160 dsam->dsa_mod_exp = mod_exp;
164 int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))
165 (DSA *, BIGNUM *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
168 return dsam->bn_mod_exp;
171 int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam,
172 int (*bn_mod_exp) (DSA *, BIGNUM *, BIGNUM *, const BIGNUM *,
173 const BIGNUM *, BN_CTX *, BN_MONT_CTX *))
175 dsam->bn_mod_exp = bn_mod_exp;
179 int (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *)
184 int DSA_meth_set_init(DSA_METHOD *dsam, int (*init)(DSA *))
190 int (*DSA_meth_get_finish(const DSA_METHOD *dsam)) (DSA *)
195 int DSA_meth_set_finish(DSA_METHOD *dsam, int (*finish) (DSA *))
197 dsam->finish = finish;
201 int (*DSA_meth_get_paramgen(const DSA_METHOD *dsam))
202 (DSA *, int, const unsigned char *, int, int *, unsigned long *,
205 return dsam->dsa_paramgen;
208 int DSA_meth_set_paramgen(DSA_METHOD *dsam,
209 int (*paramgen) (DSA *, int, const unsigned char *, int, int *,
210 unsigned long *, BN_GENCB *))
212 dsam->dsa_paramgen = paramgen;
216 int (*DSA_meth_get_keygen(const DSA_METHOD *dsam)) (DSA *)
218 return dsam->dsa_keygen;
221 int DSA_meth_set_keygen(DSA_METHOD *dsam, int (*keygen) (DSA *))
223 dsam->dsa_keygen = keygen;