dh.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* $OpenBSD: dh.h,v 1.18 2019/09/06 05:23:55 djm Exp $ */
  2. /*
  3. * Copyright (c) 2000 Niels Provos. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  15. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  16. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  17. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  18. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  19. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  21. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  23. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef DH_H
  26. #define DH_H
  27. #ifdef WITH_OPENSSL
  28. struct dhgroup {
  29. int size;
  30. BIGNUM *g;
  31. BIGNUM *p;
  32. };
  33. DH *choose_dh(int, int, int);
  34. DH *dh_new_group_asc(const char *, const char *);
  35. DH *dh_new_group(BIGNUM *, BIGNUM *);
  36. DH *dh_new_group1(void);
  37. DH *dh_new_group14(void);
  38. DH *dh_new_group16(void);
  39. DH *dh_new_group18(void);
  40. DH *dh_new_group_fallback(int);
  41. int dh_gen_key(DH *, int);
  42. int dh_pub_is_valid(const DH *, const BIGNUM *);
  43. u_int dh_estimate(int);
  44. /*
  45. * Max value from RFC4419.
  46. * Min value from RFC8270.
  47. */
  48. #define DH_GRP_MIN 2048
  49. #define DH_GRP_MAX 8192
  50. /*
  51. * Values for "type" field of moduli(5)
  52. * Specifies the internal structure of the prime modulus.
  53. */
  54. #define MODULI_TYPE_UNKNOWN (0)
  55. #define MODULI_TYPE_UNSTRUCTURED (1)
  56. #define MODULI_TYPE_SAFE (2)
  57. #define MODULI_TYPE_SCHNORR (3)
  58. #define MODULI_TYPE_SOPHIE_GERMAIN (4)
  59. #define MODULI_TYPE_STRONG (5)
  60. /*
  61. * Values for "tests" field of moduli(5)
  62. * Specifies the methods used in checking for primality.
  63. * Usually, more than one test is used.
  64. */
  65. #define MODULI_TESTS_UNTESTED (0x00)
  66. #define MODULI_TESTS_COMPOSITE (0x01)
  67. #define MODULI_TESTS_SIEVE (0x02)
  68. #define MODULI_TESTS_MILLER_RABIN (0x04)
  69. #define MODULI_TESTS_JACOBI (0x08)
  70. #define MODULI_TESTS_ELLIPTIC (0x10)
  71. #endif /* WITH_OPENSSL */
  72. #endif /* DH_H */