diff --git a/ChaosTests/Cipher/Arc4CryptTests.cpp b/ChaosTests/Cipher/Arc4CryptTests.cpp index 67de73f..8abc503 100644 --- a/ChaosTests/Cipher/Arc4CryptTests.cpp +++ b/ChaosTests/Cipher/Arc4CryptTests.cpp @@ -170,3 +170,58 @@ TEST(Arc4CryptTests, EncryptOutIteratorUsageTest) ASSERT_EQ(expected, out); } } + +TEST(Arc4CryptTests, DecryptOutIteratorUsageTest) +{ + const std::array data = { 0x45, 0xA0, 0x1F, 0x64, 0x5F, 0xC3, 0x5B, + 0x38, 0x35, 0x52, 0x54, 0x4B, 0x9B, 0xF5 }; + const std::vector key = StrToU8Vec("Secret"); + + { + Arc4Crypt crypt(key.begin(), key.end()); + + std::array out; + out.fill(0); + + std::array expected = + { + 'A', 't', 't', 'a', 'c', 'k', ' ', 'a', 't', ' ', 'd', 'a', + 0x00, 0x00 + }; + + crypt.Decrypt(out.begin(), data.begin(), 12); + + ASSERT_EQ(expected, out); + } + + { + Arc4Crypt crypt(key.begin(), key.end()); + + std::array out; + out.fill(0); + + std::array expected = + { + 'A', 't', 't', 'a', 'c', 'k', ' ', + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }; + + crypt.Decrypt(out.begin(), data.begin(), 7); + + ASSERT_EQ(expected, out); + } + + { + Arc4Crypt crypt(key.begin(), key.end()); + + std::array out; + out.fill(0); + + std::array expected; + expected.fill(0); + + crypt.Decrypt(out.begin(), data.begin(), 0); + + ASSERT_EQ(expected, out); + } +}