Skip to content

Commit

Permalink
checksum.c: Use the EVP API to compute the MD5 checksum
Browse files Browse the repository at this point in the history
As MD5 function has been marked as deprecated in OpenSSL 3.0, this change
uses EVP (Envelope) API to compute the MD5 checksum.
Reference:
https://www.openssl.org/docs/man1.0.2/man3/EVP_md5.html

Fixes: gluster#4243
Signed-off-by: root <root@li-9b8608cc-32eb-11b2-a85c-953d7297bf45.ibm.com>
  • Loading branch information
root authored and Shwetha-Acharya committed Oct 20, 2023
1 parent c22bf0f commit 89e5e8f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libglusterfs/src/checksum.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
cases as published by the Free Software Foundation.
*/

#include <openssl/md5.h>
#include <openssl/evp.h>
#include <openssl/sha.h>
#include <zlib.h>
#include <stdint.h>
Expand Down Expand Up @@ -40,5 +40,13 @@ gf_rsync_strong_checksum(unsigned char *data, size_t len,
void
gf_rsync_md5_checksum(unsigned char *data, size_t len, unsigned char *md5)
{
MD5(data, len, md5);
EVP_MD_CTX *mdctx;
// Use the MD5 digest algorithm
const EVP_MD *md = EVP_md5();

mdctx = EVP_MD_CTX_new();
EVP_DigestInit_ex(mdctx, md, NULL);
EVP_DigestUpdate(mdctx, data, len);
EVP_DigestFinal_ex(mdctx, md5, NULL);
EVP_MD_CTX_free(mdctx);
}

0 comments on commit 89e5e8f

Please sign in to comment.