diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a97d69..572318d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,15 @@ ############################################################################### -cmake_minimum_required(VERSION 3.7.0) +cmake_minimum_required(VERSION 3.20.0) project(cruft-crypto CXX) + +############################################################################### +nc_deps(util) + find_package (fmt REQUIRED) +############################################################################### list (APPEND components hash/blake hash/blake2 @@ -36,6 +41,7 @@ list (APPEND components ############################################################################### list (APPEND sources fwd.hpp) + foreach (c ${components}) list (APPEND sources "${c}.cpp" "${c}.hpp") endforeach() @@ -45,7 +51,34 @@ list (APPEND sources hash/blake/traits.hpp ) +list (TRANSFORM sources PREPEND "cruft/crypto/") + +############################################################################### +add_library (libcruft-crypto STATIC ${sources}) +target_link_libraries (libcruft-crypto PUBLIC cruft::util PRIVATE fmt::fmt) + + +##----------------------------------------------------------------------------- +target_include_directories (libcruft-crypto + PUBLIC + $ +) + +add_library(cruft::crypto ALIAS libcruft-crypto) + + +############################################################################### +add_executable (crypto_bench tools/bench.cpp) +target_link_libraries (crypto_bench cruft::crypto) + + +##----------------------------------------------------------------------------- +add_executable (crypto_hash tools/hash.cpp) +target_link_libraries (crypto_hash cruft::crypto) + + +############################################################################### option (TESTS "enable unit testing" ON) if (TESTS) @@ -55,28 +88,13 @@ if (TESTS) foreach (t ${components}) string(REPLACE "/" "_" name "test/${t}") add_executable(crypto_${name} test/${t}.cpp) - target_link_libraries(crypto_${name} PRIVATE cruft-crypto) + target_link_libraries(crypto_${name} PRIVATE cruft::crypto) target_include_directories(crypto_${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) add_test(NAME crypto_${name} COMMAND crypto_${name}) endforeach() endif () -############################################################################### -add_library (cruft-crypto STATIC ${sources}) -target_link_libraries (cruft-crypto INTERFACE cruft PRIVATE fmt::fmt) - - -##----------------------------------------------------------------------------- -add_executable (crypto_bench tools/bench.cpp) -target_link_libraries (crypto_bench cruft-crypto) - - -##----------------------------------------------------------------------------- -add_executable (crypto_hash tools/hash.cpp) -target_link_libraries (crypto_hash cruft-crypto) - - ############################################################################### configure_file(libcruft-crypto.pc.in libcruft-crypto.pc) configure_file(Doxyfile.in Doxyfile) diff --git a/block/rc2.cpp b/cruft/crypto/block/rc2.cpp similarity index 100% rename from block/rc2.cpp rename to cruft/crypto/block/rc2.cpp diff --git a/block/rc2.hpp b/cruft/crypto/block/rc2.hpp similarity index 100% rename from block/rc2.hpp rename to cruft/crypto/block/rc2.hpp diff --git a/block/rc5.cpp b/cruft/crypto/block/rc5.cpp similarity index 100% rename from block/rc5.cpp rename to cruft/crypto/block/rc5.cpp diff --git a/block/rc5.hpp b/cruft/crypto/block/rc5.hpp similarity index 100% rename from block/rc5.hpp rename to cruft/crypto/block/rc5.hpp diff --git a/block/rc6.cpp b/cruft/crypto/block/rc6.cpp similarity index 100% rename from block/rc6.cpp rename to cruft/crypto/block/rc6.cpp diff --git a/block/rc6.hpp b/cruft/crypto/block/rc6.hpp similarity index 100% rename from block/rc6.hpp rename to cruft/crypto/block/rc6.hpp diff --git a/block/speck.cpp b/cruft/crypto/block/speck.cpp similarity index 100% rename from block/speck.cpp rename to cruft/crypto/block/speck.cpp diff --git a/block/speck.hpp b/cruft/crypto/block/speck.hpp similarity index 100% rename from block/speck.hpp rename to cruft/crypto/block/speck.hpp diff --git a/block/tea.cpp b/cruft/crypto/block/tea.cpp similarity index 100% rename from block/tea.cpp rename to cruft/crypto/block/tea.cpp diff --git a/block/tea.hpp b/cruft/crypto/block/tea.hpp similarity index 100% rename from block/tea.hpp rename to cruft/crypto/block/tea.hpp diff --git a/block/xtea.cpp b/cruft/crypto/block/xtea.cpp similarity index 100% rename from block/xtea.cpp rename to cruft/crypto/block/xtea.cpp diff --git a/block/xtea.hpp b/cruft/crypto/block/xtea.hpp similarity index 100% rename from block/xtea.hpp rename to cruft/crypto/block/xtea.hpp diff --git a/block/xxtea.cpp b/cruft/crypto/block/xxtea.cpp similarity index 100% rename from block/xxtea.cpp rename to cruft/crypto/block/xxtea.cpp diff --git a/block/xxtea.hpp b/cruft/crypto/block/xxtea.hpp similarity index 100% rename from block/xxtea.hpp rename to cruft/crypto/block/xxtea.hpp diff --git a/fwd.hpp b/cruft/crypto/fwd.hpp similarity index 100% rename from fwd.hpp rename to cruft/crypto/fwd.hpp diff --git a/hash/blake.cpp b/cruft/crypto/hash/blake.cpp similarity index 100% rename from hash/blake.cpp rename to cruft/crypto/hash/blake.cpp diff --git a/hash/blake.hpp b/cruft/crypto/hash/blake.hpp similarity index 100% rename from hash/blake.hpp rename to cruft/crypto/hash/blake.hpp diff --git a/hash/blake/traits.cpp b/cruft/crypto/hash/blake/traits.cpp similarity index 100% rename from hash/blake/traits.cpp rename to cruft/crypto/hash/blake/traits.cpp diff --git a/hash/blake/traits.hpp b/cruft/crypto/hash/blake/traits.hpp similarity index 100% rename from hash/blake/traits.hpp rename to cruft/crypto/hash/blake/traits.hpp diff --git a/hash/blake2.cpp b/cruft/crypto/hash/blake2.cpp similarity index 100% rename from hash/blake2.cpp rename to cruft/crypto/hash/blake2.cpp diff --git a/hash/blake2.hpp b/cruft/crypto/hash/blake2.hpp similarity index 100% rename from hash/blake2.hpp rename to cruft/crypto/hash/blake2.hpp diff --git a/hash/hmac.cpp b/cruft/crypto/hash/hmac.cpp similarity index 100% rename from hash/hmac.cpp rename to cruft/crypto/hash/hmac.cpp diff --git a/hash/hmac.hpp b/cruft/crypto/hash/hmac.hpp similarity index 100% rename from hash/hmac.hpp rename to cruft/crypto/hash/hmac.hpp diff --git a/hash/hotp.cpp b/cruft/crypto/hash/hotp.cpp similarity index 100% rename from hash/hotp.cpp rename to cruft/crypto/hash/hotp.cpp diff --git a/hash/hotp.hpp b/cruft/crypto/hash/hotp.hpp similarity index 100% rename from hash/hotp.hpp rename to cruft/crypto/hash/hotp.hpp diff --git a/hash/md2.cpp b/cruft/crypto/hash/md2.cpp similarity index 100% rename from hash/md2.cpp rename to cruft/crypto/hash/md2.cpp diff --git a/hash/md2.hpp b/cruft/crypto/hash/md2.hpp similarity index 100% rename from hash/md2.hpp rename to cruft/crypto/hash/md2.hpp diff --git a/hash/md4.cpp b/cruft/crypto/hash/md4.cpp similarity index 100% rename from hash/md4.cpp rename to cruft/crypto/hash/md4.cpp diff --git a/hash/md4.hpp b/cruft/crypto/hash/md4.hpp similarity index 100% rename from hash/md4.hpp rename to cruft/crypto/hash/md4.hpp diff --git a/hash/md5.cpp b/cruft/crypto/hash/md5.cpp similarity index 100% rename from hash/md5.cpp rename to cruft/crypto/hash/md5.cpp diff --git a/hash/md5.hpp b/cruft/crypto/hash/md5.hpp similarity index 100% rename from hash/md5.hpp rename to cruft/crypto/hash/md5.hpp diff --git a/hash/md6.cpp b/cruft/crypto/hash/md6.cpp similarity index 100% rename from hash/md6.cpp rename to cruft/crypto/hash/md6.cpp diff --git a/hash/md6.hpp b/cruft/crypto/hash/md6.hpp similarity index 100% rename from hash/md6.hpp rename to cruft/crypto/hash/md6.hpp diff --git a/hash/pbkdf2.cpp b/cruft/crypto/hash/pbkdf2.cpp similarity index 100% rename from hash/pbkdf2.cpp rename to cruft/crypto/hash/pbkdf2.cpp diff --git a/hash/pbkdf2.hpp b/cruft/crypto/hash/pbkdf2.hpp similarity index 100% rename from hash/pbkdf2.hpp rename to cruft/crypto/hash/pbkdf2.hpp diff --git a/hash/ripemd.cpp b/cruft/crypto/hash/ripemd.cpp similarity index 100% rename from hash/ripemd.cpp rename to cruft/crypto/hash/ripemd.cpp diff --git a/hash/ripemd.hpp b/cruft/crypto/hash/ripemd.hpp similarity index 100% rename from hash/ripemd.hpp rename to cruft/crypto/hash/ripemd.hpp diff --git a/hash/sha1.cpp b/cruft/crypto/hash/sha1.cpp similarity index 100% rename from hash/sha1.cpp rename to cruft/crypto/hash/sha1.cpp diff --git a/hash/sha1.hpp b/cruft/crypto/hash/sha1.hpp similarity index 100% rename from hash/sha1.hpp rename to cruft/crypto/hash/sha1.hpp diff --git a/hash/sha2.cpp b/cruft/crypto/hash/sha2.cpp similarity index 100% rename from hash/sha2.cpp rename to cruft/crypto/hash/sha2.cpp diff --git a/hash/sha2.hpp b/cruft/crypto/hash/sha2.hpp similarity index 100% rename from hash/sha2.hpp rename to cruft/crypto/hash/sha2.hpp diff --git a/hash/sha3.cpp b/cruft/crypto/hash/sha3.cpp similarity index 100% rename from hash/sha3.cpp rename to cruft/crypto/hash/sha3.cpp diff --git a/hash/sha3.hpp b/cruft/crypto/hash/sha3.hpp similarity index 100% rename from hash/sha3.hpp rename to cruft/crypto/hash/sha3.hpp diff --git a/hash/tiger.cpp b/cruft/crypto/hash/tiger.cpp similarity index 100% rename from hash/tiger.cpp rename to cruft/crypto/hash/tiger.cpp diff --git a/hash/tiger.hpp b/cruft/crypto/hash/tiger.hpp similarity index 100% rename from hash/tiger.hpp rename to cruft/crypto/hash/tiger.hpp diff --git a/stream/chacha.cpp b/cruft/crypto/stream/chacha.cpp similarity index 100% rename from stream/chacha.cpp rename to cruft/crypto/stream/chacha.cpp diff --git a/stream/chacha.hpp b/cruft/crypto/stream/chacha.hpp similarity index 100% rename from stream/chacha.hpp rename to cruft/crypto/stream/chacha.hpp diff --git a/stream/rabbit.cpp b/cruft/crypto/stream/rabbit.cpp similarity index 100% rename from stream/rabbit.cpp rename to cruft/crypto/stream/rabbit.cpp diff --git a/stream/rabbit.hpp b/cruft/crypto/stream/rabbit.hpp similarity index 100% rename from stream/rabbit.hpp rename to cruft/crypto/stream/rabbit.hpp diff --git a/stream/rc4.cpp b/cruft/crypto/stream/rc4.cpp similarity index 100% rename from stream/rc4.cpp rename to cruft/crypto/stream/rc4.cpp diff --git a/stream/rc4.hpp b/cruft/crypto/stream/rc4.hpp similarity index 100% rename from stream/rc4.hpp rename to cruft/crypto/stream/rc4.hpp diff --git a/stream/salsa.cpp b/cruft/crypto/stream/salsa.cpp similarity index 100% rename from stream/salsa.cpp rename to cruft/crypto/stream/salsa.cpp diff --git a/stream/salsa.hpp b/cruft/crypto/stream/salsa.hpp similarity index 100% rename from stream/salsa.hpp rename to cruft/crypto/stream/salsa.hpp diff --git a/test/block/rc2.cpp b/test/block/rc2.cpp index 9b07cf8..9152bdf 100644 --- a/test/block/rc2.cpp +++ b/test/block/rc2.cpp @@ -1,6 +1,6 @@ #include -#include "block/rc2.hpp" +#include #include diff --git a/test/block/speck.cpp b/test/block/speck.cpp index 3e2767d..244f676 100644 --- a/test/block/speck.cpp +++ b/test/block/speck.cpp @@ -1,6 +1,6 @@ #include -#include "block/speck.hpp" +#include int diff --git a/test/block/tea.cpp b/test/block/tea.cpp index 912e1c1..23d9ccb 100644 --- a/test/block/tea.cpp +++ b/test/block/tea.cpp @@ -1,4 +1,4 @@ -#include "block/tea.hpp" +#include #include #include diff --git a/test/block/xtea.cpp b/test/block/xtea.cpp index fe09c0e..4e4fe21 100644 --- a/test/block/xtea.cpp +++ b/test/block/xtea.cpp @@ -1,4 +1,4 @@ -#include "block/xtea.hpp" +#include #include #include diff --git a/test/block/xxtea.cpp b/test/block/xxtea.cpp index a3b8778..f16f87e 100644 --- a/test/block/xxtea.cpp +++ b/test/block/xxtea.cpp @@ -1,4 +1,4 @@ -#include "block/xxtea.hpp" +#include #include #include diff --git a/test/hash/blake.cpp b/test/hash/blake.cpp index 5573860..63c7aab 100644 --- a/test/hash/blake.cpp +++ b/test/hash/blake.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -#include "hash/blake.hpp" +#include #include #include diff --git a/test/hash/blake2.cpp b/test/hash/blake2.cpp index a57d58b..deb61a1 100644 --- a/test/hash/blake2.cpp +++ b/test/hash/blake2.cpp @@ -1,7 +1,7 @@ #include #include -#include "hash/blake2.hpp" +#include using cruft::crypto::hash::blake2; diff --git a/test/hash/hmac.cpp b/test/hash/hmac.cpp index 19621fd..1b39d0e 100644 --- a/test/hash/hmac.cpp +++ b/test/hash/hmac.cpp @@ -1,7 +1,7 @@ -#include "hash/hmac.hpp" +#include -#include "hash/md5.hpp" -#include "hash/sha1.hpp" +#include +#include #include #include diff --git a/test/hash/hotp.cpp b/test/hash/hotp.cpp index 8538b05..c5c220a 100644 --- a/test/hash/hotp.cpp +++ b/test/hash/hotp.cpp @@ -1,4 +1,4 @@ -#include "hash/hotp.hpp" +#include #include #include diff --git a/test/hash/md2.cpp b/test/hash/md2.cpp index ed6fc45..288b172 100644 --- a/test/hash/md2.cpp +++ b/test/hash/md2.cpp @@ -1,4 +1,4 @@ -#include "hash/md2.hpp" +#include #include diff --git a/test/hash/md4.cpp b/test/hash/md4.cpp index 9896fdc..cbd182c 100644 --- a/test/hash/md4.cpp +++ b/test/hash/md4.cpp @@ -1,4 +1,4 @@ -#include "hash/md4.hpp" +#include #include diff --git a/test/hash/md5.cpp b/test/hash/md5.cpp index 9c4198d..2a6e719 100644 --- a/test/hash/md5.cpp +++ b/test/hash/md5.cpp @@ -1,4 +1,4 @@ -#include "hash/md5.hpp" +#include #include diff --git a/test/hash/md6.cpp b/test/hash/md6.cpp index df7d0b2..3abda6e 100644 --- a/test/hash/md6.cpp +++ b/test/hash/md6.cpp @@ -1,3 +1,3 @@ -#include "hash/md6.hpp" +#include int main () {} \ No newline at end of file diff --git a/test/hash/ripemd.cpp b/test/hash/ripemd.cpp index 0369e5f..5aa200d 100644 --- a/test/hash/ripemd.cpp +++ b/test/hash/ripemd.cpp @@ -1,4 +1,4 @@ -#include "hash/ripemd.hpp" +#include #include #include diff --git a/test/hash/sha1.cpp b/test/hash/sha1.cpp index 0778723..4097618 100644 --- a/test/hash/sha1.cpp +++ b/test/hash/sha1.cpp @@ -1,4 +1,4 @@ -#include "hash/sha1.hpp" +#include #include #include diff --git a/test/hash/sha2.cpp b/test/hash/sha2.cpp index 49cc39c..c9326e2 100644 --- a/test/hash/sha2.cpp +++ b/test/hash/sha2.cpp @@ -1,4 +1,4 @@ -#include "hash/sha2.hpp" +#include #include diff --git a/test/hash/tiger.cpp b/test/hash/tiger.cpp index 11570cb..74ee64d 100644 --- a/test/hash/tiger.cpp +++ b/test/hash/tiger.cpp @@ -1,4 +1,4 @@ -#include "hash/tiger.hpp" +#include #include #include diff --git a/test/stream/rc4.cpp b/test/stream/rc4.cpp index 85ea9ad..95731f4 100644 --- a/test/stream/rc4.cpp +++ b/test/stream/rc4.cpp @@ -1,4 +1,4 @@ -#include "stream/rc4.hpp" +#include #include #include diff --git a/test/stream/salsa.cpp b/test/stream/salsa.cpp index f58a742..81c187c 100644 --- a/test/stream/salsa.cpp +++ b/test/stream/salsa.cpp @@ -1,4 +1,4 @@ -#include "stream/salsa.hpp" +#include #include diff --git a/tools/hash.cpp b/tools/hash.cpp index 8de2d2c..f17439e 100644 --- a/tools/hash.cpp +++ b/tools/hash.cpp @@ -7,12 +7,12 @@ * 2014-2016, Danny Robson */ -#include "../hash/md2.hpp" -#include "../hash/md4.hpp" -#include "../hash/md5.hpp" -#include "../hash/ripemd.hpp" -#include "../hash/sha1.hpp" -#include "../hash/sha2.hpp" +#include +#include +#include +#include +#include +#include #include #include