Merge branch 'concepts'
This commit is contained in:
commit
dbadce83f0
16 files changed
+123
-187
No files matched your search
@@ -486,9 +486,9 @@ TEST(DesCryptTests, OutIteratorUsageDecryptTest)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Impl, typename InputIt>
|
||||
static std::vector<uint8_t> EncryptThroughBase(const Encryptor<Impl> & enc,
|
||||
InputIt begin, InputIt end)
|
||||
template<Encryptor EncryptorImpl, typename InputIt>
|
||||
static std::vector<uint8_t> EncryptGeneric(const EncryptorImpl & enc,
|
||||
InputIt begin, InputIt end)
|
||||
{
|
||||
std::vector<uint8_t> result;
|
||||
result.resize(enc.GetBlockSize(), 0);
|
||||
@@ -497,7 +497,7 @@ static std::vector<uint8_t> EncryptThroughBase(const Encryptor<Impl> & enc,
|
||||
return result;
|
||||
}
|
||||
|
||||
TEST(DesCryptTests, EncryptThroughBaseTest)
|
||||
TEST(DesCryptTests, EncryptGenericTest)
|
||||
{
|
||||
std::array<uint8_t, DesCrypt::KeySize> key = { 0x13, 0x34, 0x57, 0x79, 0x9b, 0xbc, 0xdf, 0xf1 };
|
||||
|
||||
@@ -507,16 +507,16 @@ TEST(DesCryptTests, EncryptThroughBaseTest)
|
||||
DesCrypt::Key desKey(key.begin(), key.end());
|
||||
DesCrypt::Encryptor enc(desKey);
|
||||
|
||||
ASSERT_EQ(expected, EncryptThroughBase(enc, data.begin(), data.end()));
|
||||
ASSERT_EQ(expected, EncryptGeneric(enc, data.begin(), data.end()));
|
||||
}
|
||||
|
||||
template<typename Impl>
|
||||
static uint64_t EncryptUInt64BlockThroughBase(const Encryptor<Impl> & enc, uint64_t block)
|
||||
template<Encryptor EncryptorImpl>
|
||||
static uint64_t EncryptUInt64BlockGeneric(const EncryptorImpl & enc, uint64_t block)
|
||||
{
|
||||
return enc.EncryptBlock(block);
|
||||
}
|
||||
|
||||
TEST(DesCryptTests, EncryptUInt64BlockThroughBaseTest)
|
||||
TEST(DesCryptTests, EncryptUInt64BlockGenericTest)
|
||||
{
|
||||
std::array<uint8_t, DesCrypt::KeySize> key = { 0x13, 0x34, 0x57, 0x79, 0x9b, 0xbc, 0xdf, 0xf1 };
|
||||
|
||||
@@ -526,12 +526,12 @@ TEST(DesCryptTests, EncryptUInt64BlockThroughBaseTest)
|
||||
DesCrypt::Key desKey(key.begin(), key.end());
|
||||
DesCrypt::Encryptor enc(desKey);
|
||||
|
||||
ASSERT_EQ(expected, EncryptUInt64BlockThroughBase(enc, data));
|
||||
ASSERT_EQ(expected, EncryptUInt64BlockGeneric(enc, data));
|
||||
}
|
||||
|
||||
template<typename Impl, typename InputIt>
|
||||
static std::vector<uint8_t> DecryptThroughBase(const Decryptor<Impl> & dec,
|
||||
InputIt begin, InputIt end)
|
||||
template<Decryptor DecryptorImpl, typename InputIt>
|
||||
static std::vector<uint8_t> DecryptGeneric(const DecryptorImpl & dec,
|
||||
InputIt begin, InputIt end)
|
||||
{
|
||||
std::vector<uint8_t> result;
|
||||
result.resize(dec.GetBlockSize(), 0);
|
||||
@@ -540,7 +540,7 @@ static std::vector<uint8_t> DecryptThroughBase(const Decryptor<Impl> & dec,
|
||||
return result;
|
||||
}
|
||||
|
||||
TEST(DesCryptTests, DecryptThroughBaseTest)
|
||||
TEST(DesCryptTests, DecryptGenericTest)
|
||||
{
|
||||
std::array<uint8_t, DesCrypt::KeySize> key = { 0x13, 0x34, 0x57, 0x79, 0x9b, 0xbc, 0xdf, 0xf1 };
|
||||
|
||||
@@ -550,16 +550,16 @@ TEST(DesCryptTests, DecryptThroughBaseTest)
|
||||
DesCrypt::Key desKey(key.begin(), key.end());
|
||||
DesCrypt::Decryptor dec(desKey);
|
||||
|
||||
ASSERT_EQ(expected, DecryptThroughBase(dec, data.begin(), data.end()));
|
||||
ASSERT_EQ(expected, DecryptGeneric(dec, data.begin(), data.end()));
|
||||
}
|
||||
|
||||
template<typename Impl>
|
||||
static uint64_t DecryptUInt64BlockThroughBase(const Decryptor<Impl> & dec, uint64_t block)
|
||||
template<Decryptor DecryptorImpl>
|
||||
static uint64_t DecryptUInt64BlockGeneric(const DecryptorImpl & dec, uint64_t block)
|
||||
{
|
||||
return dec.DecryptBlock(block);
|
||||
}
|
||||
|
||||
TEST(DesCryptTests, DecryptUInt64BlockThroughBaseTest)
|
||||
TEST(DesCryptTests, DecryptUInt64BlockGenericTest)
|
||||
{
|
||||
std::array<uint8_t, DesCrypt::KeySize> key = { 0x13, 0x34, 0x57, 0x79, 0x9b, 0xbc, 0xdf, 0xf1 };
|
||||
|
||||
@@ -569,5 +569,5 @@ TEST(DesCryptTests, DecryptUInt64BlockThroughBaseTest)
|
||||
DesCrypt::Key desKey(key.begin(), key.end());
|
||||
DesCrypt::Decryptor dec(desKey);
|
||||
|
||||
ASSERT_EQ(expected, DecryptUInt64BlockThroughBase(dec, data));
|
||||
ASSERT_EQ(expected, DecryptUInt64BlockGeneric(dec, data));
|
||||
}
|
||||
@@ -109,8 +109,8 @@ TEST(PadIso7816Tests, PadOutIteratorUsageTest)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Impl, typename OutputIt>
|
||||
void PadThroughBase(const Padder<Impl> & padder, OutputIt begin, OutputIt end)
|
||||
template<Padder PadderImpl, typename OutputIt>
|
||||
void PadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end)
|
||||
{
|
||||
padder.Pad(begin, end);
|
||||
}
|
||||
@@ -127,7 +127,7 @@ TEST(PadIso7816Tests, PadThroughBaseTest)
|
||||
};
|
||||
|
||||
const PadderIso7816 padder;
|
||||
PadThroughBase(padder, fact.begin(), fact.end());
|
||||
PadGeneric(padder, fact.begin(), fact.end());
|
||||
|
||||
ASSERT_EQ(expected, fact);
|
||||
}
|
||||
@@ -324,8 +324,8 @@ TEST(PadIso7816Tests, UnpadErrorTest)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Impl, typename OutputIt>
|
||||
auto ComputeUnpadThroughBase(const Padder<Impl> & padder, OutputIt begin, OutputIt end)
|
||||
template<Padder PadderImpl, typename OutputIt>
|
||||
auto ComputeUnpadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end)
|
||||
{
|
||||
return padder.ComputeUnpad(begin, end);
|
||||
}
|
||||
@@ -336,7 +336,7 @@ TEST(PadIso7816Tests, ComputeUnpadThroughBaseTest)
|
||||
std::array<uint8_t, 5> data = { 0x80, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
const PadderIso7816 padder;
|
||||
auto result = ComputeUnpadThroughBase(padder, data.begin(), data.end());
|
||||
auto result = ComputeUnpadGeneric(padder, data.begin(), data.end());
|
||||
|
||||
ASSERT_TRUE(result.IsOkay_);
|
||||
ASSERT_EQ(5, result.PadSize_);
|
||||
|
||||
@@ -137,8 +137,8 @@ TEST(PadPkcs7Tests, PadOutIteratorUsageTest)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Impl, typename OutputIt>
|
||||
void PadThroughBase(const Padder<Impl> & padder, OutputIt begin, OutputIt end)
|
||||
template<Padder PadderImpl, typename OutputIt>
|
||||
void PadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end)
|
||||
{
|
||||
padder.Pad(begin, end);
|
||||
}
|
||||
@@ -153,7 +153,7 @@ TEST(PadPkcs7Tests, PadThroughBaseTest)
|
||||
};
|
||||
|
||||
const PadderPkcs7 padder;
|
||||
PadThroughBase(padder, fact.begin(), fact.end());
|
||||
PadGeneric(padder, fact.begin(), fact.end());
|
||||
|
||||
ASSERT_EQ(expected, fact);
|
||||
}
|
||||
@@ -347,8 +347,8 @@ TEST(PadPkcs7Tests, UnpadErrorTest)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Impl, typename OutputIt>
|
||||
auto ComputeUnpadThroughBase(const Padder<Impl> & padder, OutputIt begin, OutputIt end)
|
||||
template<Padder PadderImpl, typename OutputIt>
|
||||
auto ComputeUnpadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end)
|
||||
{
|
||||
return padder.ComputeUnpad(begin, end);
|
||||
}
|
||||
@@ -359,7 +359,7 @@ TEST(PadPkcs7Tests, ComputeUnpadThroughBaseTest)
|
||||
std::array<uint8_t, 5> data = { 0x05, 0x05, 0x05, 0x05, 0x05 };
|
||||
|
||||
const PadderPkcs7 padder;
|
||||
auto result = ComputeUnpadThroughBase(padder, data.begin(), data.end());
|
||||
auto result = ComputeUnpadGeneric(padder, data.begin(), data.end());
|
||||
|
||||
ASSERT_TRUE(result.IsOkay_);
|
||||
ASSERT_EQ(5, result.PadSize_);
|
||||
|
||||
Reference in new issue
Block a user