xref: /freebsd/crypto/openssl/doc/man3/DSA_meth_new.pod (revision a7148ab39c03abd4d1a84997c70bf96f15dd2a09)
1e71b7053SJung-uk Kim=pod
2e71b7053SJung-uk Kim
3e71b7053SJung-uk Kim=head1 NAME
4e71b7053SJung-uk Kim
5e71b7053SJung-uk KimDSA_meth_new, DSA_meth_free, DSA_meth_dup, DSA_meth_get0_name,
6e71b7053SJung-uk KimDSA_meth_set1_name, DSA_meth_get_flags, DSA_meth_set_flags,
7e71b7053SJung-uk KimDSA_meth_get0_app_data, DSA_meth_set0_app_data, DSA_meth_get_sign,
8e71b7053SJung-uk KimDSA_meth_set_sign, DSA_meth_get_sign_setup, DSA_meth_set_sign_setup,
9e71b7053SJung-uk KimDSA_meth_get_verify, DSA_meth_set_verify, DSA_meth_get_mod_exp,
10e71b7053SJung-uk KimDSA_meth_set_mod_exp, DSA_meth_get_bn_mod_exp, DSA_meth_set_bn_mod_exp,
11e71b7053SJung-uk KimDSA_meth_get_init, DSA_meth_set_init, DSA_meth_get_finish, DSA_meth_set_finish,
12e71b7053SJung-uk KimDSA_meth_get_paramgen, DSA_meth_set_paramgen, DSA_meth_get_keygen,
13e71b7053SJung-uk KimDSA_meth_set_keygen - Routines to build up DSA methods
14e71b7053SJung-uk Kim
15e71b7053SJung-uk Kim=head1 SYNOPSIS
16e71b7053SJung-uk Kim
17e71b7053SJung-uk Kim #include <openssl/dsa.h>
18e71b7053SJung-uk Kim
19b077aed3SPierre ProncheryThe following functions have been deprecated since OpenSSL 3.0, and can be
20b077aed3SPierre Proncheryhidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value,
21b077aed3SPierre Proncherysee L<openssl_user_macros(7)>:
22b077aed3SPierre Pronchery
23e71b7053SJung-uk Kim DSA_METHOD *DSA_meth_new(const char *name, int flags);
24e71b7053SJung-uk Kim
25e71b7053SJung-uk Kim void DSA_meth_free(DSA_METHOD *dsam);
26e71b7053SJung-uk Kim
27e71b7053SJung-uk Kim DSA_METHOD *DSA_meth_dup(const DSA_METHOD *meth);
28e71b7053SJung-uk Kim
29e71b7053SJung-uk Kim const char *DSA_meth_get0_name(const DSA_METHOD *dsam);
30e71b7053SJung-uk Kim int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name);
31e71b7053SJung-uk Kim
32e71b7053SJung-uk Kim int DSA_meth_get_flags(const DSA_METHOD *dsam);
33e71b7053SJung-uk Kim int DSA_meth_set_flags(DSA_METHOD *dsam, int flags);
34e71b7053SJung-uk Kim
35e71b7053SJung-uk Kim void *DSA_meth_get0_app_data(const DSA_METHOD *dsam);
36e71b7053SJung-uk Kim int DSA_meth_set0_app_data(DSA_METHOD *dsam, void *app_data);
37e71b7053SJung-uk Kim
38e71b7053SJung-uk Kim DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam))(const unsigned char *,
39e71b7053SJung-uk Kim                                                       int, DSA *);
40e71b7053SJung-uk Kim int DSA_meth_set_sign(DSA_METHOD *dsam, DSA_SIG *(*sign)(const unsigned char *,
41e71b7053SJung-uk Kim                                                          int, DSA *));
42e71b7053SJung-uk Kim
43e71b7053SJung-uk Kim int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam))(DSA *, BN_CTX *,$
44e71b7053SJung-uk Kim                                                        BIGNUM **, BIGNUM **);
45e71b7053SJung-uk Kim int DSA_meth_set_sign_setup(DSA_METHOD *dsam, int (*sign_setup)(DSA *, BN_CTX *,
46e71b7053SJung-uk Kim                                                                 BIGNUM **, BIGNUM **));
47e71b7053SJung-uk Kim
48e71b7053SJung-uk Kim int (*DSA_meth_get_verify(const DSA_METHOD *dsam))(const unsigned char *,
49e71b7053SJung-uk Kim                                                    int, DSA_SIG *, DSA *);
50e71b7053SJung-uk Kim int DSA_meth_set_verify(DSA_METHOD *dsam, int (*verify)(const unsigned char *,
51e71b7053SJung-uk Kim                                                         int, DSA_SIG *, DSA *));
52e71b7053SJung-uk Kim
53e71b7053SJung-uk Kim int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam))(DSA *dsa, BIGNUM *rr, BIGNUM *a1,
54e71b7053SJung-uk Kim                                                     BIGNUM *p1, BIGNUM *a2, BIGNUM *p2,
55e71b7053SJung-uk Kim                                                     BIGNUM *m, BN_CTX *ctx,
56e71b7053SJung-uk Kim                                                     BN_MONT_CTX *in_mont);
57e71b7053SJung-uk Kim int DSA_meth_set_mod_exp(DSA_METHOD *dsam, int (*mod_exp)(DSA *dsa, BIGNUM *rr,
58e71b7053SJung-uk Kim                                                           BIGNUM *a1, BIGNUM *p1,
59e71b7053SJung-uk Kim                                                           BIGNUM *a2, BIGNUM *p2,
60e71b7053SJung-uk Kim                                                           BIGNUM *m, BN_CTX *ctx,
61e71b7053SJung-uk Kim                                                           BN_MONT_CTX *mont));
62e71b7053SJung-uk Kim
63e71b7053SJung-uk Kim int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam))(DSA *dsa, BIGNUM *r, BIGNUM *a,
64e71b7053SJung-uk Kim                                                        const BIGNUM *p, const BIGNUM *m,
65e71b7053SJung-uk Kim                                                        BN_CTX *ctx, BN_MONT_CTX *mont);
66e71b7053SJung-uk Kim int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam, int (*bn_mod_exp)(DSA *dsa,
67e71b7053SJung-uk Kim                                                                 BIGNUM *r,
68e71b7053SJung-uk Kim                                                                 BIGNUM *a,
69e71b7053SJung-uk Kim                                                                 const BIGNUM *p,
70e71b7053SJung-uk Kim                                                                 const BIGNUM *m,
71e71b7053SJung-uk Kim                                                                 BN_CTX *ctx,
72e71b7053SJung-uk Kim                                                                 BN_MONT_CTX *mont));
73e71b7053SJung-uk Kim
74e71b7053SJung-uk Kim int (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *);
75e71b7053SJung-uk Kim int DSA_meth_set_init(DSA_METHOD *dsam, int (*init)(DSA *));
76e71b7053SJung-uk Kim
77e71b7053SJung-uk Kim int (*DSA_meth_get_finish(const DSA_METHOD *dsam))(DSA *);
78e71b7053SJung-uk Kim int DSA_meth_set_finish(DSA_METHOD *dsam, int (*finish)(DSA *));
79e71b7053SJung-uk Kim
80e71b7053SJung-uk Kim int (*DSA_meth_get_paramgen(const DSA_METHOD *dsam))(DSA *, int,
81e71b7053SJung-uk Kim                                                      const unsigned char *,
82e71b7053SJung-uk Kim                                                      int, int *, unsigned long *,
83e71b7053SJung-uk Kim                                                      BN_GENCB *);
84e71b7053SJung-uk Kim int DSA_meth_set_paramgen(DSA_METHOD *dsam,
85e71b7053SJung-uk Kim                           int (*paramgen)(DSA *, int, const unsigned char *,
86e71b7053SJung-uk Kim                                           int, int *, unsigned long *, BN_GENCB *));
87e71b7053SJung-uk Kim
88e71b7053SJung-uk Kim int (*DSA_meth_get_keygen(const DSA_METHOD *dsam))(DSA *);
89e71b7053SJung-uk Kim int DSA_meth_set_keygen(DSA_METHOD *dsam, int (*keygen)(DSA *));
90e71b7053SJung-uk Kim
91e71b7053SJung-uk Kim=head1 DESCRIPTION
92e71b7053SJung-uk Kim
93b077aed3SPierre ProncheryAll of the functions described on this page are deprecated.
94b077aed3SPierre ProncheryApplications and extension implementations should instead use the
95b077aed3SPierre ProncheryOSSL_PROVIDER APIs.
96b077aed3SPierre Pronchery
97e71b7053SJung-uk KimThe B<DSA_METHOD> type is a structure used for the provision of custom DSA
98e71b7053SJung-uk Kimimplementations. It provides a set of functions used by OpenSSL for the
99b077aed3SPierre Proncheryimplementation of the various DSA capabilities.
100e71b7053SJung-uk Kim
101e71b7053SJung-uk KimDSA_meth_new() creates a new B<DSA_METHOD> structure. It should be given a
102e71b7053SJung-uk Kimunique B<name> and a set of B<flags>. The B<name> should be a NULL terminated
103e71b7053SJung-uk Kimstring, which will be duplicated and stored in the B<DSA_METHOD> object. It is
104e71b7053SJung-uk Kimthe callers responsibility to free the original string. The flags will be used
105e71b7053SJung-uk Kimduring the construction of a new B<DSA> object based on this B<DSA_METHOD>. Any
106e71b7053SJung-uk Kimnew B<DSA> object will have those flags set by default.
107e71b7053SJung-uk Kim
108e71b7053SJung-uk KimDSA_meth_dup() creates a duplicate copy of the B<DSA_METHOD> object passed as a
109e71b7053SJung-uk Kimparameter. This might be useful for creating a new B<DSA_METHOD> based on an
110e71b7053SJung-uk Kimexisting one, but with some differences.
111e71b7053SJung-uk Kim
112e71b7053SJung-uk KimDSA_meth_free() destroys a B<DSA_METHOD> structure and frees up any memory
113*a7148ab3SEnji Cooperassociated with it. If the argument is NULL, nothing is done.
114e71b7053SJung-uk Kim
115e71b7053SJung-uk KimDSA_meth_get0_name() will return a pointer to the name of this DSA_METHOD. This
116e71b7053SJung-uk Kimis a pointer to the internal name string and so should not be freed by the
117e71b7053SJung-uk Kimcaller. DSA_meth_set1_name() sets the name of the DSA_METHOD to B<name>. The
118e71b7053SJung-uk Kimstring is duplicated and the copy is stored in the DSA_METHOD structure, so the
119e71b7053SJung-uk Kimcaller remains responsible for freeing the memory associated with the name.
120e71b7053SJung-uk Kim
121e71b7053SJung-uk KimDSA_meth_get_flags() returns the current value of the flags associated with this
122e71b7053SJung-uk KimDSA_METHOD. DSA_meth_set_flags() provides the ability to set these flags.
123e71b7053SJung-uk Kim
124e71b7053SJung-uk KimThe functions DSA_meth_get0_app_data() and DSA_meth_set0_app_data() provide the
125e71b7053SJung-uk Kimability to associate implementation specific data with the DSA_METHOD. It is
126e71b7053SJung-uk Kimthe application's responsibility to free this data before the DSA_METHOD is
127e71b7053SJung-uk Kimfreed via a call to DSA_meth_free().
128e71b7053SJung-uk Kim
129e71b7053SJung-uk KimDSA_meth_get_sign() and DSA_meth_set_sign() get and set the function used for
130e71b7053SJung-uk Kimcreating a DSA signature respectively. This function will be
131e71b7053SJung-uk Kimcalled in response to the application calling DSA_do_sign() (or DSA_sign()). The
132e71b7053SJung-uk Kimparameters for the function have the same meaning as for DSA_do_sign().
133e71b7053SJung-uk Kim
134e71b7053SJung-uk KimDSA_meth_get_sign_setup() and DSA_meth_set_sign_setup() get and set the function
135e71b7053SJung-uk Kimused for precalculating the DSA signature values B<k^-1> and B<r>. This function
136e71b7053SJung-uk Kimwill be called in response to the application calling DSA_sign_setup(). The
137e71b7053SJung-uk Kimparameters for the function have the same meaning as for DSA_sign_setup().
138e71b7053SJung-uk Kim
139e71b7053SJung-uk KimDSA_meth_get_verify() and DSA_meth_set_verify() get and set the function used
140e71b7053SJung-uk Kimfor verifying a DSA signature respectively. This function will be called in
141e71b7053SJung-uk Kimresponse to the application calling DSA_do_verify() (or DSA_verify()). The
142e71b7053SJung-uk Kimparameters for the function have the same meaning as for DSA_do_verify().
143e71b7053SJung-uk Kim
144e71b7053SJung-uk KimDSA_meth_get_mod_exp() and DSA_meth_set_mod_exp() get and set the function used
145e71b7053SJung-uk Kimfor computing the following value:
146e71b7053SJung-uk Kim
147e71b7053SJung-uk Kim rr = a1^p1 * a2^p2 mod m
148e71b7053SJung-uk Kim
149e71b7053SJung-uk KimThis function will be called by the default OpenSSL method during verification
150e71b7053SJung-uk Kimof a DSA signature. The result is stored in the B<rr> parameter. This function
151e71b7053SJung-uk Kimmay be NULL.
152e71b7053SJung-uk Kim
153e71b7053SJung-uk KimDSA_meth_get_bn_mod_exp() and DSA_meth_set_bn_mod_exp() get and set the function
154e71b7053SJung-uk Kimused for computing the following value:
155e71b7053SJung-uk Kim
156e71b7053SJung-uk Kim r = a ^ p mod m
157e71b7053SJung-uk Kim
158e71b7053SJung-uk KimThis function will be called by the default OpenSSL function for
159e71b7053SJung-uk KimDSA_sign_setup(). The result is stored in the B<r> parameter. This function
160e71b7053SJung-uk Kimmay be NULL.
161e71b7053SJung-uk Kim
162e71b7053SJung-uk KimDSA_meth_get_init() and DSA_meth_set_init() get and set the function used
163e71b7053SJung-uk Kimfor creating a new DSA instance respectively. This function will be
164e71b7053SJung-uk Kimcalled in response to the application calling DSA_new() (if the current default
165e71b7053SJung-uk KimDSA_METHOD is this one) or DSA_new_method(). The DSA_new() and DSA_new_method()
166e71b7053SJung-uk Kimfunctions will allocate the memory for the new DSA object, and a pointer to this
167e71b7053SJung-uk Kimnewly allocated structure will be passed as a parameter to the function. This
168e71b7053SJung-uk Kimfunction may be NULL.
169e71b7053SJung-uk Kim
170e71b7053SJung-uk KimDSA_meth_get_finish() and DSA_meth_set_finish() get and set the function used
171e71b7053SJung-uk Kimfor destroying an instance of a DSA object respectively. This function will be
172e71b7053SJung-uk Kimcalled in response to the application calling DSA_free(). A pointer to the DSA
173e71b7053SJung-uk Kimto be destroyed is passed as a parameter. The destroy function should be used
174e71b7053SJung-uk Kimfor DSA implementation specific clean up. The memory for the DSA itself should
175e71b7053SJung-uk Kimnot be freed by this function. This function may be NULL.
176e71b7053SJung-uk Kim
177e71b7053SJung-uk KimDSA_meth_get_paramgen() and DSA_meth_set_paramgen() get and set the function
178e71b7053SJung-uk Kimused for generating DSA parameters respectively. This function will be called in
179e71b7053SJung-uk Kimresponse to the application calling DSA_generate_parameters_ex() (or
180e71b7053SJung-uk KimDSA_generate_parameters()). The parameters for the function have the same
181e71b7053SJung-uk Kimmeaning as for DSA_generate_parameters_ex().
182e71b7053SJung-uk Kim
183e71b7053SJung-uk KimDSA_meth_get_keygen() and DSA_meth_set_keygen() get and set the function
184e71b7053SJung-uk Kimused for generating a new DSA key pair respectively. This function will be
185e71b7053SJung-uk Kimcalled in response to the application calling DSA_generate_key(). The parameter
186e71b7053SJung-uk Kimfor the function has the same meaning as for DSA_generate_key().
187e71b7053SJung-uk Kim
188e71b7053SJung-uk Kim=head1 RETURN VALUES
189e71b7053SJung-uk Kim
190e71b7053SJung-uk KimDSA_meth_new() and DSA_meth_dup() return the newly allocated DSA_METHOD object
191e71b7053SJung-uk Kimor NULL on failure.
192e71b7053SJung-uk Kim
193e71b7053SJung-uk KimDSA_meth_get0_name() and DSA_meth_get_flags() return the name and flags
194e71b7053SJung-uk Kimassociated with the DSA_METHOD respectively.
195e71b7053SJung-uk Kim
196e71b7053SJung-uk KimAll other DSA_meth_get_*() functions return the appropriate function pointer
197e71b7053SJung-uk Kimthat has been set in the DSA_METHOD, or NULL if no such pointer has yet been
198e71b7053SJung-uk Kimset.
199e71b7053SJung-uk Kim
200e71b7053SJung-uk KimDSA_meth_set1_name() and all DSA_meth_set_*() functions return 1 on success or
201e71b7053SJung-uk Kim0 on failure.
202e71b7053SJung-uk Kim
203e71b7053SJung-uk Kim=head1 SEE ALSO
204e71b7053SJung-uk Kim
205e71b7053SJung-uk KimL<DSA_new(3)>, L<DSA_new(3)>, L<DSA_generate_parameters(3)>, L<DSA_generate_key(3)>,
206e71b7053SJung-uk KimL<DSA_dup_DH(3)>, L<DSA_do_sign(3)>, L<DSA_set_method(3)>, L<DSA_SIG_new(3)>,
207e71b7053SJung-uk KimL<DSA_sign(3)>, L<DSA_size(3)>, L<DSA_get0_pqg(3)>
208e71b7053SJung-uk Kim
209e71b7053SJung-uk Kim=head1 HISTORY
210e71b7053SJung-uk Kim
211b077aed3SPierre ProncheryThe functions described here were deprecated in OpenSSL 3.0.
212b077aed3SPierre Pronchery
213e71b7053SJung-uk KimThe functions described here were added in OpenSSL 1.1.0.
214e71b7053SJung-uk Kim
215e71b7053SJung-uk Kim=head1 COPYRIGHT
216e71b7053SJung-uk Kim
217*a7148ab3SEnji CooperCopyright 2016-2024 The OpenSSL Project Authors. All Rights Reserved.
218e71b7053SJung-uk Kim
219b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
220e71b7053SJung-uk Kimthis file except in compliance with the License.  You can obtain a copy
221e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at
222e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>.
223e71b7053SJung-uk Kim
224e71b7053SJung-uk Kim=cut
225