]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/dsa/dsa_meth.c
Copyright consolidation 07/10
[thirdparty/openssl.git] / crypto / dsa / dsa_meth.c
CommitLineData
d2e9e320
RS
1/*
2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3 *
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
8 */
9
a517f7fc
MC
10/*
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.
6e9fa57c
MC
16 */
17
18#include "dsa_locl.h"
19#include <string.h>
20
21DSA_METHOD *DSA_meth_new(const char *name, int flags)
22{
23 DSA_METHOD *dsam = OPENSSL_zalloc(sizeof(DSA_METHOD));
24
25 if (dsam != NULL) {
26 dsam->name = OPENSSL_strdup(name);
27 dsam->flags = flags;
28 }
29
30 return dsam;
31}
32
33void DSA_meth_free(DSA_METHOD *dsam)
34{
35 if (dsam != NULL) {
36 if (dsam->name != NULL)
37 OPENSSL_free(dsam->name);
38 OPENSSL_free(dsam);
39 }
40}
41
a517f7fc 42DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam)
6e9fa57c
MC
43{
44 DSA_METHOD *ret;
45
46 ret = OPENSSL_malloc(sizeof(DSA_METHOD));
47
48 if (ret != NULL) {
a517f7fc
MC
49 memcpy(ret, dsam, sizeof(*dsam));
50 ret->name = OPENSSL_strdup(dsam->name);
6e9fa57c
MC
51 }
52
53 return ret;
54}
55
a517f7fc 56const char *DSA_meth_get0_name(const DSA_METHOD *dsam)
6e9fa57c
MC
57{
58 return dsam->name;
59}
60
a517f7fc 61int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name)
6e9fa57c
MC
62{
63 OPENSSL_free(dsam->name);
64 dsam->name = OPENSSL_strdup(name);
65
66 return dsam->name != NULL;
67}
68
69int DSA_meth_get_flags(DSA_METHOD *dsam)
70{
71 return dsam->flags;
72}
73
74int DSA_meth_set_flags(DSA_METHOD *dsam, int flags)
75{
76 dsam->flags = flags;
77 return 1;
78}
79
aa05e7ca 80void *DSA_meth_get0_app_data(const DSA_METHOD *dsam)
6e9fa57c
MC
81{
82 return dsam->app_data;
83}
84
aa05e7ca 85int DSA_meth_set0_app_data(DSA_METHOD *dsam, void *app_data)
6e9fa57c
MC
86{
87 dsam->app_data = app_data;
88 return 1;
89}
90
91DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam))
92 (const unsigned char *, int, DSA *)
93{
94 return dsam->dsa_do_sign;
95}
96
97int DSA_meth_set_sign(DSA_METHOD *dsam,
98 DSA_SIG *(*sign) (const unsigned char *, int, DSA *))
99{
100 dsam->dsa_do_sign = sign;
101 return 1;
102}
103
104int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam))
105 (DSA *, BN_CTX *, BIGNUM **, BIGNUM **)
106{
107 return dsam->dsa_sign_setup;
108}
109
110int DSA_meth_set_sign_setup(DSA_METHOD *dsam,
111 int (*sign_setup) (DSA *, BN_CTX *, BIGNUM **, BIGNUM **))
112{
113 dsam->dsa_sign_setup = sign_setup;
114 return 1;
115}
116
117int (*DSA_meth_get_verify(const DSA_METHOD *dsam))
118 (const unsigned char *, int , DSA_SIG *, DSA *)
119{
120 return dsam->dsa_do_verify;
121}
122
123int DSA_meth_set_verify(DSA_METHOD *dsam,
124 int (*verify) (const unsigned char *, int, DSA_SIG *, DSA *))
125{
126 dsam->dsa_do_verify = verify;
127 return 1;
128}
129
130int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))
131 (DSA *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *,
132 BN_CTX *, BN_MONT_CTX *)
133{
134 return dsam->dsa_mod_exp;
135}
136
137int DSA_meth_set_mod_exp(DSA_METHOD *dsam,
138 int (*mod_exp) (DSA *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *,
139 BIGNUM *, BN_CTX *, BN_MONT_CTX *))
140{
141 dsam->dsa_mod_exp = mod_exp;
142 return 1;
143}
144
145int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))
146 (DSA *, BIGNUM *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
147 BN_MONT_CTX *)
148{
149 return dsam->bn_mod_exp;
150}
151
152int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam,
153 int (*bn_mod_exp) (DSA *, BIGNUM *, BIGNUM *, const BIGNUM *,
154 const BIGNUM *, BN_CTX *, BN_MONT_CTX *))
155{
156 dsam->bn_mod_exp = bn_mod_exp;
157 return 1;
158}
159
160int (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *)
161{
162 return dsam->init;
163}
164
165int DSA_meth_set_init(DSA_METHOD *dsam, int (*init)(DSA *))
166{
167 dsam->init = init;
168 return 1;
169}
170
171int (*DSA_meth_get_finish(const DSA_METHOD *dsam)) (DSA *)
172{
173 return dsam->finish;
174}
175
176int DSA_meth_set_finish(DSA_METHOD *dsam, int (*finish) (DSA *))
177{
178 dsam->finish = finish;
179 return 1;
180}
181
182int (*DSA_meth_get_paramgen(const DSA_METHOD *dsam))
183 (DSA *, int, const unsigned char *, int, int *, unsigned long *,
184 BN_GENCB *)
185{
186 return dsam->dsa_paramgen;
187}
188
189int DSA_meth_set_paramgen(DSA_METHOD *dsam,
190 int (*paramgen) (DSA *, int, const unsigned char *, int, int *,
191 unsigned long *, BN_GENCB *))
192{
193 dsam->dsa_paramgen = paramgen;
194 return 1;
195}
196
197int (*DSA_meth_get_keygen(const DSA_METHOD *dsam)) (DSA *)
198{
199 return dsam->dsa_keygen;
200}
201
202int DSA_meth_set_keygen(DSA_METHOD *dsam, int (*keygen) (DSA *))
203{
204 dsam->dsa_keygen = keygen;
205 return 1;
206}