blob: 9c1434bd8d429630e6ac2534fa3fcc86c5db5413 [file] [log] [blame]
Ulf Möller38e33ce2000-01-27 19:31:26 +00001=pod
2
3=head1 NAME
4
Geoff Thorpe5bf73872002-08-05 16:27:01 +00005DSA_set_default_method, DSA_get_default_method,
Richard Levitte5270e702000-10-26 21:07:28 +00006DSA_set_method, DSA_new_method, DSA_OpenSSL - select DSA method
Ulf Möller38e33ce2000-01-27 19:31:26 +00007
8=head1 SYNOPSIS
9
Geoff Thorpe4c0aee52000-05-29 15:52:21 +000010 #include <openssl/dsa.h>
Richard Levitte6aba6582002-10-29 04:34:43 +000011 #include <openssl/engine.h>
Ulf Möller38e33ce2000-01-27 19:31:26 +000012
Geoff Thorpe5bf73872002-08-05 16:27:01 +000013 void DSA_set_default_method(const DSA_METHOD *meth);
Ulf Möller38e33ce2000-01-27 19:31:26 +000014
Geoff Thorpe5bf73872002-08-05 16:27:01 +000015 const DSA_METHOD *DSA_get_default_method(void);
Ulf Möller38e33ce2000-01-27 19:31:26 +000016
Geoff Thorpe5bf73872002-08-05 16:27:01 +000017 int DSA_set_method(DSA *dsa, const DSA_METHOD *meth);
Ulf Möller38e33ce2000-01-27 19:31:26 +000018
Richard Levitte6aba6582002-10-29 04:34:43 +000019 DSA *DSA_new_method(ENGINE *engine);
Ulf Möller38e33ce2000-01-27 19:31:26 +000020
21 DSA_METHOD *DSA_OpenSSL(void);
22
23=head1 DESCRIPTION
24
25A B<DSA_METHOD> specifies the functions that OpenSSL uses for DSA
26operations. By modifying the method, alternative implementations
Geoff Thorpe5bf73872002-08-05 16:27:01 +000027such as hardware accelerators may be used. IMPORTANT: See the NOTES section for
28important information about how these DSA API functions are affected by the use
29of B<ENGINE> API calls.
Ulf Möller38e33ce2000-01-27 19:31:26 +000030
Geoff Thorpe5bf73872002-08-05 16:27:01 +000031Initially, the default DSA_METHOD is the OpenSSL internal implementation,
32as returned by DSA_OpenSSL().
Ulf Möller38e33ce2000-01-27 19:31:26 +000033
Geoff Thorpe5bf73872002-08-05 16:27:01 +000034DSA_set_default_method() makes B<meth> the default method for all DSA
35structures created later. B<NB>: This is true only whilst no ENGINE has
36been set as a default for DSA, so this function is no longer recommended.
Ulf Möller38e33ce2000-01-27 19:31:26 +000037
Geoff Thorpe5bf73872002-08-05 16:27:01 +000038DSA_get_default_method() returns a pointer to the current default
Lutz Jänickeb6a338c2007-11-19 09:18:03 +000039DSA_METHOD. However, the meaningfulness of this result is dependent on
Geoff Thorpe5bf73872002-08-05 16:27:01 +000040whether the ENGINE API is being used, so this function is no longer
41recommended.
Ulf Möller38e33ce2000-01-27 19:31:26 +000042
Geoff Thorpe5bf73872002-08-05 16:27:01 +000043DSA_set_method() selects B<meth> to perform all operations using the key
44B<rsa>. This will replace the DSA_METHOD used by the DSA key and if the
45previous method was supplied by an ENGINE, the handle to that ENGINE will
46be released during the change. It is possible to have DSA keys that only
47work with certain DSA_METHOD implementations (eg. from an ENGINE module
48that supports embedded hardware-protected keys), and in such cases
49attempting to change the DSA_METHOD for the key can have unexpected
50results.
Ulf Möller38e33ce2000-01-27 19:31:26 +000051
Geoff Thorpe5bf73872002-08-05 16:27:01 +000052DSA_new_method() allocates and initializes a DSA structure so that B<engine>
53will be used for the DSA operations. If B<engine> is NULL, the default engine
54for DSA operations is used, and if no default ENGINE is set, the DSA_METHOD
55controlled by DSA_set_default_method() is used.
Ulf Möller38e33ce2000-01-27 19:31:26 +000056
57=head1 THE DSA_METHOD STRUCTURE
58
59struct
60 {
61 /* name of the implementation */
Ulf Möller74235cc2000-01-30 22:16:47 +000062 const char *name;
Ulf Möller38e33ce2000-01-27 19:31:26 +000063
64 /* sign */
65 DSA_SIG *(*dsa_do_sign)(const unsigned char *dgst, int dlen,
66 DSA *dsa);
67
68 /* pre-compute k^-1 and r */
69 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
70 BIGNUM **rp);
71
72 /* verify */
73 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
74 DSA_SIG *sig, DSA *dsa);
75
Ulf Möllere4947bf2000-03-09 17:07:55 +000076 /* compute rr = a1^p1 * a2^p2 mod m (May be NULL for some
77 implementations) */
Ulf Möller38e33ce2000-01-27 19:31:26 +000078 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
79 BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
80 BN_CTX *ctx, BN_MONT_CTX *in_mont);
81
Ulf Möllere4947bf2000-03-09 17:07:55 +000082 /* compute r = a ^ p mod m (May be NULL for some implementations) */
Ulf Möller74235cc2000-01-30 22:16:47 +000083 int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a,
84 const BIGNUM *p, const BIGNUM *m,
85 BN_CTX *ctx, BN_MONT_CTX *m_ctx);
Ulf Möller38e33ce2000-01-27 19:31:26 +000086
87 /* called at DSA_new */
88 int (*init)(DSA *DSA);
89
90 /* called at DSA_free */
91 int (*finish)(DSA *DSA);
92
93 int flags;
94
95 char *app_data; /* ?? */
96
97 } DSA_METHOD;
98
99=head1 RETURN VALUES
100
Geoff Thorpe5bf73872002-08-05 16:27:01 +0000101DSA_OpenSSL() and DSA_get_default_method() return pointers to the respective
102B<DSA_METHOD>s.
Ulf Möller38e33ce2000-01-27 19:31:26 +0000103
Geoff Thorpe5bf73872002-08-05 16:27:01 +0000104DSA_set_default_method() returns no value.
Ulf Möller38e33ce2000-01-27 19:31:26 +0000105
Geoff Thorpe5bf73872002-08-05 16:27:01 +0000106DSA_set_method() returns non-zero if the provided B<meth> was successfully set as
107the method for B<dsa> (including unloading the ENGINE handle if the previous
108method was supplied by an ENGINE).
Ulf Möller38e33ce2000-01-27 19:31:26 +0000109
Richard Levitte5270e702000-10-26 21:07:28 +0000110DSA_new_method() returns NULL and sets an error code that can be
Ulf Möller38e33ce2000-01-27 19:31:26 +0000111obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation
Richard Levitte5270e702000-10-26 21:07:28 +0000112fails. Otherwise it returns a pointer to the newly allocated structure.
Ulf Möller38e33ce2000-01-27 19:31:26 +0000113
Geoff Thorpe5bf73872002-08-05 16:27:01 +0000114=head1 NOTES
115
116As of version 0.9.7, DSA_METHOD implementations are grouped together with other
117algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B<ENGINE> modules. If a
118default ENGINE is specified for DSA functionality using an ENGINE API function,
119that will override any DSA defaults set using the DSA API (ie.
120DSA_set_default_method()). For this reason, the ENGINE API is the recommended way
121to control default implementations for use in DSA and other cryptographic
122algorithms.
123
Ulf Möller38e33ce2000-01-27 19:31:26 +0000124=head1 SEE ALSO
125
126L<dsa(3)|dsa(3)>, L<DSA_new(3)|DSA_new(3)>
127
128=head1 HISTORY
129
130DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(),
131DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4.
132
Geoff Thorpe5bf73872002-08-05 16:27:01 +0000133DSA_set_default_openssl_method() and DSA_get_default_openssl_method() replaced
134DSA_set_default_method() and DSA_get_default_method() respectively, and
135DSA_set_method() and DSA_new_method() were altered to use B<ENGINE>s rather than
136B<DSA_METHOD>s during development of the engine version of OpenSSL 0.9.6. For
1370.9.7, the handling of defaults in the ENGINE API was restructured so that this
138change was reversed, and behaviour of the other functions resembled more closely
139the previous behaviour. The behaviour of defaults in the ENGINE API now
140transparently overrides the behaviour of defaults in the DSA API without
141requiring changing these function prototypes.
Richard Levitte5270e702000-10-26 21:07:28 +0000142
Ulf Möller38e33ce2000-01-27 19:31:26 +0000143=cut