Compare commits

1 Commits
Author SHA1 Message Date
hashlag 096674e854 Update googletest to 1.18.0.
Chaos Ci / test (push) Successful in 3m22s
Chaos Ci / benchmark (push) Successful in 1m28s
2026-09-06 03:00:51 +03:00
17 changed files with 197 additions and 116 deletions
+33 -16
View File
@@ -1,27 +1,44 @@
#ifndef CHAOS_CIPHER_BLOCK_DECRYPTOR_HPP #ifndef CHAOS_CIPHER_BLOCK_DECRYPTOR_HPP
#define CHAOS_CIPHER_BLOCK_DECRYPTOR_HPP #define CHAOS_CIPHER_BLOCK_DECRYPTOR_HPP
#include <concepts>
#include <cstdint>
#include <type_traits>
namespace Chaos::Cipher::Block namespace Chaos::Cipher::Block
{ {
template<typename T> template<typename T>
concept Decryptor = requires(T decryptor, class Decryptor
typename T::Block block,
uint8_t * outBegin, uint8_t * outEnd,
uint8_t * inBegin, uint8_t * inEnd)
{ {
typename T::Block; public:
typename T::Key; template<typename OutputIt, typename InputIt>
requires std::constructible_from<T, typename T::Key>; void DecryptBlock(OutputIt outBegin, OutputIt outEnd,
requires std::unsigned_integral<std::remove_cvref_t<decltype(T::BlockSize)>>; InputIt inBegin, InputIt inEnd) const
requires std::unsigned_integral<std::remove_cvref_t<decltype(T::KeySize)>>; {
decryptor.DecryptBlock(outBegin, outEnd, inBegin, inEnd); Impl().DecryptBlock(outBegin, outEnd, inBegin, inEnd);
{ decryptor.DecryptBlock(block) } -> std::same_as<typename T::Block>; }
{ decryptor.GetBlockSize() } -> std::unsigned_integral;
template<typename Block>
auto DecryptBlock(Block block) const
{
return Impl().DecryptBlock(block);
}
auto GetBlockSize() const
{
return Impl().GetBlockSize();
}
protected:
Decryptor() = default;
private:
const T & Impl() const
{
return static_cast<const T &>(*this);
}
T & Impl()
{
return static_cast<T &>(*this);
}
}; };
} // namespace Chaos::Cipher::Block } // namespace Chaos::Cipher::Block
+2 -8
View File
@@ -233,10 +233,9 @@ public:
Inner_::RawKey Key_; Inner_::RawKey Key_;
}; };
class Encryptor class Encryptor : public Chaos::Cipher::Block::Encryptor<Encryptor>
{ {
public: public:
using Block = DesCrypt::Block;
using Key = DesCrypt::Key; using Key = DesCrypt::Key;
static constexpr size_t BlockSize = DesCrypt::BlockSize; static constexpr size_t BlockSize = DesCrypt::BlockSize;
static constexpr size_t KeySize = DesCrypt::KeySize; static constexpr size_t KeySize = DesCrypt::KeySize;
@@ -279,12 +278,9 @@ public:
Inner_::KeySchedule Schedule_; Inner_::KeySchedule Schedule_;
}; };
static_assert(Chaos::Cipher::Block::Encryptor<Encryptor>); class Decryptor : public Chaos::Cipher::Block::Decryptor<Decryptor>
class Decryptor
{ {
public: public:
using Block = DesCrypt::Block;
using Key = DesCrypt::Key; using Key = DesCrypt::Key;
static constexpr size_t BlockSize = DesCrypt::BlockSize; static constexpr size_t BlockSize = DesCrypt::BlockSize;
static constexpr size_t KeySize = DesCrypt::KeySize; static constexpr size_t KeySize = DesCrypt::KeySize;
@@ -327,8 +323,6 @@ public:
Inner_::KeySchedule Schedule_; Inner_::KeySchedule Schedule_;
}; };
static_assert(Chaos::Cipher::Block::Decryptor<Decryptor>);
private: private:
using BlockHalf = uint32_t; using BlockHalf = uint32_t;
using RawBlockArray = Service::SeArray<uint8_t, 8>; using RawBlockArray = Service::SeArray<uint8_t, 8>;
+33 -16
View File
@@ -1,27 +1,44 @@
#ifndef CHAOS_CIPHER_BLOCK_ENCRYPTOR_HPP #ifndef CHAOS_CIPHER_BLOCK_ENCRYPTOR_HPP
#define CHAOS_CIPHER_BLOCK_ENCRYPTOR_HPP #define CHAOS_CIPHER_BLOCK_ENCRYPTOR_HPP
#include <concepts>
#include <cstdint>
#include <type_traits>
namespace Chaos::Cipher::Block namespace Chaos::Cipher::Block
{ {
template<typename T> template<typename T>
concept Encryptor = requires(T encryptor, class Encryptor
typename T::Block block,
uint8_t * outBegin, uint8_t * outEnd,
uint8_t * inBegin, uint8_t * inEnd)
{ {
typename T::Block; public:
typename T::Key; template<typename OutputIt, typename InputIt>
requires std::constructible_from<T, typename T::Key>; void EncryptBlock(OutputIt outBegin, OutputIt outEnd,
requires std::unsigned_integral<std::remove_cvref_t<decltype(T::BlockSize)>>; InputIt inBegin, InputIt inEnd) const
requires std::unsigned_integral<std::remove_cvref_t<decltype(T::KeySize)>>; {
encryptor.EncryptBlock(outBegin, outEnd, inBegin, inEnd); Impl().EncryptBlock(outBegin, outEnd, inBegin, inEnd);
{ encryptor.EncryptBlock(block) } -> std::same_as<typename T::Block>; }
{ encryptor.GetBlockSize() } -> std::unsigned_integral;
template<typename Block>
auto EncryptBlock(Block block) const
{
return Impl().EncryptBlock(block);
}
auto GetBlockSize() const
{
return Impl().GetBlockSize();
}
protected:
Encryptor() = default;
private:
const T & Impl() const
{
return static_cast<const T &>(*this);
}
T & Impl()
{
return static_cast<T &>(*this);
}
}; };
} // namespace Chaos::Cipher::Block } // namespace Chaos::Cipher::Block
+25 -4
View File
@@ -1,17 +1,38 @@
#ifndef CHAOS_HASH_HASH_HPP #ifndef CHAOS_HASH_HASH_HPP
#define CHAOS_HASH_HASH_HPP #define CHAOS_HASH_HASH_HPP
#include <concepts>
#include <string> #include <string>
namespace Chaos::Hash namespace Chaos::Hash
{ {
template<typename T> template<typename T>
concept Hash = requires(T hash) class Hash
{ {
hash.GetRawDigest(); public:
{ hash.ToHexString() } -> std::same_as<std::string>; auto GetRawDigest() const
{
return Impl().GetRawDigest();
}
std::string ToHexString() const
{
return Impl().ToHexString();
}
protected:
Hash() = default;
private:
const T & Impl() const
{
return static_cast<const T &>(*this);
}
T & Impl()
{
return static_cast<T &>(*this);
}
}; };
} // namespace Chaos::Hash } // namespace Chaos::Hash
+31 -8
View File
@@ -1,19 +1,42 @@
#ifndef CHAOS_HASH_HASHER_HPP #ifndef CHAOS_HASH_HASHER_HPP
#define CHAOS_HASH_HASHER_HPP #define CHAOS_HASH_HASHER_HPP
#include <cstdint>
#include "Hash.hpp"
namespace Chaos::Hash namespace Chaos::Hash
{ {
template<typename T> template<typename T>
concept Hasher = requires(T hasher, uint8_t * begin, uint8_t * end) class Hasher
{ {
hasher.Reset(); public:
hasher.Update(begin, end); void Reset()
{ hasher.Finish() } -> Hash; {
Impl().Reset();
}
template<typename InputIt>
void Update(InputIt begin, InputIt end)
{
Impl().Update(begin, end);
}
auto Finish()
{
return Impl().Finish();
}
protected:
Hasher() = default;
private:
const T & Impl() const
{
return static_cast<const T &>(*this);
}
T & Impl()
{
return static_cast<T &>(*this);
}
}; };
} // namespace Chaos::Hash } // namespace Chaos::Hash
+2 -6
View File
@@ -136,7 +136,7 @@ private:
namespace Chaos::Hash::Md4 namespace Chaos::Hash::Md4
{ {
struct Md4Hash struct Md4Hash : public Hash<Md4Hash>
{ {
std::array<uint8_t, 16> GetRawDigest() const std::array<uint8_t, 16> GetRawDigest() const
{ {
@@ -161,9 +161,7 @@ struct Md4Hash
std::array<uint8_t, 16> RawDigest_; std::array<uint8_t, 16> RawDigest_;
}; };
static_assert(Hash<Md4Hash>); class Md4Hasher : public Hasher<Md4Hasher>
class Md4Hasher
{ {
public: public:
using HashType = Md4Hash; using HashType = Md4Hash;
@@ -304,8 +302,6 @@ private:
} }
}; };
static_assert(Hasher<Md4Hasher>);
} // namespace Chaos::Hash::Md4 } // namespace Chaos::Hash::Md4
#endif // CHAOS_HASH_MD4_HPP #endif // CHAOS_HASH_MD4_HPP
+2 -6
View File
@@ -160,7 +160,7 @@ private:
namespace Chaos::Hash::Md5 namespace Chaos::Hash::Md5
{ {
struct Md5Hash struct Md5Hash : public Hash<Md5Hash>
{ {
std::array<uint8_t, 16> GetRawDigest() const std::array<uint8_t, 16> GetRawDigest() const
{ {
@@ -185,9 +185,7 @@ struct Md5Hash
std::array<uint8_t, 16> RawDigest_; std::array<uint8_t, 16> RawDigest_;
}; };
static_assert(Hash<Md5Hash>); class Md5Hasher : public Hasher<Md5Hasher>
class Md5Hasher
{ {
public: public:
using HashType = Md5Hash; using HashType = Md5Hash;
@@ -328,8 +326,6 @@ private:
} }
}; };
static_assert(Hasher<Md5Hasher>);
} // namespace Chaos::Hash::Md5 } // namespace Chaos::Hash::Md5
#endif // CHAOS_HASH_MD5_HPP #endif // CHAOS_HASH_MD5_HPP
+2 -6
View File
@@ -129,7 +129,7 @@ private:
namespace Chaos::Hash::Sha1 namespace Chaos::Hash::Sha1
{ {
struct Sha1Hash struct Sha1Hash : public Hash<Sha1Hash>
{ {
std::array<uint8_t, 20> GetRawDigest() const std::array<uint8_t, 20> GetRawDigest() const
{ {
@@ -155,9 +155,7 @@ struct Sha1Hash
std::array<uint8_t, 20> RawDigest_; std::array<uint8_t, 20> RawDigest_;
}; };
static_assert(Hash<Sha1Hash>); class Sha1Hasher : public Hasher<Sha1Hasher>
class Sha1Hasher
{ {
public: public:
using HashType = Sha1Hash; using HashType = Sha1Hash;
@@ -298,8 +296,6 @@ private:
} }
}; };
static_assert(Hasher<Sha1Hasher>);
} // namespace Chaos::Hash::Sha1 } // namespace Chaos::Hash::Sha1
#endif // CHAOS_HASH_SHA1_HPP #endif // CHAOS_HASH_SHA1_HPP
+3 -1
View File
@@ -3,6 +3,7 @@
#include <array> #include <array>
#include <cstdint> #include <cstdint>
#include <type_traits>
#include "Hash/Hasher.hpp" #include "Hash/Hasher.hpp"
#include "Service/ChaosException.hpp" #include "Service/ChaosException.hpp"
@@ -10,7 +11,8 @@
namespace Chaos::Mac::Hmac namespace Chaos::Mac::Hmac
{ {
template<Hash::Hasher HasherImpl> template<typename HasherImpl,
typename = std::enable_if_t<std::is_base_of_v<Hash::Hasher<HasherImpl>, HasherImpl>>>
class Hmac class Hmac
{ {
public: public:
+27 -5
View File
@@ -1,16 +1,38 @@
#ifndef CHAOS_PADDING_PADDER_HPP #ifndef CHAOS_PADDING_PADDER_HPP
#define CHAOS_PADDING_PADDER_HPP #define CHAOS_PADDING_PADDER_HPP
#include <cstdint>
namespace Chaos::Padding namespace Chaos::Padding
{ {
template<typename T> template<typename T>
concept Padder = requires(uint8_t * begin, uint8_t * end) class Padder
{ {
T::Pad(begin, end); public:
{ T::ComputeUnpad(begin, end) } noexcept; template<typename OutputIt>
void Pad(OutputIt begin, OutputIt end) const
{
Impl().Pad(begin, end);
}
template<typename InputIt>
auto ComputeUnpad(InputIt begin, InputIt end) const noexcept
{
return Impl().ComputeUnpad(begin, end);
}
protected:
Padder() = default;
private:
const T & Impl() const
{
return static_cast<const T &>(*this);
}
T & Impl()
{
return static_cast<T &>(*this);
}
}; };
} // namespace Chaos::Padding } // namespace Chaos::Padding
+1 -3
View File
@@ -12,7 +12,7 @@
namespace Chaos::Padding namespace Chaos::Padding
{ {
class PadderIso7816 class PadderIso7816 : public Padder<PadderIso7816>
{ {
public: public:
template<typename OutputIt> template<typename OutputIt>
@@ -82,8 +82,6 @@ private:
using Branchless = Service::Branchless; using Branchless = Service::Branchless;
}; };
static_assert(Padder<PadderIso7816>);
} // namespace Chaos::Padding } // namespace Chaos::Padding
#endif // CHAOS_PADDING_PADDERISO7816_HPP #endif // CHAOS_PADDING_PADDERISO7816_HPP
+1 -3
View File
@@ -13,7 +13,7 @@
namespace Chaos::Padding namespace Chaos::Padding
{ {
class PadderPkcs7 class PadderPkcs7 : public Padder<PadderPkcs7>
{ {
public: public:
template<typename OutputIt> template<typename OutputIt>
@@ -75,8 +75,6 @@ private:
using Branchless = Service::Branchless; using Branchless = Service::Branchless;
}; };
static_assert(Padder<PadderPkcs7>);
} // namespace Chaos::Padding } // namespace Chaos::Padding
#endif // CHAOS_PADDING_PADDERPKCS7_HPP #endif // CHAOS_PADDING_PADDERPKCS7_HPP
+3 -2
View File
@@ -2,13 +2,14 @@
#define CHAOS_SERVICE_SEARRAY_HPP #define CHAOS_SERVICE_SEARRAY_HPP
#include <array> #include <array>
#include <concepts> #include <type_traits>
#include <cstddef> #include <cstddef>
namespace Chaos::Service namespace Chaos::Service
{ {
template<std::integral T, size_t S> template<typename T, size_t S,
typename = std::enable_if_t<std::is_integral_v<T>>>
class SeArray class SeArray
{ {
public: public:
+2 -2
View File
@@ -4,8 +4,8 @@ cmake_policy(SET CMP0135 NEW)
FetchContent_Declare( FetchContent_Declare(
googletest googletest
URL https://git.hashlag.net/hashlag/chaos-deps/raw/branch/main/google_googletest/googletest-1.17.0.tar.gz URL https://git.hashlag.net/hashlag/chaos-deps/raw/branch/main/google_googletest/googletest-1.18.0.tar.gz
URL_HASH SHA256=65fab701d9829d38cb77c14acdc431d2108bfdbf8979e40eb8ae567edf10b27c URL_HASH SHA256=6e3191c1455468b3fc35a417fb565c1c5071aee1b7e7f85e30cf48a98d37d8b5
) )
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
+18 -18
View File
@@ -486,9 +486,9 @@ TEST(DesCryptTests, OutIteratorUsageDecryptTest)
} }
} }
template<Encryptor EncryptorImpl, typename InputIt> template<typename Impl, typename InputIt>
static std::vector<uint8_t> EncryptGeneric(const EncryptorImpl & enc, static std::vector<uint8_t> EncryptThroughBase(const Encryptor<Impl> & enc,
InputIt begin, InputIt end) InputIt begin, InputIt end)
{ {
std::vector<uint8_t> result; std::vector<uint8_t> result;
result.resize(enc.GetBlockSize(), 0); result.resize(enc.GetBlockSize(), 0);
@@ -497,7 +497,7 @@ static std::vector<uint8_t> EncryptGeneric(const EncryptorImpl & enc,
return result; return result;
} }
TEST(DesCryptTests, EncryptGenericTest) TEST(DesCryptTests, EncryptThroughBaseTest)
{ {
std::array<uint8_t, DesCrypt::KeySize> key = { 0x13, 0x34, 0x57, 0x79, 0x9b, 0xbc, 0xdf, 0xf1 }; std::array<uint8_t, DesCrypt::KeySize> key = { 0x13, 0x34, 0x57, 0x79, 0x9b, 0xbc, 0xdf, 0xf1 };
@@ -507,16 +507,16 @@ TEST(DesCryptTests, EncryptGenericTest)
DesCrypt::Key desKey(key.begin(), key.end()); DesCrypt::Key desKey(key.begin(), key.end());
DesCrypt::Encryptor enc(desKey); DesCrypt::Encryptor enc(desKey);
ASSERT_EQ(expected, EncryptGeneric(enc, data.begin(), data.end())); ASSERT_EQ(expected, EncryptThroughBase(enc, data.begin(), data.end()));
} }
template<Encryptor EncryptorImpl> template<typename Impl>
static uint64_t EncryptUInt64BlockGeneric(const EncryptorImpl & enc, uint64_t block) static uint64_t EncryptUInt64BlockThroughBase(const Encryptor<Impl> & enc, uint64_t block)
{ {
return enc.EncryptBlock(block); return enc.EncryptBlock(block);
} }
TEST(DesCryptTests, EncryptUInt64BlockGenericTest) TEST(DesCryptTests, EncryptUInt64BlockThroughBaseTest)
{ {
std::array<uint8_t, DesCrypt::KeySize> key = { 0x13, 0x34, 0x57, 0x79, 0x9b, 0xbc, 0xdf, 0xf1 }; std::array<uint8_t, DesCrypt::KeySize> key = { 0x13, 0x34, 0x57, 0x79, 0x9b, 0xbc, 0xdf, 0xf1 };
@@ -526,12 +526,12 @@ TEST(DesCryptTests, EncryptUInt64BlockGenericTest)
DesCrypt::Key desKey(key.begin(), key.end()); DesCrypt::Key desKey(key.begin(), key.end());
DesCrypt::Encryptor enc(desKey); DesCrypt::Encryptor enc(desKey);
ASSERT_EQ(expected, EncryptUInt64BlockGeneric(enc, data)); ASSERT_EQ(expected, EncryptUInt64BlockThroughBase(enc, data));
} }
template<Decryptor DecryptorImpl, typename InputIt> template<typename Impl, typename InputIt>
static std::vector<uint8_t> DecryptGeneric(const DecryptorImpl & dec, static std::vector<uint8_t> DecryptThroughBase(const Decryptor<Impl> & dec,
InputIt begin, InputIt end) InputIt begin, InputIt end)
{ {
std::vector<uint8_t> result; std::vector<uint8_t> result;
result.resize(dec.GetBlockSize(), 0); result.resize(dec.GetBlockSize(), 0);
@@ -540,7 +540,7 @@ static std::vector<uint8_t> DecryptGeneric(const DecryptorImpl & dec,
return result; return result;
} }
TEST(DesCryptTests, DecryptGenericTest) TEST(DesCryptTests, DecryptThroughBaseTest)
{ {
std::array<uint8_t, DesCrypt::KeySize> key = { 0x13, 0x34, 0x57, 0x79, 0x9b, 0xbc, 0xdf, 0xf1 }; std::array<uint8_t, DesCrypt::KeySize> key = { 0x13, 0x34, 0x57, 0x79, 0x9b, 0xbc, 0xdf, 0xf1 };
@@ -550,16 +550,16 @@ TEST(DesCryptTests, DecryptGenericTest)
DesCrypt::Key desKey(key.begin(), key.end()); DesCrypt::Key desKey(key.begin(), key.end());
DesCrypt::Decryptor dec(desKey); DesCrypt::Decryptor dec(desKey);
ASSERT_EQ(expected, DecryptGeneric(dec, data.begin(), data.end())); ASSERT_EQ(expected, DecryptThroughBase(dec, data.begin(), data.end()));
} }
template<Decryptor DecryptorImpl> template<typename Impl>
static uint64_t DecryptUInt64BlockGeneric(const DecryptorImpl & dec, uint64_t block) static uint64_t DecryptUInt64BlockThroughBase(const Decryptor<Impl> & dec, uint64_t block)
{ {
return dec.DecryptBlock(block); return dec.DecryptBlock(block);
} }
TEST(DesCryptTests, DecryptUInt64BlockGenericTest) TEST(DesCryptTests, DecryptUInt64BlockThroughBaseTest)
{ {
std::array<uint8_t, DesCrypt::KeySize> key = { 0x13, 0x34, 0x57, 0x79, 0x9b, 0xbc, 0xdf, 0xf1 }; std::array<uint8_t, DesCrypt::KeySize> key = { 0x13, 0x34, 0x57, 0x79, 0x9b, 0xbc, 0xdf, 0xf1 };
@@ -569,5 +569,5 @@ TEST(DesCryptTests, DecryptUInt64BlockGenericTest)
DesCrypt::Key desKey(key.begin(), key.end()); DesCrypt::Key desKey(key.begin(), key.end());
DesCrypt::Decryptor dec(desKey); DesCrypt::Decryptor dec(desKey);
ASSERT_EQ(expected, DecryptUInt64BlockGeneric(dec, data)); ASSERT_EQ(expected, DecryptUInt64BlockThroughBase(dec, data));
} }
+6 -6
View File
@@ -109,8 +109,8 @@ TEST(PadIso7816Tests, PadOutIteratorUsageTest)
} }
} }
template<Padder PadderImpl, typename OutputIt> template<typename Impl, typename OutputIt>
void PadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end) void PadThroughBase(const Padder<Impl> & padder, OutputIt begin, OutputIt end)
{ {
padder.Pad(begin, end); padder.Pad(begin, end);
} }
@@ -127,7 +127,7 @@ TEST(PadIso7816Tests, PadThroughBaseTest)
}; };
const PadderIso7816 padder; const PadderIso7816 padder;
PadGeneric(padder, fact.begin(), fact.end()); PadThroughBase(padder, fact.begin(), fact.end());
ASSERT_EQ(expected, fact); ASSERT_EQ(expected, fact);
} }
@@ -324,8 +324,8 @@ TEST(PadIso7816Tests, UnpadErrorTest)
} }
} }
template<Padder PadderImpl, typename OutputIt> template<typename Impl, typename OutputIt>
auto ComputeUnpadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end) auto ComputeUnpadThroughBase(const Padder<Impl> & padder, OutputIt begin, OutputIt end)
{ {
return padder.ComputeUnpad(begin, end); return padder.ComputeUnpad(begin, end);
} }
@@ -336,7 +336,7 @@ TEST(PadIso7816Tests, ComputeUnpadThroughBaseTest)
std::array<uint8_t, 5> data = { 0x80, 0x00, 0x00, 0x00, 0x00 }; std::array<uint8_t, 5> data = { 0x80, 0x00, 0x00, 0x00, 0x00 };
const PadderIso7816 padder; const PadderIso7816 padder;
auto result = ComputeUnpadGeneric(padder, data.begin(), data.end()); auto result = ComputeUnpadThroughBase(padder, data.begin(), data.end());
ASSERT_TRUE(result.IsOkay_); ASSERT_TRUE(result.IsOkay_);
ASSERT_EQ(5, result.PadSize_); ASSERT_EQ(5, result.PadSize_);
+6 -6
View File
@@ -137,8 +137,8 @@ TEST(PadPkcs7Tests, PadOutIteratorUsageTest)
} }
} }
template<Padder PadderImpl, typename OutputIt> template<typename Impl, typename OutputIt>
void PadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end) void PadThroughBase(const Padder<Impl> & padder, OutputIt begin, OutputIt end)
{ {
padder.Pad(begin, end); padder.Pad(begin, end);
} }
@@ -153,7 +153,7 @@ TEST(PadPkcs7Tests, PadThroughBaseTest)
}; };
const PadderPkcs7 padder; const PadderPkcs7 padder;
PadGeneric(padder, fact.begin(), fact.end()); PadThroughBase(padder, fact.begin(), fact.end());
ASSERT_EQ(expected, fact); ASSERT_EQ(expected, fact);
} }
@@ -347,8 +347,8 @@ TEST(PadPkcs7Tests, UnpadErrorTest)
} }
} }
template<Padder PadderImpl, typename OutputIt> template<typename Impl, typename OutputIt>
auto ComputeUnpadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end) auto ComputeUnpadThroughBase(const Padder<Impl> & padder, OutputIt begin, OutputIt end)
{ {
return padder.ComputeUnpad(begin, end); return padder.ComputeUnpad(begin, end);
} }
@@ -359,7 +359,7 @@ TEST(PadPkcs7Tests, ComputeUnpadThroughBaseTest)
std::array<uint8_t, 5> data = { 0x05, 0x05, 0x05, 0x05, 0x05 }; std::array<uint8_t, 5> data = { 0x05, 0x05, 0x05, 0x05, 0x05 };
const PadderPkcs7 padder; const PadderPkcs7 padder;
auto result = ComputeUnpadGeneric(padder, data.begin(), data.end()); auto result = ComputeUnpadThroughBase(padder, data.begin(), data.end());
ASSERT_TRUE(result.IsOkay_); ASSERT_TRUE(result.IsOkay_);
ASSERT_EQ(5, result.PadSize_); ASSERT_EQ(5, result.PadSize_);