1*2175Sjp161948=pod 2*2175Sjp161948 3*2175Sjp161948=head1 NAME 4*2175Sjp161948 5*2175Sjp161948DSA_set_default_method, DSA_get_default_method, 6*2175Sjp161948DSA_set_method, DSA_new_method, DSA_OpenSSL - select DSA method 7*2175Sjp161948 8*2175Sjp161948=head1 SYNOPSIS 9*2175Sjp161948 10*2175Sjp161948 #include <openssl/dsa.h> 11*2175Sjp161948 #include <openssl/engine.h> 12*2175Sjp161948 13*2175Sjp161948 void DSA_set_default_method(const DSA_METHOD *meth); 14*2175Sjp161948 15*2175Sjp161948 const DSA_METHOD *DSA_get_default_method(void); 16*2175Sjp161948 17*2175Sjp161948 int DSA_set_method(DSA *dsa, const DSA_METHOD *meth); 18*2175Sjp161948 19*2175Sjp161948 DSA *DSA_new_method(ENGINE *engine); 20*2175Sjp161948 21*2175Sjp161948 DSA_METHOD *DSA_OpenSSL(void); 22*2175Sjp161948 23*2175Sjp161948=head1 DESCRIPTION 24*2175Sjp161948 25*2175Sjp161948A B<DSA_METHOD> specifies the functions that OpenSSL uses for DSA 26*2175Sjp161948operations. By modifying the method, alternative implementations 27*2175Sjp161948such as hardware accelerators may be used. IMPORTANT: See the NOTES section for 28*2175Sjp161948important information about how these DSA API functions are affected by the use 29*2175Sjp161948of B<ENGINE> API calls. 30*2175Sjp161948 31*2175Sjp161948Initially, the default DSA_METHOD is the OpenSSL internal implementation, 32*2175Sjp161948as returned by DSA_OpenSSL(). 33*2175Sjp161948 34*2175Sjp161948DSA_set_default_method() makes B<meth> the default method for all DSA 35*2175Sjp161948structures created later. B<NB>: This is true only whilst no ENGINE has 36*2175Sjp161948been set as a default for DSA, so this function is no longer recommended. 37*2175Sjp161948 38*2175Sjp161948DSA_get_default_method() returns a pointer to the current default 39*2175Sjp161948DSA_METHOD. However, the meaningfulness of this result is dependant on 40*2175Sjp161948whether the ENGINE API is being used, so this function is no longer 41*2175Sjp161948recommended. 42*2175Sjp161948 43*2175Sjp161948DSA_set_method() selects B<meth> to perform all operations using the key 44*2175Sjp161948B<rsa>. This will replace the DSA_METHOD used by the DSA key and if the 45*2175Sjp161948previous method was supplied by an ENGINE, the handle to that ENGINE will 46*2175Sjp161948be released during the change. It is possible to have DSA keys that only 47*2175Sjp161948work with certain DSA_METHOD implementations (eg. from an ENGINE module 48*2175Sjp161948that supports embedded hardware-protected keys), and in such cases 49*2175Sjp161948attempting to change the DSA_METHOD for the key can have unexpected 50*2175Sjp161948results. 51*2175Sjp161948 52*2175Sjp161948DSA_new_method() allocates and initializes a DSA structure so that B<engine> 53*2175Sjp161948will be used for the DSA operations. If B<engine> is NULL, the default engine 54*2175Sjp161948for DSA operations is used, and if no default ENGINE is set, the DSA_METHOD 55*2175Sjp161948controlled by DSA_set_default_method() is used. 56*2175Sjp161948 57*2175Sjp161948=head1 THE DSA_METHOD STRUCTURE 58*2175Sjp161948 59*2175Sjp161948struct 60*2175Sjp161948 { 61*2175Sjp161948 /* name of the implementation */ 62*2175Sjp161948 const char *name; 63*2175Sjp161948 64*2175Sjp161948 /* sign */ 65*2175Sjp161948 DSA_SIG *(*dsa_do_sign)(const unsigned char *dgst, int dlen, 66*2175Sjp161948 DSA *dsa); 67*2175Sjp161948 68*2175Sjp161948 /* pre-compute k^-1 and r */ 69*2175Sjp161948 int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, 70*2175Sjp161948 BIGNUM **rp); 71*2175Sjp161948 72*2175Sjp161948 /* verify */ 73*2175Sjp161948 int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len, 74*2175Sjp161948 DSA_SIG *sig, DSA *dsa); 75*2175Sjp161948 76*2175Sjp161948 /* compute rr = a1^p1 * a2^p2 mod m (May be NULL for some 77*2175Sjp161948 implementations) */ 78*2175Sjp161948 int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, 79*2175Sjp161948 BIGNUM *a2, BIGNUM *p2, BIGNUM *m, 80*2175Sjp161948 BN_CTX *ctx, BN_MONT_CTX *in_mont); 81*2175Sjp161948 82*2175Sjp161948 /* compute r = a ^ p mod m (May be NULL for some implementations) */ 83*2175Sjp161948 int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a, 84*2175Sjp161948 const BIGNUM *p, const BIGNUM *m, 85*2175Sjp161948 BN_CTX *ctx, BN_MONT_CTX *m_ctx); 86*2175Sjp161948 87*2175Sjp161948 /* called at DSA_new */ 88*2175Sjp161948 int (*init)(DSA *DSA); 89*2175Sjp161948 90*2175Sjp161948 /* called at DSA_free */ 91*2175Sjp161948 int (*finish)(DSA *DSA); 92*2175Sjp161948 93*2175Sjp161948 int flags; 94*2175Sjp161948 95*2175Sjp161948 char *app_data; /* ?? */ 96*2175Sjp161948 97*2175Sjp161948 } DSA_METHOD; 98*2175Sjp161948 99*2175Sjp161948=head1 RETURN VALUES 100*2175Sjp161948 101*2175Sjp161948DSA_OpenSSL() and DSA_get_default_method() return pointers to the respective 102*2175Sjp161948B<DSA_METHOD>s. 103*2175Sjp161948 104*2175Sjp161948DSA_set_default_method() returns no value. 105*2175Sjp161948 106*2175Sjp161948DSA_set_method() returns non-zero if the provided B<meth> was successfully set as 107*2175Sjp161948the method for B<dsa> (including unloading the ENGINE handle if the previous 108*2175Sjp161948method was supplied by an ENGINE). 109*2175Sjp161948 110*2175Sjp161948DSA_new_method() returns NULL and sets an error code that can be 111*2175Sjp161948obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation 112*2175Sjp161948fails. Otherwise it returns a pointer to the newly allocated structure. 113*2175Sjp161948 114*2175Sjp161948=head1 NOTES 115*2175Sjp161948 116*2175Sjp161948As of version 0.9.7, DSA_METHOD implementations are grouped together with other 117*2175Sjp161948algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B<ENGINE> modules. If a 118*2175Sjp161948default ENGINE is specified for DSA functionality using an ENGINE API function, 119*2175Sjp161948that will override any DSA defaults set using the DSA API (ie. 120*2175Sjp161948DSA_set_default_method()). For this reason, the ENGINE API is the recommended way 121*2175Sjp161948to control default implementations for use in DSA and other cryptographic 122*2175Sjp161948algorithms. 123*2175Sjp161948 124*2175Sjp161948=head1 SEE ALSO 125*2175Sjp161948 126*2175Sjp161948L<dsa(3)|dsa(3)>, L<DSA_new(3)|DSA_new(3)> 127*2175Sjp161948 128*2175Sjp161948=head1 HISTORY 129*2175Sjp161948 130*2175Sjp161948DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(), 131*2175Sjp161948DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4. 132*2175Sjp161948 133*2175Sjp161948DSA_set_default_openssl_method() and DSA_get_default_openssl_method() replaced 134*2175Sjp161948DSA_set_default_method() and DSA_get_default_method() respectively, and 135*2175Sjp161948DSA_set_method() and DSA_new_method() were altered to use B<ENGINE>s rather than 136*2175Sjp161948B<DSA_METHOD>s during development of the engine version of OpenSSL 0.9.6. For 137*2175Sjp1619480.9.7, the handling of defaults in the ENGINE API was restructured so that this 138*2175Sjp161948change was reversed, and behaviour of the other functions resembled more closely 139*2175Sjp161948the previous behaviour. The behaviour of defaults in the ENGINE API now 140*2175Sjp161948transparently overrides the behaviour of defaults in the DSA API without 141*2175Sjp161948requiring changing these function prototypes. 142*2175Sjp161948 143*2175Sjp161948=cut 144