Skip to content

Instantly share code, notes, and snippets.

@mugwort-rc
Last active August 29, 2015 14:02
Show Gist options
  • Save mugwort-rc/46cf754611577d318bf8 to your computer and use it in GitHub Desktop.
Save mugwort-rc/46cf754611577d318bf8 to your computer and use it in GitHub Desktop.
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from IDEATest
[ RUN ] IDEATest.test_idea_ecb
test_idea.cpp:17: Failure
Value of: CIPHER
Actual: "\xB1\xF5\xF7\xF8y\x1" "7\xF"
Expected: idea.encrypt(PLAIN)
Which is: "\xF\xE4\xF7\xF3v\xED\x87\f"
test_idea.cpp:18: Failure
Value of: PLAIN
Actual: "\0\0\0\0\0\0\0\0"
Expected: idea.decrypt(CIPHER)
Which is: "\0\x3\0\x1\xFF\xFF\0\0"
test_idea.cpp:21: Failure
Value of: PLAIN
Actual: "\0\0\0\0\0\0\0\0"
Expected: newidea.decrypt(newidea.encrypt(PLAIN))
Which is: "\0\x1\0\x1\0\x1\0\0"
[ FAILED ] IDEATest.test_idea_ecb (1 ms)
[----------] 1 test from IDEATest (1 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (1 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] IDEATest.test_idea_ecb
1 FAILED TEST
#include <gtest/gtest.h>
#include <OpenPGP/Encryptions/IDEA.h>
TEST(IDEATest, test_idea_ecb) {
//!
//! Test vector from <https://www.cosic.esat.kuleuven.be/nessie/testvectors/bc/idea/Idea-128-64.verified.test-vectors>
//!
//! Set1, vector" 1
//!
std::string KEY = unhexlify("80000000000000000000000000000000");
std::string PLAIN = unhexlify("0000000000000000");
std::string CIPHER = unhexlify("B1F5F7F87901370F");
auto idea = IDEA(KEY);
EXPECT_EQ(idea.encrypt(PLAIN), CIPHER);
EXPECT_EQ(idea.decrypt(CIPHER), PLAIN);
auto newidea = IDEA(KEY);
EXPECT_EQ(newidea.decrypt(newidea.encrypt(PLAIN)), PLAIN);
}
int main(int argc, char *argv[]) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment