VirtualBox

source: vbox/trunk/src/libs/openssl-1.1.1l/crypto/dsa/dsa_meth.c@ 91772

Last change on this file since 91772 was 91772, checked in by vboxsync, 3 years ago

openssl-1.1.1l: Applied and adjusted our OpenSSL changes to 1.1.1l. bugref:10126

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

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