You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.1 KiB

  1. From ce7de0261f0c1f1640da5673dd24939a37e33bd9 Mon Sep 17 00:00:00 2001
  2. From: Rosen Penev <rosenp@gmail.com>
  3. Date: Thu, 23 Jan 2020 18:53:06 -0800
  4. Subject: [PATCH 1/2] libcrypto-compat: add extra functions
  5. Changed the define to compare OPENSSL_API_COMPAT instead of version as
  6. OpenSSL can be compiled in different ways. One is to disable all
  7. deprecated APIs.
  8. Added extra functions. The next commit will switch to them.
  9. Signed-off-by: Rosen Penev <rosenp@gmail.com>
  10. ---
  11. src/libcrypto-compat.c | 14 ++++++++++++++
  12. src/libcrypto-compat.h | 8 +++++++-
  13. 2 files changed, 21 insertions(+), 1 deletion(-)
  14. diff --git a/src/libcrypto-compat.c b/src/libcrypto-compat.c
  15. index 048d1781..3604763f 100644
  16. --- a/src/libcrypto-compat.c
  17. +++ b/src/libcrypto-compat.c
  18. @@ -280,6 +280,11 @@ void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  19. OPENSSL_free(ctx);
  20. }
  21. +int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx)
  22. +{
  23. + EVP_CIPHER_CTX_init(ctx);
  24. +}
  25. +
  26. HMAC_CTX *HMAC_CTX_new(void)
  27. {
  28. HMAC_CTX *ctx = OPENSSL_zalloc(sizeof(HMAC_CTX));
  29. @@ -394,3 +399,12 @@ int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key)
  30. }
  31. return 1;
  32. }
  33. +
  34. +const char *OpenSSL_version(int type)
  35. +{
  36. + return SSLeay_version(type);
  37. +}
  38. +unsigned long OpenSSL_version_num(void)
  39. +{
  40. + return SSLeay();
  41. +}
  42. diff --git a/src/libcrypto-compat.h b/src/libcrypto-compat.h
  43. index bda0473e..44e14801 100644
  44. --- a/src/libcrypto-compat.h
  45. +++ b/src/libcrypto-compat.h
  46. @@ -34,6 +34,8 @@ int EVP_MD_CTX_reset(EVP_MD_CTX *ctx);
  47. EVP_MD_CTX *EVP_MD_CTX_new(void);
  48. void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
  49. +int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *ctx);
  50. +
  51. HMAC_CTX *HMAC_CTX_new(void);
  52. int HMAC_CTX_reset(HMAC_CTX *ctx);
  53. void HMAC_CTX_free(HMAC_CTX *ctx);
  54. @@ -44,6 +46,10 @@ int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g);
  55. void DH_get0_key(const DH *dh,
  56. const BIGNUM **pub_key, const BIGNUM **priv_key);
  57. int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key);
  58. +
  59. +const char *OpenSSL_version(int type);
  60. +unsigned long OpenSSL_version_num(void);
  61. +
  62. #endif /* OPENSSL_VERSION_NUMBER */
  63. #endif /* LIBCRYPTO_COMPAT_H */
  64. --
  65. 2.24.1