TEA: use static sized storage for tests
This commit is contained in:
parent
9d3c058873
commit
dd05d677dd
@ -9,8 +9,8 @@ main ()
|
|||||||
// test vectors from 'TeaCrypt', by Logan J. Drews.
|
// test vectors from 'TeaCrypt', by Logan J. Drews.
|
||||||
struct {
|
struct {
|
||||||
std::array<uint32_t,4> key;
|
std::array<uint32_t,4> key;
|
||||||
std::vector<uint32_t> dec;
|
std::array<uint32_t,2> dec;
|
||||||
std::vector<uint32_t> enc;
|
std::array<uint32_t,2> enc;
|
||||||
} TESTS[] = {
|
} TESTS[] = {
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -44,8 +44,7 @@ main ()
|
|||||||
const auto &t = TESTS[i];
|
const auto &t = TESTS[i];
|
||||||
util::crypto::TEA gen (t.key);
|
util::crypto::TEA gen (t.key);
|
||||||
|
|
||||||
std::vector<uint32_t> enc (t.dec.size ()),
|
std::array<uint32_t,2> enc, dec;
|
||||||
dec (t.enc.size ());
|
|
||||||
|
|
||||||
gen.encrypt (enc.data (), t.dec.data (), t.dec.size ());
|
gen.encrypt (enc.data (), t.dec.data (), t.dec.size ());
|
||||||
gen.decrypt (dec.data (), t.enc.data (), t.enc.size ());
|
gen.decrypt (dec.data (), t.enc.data (), t.enc.size ());
|
||||||
@ -53,13 +52,13 @@ main ()
|
|||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "TEA_enc " << i;
|
os << "TEA_enc " << i;
|
||||||
tap.expect (std::equal (enc.begin (), enc.end (), t.enc.begin ()), os.str ());
|
tap.expect (enc == t.enc, os.str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "TEA_dec " << i;
|
os << "TEA_dec " << i;
|
||||||
tap.expect (std::equal (dec.begin (), dec.end (), t.dec.begin ()), os.str ());
|
tap.expect (dec == t.dec, os.str ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user