DSA_set_method.pod 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. =pod
  2. =head1 NAME
  3. DSA_set_default_method, DSA_get_default_method,
  4. DSA_set_method, DSA_new_method, DSA_OpenSSL - select DSA method
  5. =head1 SYNOPSIS
  6. #include <openssl/dsa.h>
  7. #include <openssl/engine.h>
  8. void DSA_set_default_method(const DSA_METHOD *meth);
  9. const DSA_METHOD *DSA_get_default_method(void);
  10. int DSA_set_method(DSA *dsa, const DSA_METHOD *meth);
  11. DSA *DSA_new_method(ENGINE *engine);
  12. DSA_METHOD *DSA_OpenSSL(void);
  13. =head1 DESCRIPTION
  14. A B<DSA_METHOD> specifies the functions that OpenSSL uses for DSA
  15. operations. By modifying the method, alternative implementations
  16. such as hardware accelerators may be used. IMPORTANT: See the NOTES section for
  17. important information about how these DSA API functions are affected by the use
  18. of B<ENGINE> API calls.
  19. Initially, the default DSA_METHOD is the OpenSSL internal implementation,
  20. as returned by DSA_OpenSSL().
  21. DSA_set_default_method() makes B<meth> the default method for all DSA
  22. structures created later. B<NB>: This is true only whilst no ENGINE has
  23. been set as a default for DSA, so this function is no longer recommended.
  24. DSA_get_default_method() returns a pointer to the current default
  25. DSA_METHOD. However, the meaningfulness of this result is dependent on
  26. whether the ENGINE API is being used, so this function is no longer
  27. recommended.
  28. DSA_set_method() selects B<meth> to perform all operations using the key
  29. B<rsa>. This will replace the DSA_METHOD used by the DSA key and if the
  30. previous method was supplied by an ENGINE, the handle to that ENGINE will
  31. be released during the change. It is possible to have DSA keys that only
  32. work with certain DSA_METHOD implementations (eg. from an ENGINE module
  33. that supports embedded hardware-protected keys), and in such cases
  34. attempting to change the DSA_METHOD for the key can have unexpected
  35. results.
  36. DSA_new_method() allocates and initializes a DSA structure so that B<engine>
  37. will be used for the DSA operations. If B<engine> is NULL, the default engine
  38. for DSA operations is used, and if no default ENGINE is set, the DSA_METHOD
  39. controlled by DSA_set_default_method() is used.
  40. =head1 THE DSA_METHOD STRUCTURE
  41. struct
  42. {
  43. /* name of the implementation */
  44. const char *name;
  45. /* sign */
  46. DSA_SIG *(*dsa_do_sign)(const unsigned char *dgst, int dlen,
  47. DSA *dsa);
  48. /* pre-compute k^-1 and r */
  49. int (*dsa_sign_setup)(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
  50. BIGNUM **rp);
  51. /* verify */
  52. int (*dsa_do_verify)(const unsigned char *dgst, int dgst_len,
  53. DSA_SIG *sig, DSA *dsa);
  54. /* compute rr = a1^p1 * a2^p2 mod m (May be NULL for some
  55. implementations) */
  56. int (*dsa_mod_exp)(DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
  57. BIGNUM *a2, BIGNUM *p2, BIGNUM *m,
  58. BN_CTX *ctx, BN_MONT_CTX *in_mont);
  59. /* compute r = a ^ p mod m (May be NULL for some implementations) */
  60. int (*bn_mod_exp)(DSA *dsa, BIGNUM *r, BIGNUM *a,
  61. const BIGNUM *p, const BIGNUM *m,
  62. BN_CTX *ctx, BN_MONT_CTX *m_ctx);
  63. /* called at DSA_new */
  64. int (*init)(DSA *DSA);
  65. /* called at DSA_free */
  66. int (*finish)(DSA *DSA);
  67. int flags;
  68. char *app_data; /* ?? */
  69. } DSA_METHOD;
  70. =head1 RETURN VALUES
  71. DSA_OpenSSL() and DSA_get_default_method() return pointers to the respective
  72. B<DSA_METHOD>s.
  73. DSA_set_default_method() returns no value.
  74. DSA_set_method() returns non-zero if the provided B<meth> was successfully set as
  75. the method for B<dsa> (including unloading the ENGINE handle if the previous
  76. method was supplied by an ENGINE).
  77. DSA_new_method() returns NULL and sets an error code that can be
  78. obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation
  79. fails. Otherwise it returns a pointer to the newly allocated structure.
  80. =head1 NOTES
  81. As of version 0.9.7, DSA_METHOD implementations are grouped together with other
  82. algorithmic APIs (eg. RSA_METHOD, EVP_CIPHER, etc) in B<ENGINE> modules. If a
  83. default ENGINE is specified for DSA functionality using an ENGINE API function,
  84. that will override any DSA defaults set using the DSA API (ie.
  85. DSA_set_default_method()). For this reason, the ENGINE API is the recommended way
  86. to control default implementations for use in DSA and other cryptographic
  87. algorithms.
  88. =head1 SEE ALSO
  89. L<dsa(3)|dsa(3)>, L<DSA_new(3)|DSA_new(3)>
  90. =head1 HISTORY
  91. DSA_set_default_method(), DSA_get_default_method(), DSA_set_method(),
  92. DSA_new_method() and DSA_OpenSSL() were added in OpenSSL 0.9.4.
  93. DSA_set_default_openssl_method() and DSA_get_default_openssl_method() replaced
  94. DSA_set_default_method() and DSA_get_default_method() respectively, and
  95. DSA_set_method() and DSA_new_method() were altered to use B<ENGINE>s rather than
  96. B<DSA_METHOD>s during development of the engine version of OpenSSL 0.9.6. For
  97. 0.9.7, the handling of defaults in the ENGINE API was restructured so that this
  98. change was reversed, and behaviour of the other functions resembled more closely
  99. the previous behaviour. The behaviour of defaults in the ENGINE API now
  100. transparently overrides the behaviour of defaults in the DSA API without
  101. requiring changing these function prototypes.
  102. =cut