build: avoid repeating module names for sources and tests
This commit is contained in:
parent
c2ef2ed89c
commit
5f32d21c59
@ -3,68 +3,7 @@ cmake_minimum_required(VERSION 3.7.0)
|
|||||||
project(cruft-crypto CXX)
|
project(cruft-crypto CXX)
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
list (APPEND components
|
||||||
list (APPEND sources
|
|
||||||
fwd.hpp
|
|
||||||
|
|
||||||
hash/blake.cpp
|
|
||||||
hash/blake.hpp
|
|
||||||
hash/blake2.cpp
|
|
||||||
hash/blake2.hpp
|
|
||||||
hash/md2.cpp
|
|
||||||
hash/md2.hpp
|
|
||||||
hash/md4.cpp
|
|
||||||
hash/md4.hpp
|
|
||||||
hash/md5.cpp
|
|
||||||
hash/md5.hpp
|
|
||||||
hash/md6.cpp
|
|
||||||
hash/md6.hpp
|
|
||||||
hash/ripemd.cpp
|
|
||||||
hash/ripemd.hpp
|
|
||||||
hash/sha1.cpp
|
|
||||||
hash/sha1.hpp
|
|
||||||
hash/sha2.cpp
|
|
||||||
hash/sha2.hpp
|
|
||||||
|
|
||||||
hash/pbkdf2.cpp
|
|
||||||
hash/pbkdf2.hpp
|
|
||||||
hash/hmac.cpp
|
|
||||||
hash/hmac.hpp
|
|
||||||
|
|
||||||
hash/hotp.cpp
|
|
||||||
hash/hotp.hpp
|
|
||||||
|
|
||||||
stream/chacha.cpp
|
|
||||||
stream/chacha.hpp
|
|
||||||
stream/rabbit.cpp
|
|
||||||
stream/rabbit.hpp
|
|
||||||
stream/rc4.cpp
|
|
||||||
stream/rc4.hpp
|
|
||||||
stream/salsa.cpp
|
|
||||||
stream/salsa.hpp
|
|
||||||
|
|
||||||
block/rc5.cpp
|
|
||||||
block/rc5.hpp
|
|
||||||
block/rc6.cpp
|
|
||||||
block/rc6.hpp
|
|
||||||
block/speck.cpp
|
|
||||||
block/speck.hpp
|
|
||||||
block/tea.cpp
|
|
||||||
block/tea.hpp
|
|
||||||
block/xtea.cpp
|
|
||||||
block/xtea.hpp
|
|
||||||
block/xxtea.cpp
|
|
||||||
block/xxtea.hpp
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
option (TESTS "enable unit testing" ON)
|
|
||||||
|
|
||||||
if (TESTS)
|
|
||||||
include (CTest)
|
|
||||||
enable_testing ()
|
|
||||||
|
|
||||||
list (APPEND tests
|
|
||||||
hash/blake
|
hash/blake
|
||||||
hash/blake2
|
hash/blake2
|
||||||
hash/md2
|
hash/md2
|
||||||
@ -74,20 +13,37 @@ if (TESTS)
|
|||||||
hash/ripemd
|
hash/ripemd
|
||||||
hash/sha1
|
hash/sha1
|
||||||
hash/sha2
|
hash/sha2
|
||||||
|
hash/pbkdf2
|
||||||
hash/hmac
|
hash/hmac
|
||||||
hash/hotp
|
hash/hotp
|
||||||
|
stream/chacha
|
||||||
|
stream/rabbit
|
||||||
stream/rc4
|
stream/rc4
|
||||||
stream/salsa
|
stream/salsa
|
||||||
|
block/rc2
|
||||||
|
block/rc5
|
||||||
|
block/rc6
|
||||||
block/speck
|
block/speck
|
||||||
block/tea
|
block/tea
|
||||||
block/xtea
|
block/xtea
|
||||||
block/xxtea
|
block/xxtea
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach (t ${tests})
|
|
||||||
|
###############################################################################
|
||||||
|
list (APPEND sources fwd.hpp)
|
||||||
|
foreach (c ${components})
|
||||||
|
list (APPEND sources "${c}.cpp" "${c}.hpp")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
|
option (TESTS "enable unit testing" ON)
|
||||||
|
|
||||||
|
if (TESTS)
|
||||||
|
include (CTest)
|
||||||
|
enable_testing ()
|
||||||
|
|
||||||
|
foreach (t ${components})
|
||||||
string(REPLACE "/" "_" name "test/${t}")
|
string(REPLACE "/" "_" name "test/${t}")
|
||||||
add_executable(crypto_${name} test/${t}.cpp)
|
add_executable(crypto_${name} test/${t}.cpp)
|
||||||
target_link_libraries(crypto_${name} PRIVATE cruft-crypto)
|
target_link_libraries(crypto_${name} PRIVATE cruft-crypto)
|
||||||
|
13
block/rc2.cpp
Normal file
13
block/rc2.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*
|
||||||
|
* Copyright 2018 Danny Robson <danny@nerdcruft.net>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rc2.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
32
block/rc2.hpp
Normal file
32
block/rc2.hpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*
|
||||||
|
* Copyright 2018 Danny Robson <danny@nerdcruft.net>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include <cruft/util/std.hpp>
|
||||||
|
#include <cruft/util/view.hpp>
|
||||||
|
|
||||||
|
namespace cruft::crypto::block {
|
||||||
|
/// An implementation of the RC2 block cipher (RFC2268)
|
||||||
|
class rc2 {
|
||||||
|
public:
|
||||||
|
using word_t = u16;
|
||||||
|
static constexpr auto block_size = sizeof (word_t) * 4;
|
||||||
|
|
||||||
|
explicit rc2 (cruft::view<u16 const*> key);
|
||||||
|
|
||||||
|
std::array<word_t,4> encrypt (std::array<word_t,4> src) const;
|
||||||
|
std::array<word_t,4> decrypt (std::array<word_t,4> src) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::array<u16,64> m_key;
|
||||||
|
};
|
||||||
|
}
|
3
test/block/rc2.cpp
Normal file
3
test/block/rc2.cpp
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#include "block/rc2.hpp"
|
||||||
|
|
||||||
|
int main () { }
|
1
test/block/rc5.cpp
Normal file
1
test/block/rc5.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
int main () { }
|
1
test/block/rc6.cpp
Normal file
1
test/block/rc6.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
int main () { }
|
1
test/hash/pbkdf2.cpp
Normal file
1
test/hash/pbkdf2.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
int main () { }
|
1
test/stream/chacha.cpp
Normal file
1
test/stream/chacha.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
int main () { }
|
1
test/stream/rabbit.cpp
Normal file
1
test/stream/rabbit.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
int main () { }
|
Loading…
Reference in New Issue
Block a user