5 DSA_set_default_method, DSA_get_default_method,
6 DSA_set_method, DSA_new_method, DSA_OpenSSL - select DSA method
10 #include <openssl/dsa.h>
12 void DSA_set_default_method(const DSA_METHOD *meth);
14 const DSA_METHOD *DSA_get_default_method(void);
16 int DSA_set_method(DSA *dsa, const DSA_METHOD *meth);
18 DSA *DSA_new_method(DSA_METHOD *meth);
20 DSA_METHOD *DSA_OpenSSL(void);
24 A B<DSA_METHOD> specifies the functions that OpenSSL uses for DSA
25 operations. By modifying the method, alternative implementations
26 such as hardware accelerators may be used. IMPORTANT: See the NOTES section for
27 important information about how these DSA API functions are affected by the use
28 of B<ENGINE> API calls.
30 Initially, the default DSA_METHOD is the OpenSSL internal implementation,
31 as returned by DSA_OpenSSL().
33 DSA_set_default_method() makes B<meth> the default method for all DSA
34 structures created later. B<NB>: This is true only whilst no ENGINE has
35 been set as a default for DSA, so this function is no longer recommended.
37 DSA_get_default_method() returns a pointer to the current default
38 DSA_METHOD. However, the meaningfulness of this result is dependant on
39 whether the ENGINE API is being used, so this function is no longer
42 DSA_set_method() selects B<meth> to perform all operations using the key
43 B<rsa>. This will replace the DSA_METHOD used by the DSA key and if the
44 previous method was supplied by an ENGINE, the handle to that ENGINE will
45 be released during the change. It is possible to have DSA keys that only
46 work with certain DSA_METHOD implementations (eg. from an ENGINE module
47 that supports embedded hardware-protected keys), and in such cases
48 attempting to change the DSA_METHOD for the key can have unexpected
51 DSA_new_method() allocates and initializes a DSA structure so that B<engine>
52 will be used for the DSA operations. If B<engine> is NULL, the default engine
53 for DSA operations is used, and if no default ENGINE is set, the DSA_METHOD
54 controlled by DSA_set_default_method() is used.
56 =head1 THE DSA_METHOD STRUCTURE
60 /* name of the implementation */
64 DSA_SIG *(*dsa_do_sign)(const unsigned char *dgst, int dlen,
67 /* pre-compute k^-1 and r */
68 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
72 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
73 DSA_SIG *sig, DSA *dsa);
75 /* compute rr = a1^p1 * a2^p2 mod m (May be NULL for some
77 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
78 BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
79 BN_CTX *ctx, BN_MONT_CTX *in_mont);
81 /* compute r = a ^ p mod m (May be NULL for some implementations) */
82 int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a,
83 const BIGNUM *p, const BIGNUM *m,
84 BN_CTX *ctx, BN_MONT_CTX *m_ctx);
86 /* called at DSA_new */
87 int (*init)(DSA *DSA);
89 /* called at DSA_free */
90 int (*finish)(DSA *DSA);
94 char *app_data; /* ?? */
100 DSA_OpenSSL() and DSA_get_default_method() return pointers to the respective
103 DSA_set_default_method() returns no value.
105 DSA_set_method() returns non-zero if the provided B<meth> was successfully set as
106 the method for B<dsa> (including unloading the ENGINE handle if the previous
107 method was supplied by an ENGINE).
109 DSA_new_method() returns NULL and sets an error code that can be
110 obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation
111 fails. Otherwise it returns a pointer to the newly allocated structure.
115 As of version 0.9.7, DSA_METHOD implementations are grouped together with other
116 algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B<ENGINE> modules. If a
117 default ENGINE is specified for DSA functionality using an ENGINE API function,
118 that will override any DSA defaults set using the DSA API (ie.
119 DSA_set_default_method()). For this reason, the ENGINE API is the recommended way
120 to control default implementations for use in DSA and other cryptographic
125 L<dsa(3)|dsa(3)>, L<DSA_new(3)|DSA_new(3)>
129 DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(),
130 DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4.
132 DSA_set_default_openssl_method() and DSA_get_default_openssl_method() replaced
133 DSA_set_default_method() and DSA_get_default_method() respectively, and
134 DSA_set_method() and DSA_new_method() were altered to use B<ENGINE>s rather than
135 B<DSA_METHOD>s during development of the engine version of OpenSSL 0.9.6. For
136 0.9.7, the handling of defaults in the ENGINE API was restructured so that this
137 change was reversed, and behaviour of the other functions resembled more closely
138 the previous behaviour. The behaviour of defaults in the ENGINE API now
139 transparently overrides the behaviour of defaults in the DSA API without
140 requiring changing these function prototypes.