aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-08-08 16:39:05 -0400
committerJack Lloyd <[email protected]>2018-08-08 16:39:05 -0400
commitbab49afef583a32b4e084b6a56bb36911b528331 (patch)
tree80bff04a09a8e301fe25af7d05f3aa079fda9859
parent2029ea0a633ef3060d4a2b819c60ca97e9d9512d (diff)
Add a test of Threefish-512 tweak functionality
-rw-r--r--src/tests/data/block/threefish.vec5
-rw-r--r--src/tests/test_block.cpp15
2 files changed, 19 insertions, 1 deletions
diff --git a/src/tests/data/block/threefish.vec b/src/tests/data/block/threefish.vec
index dfaccb7ff..031dba7e8 100644
--- a/src/tests/data/block/threefish.vec
+++ b/src/tests/data/block/threefish.vec
@@ -18,3 +18,8 @@ Key = F13CA06760DD9BBEAB87B6C56F3BBBDBE9D08A77978B942AC02D471DC10268F2261C3D4330
In = B1A2BBC6EF6025BC40EB3822161F36E375D1BB0AEE3186FBD19E47C5D479947B7BC2F8586E35F0CFF7E7F03084B0B7B1F1AB3961A580A3E97EB41EA14A6D7BBEB1A2BBC6EF6025BC40EB3822161F36E375D1BB0AEE3186FBD19E47C5D479947B7BC2F8586E35F0CFF7E7F03084B0B7B1F1AB3961A580A3E97EB41EA14A6D7BBF
Out = 1BEC82CBA1357566B34E1CF1FBF123A141C8F4089F6E4CE3209AEA10095AEC93C900D068BDC7F7A2DD58513C11DEC956B93169B1C4F24CEDE31A265DE83E36B4073CB5F8FABFA17DB751477F294EB3DD4ACD92B78397331FCC36A9C3D3055B81D867CBDD56279037373359CA1832669AF4B87A1F2FDAF8D36E2FB7A6D19F5D45
+
+Key = 101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f
+Tweak = 000102030405060708090a0b0c0d0e0f
+In = fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0
+Out = e304439626d45a2cb401cad8d636249a6338330eb06d45dd8b36b90e97254779272a0a8d99463504784420ea18c9a725af11dffea10162348927673d5c1caf3d
diff --git a/src/tests/test_block.cpp b/src/tests/test_block.cpp
index 111e79b4b..7a5c8492b 100644
--- a/src/tests/test_block.cpp
+++ b/src/tests/test_block.cpp
@@ -10,12 +10,16 @@
#include <botan/block_cipher.h>
+#if defined(BOTAN_HAS_THREEFISH_512)
+ #include <botan/threefish_512.h>
+#endif
+
namespace Botan_Tests {
class Block_Cipher_Tests final : public Text_Based_Test
{
public:
- Block_Cipher_Tests() : Text_Based_Test("block", "Key,In,Out", "Iterations") {}
+ Block_Cipher_Tests() : Text_Based_Test("block", "Key,In,Out", "Tweak,Iterations") {}
std::vector<std::string> possible_providers(const std::string& algo) override
{
@@ -27,6 +31,7 @@ class Block_Cipher_Tests final : public Text_Based_Test
const std::vector<uint8_t> key = vars.get_req_bin("Key");
const std::vector<uint8_t> input = vars.get_req_bin("In");
const std::vector<uint8_t> expected = vars.get_req_bin("Out");
+ const std::vector<uint8_t> tweak = vars.get_opt_bin("Tweak");
const size_t iterations = vars.get_opt_sz("Iterations", 1);
Test::Result result(algo);
@@ -87,6 +92,14 @@ class Block_Cipher_Tests final : public Text_Based_Test
cipher->set_key(key);
+ if(tweak.size() > 0)
+ {
+ Botan::Threefish_512* t512 = dynamic_cast<Botan::Threefish_512*>(cipher.get());
+ result.confirm("Only Threefish supports tweaks", t512);
+ if(t512)
+ t512->set_tweak(tweak.data(), tweak.size());
+ }
+
// Test that clone works and does not affect parent object
std::unique_ptr<Botan::BlockCipher> clone(cipher->clone());
result.confirm("Clone has different pointer", cipher.get() != clone.get());