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.

47 lines
1.2 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. --- a/utils.c
  9. +++ b/utils.c
  10. @@ -791,8 +791,14 @@ char *encode_cram_md5(char *challenge,ch
  11. unsigned char
  12. hmac_md5[16];
  13. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  14. HMAC_CTX
  15. ctx;
  16. +#else
  17. + /* OpenSSL 1.1.x*/
  18. + HMAC_CTX
  19. + *ctx;
  20. +#endif
  21. const EVP_MD
  22. *md5=NULL;
  23. @@ -831,11 +837,20 @@ char *encode_cram_md5(char *challenge,ch
  24. showVerbose("Challenge After decoding: %s\n",data);
  25. /* take HMAC-MD5 of the challenge*/
  26. +
  27. +#if OPENSSL_VERSION_NUMBER < 0x10100000L
  28. md5=EVP_get_digestbyname("md5");
  29. HMAC_CTX_init(&ctx);
  30. HMAC_Init(&ctx,secret,strlen(secret),md5);
  31. HMAC_Update(&ctx,data,data_len);
  32. HMAC_Final(&ctx,hmac_md5,&hmac_len);
  33. +#else
  34. + /* OpenSSL 1.1.x */
  35. + ctx = HMAC_CTX_new();
  36. + HMAC_Init_ex(ctx,secret,strlen(secret),EVP_md5(),NULL);
  37. + HMAC_Update(ctx,data,data_len);
  38. + HMAC_Final(ctx,hmac_md5,&hmac_len);
  39. +#endif
  40. /* convert the digest to hex */
  41. memset(hex,0,sizeof(hex));