General Purpose library for Freestanding C++ and POSIX systems
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

56 行
1.1 KiB

#include "rc6_generic.hpp"
#include "test_scaffold.h"
#include <iostream>
#include <ios>
struct RC6test : public test_scaffold {
RC6test() {
name = __FILE__ ":1";
}
virtual int run() {
using rc = RC6<>;
auto test = [](rc::key_type key, rc::block_type plaintext, rc::block_type expected) -> bool {
auto cipher = rc{key};
plaintext = cipher.encrypt(plaintext);
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;
}
};
append_test dummy_szfhu5463(new RC6test{});
struct RC6test2 : public test_scaffold {
RC6test2() {
name = __FILE__ ":2";
}
virtual int run() {
using rc = RC6<>;
rc::key_type key{0,0,0,0};
rc::block_type plaintext{0,0,0,0};
rc::block_type expected{0,0,0,0};
auto cipher = rc{key};
auto plaintext2 = cipher.encrypt(plaintext);
auto plaintext3 = cipher.decrypt(plaintext2);
return plaintext3 != expected;
}
};
append_test dummy_szmltz63(new RC6test2{});