2 * Copyright 2016-2018 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(*dsam));
29 dsam->name = OPENSSL_strdup(name);
30 if (dsam->name != NULL)
36 DSAerr(DSA_F_DSA_METH_NEW, ERR_R_MALLOC_FAILURE);
40 void DSA_meth_free(DSA_METHOD *dsam)
43 OPENSSL_free(dsam->name);
48 DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam)
50 DSA_METHOD *ret = OPENSSL_malloc(sizeof(*ret));
53 memcpy(ret, dsam, sizeof(*dsam));
55 ret->name = OPENSSL_strdup(dsam->name);
56 if (ret->name != NULL)
62 DSAerr(DSA_F_DSA_METH_DUP, ERR_R_MALLOC_FAILURE);
66 const char *DSA_meth_get0_name(const DSA_METHOD *dsam)
71 int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name)
73 char *tmpname = OPENSSL_strdup(name);
75 if (tmpname == NULL) {
76 DSAerr(DSA_F_DSA_METH_SET1_NAME, ERR_R_MALLOC_FAILURE);
80 OPENSSL_free(dsam->name);
86 int DSA_meth_get_flags(const DSA_METHOD *dsam)
91 int DSA_meth_set_flags(DSA_METHOD *dsam, int flags)
97 void *DSA_meth_get0_app_data(const DSA_METHOD *dsam)
99 return dsam->app_data;
102 int DSA_meth_set0_app_data(DSA_METHOD *dsam, void *app_data)
104 dsam->app_data = app_data;
108 DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam))
109 (const unsigned char *, int, DSA *)
111 return dsam->dsa_do_sign;
114 int DSA_meth_set_sign(DSA_METHOD *dsam,
115 DSA_SIG *(*sign) (const unsigned char *, int, DSA *))
117 dsam->dsa_do_sign = sign;
121 int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam))
122 (DSA *, BN_CTX *, BIGNUM **, BIGNUM **)
124 return dsam->dsa_sign_setup;
127 int DSA_meth_set_sign_setup(DSA_METHOD *dsam,
128 int (*sign_setup) (DSA *, BN_CTX *, BIGNUM **, BIGNUM **))
130 dsam->dsa_sign_setup = sign_setup;
134 int (*DSA_meth_get_verify(const DSA_METHOD *dsam))
135 (const unsigned char *, int, DSA_SIG *, DSA *)
137 return dsam->dsa_do_verify;
140 int DSA_meth_set_verify(DSA_METHOD *dsam,
141 int (*verify) (const unsigned char *, int, DSA_SIG *, DSA *))
143 dsam->dsa_do_verify = verify;
147 int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))
148 (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
149 const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *)
151 return dsam->dsa_mod_exp;
154 int DSA_meth_set_mod_exp(DSA_METHOD *dsam,
155 int (*mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
156 const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
159 dsam->dsa_mod_exp = mod_exp;
163 int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))
164 (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
167 return dsam->bn_mod_exp;
170 int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam,
171 int (*bn_mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
172 const BIGNUM *, BN_CTX *, BN_MONT_CTX *))
174 dsam->bn_mod_exp = bn_mod_exp;
178 int (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *)
183 int DSA_meth_set_init(DSA_METHOD *dsam, int (*init)(DSA *))
189 int (*DSA_meth_get_finish(const DSA_METHOD *dsam)) (DSA *)
194 int DSA_meth_set_finish(DSA_METHOD *dsam, int (*finish) (DSA *))
196 dsam->finish = finish;
200 int (*DSA_meth_get_paramgen(const DSA_METHOD *dsam))
201 (DSA *, int, const unsigned char *, int, int *, unsigned long *,
204 return dsam->dsa_paramgen;
207 int DSA_meth_set_paramgen(DSA_METHOD *dsam,
208 int (*paramgen) (DSA *, int, const unsigned char *, int, int *,
209 unsigned long *, BN_GENCB *))
211 dsam->dsa_paramgen = paramgen;
215 int (*DSA_meth_get_keygen(const DSA_METHOD *dsam)) (DSA *)
217 return dsam->dsa_keygen;
220 int DSA_meth_set_keygen(DSA_METHOD *dsam, int (*keygen) (DSA *))
222 dsam->dsa_keygen = keygen;