VirtualBox

source: vbox/trunk/src/libs/openssl-3.3.2/crypto/dsa/dsa_meth.c@ 108550

Last change on this file since 108550 was 108206, checked in by vboxsync, 3 months ago

openssl-3.3.2: Exported all files to OSE and removed .scm-settings ​bugref:10757

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/*
2 * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (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
10/*
11 * DSA low level APIs are deprecated for public use, but still ok for
12 * internal use.
13 */
14#include "internal/deprecated.h"
15
16#include "dsa_local.h"
17#include <string.h>
18#include <openssl/err.h>
19
20#ifndef OPENSSL_NO_DEPRECATED_3_0
21DSA_METHOD *DSA_meth_new(const char *name, int flags)
22{
23 DSA_METHOD *dsam = OPENSSL_zalloc(sizeof(*dsam));
24
25 if (dsam != NULL) {
26 dsam->flags = flags;
27
28 dsam->name = OPENSSL_strdup(name);
29 if (dsam->name != NULL)
30 return dsam;
31
32 OPENSSL_free(dsam);
33 }
34
35 return NULL;
36}
37
38void DSA_meth_free(DSA_METHOD *dsam)
39{
40 if (dsam != NULL) {
41 OPENSSL_free(dsam->name);
42 OPENSSL_free(dsam);
43 }
44}
45
46DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam)
47{
48 DSA_METHOD *ret = OPENSSL_malloc(sizeof(*ret));
49
50 if (ret != NULL) {
51 memcpy(ret, dsam, sizeof(*dsam));
52
53 ret->name = OPENSSL_strdup(dsam->name);
54 if (ret->name != NULL)
55 return ret;
56
57 OPENSSL_free(ret);
58 }
59
60 return NULL;
61}
62
63const char *DSA_meth_get0_name(const DSA_METHOD *dsam)
64{
65 return dsam->name;
66}
67
68int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name)
69{
70 char *tmpname = OPENSSL_strdup(name);
71
72 if (tmpname == NULL)
73 return 0;
74
75 OPENSSL_free(dsam->name);
76 dsam->name = tmpname;
77
78 return 1;
79}
80
81int DSA_meth_get_flags(const DSA_METHOD *dsam)
82{
83 return dsam->flags;
84}
85
86int DSA_meth_set_flags(DSA_METHOD *dsam, int flags)
87{
88 dsam->flags = flags;
89 return 1;
90}
91
92void *DSA_meth_get0_app_data(const DSA_METHOD *dsam)
93{
94 return dsam->app_data;
95}
96
97int DSA_meth_set0_app_data(DSA_METHOD *dsam, void *app_data)
98{
99 dsam->app_data = app_data;
100 return 1;
101}
102
103DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam))
104 (const unsigned char *, int, DSA *)
105{
106 return dsam->dsa_do_sign;
107}
108
109int DSA_meth_set_sign(DSA_METHOD *dsam,
110 DSA_SIG *(*sign) (const unsigned char *, int, DSA *))
111{
112 dsam->dsa_do_sign = sign;
113 return 1;
114}
115
116int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam))
117 (DSA *, BN_CTX *, BIGNUM **, BIGNUM **)
118{
119 return dsam->dsa_sign_setup;
120}
121
122int DSA_meth_set_sign_setup(DSA_METHOD *dsam,
123 int (*sign_setup) (DSA *, BN_CTX *, BIGNUM **, BIGNUM **))
124{
125 dsam->dsa_sign_setup = sign_setup;
126 return 1;
127}
128
129int (*DSA_meth_get_verify(const DSA_METHOD *dsam))
130 (const unsigned char *, int, DSA_SIG *, DSA *)
131{
132 return dsam->dsa_do_verify;
133}
134
135int DSA_meth_set_verify(DSA_METHOD *dsam,
136 int (*verify) (const unsigned char *, int, DSA_SIG *, DSA *))
137{
138 dsam->dsa_do_verify = verify;
139 return 1;
140}
141
142int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))
143 (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *,
144 const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *)
145{
146 return dsam->dsa_mod_exp;
147}
148
149int DSA_meth_set_mod_exp(DSA_METHOD *dsam,
150 int (*mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
151 const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
152 BN_MONT_CTX *))
153{
154 dsam->dsa_mod_exp = mod_exp;
155 return 1;
156}
157
158int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))
159 (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *,
160 BN_MONT_CTX *)
161{
162 return dsam->bn_mod_exp;
163}
164
165int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam,
166 int (*bn_mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *,
167 const BIGNUM *, BN_CTX *, BN_MONT_CTX *))
168{
169 dsam->bn_mod_exp = bn_mod_exp;
170 return 1;
171}
172
173int (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *)
174{
175 return dsam->init;
176}
177
178int DSA_meth_set_init(DSA_METHOD *dsam, int (*init)(DSA *))
179{
180 dsam->init = init;
181 return 1;
182}
183
184int (*DSA_meth_get_finish(const DSA_METHOD *dsam)) (DSA *)
185{
186 return dsam->finish;
187}
188
189int DSA_meth_set_finish(DSA_METHOD *dsam, int (*finish) (DSA *))
190{
191 dsam->finish = finish;
192 return 1;
193}
194
195int (*DSA_meth_get_paramgen(const DSA_METHOD *dsam))
196 (DSA *, int, const unsigned char *, int, int *, unsigned long *,
197 BN_GENCB *)
198{
199 return dsam->dsa_paramgen;
200}
201
202int DSA_meth_set_paramgen(DSA_METHOD *dsam,
203 int (*paramgen) (DSA *, int, const unsigned char *, int, int *,
204 unsigned long *, BN_GENCB *))
205{
206 dsam->dsa_paramgen = paramgen;
207 return 1;
208}
209
210int (*DSA_meth_get_keygen(const DSA_METHOD *dsam)) (DSA *)
211{
212 return dsam->dsa_keygen;
213}
214
215int DSA_meth_set_keygen(DSA_METHOD *dsam, int (*keygen) (DSA *))
216{
217 dsam->dsa_keygen = keygen;
218 return 1;
219}
220#endif
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette