build: avoid repeating module names for sources and tests
This commit is contained in:
parent
c2ef2ed89c
commit
5f32d21c59
108
CMakeLists.txt
108
CMakeLists.txt
@ -3,91 +3,47 @@ cmake_minimum_required(VERSION 3.7.0)
|
|||||||
project(cruft-crypto CXX)
|
project(cruft-crypto CXX)
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
list (APPEND components
|
||||||
list (APPEND sources
|
hash/blake
|
||||||
fwd.hpp
|
hash/blake2
|
||||||
|
hash/md2
|
||||||
hash/blake.cpp
|
hash/md4
|
||||||
hash/blake.hpp
|
hash/md5
|
||||||
hash/blake2.cpp
|
hash/md6
|
||||||
hash/blake2.hpp
|
hash/ripemd
|
||||||
hash/md2.cpp
|
hash/sha1
|
||||||
hash/md2.hpp
|
hash/sha2
|
||||||
hash/md4.cpp
|
hash/pbkdf2
|
||||||
hash/md4.hpp
|
hash/hmac
|
||||||
hash/md5.cpp
|
hash/hotp
|
||||||
hash/md5.hpp
|
stream/chacha
|
||||||
hash/md6.cpp
|
stream/rabbit
|
||||||
hash/md6.hpp
|
stream/rc4
|
||||||
hash/ripemd.cpp
|
stream/salsa
|
||||||
hash/ripemd.hpp
|
block/rc2
|
||||||
hash/sha1.cpp
|
block/rc5
|
||||||
hash/sha1.hpp
|
block/rc6
|
||||||
hash/sha2.cpp
|
block/speck
|
||||||
hash/sha2.hpp
|
block/tea
|
||||||
|
block/xtea
|
||||||
hash/pbkdf2.cpp
|
block/xxtea
|
||||||
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
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
list (APPEND sources fwd.hpp)
|
||||||
|
foreach (c ${components})
|
||||||
|
list (APPEND sources "${c}.cpp" "${c}.hpp")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
option (TESTS "enable unit testing" ON)
|
option (TESTS "enable unit testing" ON)
|
||||||
|
|
||||||
if (TESTS)
|
if (TESTS)
|
||||||
include (CTest)
|
include (CTest)
|
||||||
enable_testing ()
|
enable_testing ()
|
||||||
|
|
||||||
list (APPEND tests
|
foreach (t ${components})
|
||||||
hash/blake
|
|
||||||
hash/blake2
|
|
||||||
hash/md2
|
|
||||||
hash/md4
|
|
||||||
hash/md5
|
|
||||||
hash/md6
|
|
||||||
hash/ripemd
|
|
||||||
hash/sha1
|
|
||||||
hash/sha2
|
|
||||||
|
|
||||||
hash/hmac
|
|
||||||
hash/hotp
|
|
||||||
|
|
||||||
stream/rc4
|
|
||||||
stream/salsa
|
|
||||||
|
|
||||||
block/speck
|
|
||||||
block/tea
|
|
||||||
block/xtea
|
|
||||||
block/xxtea
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach (t ${tests})
|
|
||||||
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