|
|
3e1c26 |
From 11eab76046e2df31248d358ab85bdbcf366d2c78 Mon Sep 17 00:00:00 2001
|
|
|
3e1c26 |
From: Nicola Sella <nsella@redhat.com>
|
|
|
3e1c26 |
Date: Wed, 11 Nov 2020 14:52:14 +0100
|
|
|
3e1c26 |
Subject: [PATCH 1/1] Add support for computing hashes using OpenSSL
|
|
|
3e1c26 |
|
|
|
3e1c26 |
It adds WITH_OPENSSL build option.
|
|
|
3e1c26 |
If it is ON, OpenSSL will be used instead of internal implementation
|
|
|
3e1c26 |
of computing hashes (MD5, SHA1, SHA224, SHA256, SHA384, SHA512).
|
|
|
3e1c26 |
|
|
|
3e1c26 |
Rebase of https://github.com/openSUSE/libsolv/commit/9839a88e4fda23b46015170b201c98da7bcdd55e
|
|
|
3e1c26 |
---
|
|
|
3e1c26 |
CMakeLists.txt | 13 +++++++++++--
|
|
|
3e1c26 |
src/CMakeLists.txt | 16 +++++++++++-----
|
|
|
3e1c26 |
src/chksum.c | 32 ++++++++++++++++++++++++++++++++
|
|
|
3e1c26 |
tools/CMakeLists.txt | 2 +-
|
|
|
3e1c26 |
4 files changed, 55 insertions(+), 8 deletions(-)
|
|
|
3e1c26 |
|
|
|
3e1c26 |
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
|
3e1c26 |
index 3541f496..e73dc552 100644
|
|
|
3e1c26 |
--- a/CMakeLists.txt
|
|
|
3e1c26 |
+++ b/CMakeLists.txt
|
|
|
3e1c26 |
@@ -40,6 +40,7 @@ OPTION (ENABLE_ZCHUNK_COMPRESSION "Build with zchunk compression support?" OFF)
|
|
|
3e1c26 |
OPTION (WITH_SYSTEM_ZCHUNK "Use system zchunk library?" OFF)
|
|
|
3e1c26 |
OPTION (WITH_LIBXML2 "Build with libxml2 instead of libexpat?" OFF)
|
|
|
3e1c26 |
OPTION (WITHOUT_COOKIEOPEN "Disable the use of stdio cookie opens?" OFF)
|
|
|
3e1c26 |
+OPTION (WITH_OPENSSL "Use OpenSSL instead of internal implementation of hashes?" OFF)
|
|
|
3e1c26 |
|
|
|
3e1c26 |
include (GNUInstallDirs)
|
|
|
3e1c26 |
message (STATUS "Libraries will be installed in ${CMAKE_INSTALL_FULL_LIBDIR}")
|
|
|
3e1c26 |
@@ -164,6 +165,11 @@ INCLUDE_DIRECTORIES (${EXPAT_INCLUDE_DIRS})
|
|
|
3e1c26 |
ENDIF (WITH_LIBXML2 )
|
|
|
3e1c26 |
ENDIF (ENABLE_RPMMD OR ENABLE_SUSEREPO OR ENABLE_APPDATA OR ENABLE_COMPS OR ENABLE_HELIXREPO OR ENABLE_MDKREPO)
|
|
|
3e1c26 |
|
|
|
3e1c26 |
+IF (WITH_OPENSSL)
|
|
|
3e1c26 |
+FIND_PACKAGE (OpenSSL REQUIRED)
|
|
|
3e1c26 |
+INCLUDE_DIRECTORIES (${OPENSSL_INCLUDE_DIR})
|
|
|
3e1c26 |
+ENDIF(WITH_OPENSSL)
|
|
|
3e1c26 |
+
|
|
|
3e1c26 |
IF (ENABLE_ZLIB_COMPRESSION)
|
|
|
3e1c26 |
FIND_PACKAGE (ZLIB REQUIRED)
|
|
|
3e1c26 |
INCLUDE_DIRECTORIES (${ZLIB_INCLUDE_DIRS})
|
|
|
3e1c26 |
@@ -288,8 +294,8 @@ ENDIF (${CMAKE_MAJOR_VERSION} GREATER 2)
|
|
|
3e1c26 |
|
|
|
3e1c26 |
# should create config.h with #cmakedefine instead...
|
|
|
3e1c26 |
FOREACH (VAR HAVE_STRCHRNUL HAVE_FOPENCOOKIE HAVE_FUNOPEN WORDS_BIGENDIAN
|
|
|
3e1c26 |
- HAVE_RPM_DB_H HAVE_RPMDBNEXTITERATORHEADERBLOB HAVE_RPMDBFSTAT
|
|
|
3e1c26 |
- WITH_LIBXML2 WITHOUT_COOKIEOPEN)
|
|
|
3e1c26 |
+ HAVE_RPM_DB_H HAVE_PGPDIGGETPARAMS HAVE_RPMDBNEXTITERATORHEADERBLOB HAVE_RPMDBFSTAT
|
|
|
3e1c26 |
+ WITH_LIBXML2 WITHOUT_COOKIEOPEN WITH_OPENSSL)
|
|
|
3e1c26 |
IF(${VAR})
|
|
|
3e1c26 |
ADD_DEFINITIONS (-D${VAR}=1)
|
|
|
3e1c26 |
SET (SWIG_FLAGS ${SWIG_FLAGS} -D${VAR})
|
|
|
3e1c26 |
@@ -426,6 +432,9 @@ ENDIF (ENABLE_ZSTD_COMPRESSION)
|
|
|
3e1c26 |
IF (WITH_SYSTEM_ZCHUNK)
|
|
|
3e1c26 |
SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${ZCHUNK_LIBRARIES})
|
|
|
3e1c26 |
ENDIF (WITH_SYSTEM_ZCHUNK)
|
|
|
3e1c26 |
+IF (WITH_OPENSSL)
|
|
|
3e1c26 |
+SET (SYSTEM_LIBRARIES ${SYSTEM_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARY})
|
|
|
3e1c26 |
+ENDIF (WITH_OPENSSL)
|
|
|
3e1c26 |
IF (ENABLE_RPMDB)
|
|
|
3e1c26 |
SET (SYSTEM_LIBRARIES ${RPMDB_LIBRARY} ${SYSTEM_LIBRARIES})
|
|
|
3e1c26 |
ENDIF (ENABLE_RPMDB)
|
|
|
3e1c26 |
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
|
|
3e1c26 |
index bbf30bac..ece870ee 100644
|
|
|
3e1c26 |
--- a/src/CMakeLists.txt
|
|
|
3e1c26 |
+++ b/src/CMakeLists.txt
|
|
|
3e1c26 |
@@ -18,9 +18,8 @@ SET (libsolv_SRCS
|
|
|
3e1c26 |
solver.c solverdebug.c repo_solv.c repo_write.c evr.c pool.c
|
|
|
3e1c26 |
queue.c repo.c repodata.c repopage.c util.c policy.c solvable.c
|
|
|
3e1c26 |
transaction.c order.c rules.c problems.c linkedpkg.c cplxdeps.c
|
|
|
3e1c26 |
- chksum.c md5.c sha1.c sha2.c solvversion.c selection.c
|
|
|
3e1c26 |
- fileprovides.c diskusage.c suse.c solver_util.c cleandeps.c
|
|
|
3e1c26 |
- userinstalled.c filelistfilter.c)
|
|
|
3e1c26 |
+ chksum.c solvversion.c selection.c fileprovides.c diskusage.c
|
|
|
3e1c26 |
+ suse.c solver_util.c cleandeps.c userinstalled.c filelistfilter.c)
|
|
|
3e1c26 |
|
|
|
3e1c26 |
SET (libsolv_HEADERS
|
|
|
3e1c26 |
bitmap.h evr.h hash.h policy.h poolarch.h poolvendor.h pool.h
|
|
|
3e1c26 |
@@ -43,14 +42,21 @@ IF (WIN32)
|
|
|
3e1c26 |
LIST (APPEND libsolv_SRCS ${WIN32_COMPAT_SOURCES})
|
|
|
3e1c26 |
ENDIF (WIN32)
|
|
|
3e1c26 |
|
|
|
3e1c26 |
+IF (NOT WITH_OPENSSL)
|
|
|
3e1c26 |
+ SET (libsolv_SRCS ${libsolv_SRCS} md5.c sha1.c sha2.c)
|
|
|
3e1c26 |
+ENDIF (NOT WITH_OPENSSL)
|
|
|
3e1c26 |
+
|
|
|
3e1c26 |
IF (HAVE_LINKER_VERSION_SCRIPT)
|
|
|
3e1c26 |
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINK_FLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/src/libsolv.ver")
|
|
|
3e1c26 |
ENDIF (HAVE_LINKER_VERSION_SCRIPT)
|
|
|
3e1c26 |
|
|
|
3e1c26 |
IF (DISABLE_SHARED)
|
|
|
3e1c26 |
- ADD_LIBRARY (libsolv STATIC ${libsolv_SRCS})
|
|
|
3e1c26 |
+ ADD_LIBRARY (libsolv STATIC ${libsolv_SRCS})
|
|
|
3e1c26 |
ELSE (DISABLE_SHARED)
|
|
|
3e1c26 |
- ADD_LIBRARY (libsolv SHARED ${libsolv_SRCS})
|
|
|
3e1c26 |
+ ADD_LIBRARY (libsolv SHARED ${libsolv_SRCS})
|
|
|
3e1c26 |
+ IF (WITH_OPENSSL)
|
|
|
3e1c26 |
+ TARGET_LINK_LIBRARIES (libsolv ${OPENSSL_CRYPTO_LIBRARY})
|
|
|
3e1c26 |
+ ENDIF (WITH_OPENSSL)
|
|
|
3e1c26 |
ENDIF (DISABLE_SHARED)
|
|
|
3e1c26 |
|
|
|
3e1c26 |
IF (WIN32)
|
|
|
3e1c26 |
diff --git a/src/chksum.c b/src/chksum.c
|
|
|
3e1c26 |
index 1f8ab471..9189b744 100644
|
|
|
3e1c26 |
--- a/src/chksum.c
|
|
|
3e1c26 |
+++ b/src/chksum.c
|
|
|
3e1c26 |
@@ -15,10 +15,42 @@
|
|
|
3e1c26 |
#include "util.h"
|
|
|
3e1c26 |
#include "chksum.h"
|
|
|
3e1c26 |
|
|
|
3e1c26 |
+#ifdef WITH_OPENSSL
|
|
|
3e1c26 |
+
|
|
|
3e1c26 |
+#include <openssl/md5.h>
|
|
|
3e1c26 |
+#include <openssl/sha.h>
|
|
|
3e1c26 |
+
|
|
|
3e1c26 |
+typedef SHA_CTX SHA1_CTX;
|
|
|
3e1c26 |
+typedef SHA256_CTX SHA224_CTX;
|
|
|
3e1c26 |
+typedef SHA512_CTX SHA384_CTX;
|
|
|
3e1c26 |
+
|
|
|
3e1c26 |
+#define solv_MD5_Init(ctx) MD5_Init(ctx)
|
|
|
3e1c26 |
+#define solv_MD5_Update(ctx, data, len) MD5_Update(ctx, data, len)
|
|
|
3e1c26 |
+#define solv_MD5_Final(md, ctx) MD5_Final(md, ctx)
|
|
|
3e1c26 |
+#define solv_SHA1_Init(ctx) SHA1_Init(ctx)
|
|
|
3e1c26 |
+#define solv_SHA1_Update(ctx, data, len) SHA1_Update(ctx, data, len)
|
|
|
3e1c26 |
+#define solv_SHA1_Final(ctx, md) SHA1_Final(md, ctx)
|
|
|
3e1c26 |
+#define solv_SHA224_Init(ctx) SHA224_Init(ctx)
|
|
|
3e1c26 |
+#define solv_SHA224_Update(ctx, data, len) SHA224_Update(ctx, data, len)
|
|
|
3e1c26 |
+#define solv_SHA224_Final(md, ctx) SHA224_Final(md, ctx)
|
|
|
3e1c26 |
+#define solv_SHA256_Init(ctx) SHA256_Init(ctx)
|
|
|
3e1c26 |
+#define solv_SHA256_Update(ctx, data, len) SHA256_Update(ctx, data, len)
|
|
|
3e1c26 |
+#define solv_SHA256_Final(md, ctx) SHA256_Final(md, ctx)
|
|
|
3e1c26 |
+#define solv_SHA384_Init(ctx) SHA384_Init(ctx)
|
|
|
3e1c26 |
+#define solv_SHA384_Update(ctx, data, len) SHA384_Update(ctx, data, len)
|
|
|
3e1c26 |
+#define solv_SHA384_Final(md, ctx) SHA384_Final(md, ctx)
|
|
|
3e1c26 |
+#define solv_SHA512_Init(ctx) SHA512_Init(ctx)
|
|
|
3e1c26 |
+#define solv_SHA512_Update(ctx, data, len) SHA512_Update(ctx, data, len)
|
|
|
3e1c26 |
+#define solv_SHA512_Final(md, ctx) SHA512_Final(md, ctx)
|
|
|
3e1c26 |
+
|
|
|
3e1c26 |
+#else
|
|
|
3e1c26 |
+
|
|
|
3e1c26 |
#include "md5.h"
|
|
|
3e1c26 |
#include "sha1.h"
|
|
|
3e1c26 |
#include "sha2.h"
|
|
|
3e1c26 |
|
|
|
3e1c26 |
+#endif
|
|
|
3e1c26 |
+
|
|
|
3e1c26 |
#ifdef _WIN32
|
|
|
3e1c26 |
#include "strfncs.h"
|
|
|
3e1c26 |
#endif
|
|
|
3e1c26 |
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
|
|
|
3e1c26 |
index f19030eb..d477e195 100644
|
|
|
3e1c26 |
--- a/tools/CMakeLists.txt
|
|
|
3e1c26 |
+++ b/tools/CMakeLists.txt
|
|
|
3e1c26 |
@@ -116,7 +116,7 @@ SET(tools_list ${tools_list} repo2solv)
|
|
|
3e1c26 |
ENDIF (NOT WIN32)
|
|
|
3e1c26 |
|
|
|
3e1c26 |
ADD_EXECUTABLE (dumpsolv dumpsolv.c )
|
|
|
3e1c26 |
-TARGET_LINK_LIBRARIES (dumpsolv libsolv)
|
|
|
3e1c26 |
+TARGET_LINK_LIBRARIES (dumpsolv libsolv ${SYSTEM_LIBRARIES})
|
|
|
3e1c26 |
|
|
|
3e1c26 |
ADD_EXECUTABLE (mergesolv mergesolv.c )
|
|
|
3e1c26 |
TARGET_LINK_LIBRARIES (mergesolv toolstuff libsolvext libsolv ${SYSTEM_LIBRARIES})
|
|
|
3e1c26 |
--
|
|
|
3e1c26 |
2.26.2
|
|
|
3e1c26 |
|