|
|
@ -10,23 +10,22 @@ struct RC6test : public test_scaffold { |
|
|
|
|
|
|
|
virtual int run() { |
|
|
|
using rc = RC6<>; |
|
|
|
auto res = 0; |
|
|
|
{ |
|
|
|
rc::key_type key = {0x00000000, 0x00000000, 0x00000000, 0x00000000}; |
|
|
|
rc::block_type plaintext = {0,0,0,0}; |
|
|
|
rc::block_type expected = {0x8fc3a536,0x56b1f778,0xc129df4e,0x9848a41e}; |
|
|
|
auto cipher = rc{key}; |
|
|
|
plaintext = cipher.encrypt(plaintext); |
|
|
|
res += plaintext != expected; |
|
|
|
} |
|
|
|
{ |
|
|
|
rc::key_type key = {0x80000000, 0x00000000, 0x00000000, 0x00000000}; |
|
|
|
rc::block_type plaintext = {0,0,0,0}; |
|
|
|
rc::block_type expected = {0x1AD578A0, 0x2A081628, 0x50A15A15, 0x52A17AD4}; |
|
|
|
auto test = [](rc::key_type key, rc::block_type plaintext, rc::block_type expected) -> bool { |
|
|
|
auto cipher = rc{key}; |
|
|
|
plaintext = cipher.encrypt(plaintext); |
|
|
|
res += plaintext != expected; |
|
|
|
} |
|
|
|
return plaintext != expected; |
|
|
|
}; |
|
|
|
auto res = 0; |
|
|
|
res += test( |
|
|
|
{0, 0, 0, 0}, |
|
|
|
{0,0,0,0}, |
|
|
|
{0x8fc3a536,0x56b1f778,0xc129df4e,0x9848a41e} |
|
|
|
); |
|
|
|
res += test( |
|
|
|
{0x80000000, 0x00000000, 0x00000000, 0x00000000}, |
|
|
|
{0,0,0,0}, |
|
|
|
{0x1AD578A0, 0x2A081628, 0x50A15A15, 0x52A17AD4} |
|
|
|
); |
|
|
|
return res; |
|
|
|
} |
|
|
|
}; |
|
|
|