More BIO docs.
[openssl.git] / doc / crypto / DSA_set_method.pod
1 =pod
2
3 =head1 NAME
4
5 DSA_set_default_method, DSA_get_default_method, DSA_set_method,
6 DSA_new_method, DSA_OpenSSL - select DSA method
7
8 =head1 SYNOPSIS
9
10  #include <openssl/dsa.h>
11
12  void DSA_set_default_method(DSA_METHOD *meth);
13
14  DSA_METHOD *DSA_get_default_method(void);
15
16  DSA_METHOD *DSA_set_method(DSA *dsa, DSA_METHOD *meth);
17
18  DSA *DSA_new_method(DSA_METHOD *meth);
19
20  DSA_METHOD *DSA_OpenSSL(void);
21
22 =head1 DESCRIPTION
23
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.
27
28 Initially, the default is to use the OpenSSL internal implementation.
29 DSA_OpenSSL() returns a pointer to that method.
30
31 DSA_set_default_method() makes B<meth> the default method for all B<DSA>
32 structures created later.
33
34 DSA_get_default_method() returns a pointer to the current default
35 method.
36
37 DSA_set_method() selects B<meth> for all operations using the structure B<dsa>.
38
39 DSA_new_method() allocates and initializes a B<DSA> structure so that
40 B<method> will be used for the DSA operations. If B<method> is B<NULL>,
41 the default method is used.
42
43 =head1 THE DSA_METHOD STRUCTURE
44
45 struct
46  {
47      /* name of the implementation */
48         const char *name;
49
50      /* sign */
51         DSA_SIG *(*dsa_do_sign)(const unsigned char *dgst, int dlen,
52                                  DSA *dsa);
53
54      /* pre-compute k^-1 and r */
55         int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
56                                  BIGNUM **rp);
57
58      /* verify */
59         int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
60                                  DSA_SIG *sig, DSA *dsa);
61
62      /* compute rr = a1^p1 * a2^p2 mod m (May be NULL for some
63                                           implementations) */
64         int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
65                                  BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
66                                  BN_CTX *ctx, BN_MONT_CTX *in_mont);
67
68      /* compute r = a ^ p mod m (May be NULL for some implementations) */
69         int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a,
70                                  const BIGNUM *p, const BIGNUM *m,
71                                  BN_CTX *ctx, BN_MONT_CTX *m_ctx);
72
73      /* called at DSA_new */
74         int (*init)(DSA *DSA);
75
76      /* called at DSA_free */
77         int (*finish)(DSA *DSA);
78
79         int flags;
80
81         char *app_data; /* ?? */
82
83  } DSA_METHOD;
84
85 =head1 RETURN VALUES
86
87 DSA_OpenSSL() and DSA_get_default_method() return pointers to the
88 respective B<DSA_METHOD>s.
89
90 DSA_set_default_method() returns no value.
91
92 DSA_set_method() returns a pointer to the B<DSA_METHOD> previously
93 associated with B<dsa>.
94
95 DSA_new_method() returns B<NULL> and sets an error code that can be
96 obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation
97 fails. Otherwise it returns a pointer to the newly allocated
98 structure.
99
100 =head1 SEE ALSO
101
102 L<dsa(3)|dsa(3)>, L<DSA_new(3)|DSA_new(3)>
103
104 =head1 HISTORY
105
106 DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(),
107 DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4.
108
109 =cut