Perform aggregate zero-init instead of .fill(0) where appropriate.
All checks were successful
Chaos Ci / test-and-benchmark (push) Successful in 1m50s
All checks were successful
Chaos Ci / test-and-benchmark (push) Successful in 1m50s
Simpler and more consistent code.
This commit is contained in:
@@ -58,11 +58,8 @@ TEST(Arc4CryptTests, UninitializedArc4CryptTest)
|
|||||||
Arc4Crypt arc4;
|
Arc4Crypt arc4;
|
||||||
|
|
||||||
{
|
{
|
||||||
std::array<uint8_t, 10> in;
|
std::array<uint8_t, 10> in = {};
|
||||||
in.fill(0);
|
std::array<uint8_t, 10> out = {};
|
||||||
|
|
||||||
std::array<uint8_t, 10> out;
|
|
||||||
out.fill(0);
|
|
||||||
|
|
||||||
ASSERT_THROW(arc4.Encrypt(out.begin(), in.begin(), in.size()), Chaos::Service::ChaosException);
|
ASSERT_THROW(arc4.Encrypt(out.begin(), in.begin(), in.size()), Chaos::Service::ChaosException);
|
||||||
ASSERT_THROW(arc4.Decrypt(out.begin(), in.begin(), in.size()), Chaos::Service::ChaosException);
|
ASSERT_THROW(arc4.Decrypt(out.begin(), in.begin(), in.size()), Chaos::Service::ChaosException);
|
||||||
@@ -117,8 +114,7 @@ TEST(Arc4CryptTests, EncryptOutIteratorUsageTest)
|
|||||||
|
|
||||||
Arc4Crypt crypt(key.begin(), key.end());
|
Arc4Crypt crypt(key.begin(), key.end());
|
||||||
|
|
||||||
std::array<uint8_t, 47> out;
|
std::array<uint8_t, 47> out = {};
|
||||||
out.fill(0);
|
|
||||||
|
|
||||||
std::array<uint8_t, 47> expected =
|
std::array<uint8_t, 47> expected =
|
||||||
{
|
{
|
||||||
@@ -139,8 +135,7 @@ TEST(Arc4CryptTests, EncryptOutIteratorUsageTest)
|
|||||||
|
|
||||||
Arc4Crypt crypt(key.begin(), key.end());
|
Arc4Crypt crypt(key.begin(), key.end());
|
||||||
|
|
||||||
std::array<uint8_t, 47> out;
|
std::array<uint8_t, 47> out = {};
|
||||||
out.fill(0);
|
|
||||||
|
|
||||||
std::array<uint8_t, 47> expected =
|
std::array<uint8_t, 47> expected =
|
||||||
{
|
{
|
||||||
@@ -161,11 +156,8 @@ TEST(Arc4CryptTests, EncryptOutIteratorUsageTest)
|
|||||||
|
|
||||||
Arc4Crypt crypt(key.begin(), key.end());
|
Arc4Crypt crypt(key.begin(), key.end());
|
||||||
|
|
||||||
std::array<uint8_t, 44> out;
|
std::array<uint8_t, 44> out = {};
|
||||||
out.fill(0);
|
std::array<uint8_t, 44> expected = {};
|
||||||
|
|
||||||
std::array<uint8_t, 44> expected;
|
|
||||||
expected.fill(0);
|
|
||||||
|
|
||||||
crypt.Encrypt(out.begin() + 3, data.begin(), 0);
|
crypt.Encrypt(out.begin() + 3, data.begin(), 0);
|
||||||
|
|
||||||
@@ -182,8 +174,7 @@ TEST(Arc4CryptTests, DecryptOutIteratorUsageTest)
|
|||||||
{
|
{
|
||||||
Arc4Crypt crypt(key.begin(), key.end());
|
Arc4Crypt crypt(key.begin(), key.end());
|
||||||
|
|
||||||
std::array<uint8_t, 17> out;
|
std::array<uint8_t, 17> out = {};
|
||||||
out.fill(0);
|
|
||||||
|
|
||||||
std::array<uint8_t, 17> expected =
|
std::array<uint8_t, 17> expected =
|
||||||
{
|
{
|
||||||
@@ -200,8 +191,7 @@ TEST(Arc4CryptTests, DecryptOutIteratorUsageTest)
|
|||||||
{
|
{
|
||||||
Arc4Crypt crypt(key.begin(), key.end());
|
Arc4Crypt crypt(key.begin(), key.end());
|
||||||
|
|
||||||
std::array<uint8_t, 17> out;
|
std::array<uint8_t, 17> out = {};
|
||||||
out.fill(0);
|
|
||||||
|
|
||||||
std::array<uint8_t, 17> expected =
|
std::array<uint8_t, 17> expected =
|
||||||
{
|
{
|
||||||
@@ -218,11 +208,8 @@ TEST(Arc4CryptTests, DecryptOutIteratorUsageTest)
|
|||||||
{
|
{
|
||||||
Arc4Crypt crypt(key.begin(), key.end());
|
Arc4Crypt crypt(key.begin(), key.end());
|
||||||
|
|
||||||
std::array<uint8_t, 14> out;
|
std::array<uint8_t, 14> out = {};
|
||||||
out.fill(0);
|
std::array<uint8_t, 14> expected = {};
|
||||||
|
|
||||||
std::array<uint8_t, 14> expected;
|
|
||||||
expected.fill(0);
|
|
||||||
|
|
||||||
crypt.Decrypt(out.begin() + 3, data.begin(), 0);
|
crypt.Decrypt(out.begin() + 3, data.begin(), 0);
|
||||||
|
|
||||||
|
|||||||
@@ -360,8 +360,7 @@ TEST(Arc4GenTests, GenerateOutIteratorUsageTest)
|
|||||||
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
|
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
|
||||||
Arc4Gen gen(key, key + std::size(key));
|
Arc4Gen gen(key, key + std::size(key));
|
||||||
|
|
||||||
std::array<uint8_t, 23> out;
|
std::array<uint8_t, 23> out = {};
|
||||||
out.fill(0);
|
|
||||||
|
|
||||||
std::array<uint8_t, 23> expected =
|
std::array<uint8_t, 23> expected =
|
||||||
{
|
{
|
||||||
@@ -380,8 +379,7 @@ TEST(Arc4GenTests, GenerateOutIteratorUsageTest)
|
|||||||
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
|
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
|
||||||
Arc4Gen gen(key, key + std::size(key));
|
Arc4Gen gen(key, key + std::size(key));
|
||||||
|
|
||||||
std::array<uint8_t, 23> out;
|
std::array<uint8_t, 23> out = {};
|
||||||
out.fill(0);
|
|
||||||
|
|
||||||
std::array<uint8_t, 23> expected =
|
std::array<uint8_t, 23> expected =
|
||||||
{
|
{
|
||||||
@@ -400,11 +398,8 @@ TEST(Arc4GenTests, GenerateOutIteratorUsageTest)
|
|||||||
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
|
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
|
||||||
Arc4Gen gen(key, key + std::size(key));
|
Arc4Gen gen(key, key + std::size(key));
|
||||||
|
|
||||||
std::array<uint8_t, 20> out;
|
std::array<uint8_t, 20> out = {};
|
||||||
out.fill(0);
|
std::array<uint8_t, 20> expected = {};
|
||||||
|
|
||||||
std::array<uint8_t, 20> expected;
|
|
||||||
expected.fill(0);
|
|
||||||
|
|
||||||
gen.Generate(out.begin() + 3, 0);
|
gen.Generate(out.begin() + 3, 0);
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,7 @@ TEST(DesCryptTests, EncryptTest)
|
|||||||
std::array<uint8_t, DesCrypt::BlockSize> operator()(const std::array<uint8_t, DesCrypt::BlockSize> & data,
|
std::array<uint8_t, DesCrypt::BlockSize> operator()(const std::array<uint8_t, DesCrypt::BlockSize> & data,
|
||||||
const std::array<uint8_t, 8> & key) const
|
const std::array<uint8_t, 8> & key) const
|
||||||
{
|
{
|
||||||
std::array<uint8_t, DesCrypt::BlockSize> result;
|
std::array<uint8_t, DesCrypt::BlockSize> result = {};
|
||||||
result.fill(0);
|
|
||||||
|
|
||||||
DesCrypt::Key desKey(key.begin(), key.end());
|
DesCrypt::Key desKey(key.begin(), key.end());
|
||||||
DesCrypt::DesEncryptor enc(desKey);
|
DesCrypt::DesEncryptor enc(desKey);
|
||||||
@@ -206,8 +205,7 @@ TEST(DesCryptTests, DecryptTest)
|
|||||||
std::array<uint8_t, DesCrypt::BlockSize> operator()(const std::array<uint8_t, DesCrypt::BlockSize> & data,
|
std::array<uint8_t, DesCrypt::BlockSize> operator()(const std::array<uint8_t, DesCrypt::BlockSize> & data,
|
||||||
const std::array<uint8_t, 8> & key) const
|
const std::array<uint8_t, 8> & key) const
|
||||||
{
|
{
|
||||||
std::array<uint8_t, DesCrypt::BlockSize> result;
|
std::array<uint8_t, DesCrypt::BlockSize> result = {};
|
||||||
result.fill(0);
|
|
||||||
|
|
||||||
DesCrypt::Key desKey(key.begin(), key.end());
|
DesCrypt::Key desKey(key.begin(), key.end());
|
||||||
DesCrypt::DesDecryptor dec(desKey);
|
DesCrypt::DesDecryptor dec(desKey);
|
||||||
|
|||||||
@@ -99,8 +99,7 @@ TEST(HmacTests, LongKeyTest)
|
|||||||
|
|
||||||
TEST(HmacTests, UninitializedHmacTest)
|
TEST(HmacTests, UninitializedHmacTest)
|
||||||
{
|
{
|
||||||
std::array<uint8_t, 10> in;
|
std::array<uint8_t, 10> in = {};
|
||||||
in.fill(0);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Hmac<Md5Hasher> hmac;
|
Hmac<Md5Hasher> hmac;
|
||||||
|
|||||||
Reference in New Issue
Block a user