Ludovic 'Archivist' Lagouardette 4 лет назад
Родитель
Сommit
42e3ae6c81
1 измененных файлов: 14 добавлений и 15 удалений
  1. +14
    -15
      tests/rc6_generic.cpp

+ 14
- 15
tests/rc6_generic.cpp Просмотреть файл

@ -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;
}
};

Загрузка…
Отмена
Сохранить