dsa_local.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (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. #include "internal/ffc.h"
  12. struct dsa_st {
  13. /*
  14. * This first variable is used to pick up errors where a DSA is passed
  15. * instead of an EVP_PKEY
  16. */
  17. int pad;
  18. int32_t version;
  19. FFC_PARAMS params;
  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. CRYPTO_REF_COUNT references;
  26. #ifndef FIPS_MODULE
  27. CRYPTO_EX_DATA ex_data;
  28. #endif
  29. const DSA_METHOD *meth;
  30. /* functional reference if 'meth' is ENGINE-provided */
  31. ENGINE *engine;
  32. CRYPTO_RWLOCK *lock;
  33. OSSL_LIB_CTX *libctx;
  34. /* Provider data */
  35. size_t dirty_cnt; /* If any key material changes, increment this */
  36. };
  37. struct DSA_SIG_st {
  38. BIGNUM *r;
  39. BIGNUM *s;
  40. };
  41. struct dsa_method {
  42. char *name;
  43. DSA_SIG *(*dsa_do_sign) (const unsigned char *dgst, int dlen, DSA *dsa);
  44. int (*dsa_sign_setup) (DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp,
  45. BIGNUM **rp);
  46. int (*dsa_do_verify) (const unsigned char *dgst, int dgst_len,
  47. DSA_SIG *sig, DSA *dsa);
  48. int (*dsa_mod_exp) (DSA *dsa, BIGNUM *rr, const BIGNUM *a1,
  49. const BIGNUM *p1, const BIGNUM *a2, const BIGNUM *p2,
  50. const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont);
  51. /* Can be null */
  52. int (*bn_mod_exp) (DSA *dsa, BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
  53. const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
  54. int (*init) (DSA *dsa);
  55. int (*finish) (DSA *dsa);
  56. int flags;
  57. void *app_data;
  58. /* If this is non-NULL, it is used to generate DSA parameters */
  59. int (*dsa_paramgen) (DSA *dsa, int bits,
  60. const unsigned char *seed, int seed_len,
  61. int *counter_ret, unsigned long *h_ret,
  62. BN_GENCB *cb);
  63. /* If this is non-NULL, it is used to generate DSA keys */
  64. int (*dsa_keygen) (DSA *dsa);
  65. };
  66. DSA_SIG *ossl_dsa_do_sign_int(const unsigned char *dgst, int dlen, DSA *dsa,
  67. unsigned int nonce_type, const char *digestname,
  68. OSSL_LIB_CTX *libctx, const char *propq);