From e5caea5fbb2fd1367439eb4b0391c64c0238a40a Mon Sep 17 00:00:00 2001
From: Andy Weidenbaum <atweiden@ioiojo.com>
Date: Sat, 22 Jul 2023 03:18:53 +0000
Subject: [PATCH 2/2] de-vendor crypto++ for void

---
 .../implementations/compressing/compressors/Gzip.cpp |  2 +-
 src/cpp-utils/crypto/hash/Hash.cpp                   |  2 +-
 src/cpp-utils/crypto/kdf/Scrypt.cpp                  |  2 +-
 src/cpp-utils/crypto/symmetric/CFB_Cipher.h          |  2 +-
 src/cpp-utils/crypto/symmetric/GCM_Cipher.h          |  2 +-
 src/cpp-utils/crypto/symmetric/ciphers.h             | 12 ++++++------
 src/cpp-utils/data/Data.cpp                          |  2 +-
 src/cpp-utils/data/FixedSizeData.h                   |  2 +-
 src/cpp-utils/random/OSRandomGenerator.h             |  2 +-
 src/cpp-utils/random/RandomGeneratorThread.h         |  2 +-
 src/cryfs/impl/localstate/BasedirMetadata.cpp        |  2 +-
 test/cryfs/impl/config/CompatibilityTest.cpp         |  2 +-
 vendor/CMakeLists.txt                                |  1 -
 13 files changed, 17 insertions(+), 18 deletions(-)

--- a/src/blockstore/implementations/compressing/compressors/Gzip.cpp
+++ b/src/blockstore/implementations/compressing/compressors/Gzip.cpp
@@ -1,5 +1,5 @@
 #include "Gzip.h"
-#include <vendor_cryptopp/gzip.h>
+#include <cryptopp/gzip.h>
 
 using cpputils::Data;
 
--- a/src/cpp-utils/crypto/hash/Hash.cpp
+++ b/src/cpp-utils/crypto/hash/Hash.cpp
@@ -1,6 +1,6 @@
 #include "Hash.h"
 #include <cpp-utils/random/Random.h>
-#include <vendor_cryptopp/sha.h>
+#include <cryptopp/sha.h>
 
 using CryptoPP::SHA512;
 
--- a/src/cpp-utils/crypto/kdf/Scrypt.cpp
+++ b/src/cpp-utils/crypto/kdf/Scrypt.cpp
@@ -1,5 +1,5 @@
 #include "Scrypt.h"
-#include <vendor_cryptopp/scrypt.h>
+#include <cryptopp/scrypt.h>
 
 using std::string;
 
--- a/src/cpp-utils/crypto/symmetric/CFB_Cipher.h
+++ b/src/cpp-utils/crypto/symmetric/CFB_Cipher.h
@@ -6,7 +6,7 @@
 #include "../../data/Data.h"
 #include "../../random/Random.h"
 #include <boost/optional.hpp>
-#include <vendor_cryptopp/modes.h>
+#include <cryptopp/modes.h>
 #include "Cipher.h"
 #include "EncryptionKey.h"
 
--- a/src/cpp-utils/crypto/symmetric/GCM_Cipher.h
+++ b/src/cpp-utils/crypto/symmetric/GCM_Cipher.h
@@ -3,7 +3,7 @@
 #define MESSMER_CPPUTILS_CRYPTO_SYMMETRIC_GCMCIPHER_H_
 
 #include "AEAD_Cipher.h"
