fix: remove openssl includes

This commit is contained in:
Max Luebke 2023-03-31 15:00:19 +02:00
parent 18eff17773
commit 9f290d584a
3 changed files with 2 additions and 48 deletions

View File

@ -1,4 +1,4 @@
// // Time-stamp: "Last modified 2023-03-27 14:51:05 mluebke" // // Time-stamp: "Last modified 2023-03-31 14:59:49 mluebke"
/* /*
** Copyright (C) 2018-2021 Alexander Lindemann, Max Luebke (University of ** Copyright (C) 2018-2021 Alexander Lindemann, Max Luebke (University of
@ -24,17 +24,12 @@
#define HASHFUNCTIONS_H_ #define HASHFUNCTIONS_H_
#include <cstdint> #include <cstdint>
#include <openssl/evp.h>
namespace poet { namespace poet {
// Sum of POET interpreted as ASCII // Sum of POET interpreted as ASCII
constexpr uint32_t HASH_SEED = 80 + 79 + 69 + 84; constexpr uint32_t HASH_SEED = 80 + 79 + 69 + 84;
void initHashCtx(const EVP_MD *md);
void freeHashCtx();
uint64_t hashDHT(int key_size, const void *key);
uint64_t Murmur2_64A(int len, const void *key); uint64_t Murmur2_64A(int len, const void *key);
} // namespace poet } // namespace poet

View File

@ -29,7 +29,6 @@
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include <math.h> #include <math.h>
#include <openssl/evp.h>
#include <stdexcept> #include <stdexcept>
#include <vector> #include <vector>
@ -71,7 +70,6 @@ void poet::DHT_ResultObject::ResultsToWP(std::vector<double> &curr_wp) {
DHT_Wrapper::DHT_Wrapper(MPI_Comm dht_comm, uint32_t dht_size, DHT_Wrapper::DHT_Wrapper(MPI_Comm dht_comm, uint32_t dht_size,
uint32_t key_count, uint32_t data_count) uint32_t key_count, uint32_t data_count)
: key_count(key_count), data_count(data_count) { : key_count(key_count), data_count(data_count) {
poet::initHashCtx(EVP_md5());
// initialize DHT object // initialize DHT object
uint32_t key_size = key_count * sizeof(DHT_Keyelement); uint32_t key_size = key_count * sizeof(DHT_Keyelement);
uint32_t data_size = data_count * sizeof(double); uint32_t data_size = data_count * sizeof(double);
@ -100,7 +98,6 @@ DHT_Wrapper::~DHT_Wrapper() {
// free DHT // free DHT
DHT_free(dht_object, NULL, NULL); DHT_free(dht_object, NULL, NULL);
poet::freeHashCtx();
} }
auto DHT_Wrapper::checkDHT(int length, double dt, auto DHT_Wrapper::checkDHT(int length, double dt,
const std::vector<double> &work_package) const std::vector<double> &work_package)

View File

@ -1,4 +1,4 @@
// Time-stamp: "Last modified 2023-03-27 14:50:53 mluebke" // Time-stamp: "Last modified 2023-03-31 15:00:11 mluebke"
/* /*
**----------------------------------------------------------------------------- **-----------------------------------------------------------------------------
** MurmurHash2 was written by Austin Appleby, and is placed in the public ** MurmurHash2 was written by Austin Appleby, and is placed in the public
@ -27,8 +27,6 @@
#include "poet/HashFunctions.hpp" #include "poet/HashFunctions.hpp"
#include <cstddef> #include <cstddef>
#include <openssl/evp.h>
#include <openssl/md5.h>
#include <stdexcept> #include <stdexcept>
#if defined(_MSC_VER) #if defined(_MSC_VER)
@ -43,42 +41,6 @@
#endif // !defined(_MSC_VER) #endif // !defined(_MSC_VER)
// HACK: I know this is not a good practice, but this will do it for now!
EVP_MD_CTX *ctx = NULL;
void poet::initHashCtx(const EVP_MD *md) {
if (ctx == NULL) {
ctx = EVP_MD_CTX_new();
EVP_DigestInit_ex(ctx, md, NULL);
}
}
void poet::freeHashCtx() {
EVP_MD_CTX_free(ctx);
ctx = NULL;
}
uint64_t poet::hashDHT(int key_size, const void *key) {
unsigned char sum[MD5_DIGEST_LENGTH];
uint32_t md_len;
uint64_t retval, *v1, *v2;
// calculate md5 using MD5 functions
EVP_DigestUpdate(ctx, key, key_size);
EVP_DigestFinal_ex(ctx, sum, &md_len);
if (md_len != MD5_DIGEST_LENGTH) {
throw std::runtime_error("Something went wrong during MD5 hashing!");
}
// divide hash in 2 64 bit parts and XOR them
v1 = (uint64_t *)&sum[0];
v2 = (uint64_t *)&sum[8];
retval = *v1 ^ *v2;
return retval;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// MurmurHash2, 64-bit versions, by Austin Appleby // MurmurHash2, 64-bit versions, by Austin Appleby