jcs's openbsd hax
openbsd
1.\" $OpenBSD: DSA_set_method.3,v 1.13 2025/06/08 22:40:29 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2002, 2007 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 8 2025 $
52.Dt DSA_SET_METHOD 3
53.Os
54.Sh NAME
55.Nm DSA_set_default_method ,
56.Nm DSA_get_default_method ,
57.Nm DSA_set_method ,
58.Nm DSA_new_method ,
59.Nm DSA_OpenSSL
60.Nd select DSA method
61.Sh SYNOPSIS
62.Lb libcrypto
63.In openssl/dsa.h
64.Ft void
65.Fo DSA_set_default_method
66.Fa "const DSA_METHOD *meth"
67.Fc
68.Ft const DSA_METHOD *
69.Fn DSA_get_default_method void
70.Ft int
71.Fo DSA_set_method
72.Fa "DSA *dsa"
73.Fa "const DSA_METHOD *meth"
74.Fc
75.Ft DSA *
76.Fo DSA_new_method
77.Fa "ENGINE *engine"
78.Fc
79.Ft DSA_METHOD *
80.Fn DSA_OpenSSL void
81.Sh DESCRIPTION
82A
83.Vt DSA_METHOD
84object contains pointers to the functions used for DSA operations.
85By default, the internal implementation returned by
86.Fn DSA_OpenSSL
87is used.
88By selecting another method, alternative implementations
89such as hardware accelerators may be used.
90.Pp
91.Fn DSA_set_default_method
92selects
93.Fa meth
94as the default method for all
95.Vt DSA
96structures created later.
97.Pp
98.Fn DSA_get_default_method
99returns a pointer to the current default method.
100.Pp
101.Fn DSA_set_method
102selects
103.Fa meth
104to perform all operations using the key
105.Fa dsa .
106This replaces the
107.Vt DSA_METHOD
108used by the DSA key.
109It is possible to have DSA keys that only work with certain
110.Vt DSA_METHOD
111implementations,
112and in such cases attempting to change the
113.Vt DSA_METHOD
114for the key can have unexpected results.
115.Pp
116.Fn DSA_new_method
117allocates and initializes a
118.Vt DSA
119structure.
120The
121.Fa engine
122argument is ignored and
123the default method controlled by
124.Fn DSA_set_default_method
125is used.
126.Pp
127The
128.Vt DSA_METHOD
129structure is defined as follows:
130.Bd -literal
131struct {
132 /* name of the implementation */
133 const char *name;
134 /* sign */
135 DSA_SIG *(*dsa_do_sign)(const unsigned char *dgst, int dlen,
136 DSA *dsa);
137 /* pre-compute k^-1 and r */
138 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
139 BIGNUM **rp);
140 /* verify */
141 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
142 DSA_SIG *sig, DSA *dsa);
143 /* called at DSA_new */
144 int (*init)(DSA *DSA);
145 /* called at DSA_free */
146 int (*finish)(DSA *DSA);
147 int flags;
148} DSA_METHOD;
149.Ed
150.Sh RETURN VALUES
151.Fn DSA_OpenSSL
152and
153.Fn DSA_get_default_method
154return pointers to the respective
155.Vt DSA_METHOD .
156.Pp
157.Fn DSA_set_method
158returns 1 on success or 0 on failure.
159Currently, it cannot fail.
160.Pp
161.Fn DSA_new_method
162returns
163.Dv NULL
164and sets an error code that can be obtained by
165.Xr ERR_get_error 3
166if the allocation fails.
167Otherwise it returns a pointer to the newly allocated structure.
168.Sh SEE ALSO
169.Xr DSA_meth_new 3 ,
170.Xr DSA_new 3
171.Sh HISTORY
172.Fn DSA_set_default_method ,
173.Fn DSA_get_default_method ,
174.Fn DSA_set_method ,
175.Fn DSA_new_method ,
176and
177.Fn DSA_OpenSSL
178first appeared in OpenSSL 0.9.5 and have been available since
179.Ox 2.7 .