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.

49 lines
1.3 KiB

  1. From 960df6d7a11eef90128dc2ae660866b27f0e4336 Mon Sep 17 00:00:00 2001
  2. From: muquit <muquit@gmail.com>
  3. Date: Wed, 21 Sep 2016 12:46:24 -0400
  4. Subject: [PATCH] OpenSSL 1.1 support for HMAC api
  5. ---
  6. utils.c | 15 +++++++++++++++
  7. 1 file changed, 15 insertions(+)
  8. diff --git a/utils.c b/utils.c
  9. index b072138..abfb86e 100755
  10. --- a/utils.c
  11. +++ b/utils.c
  12. @@ -791,8 +791,14 @@ char *encode_cram_md5(char *challenge,char *user,char *secret)
  13. unsigned char
  14. hmac_md5[16];
  15. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  16. HMAC_CTX
  17. ctx;
  18. +#else
  19. + /* OpenSSL 1.1.x*/
  20. + HMAC_CTX
  21. + *ctx;
  22. +#endif
  23. const EVP_MD
  24. *md5=NULL;
  25. @@ -831,11 +837,20 @@ char *encode_cram_md5(char *challenge,char *user,char *secret)
  26. showVerbose("Challenge After decoding: %s\n",data);
  27. /* take HMAC-MD5 of the challenge*/
  28. +
  29. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  30. md5=EVP_get_digestbyname("md5");
  31. HMAC_CTX_init(&ctx);
  32. HMAC_Init(&ctx,secret,strlen(secret),md5);
  33. HMAC_Update(&ctx,data,data_len);
  34. HMAC_Final(&ctx,hmac_md5,&hmac_len);
  35. +#else
  36. + /* OpenSSL 1.1.x */
  37. + ctx = HMAC_CTX_new();
  38. + HMAC_Init_ex(ctx,secret,strlen(secret),EVP_md5(),NULL);
  39. + HMAC_Update(ctx,data,data_len);
  40. + HMAC_Final(ctx,hmac_md5,&hmac_len);
  41. +#endif
  42. /* convert the digest to hex */
  43. memset(hex,0,sizeof(hex));