Changed calls to OpenSSL API to use OpenSSL3 style functions with
proper error handling. Suppressed warnings about strncpy which is
used in a liblp library for copying bytes between char arrays
which don't have to be terminated with NUL
Change-Id: Ifb4c1e10ae39fbf03f7bd9a4087b631884fcddc0
add_library(lp STATIC reader.cpp utility.cpp)
target_include_directories(lp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
-target_compile_options(lp PRIVATE -Wall -Wextra -pedantic -fPIE)
+target_compile_options(lp PRIVATE -Wall -Wextra -pedantic -fPIE -Wno-stringop-truncation)
find_package(OpenSSL REQUIRED)
target_link_libraries(lp PRIVATE OpenSSL::Crypto)
\ No newline at end of file
#include <vector>
#include <openssl/sha.h>
+#include <openssl/evp.h>
#include "utility.h"
}
void SHA256(const void* data, size_t length, uint8_t out[32]) {
- SHA256_CTX c;
- SHA256_Init(&c);
- SHA256_Update(&c, data, length);
- SHA256_Final(out, &c);
+ const EVP_MD *md = EVP_sha256();
+
+ if (!EVP_Digest(data, length, out, nullptr, md, nullptr))
+ LERROR << __PRETTY_FUNCTION__ << "Unable to compute hash";
}
uint32_t SlotNumberForSlotSuffix(const std::string& suffix) {