Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use New MD5 API Function #791

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions common/src/unifyfs_meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
* Please read https://github.com/LLNL/UnifyFS/LICENSE for full license text.
*/

#include <assert.h>
#include <endian.h>
#include <openssl/evp.h>
#include <string.h>
#include <openssl/md5.h>

#include "unifyfs_meta.h"

Expand All @@ -39,9 +40,13 @@ uint64_t compute_path_md5(const char* path)
{
unsigned long len;
unsigned char digested[16] = {0};
unsigned int digestSize;
/* digestSize is set by EVP_Digest(). For MD5 digests, it should always
* be 16. */

len = strlen(path);
MD5((const unsigned char*) path, len, digested);
EVP_Digest(path, len, digested, &digestSize, EVP_md5(), NULL);
assert(digestSize == 16);

/* construct uint64_t hash from first 8 digest bytes */
uint64_t* digest_value = (uint64_t*) digested;
Expand Down
14 changes: 14 additions & 0 deletions m4/openssl.m4
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ AC_DEFUN([UNIFYFS_AC_OPENSSL], [
couldn't find a suitable openssl-devel
]))])




AC_CHECK_LIB([crypto], [EVP_Digest],
MichaelBrim marked this conversation as resolved.
Show resolved Hide resolved
[
AM_CONDITIONAL([HAVE_OPENSSL_EVP], [true])
],
[
AC_MSG_ERROR([couldn't find a sufficiently new OpenSSL installation])
],
[]
)


# restore flags
CFLAGS=$OPENSSL_OLD_CFLAGS
CXXFLAGS=$OPENSSL_OLD_CXXFLAGS
Expand Down
Loading