dh_local.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright 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/dh.h>
  10. #include "internal/refcount.h"
  11. struct dh_st {
  12. /*
  13. * This first argument is used to pick up errors when a DH is passed
  14. * instead of a EVP_PKEY
  15. */
  16. int pad;
  17. int version;
  18. BIGNUM *p;
  19. BIGNUM *g;
  20. int32_t length; /* optional */
  21. BIGNUM *pub_key; /* g^x % p */
  22. BIGNUM *priv_key; /* x */
  23. int flags;
  24. BN_MONT_CTX *method_mont_p;
  25. /* Place holders if we want to do X9.42 DH */
  26. BIGNUM *q;
  27. BIGNUM *j;
  28. unsigned char *seed;
  29. int seedlen;
  30. BIGNUM *counter;
  31. CRYPTO_REF_COUNT references;
  32. CRYPTO_EX_DATA ex_data;
  33. const DH_METHOD *meth;
  34. ENGINE *engine;
  35. CRYPTO_RWLOCK *lock;
  36. };
  37. struct dh_method {
  38. char *name;
  39. /* Methods here */
  40. int (*generate_key) (DH *dh);
  41. int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh);
  42. /* Can be null */
  43. int (*bn_mod_exp) (const DH *dh, BIGNUM *r, const BIGNUM *a,
  44. const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
  45. BN_MONT_CTX *m_ctx);
  46. int (*init) (DH *dh);
  47. int (*finish) (DH *dh);
  48. int flags;
  49. char *app_data;
  50. /* If this is non-NULL, it will be used to generate parameters */
  51. int (*generate_params) (DH *dh, int prime_len, int generator,
  52. BN_GENCB *cb);
  53. };