2
0

dsa_locl.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #include "internal/refcount.h"
  11. struct dsa_st {
  12. /*
  13. * This first variable is used to pick up errors where a DSA is passed
  14. * instead of of a EVP_PKEY
  15. */
  16. int pad;
  17. int32_t version;
  18. BIGNUM *p;
  19. BIGNUM *q; /* == 20 */
  20. BIGNUM *g;
  21. BIGNUM *pub_key; /* y public key */
  22. BIGNUM *priv_key; /* x private key */
  23. int flags;
  24. /* Normally used to cache montgomery values */
  25. BN_MONT_CTX *method_mont_p;
  26. CRYPTO_REF_COUNT references;
  27. CRYPTO_EX_DATA ex_data;
  28. const DSA_METHOD *meth;
  29. /* functional reference if 'meth' is ENGINE-provided */
  30. ENGINE *engine;
  31. CRYPTO_RWLOCK *lock;
  32. };
  33. struct DSA_SIG_st {
  34. BIGNUM *r;
  35. BIGNUM *s;
  36. };
  37. struct dsa_method {
  38. char *name;
  39. DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa);
  40. int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
  41. BIGNUM **rp);
  42. int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len,
  43. DSA_SIG *sig, DSA *dsa);
  44. int (*dsa_mod_exp) (DSA *dsa, BIGNUM *rr, const BIGNUM *a1,
  45. const BIGNUM *p1, const BIGNUM *a2, const BIGNUM *p2,
  46. const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
  47. /* Can be null */
  48. int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
  49. const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
  50. int (*init) (DSA *dsa);
  51. int (*finish) (DSA *dsa);
  52. int flags;
  53. void *app_data;
  54. /* If this is non-NULL, it is used to generate DSA parameters */
  55. int (*dsa_paramgen) (DSA *dsa, int bits,
  56. const unsigned char *seed, int seed_len,
  57. int *counter_ret, unsigned long *h_ret,
  58. BN_GENCB *cb);
  59. /* If this is non-NULL, it is used to generate DSA keys */
  60. int (*dsa_keygen) (DSA *dsa);
  61. };
  62. int dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits,
  63. const EVP_MD *evpmd, const unsigned char *seed_in,
  64. size_t seed_len, unsigned char *seed_out,
  65. int *counter_ret, unsigned long *h_ret,
  66. BN_GENCB *cb);
  67. int dsa_builtin_paramgen2(DSA *ret, size_t L, size_t N,
  68. const EVP_MD *evpmd, const unsigned char *seed_in,
  69. size_t seed_len, int idx, unsigned char *seed_out,
  70. int *counter_ret, unsigned long *h_ret,
  71. BN_GENCB *cb);