dh.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* dh.h
  2. *
  3. * Copyright (C) 2006-2017 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. /* dh.h for openSSL */
  22. #ifndef WOLFSSL_DH_H_
  23. #define WOLFSSL_DH_H_
  24. #include <wolfssl/openssl/ssl.h>
  25. #include <wolfssl/openssl/bn.h>
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. struct WOLFSSL_DH {
  30. WOLFSSL_BIGNUM* p;
  31. WOLFSSL_BIGNUM* g;
  32. WOLFSSL_BIGNUM* q;
  33. WOLFSSL_BIGNUM* pub_key; /* openssh deference g^x */
  34. WOLFSSL_BIGNUM* priv_key; /* openssh deference x */
  35. void* internal; /* our DH */
  36. char inSet; /* internal set from external ? */
  37. char exSet; /* external set from internal ? */
  38. /*added for lighttpd openssl compatibility, go back and add a getter in
  39. * lighttpd src code.
  40. */
  41. int length;
  42. };
  43. WOLFSSL_API WOLFSSL_DH* wolfSSL_DH_new(void);
  44. WOLFSSL_API void wolfSSL_DH_free(WOLFSSL_DH*);
  45. WOLFSSL_API int wolfSSL_DH_size(WOLFSSL_DH*);
  46. WOLFSSL_API int wolfSSL_DH_generate_key(WOLFSSL_DH*);
  47. WOLFSSL_API int wolfSSL_DH_compute_key(unsigned char* key, WOLFSSL_BIGNUM* pub,
  48. WOLFSSL_DH*);
  49. typedef WOLFSSL_DH DH;
  50. #define DH_new wolfSSL_DH_new
  51. #define DH_free wolfSSL_DH_free
  52. #define DH_size wolfSSL_DH_size
  53. #define DH_generate_key wolfSSL_DH_generate_key
  54. #define DH_compute_key wolfSSL_DH_compute_key
  55. #define get_rfc3526_prime_1536 wolfSSL_DH_1536_prime
  56. #ifdef __cplusplus
  57. } /* extern "C" */
  58. #endif
  59. #ifdef HAVE_STUNNEL
  60. #define DH_generate_parameters wolfSSL_DH_generate_parameters
  61. #define DH_generate_parameters_ex wolfSSL_DH_generate_parameters_ex
  62. #endif /* HAVE_STUNNEL */
  63. #endif /* header */