A local copy of OpenSSL from GitHub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.7 KiB

  1. /*
  2. * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include <openssl/dsa.h>
  10. struct dsa_st {
  11. /*
  12. * This first variable is used to pick up errors where a DSA is passed
  13. * instead of of a EVP_PKEY
  14. */
  15. int pad;
  16. long version;
  17. BIGNUM *p;
  18. BIGNUM *q; /* == 20 */
  19. BIGNUM *g;
  20. BIGNUM *pub_key; /* y public key */
  21. BIGNUM *priv_key; /* x private key */
  22. int flags;
  23. /* Normally used to cache montgomery values */
  24. BN_MONT_CTX *method_mont_p;
  25. int references;
  26. CRYPTO_EX_DATA ex_data;
  27. const DSA_METHOD *meth;
  28. /* functional reference if 'meth' is ENGINE-provided */
  29. ENGINE *engine;
  30. CRYPTO_RWLOCK *lock;
  31. };
  32. struct dsa_method {
  33. char *name;
  34. DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa);
  35. int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
  36. BIGNUM **rp);
  37. int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len,
  38. DSA_SIG *sig, DSA *dsa);
  39. int (*dsa_mod_exp) (DSA *dsa, BIGNUM *rr, BIGNUM *a1, BIGNUM *p1,
  40. BIGNUM *a2, BIGNUM *p2, BIGNUM *m, BN_CTX *ctx,
  41. BN_MONT_CTX *in_mont);
  42. /* Can be null */
  43. int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
  44. const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
  45. int (*init) (DSA *dsa);
  46. int (*finish) (DSA *dsa);
  47. int flags;
  48. void *app_data;
  49. /* If this is non-NULL, it is used to generate DSA parameters */
  50. int (*dsa_paramgen) (DSA *dsa, int bits,
  51. const unsigned char *seed, int seed_len,
  52. int *counter_ret, unsigned long *h_ret,
  53. BN_GENCB *cb);
  54. /* If this is non-NULL, it is used to generate DSA keys */
  55. int (*dsa_keygen) (DSA *dsa);
  56. };
  57. int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits,
  58. const EVP_MD *evpmd, const unsigned char *seed_in,
  59. size_t seed_len, unsigned char *seed_out,
  60. int *counter_ret, unsigned long *h_ret,
  61. BN_GENCB *cb);
  62. int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N,
  63. const EVP_MD *evpmd, const unsigned char *seed_in,
  64. size_t seed_len, int idx, unsigned char *seed_out,
  65. int *counter_ret, unsigned long *h_ret,
  66. BN_GENCB *cb);