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 OPENSSL_free(dsam->name);
47 DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam)
51 ret = OPENSSL_malloc(sizeof(DSA_METHOD));
54 memcpy(ret, dsam, sizeof(*dsam));
55 ret->name = OPENSSL_strdup(dsam->name);
56 if (ret->name == NULL) {
58 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)
75 tmpname = OPENSSL_strdup(name);
76 if (tmpname == NULL) {
77 DSAerr(DSA_F_DSA_METH_SET1_NAME, ERR_R_MALLOC_FAILURE);
81 OPENSSL_free(dsam->name);
87 int DSA_meth_get_flags(DSA_METHOD *dsam)
92 int DSA_meth_set_flags(DSA_METHOD *dsam, int flags)
98 void *DSA_meth_get0_app_data(const DSA_METHOD *dsam)
100 return dsam->app_data;
103 int DSA_meth_set0_app_data(DSA_METHOD *dsam, void *app_data)
105 dsam->app_data = app_data;
109 DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam))
110 (const unsigned char *, int, DSA *)
112 return dsam->dsa_do_sign;
115 int DSA_meth_set_sign(DSA_METHOD *dsam,
116 DSA_SIG *(*sign) (const unsigned char *, int, DSA *))
118 dsam->dsa_do_sign = sign;
122 int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam))
123 (DSA *, BN_CTX *, BIGNUM **, BIGNUM **)
125 return dsam->dsa_sign_setup;
128 int DSA_meth_set_sign_setup(DSA_METHOD *dsam,
129 int (*sign_setup) (DSA *, BN_CTX *, BIGNUM **, BIGNUM **))
131 dsam->dsa_sign_setup = sign_setup;
135 int (*DSA_meth_get_verify(const DSA_METHOD *dsam))
136 (const unsigned char *, int , DSA_SIG *, DSA *)
138 return dsam->dsa_do_verify;
141 int DSA_meth_set_verify(DSA_METHOD *dsam,
142 int (*verify) (const unsigned char *, int, DSA_SIG *, DSA *))
144 dsam->dsa_do_verify = verify;
148 int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))
149 (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
150 const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *)
152 return dsam->dsa_mod_exp;
155 int DSA_meth_set_mod_exp(DSA_METHOD *dsam,
156 int (*mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
157 const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
160 dsam->dsa_mod_exp = mod_exp;
164 int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))
165 (DSA *, BIGNUM *, const 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 *, const 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;