-#include <vendor_cryptopp/gcm.h>
+#include <cryptopp/gcm.h>
 
 namespace cpputils {
 
--- a/src/cpp-utils/crypto/symmetric/ciphers.h
+++ b/src/cpp-utils/crypto/symmetric/ciphers.h
@@ -2,12 +2,12 @@
 #ifndef MESSMER_CPPUTILS_CRYPTO_SYMMETRIC_CIPHERS_H_
 #define MESSMER_CPPUTILS_CRYPTO_SYMMETRIC_CIPHERS_H_
 
-#include <vendor_cryptopp/aes.h>
-#include <vendor_cryptopp/twofish.h>
-#include <vendor_cryptopp/serpent.h>
-#include <vendor_cryptopp/cast.h>
-#include <vendor_cryptopp/mars.h>
-#include <vendor_cryptopp/chachapoly.h>
+#include <cryptopp/aes.h>
+#include <cryptopp/twofish.h>
+#include <cryptopp/serpent.h>
+#include <cryptopp/cast.h>
+#include <cryptopp/mars.h>
+#include <cryptopp/chachapoly.h>
 #include "GCM_Cipher.h"
 #include "CFB_Cipher.h"
 
--- a/src/cpp-utils/data/Data.cpp
+++ b/src/cpp-utils/data/Data.cpp
@@ -1,6 +1,6 @@
 #include "Data.h"
 #include <stdexcept>
-#include <vendor_cryptopp/hex.h>
+#include <cryptopp/hex.h>
 
 using std::istream;
 using std::ofstream;
--- a/src/cpp-utils/data/FixedSizeData.h
+++ b/src/cpp-utils/data/FixedSizeData.h
@@ -2,7 +2,7 @@
 #ifndef MESSMER_CPPUTILS_DATA_FIXEDSIZEDATA_H_
 #define MESSMER_CPPUTILS_DATA_FIXEDSIZEDATA_H_
 
-#include <vendor_cryptopp/hex.h>
+#include <cryptopp/hex.h>
 #include <string>
 #include <array>
 #include <cstring>
--- a/src/cpp-utils/random/OSRandomGenerator.h
+++ b/src/cpp-utils/random/OSRandomGenerator.h
@@ -3,7 +3,7 @@
 #define MESSMER_CPPUTILS_RANDOM_OSRANDOMGENERATOR_H
 
 #include "RandomGenerator.h"
-#include <vendor_cryptopp/osrng.h>
+#include <cryptopp/osrng.h>
 
 namespace cpputils {
     class OSRandomGenerator final : public RandomGenerator {
--- a/src/cpp-utils/random/RandomGeneratorThread.h
+++ b/src/cpp-utils/random/RandomGeneratorThread.h
@@ -4,7 +4,7 @@
 
 #include "../thread/LoopThread.h"
 #include "ThreadsafeRandomDataBuffer.h"
-#include <vendor_cryptopp/osrng.h>
+#include <cryptopp/osrng.h>
 
 namespace cpputils {
     //TODO Test
--- a/src/cryfs/impl/localstate/BasedirMetadata.cpp
+++ b/src/cryfs/impl/localstate/BasedirMetadata.cpp
@@ -1,7 +1,7 @@
 #include "BasedirMetadata.h"
 #include <boost/property_tree/ptree.hpp>
 #include <boost/property_tree/json_parser.hpp>
-#include <vendor_cryptopp/sha.h>
+#include <cryptopp/sha.h>
 #include <boost/filesystem/operations.hpp>
 #include "LocalStateDir.h"
 #include <cpp-utils/logging/logging.h>
--- a/test/cryfs/impl/config/CompatibilityTest.cpp
+++ b/test/cryfs/impl/config/CompatibilityTest.cpp
@@ -2,7 +2,7 @@
 #include <vector>
 #include <boost/filesystem.hpp>
 #include <cpp-utils/data/Data.h>
-#include <vendor_cryptopp/hex.h>
+#include <cryptopp/hex.h>
 #include <cpp-utils/crypto/symmetric/ciphers.h>
 #include <cpp-utils/tempfile/TempFile.h>
 #include <cryfs/impl/config/CryConfigFile.h>
--- a/vendor/CMakeLists.txt
+++ b/vendor/CMakeLists.txt
@@ -1 +1 @@
-add_subdirectory(cryptopp)
+# add_subdirectory(cryptopp)
--- a/cmake-utils/Dependencies.cmake
+++ b/cmake-utils/Dependencies.cmake
@@ -25,9 +25,12 @@ find_package(CURL REQUIRED)
 add_library(CryfsDependencies_libcurl INTERFACE)
 target_link_libraries(CryfsDependencies_libcurl INTERFACE CURL::libcurl)
 
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(CryptoPP REQUIRED libcryptopp)
+
 # Setup gtest dependency
 if (BUILD_TESTING)
     find_package(GTest REQUIRED)
     add_library(CryfsDependencies_gtest INTERFACE)
     target_link_libraries(CryfsDependencies_gtest INTERFACE GTest::gtest GTest::gmock)
-endif()
\ No newline at end of file
+endif()
--- a/src/cpp-utils/CMakeLists.txt
+++ b/src/cpp-utils/CMakeLists.txt
@@ -71,7 +71,8 @@ target_link_libraries(${PROJECT_NAME} PU
 
 target_link_libraries(${PROJECT_NAME} PUBLIC ${CMAKE_DL_LIBS})
 
-target_link_libraries(${PROJECT_NAME} PUBLIC CryfsDependencies_spdlog cryfs_vendor_cryptopp CryfsDependencies_range-v3)
+target_link_libraries(${PROJECT_NAME} PUBLIC CryfsDependencies_spdlog
+	${CryptoPP_LIBRARIES} CryfsDependencies_range-v3)
 if(CRYFS_UPDATE_CHECKS)
     target_compile_definitions(${PROJECT_NAME} PUBLIC -DCRYFS_UPDATE_CHECKS)
     target_link_libraries(${PROJECT_NAME} PUBLIC CryfsDependencies_libcurl)
