Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
779bd6c568 | ||
|
|
8a82d33f39 | ||
|
|
a360e1b95a | ||
|
|
c4311991a9 | ||
|
|
0b12c1303f | ||
|
|
7d312f9ba5 | ||
|
|
0ee4962f70 | ||
|
|
6b632b8be1 | ||
|
|
b129507559 | ||
|
|
3582890bb1 | ||
|
|
706e20821a | ||
|
|
e7f346cda2 | ||
|
|
0c041a5e9a | ||
|
|
a720c7b812 | ||
|
|
6638e46dd9 | ||
|
|
ac89f55feb | ||
|
|
f776caa528 | ||
|
|
8dcdaa6b85 | ||
|
|
f636a60dab | ||
|
|
22ad1fbb2b | ||
|
|
643c1364c7 | ||
|
|
62903ff9be | ||
|
|
56d6aa3601 | ||
|
|
9ec4e6f7e6 | ||
|
|
e9c7b16d34 | ||
|
|
90dafee249 | ||
|
|
da47dfa954 | ||
|
|
0be43c9cf6 | ||
|
|
fc67ba6b46 | ||
|
|
89bf5914d5 | ||
|
|
ceccd04b35 | ||
|
|
f8a110964b | ||
|
|
6ee9873538 | ||
|
|
d5ddaa078e | ||
|
|
8d8e452e87 | ||
|
|
112143a9b3 | ||
|
|
000e6994a4 | ||
|
|
e3d729a301 | ||
|
|
3f257dd483 | ||
|
|
82aa01b6f4 | ||
|
|
46c01bc85e | ||
|
|
840b1f8149 | ||
|
|
77c0f785ff | ||
|
|
11dadf8c77 | ||
|
|
dea896bd5f | ||
|
|
2b4972fe95 | ||
|
|
f9e71d2c9f | ||
|
|
8b7e485179 | ||
|
|
ba47480cb2 | ||
|
|
8e08aad6ba | ||
|
|
eeb57733e7 | ||
|
|
d78922e235 | ||
|
|
4214497426 | ||
|
|
b464d6a6a2 | ||
|
|
78836e4b75 | ||
|
|
5ba326aa5a | ||
|
|
dcaeab7b43 | ||
|
|
49a4b18163 | ||
|
|
ef848d6876 | ||
|
|
5c7cf222bd | ||
|
|
d892b83e0a | ||
|
|
8d0780e016 | ||
|
|
baaa98de03 | ||
|
|
6cad16991e |
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
returnByReference:Chaos/Hash/Md4.hpp:141
|
||||||
|
returnByReference:Chaos/Hash/Md5.hpp:165
|
||||||
|
returnByReference:Chaos/Hash/Sha1.hpp:134
|
||||||
|
useInitializationList:Chaos/Service/SeArray.hpp:25
|
||||||
|
accessMoved:ChaosTests/Service/SeArrayTests.cpp:309
|
||||||
|
accessMoved:ChaosTests/Service/SeArrayTests.cpp:331
|
||||||
|
accessMoved:ChaosTests/Service/SeArrayTests.cpp:367
|
||||||
@@ -58,6 +58,38 @@ jobs:
|
|||||||
include-hidden-files: true
|
include-hidden-files: true
|
||||||
retention-days: 10
|
retention-days: 10
|
||||||
|
|
||||||
|
static-analysis:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y build-essential cmake cppcheck
|
||||||
|
|
||||||
|
- name: Generate compile commands
|
||||||
|
run: |
|
||||||
|
mkdir build-debug
|
||||||
|
cmake -S . -B build-debug/ -D CMAKE_BUILD_TYPE=Debug -D CMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||||
|
|
||||||
|
- name: Run cppcheck
|
||||||
|
run: |
|
||||||
|
cppcheck --version
|
||||||
|
cppcheck --project=build-debug/compile_commands.json \
|
||||||
|
--file-filter='*ChaosTests/*' \
|
||||||
|
--file-filter='*ChaosBenches/*' \
|
||||||
|
--enable=warning,performance,portability \
|
||||||
|
--suppress='*:*/_deps/*' \
|
||||||
|
--suppress=missingIncludeSystem \
|
||||||
|
--suppressions-list=.cppcheck \
|
||||||
|
--inline-suppr \
|
||||||
|
--error-exitcode=1
|
||||||
|
|
||||||
benchmark:
|
benchmark:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,12 @@ public:
|
|||||||
Decrypt
|
Decrypt
|
||||||
};
|
};
|
||||||
|
|
||||||
|
KeySchedule(const KeySchedule & other) = delete;
|
||||||
|
KeySchedule(KeySchedule && other) = delete;
|
||||||
|
|
||||||
|
KeySchedule & operator=(const KeySchedule & other) = delete;
|
||||||
|
KeySchedule & operator=(KeySchedule && other) = delete;
|
||||||
|
|
||||||
KeySchedule(Direction direction, const RawKey & rawKey)
|
KeySchedule(Direction direction, const RawKey & rawKey)
|
||||||
{
|
{
|
||||||
Key56 key56 = Pc1(Bitwise::PackUInt64(rawKey.Begin(), rawKey.End()));
|
Key56 key56 = Pc1(Bitwise::PackUInt64(rawKey.Begin(), rawKey.End()));
|
||||||
@@ -210,10 +216,22 @@ public:
|
|||||||
|
|
||||||
DesCrypt() = delete;
|
DesCrypt() = delete;
|
||||||
|
|
||||||
|
DesCrypt(const DesCrypt & other) = delete;
|
||||||
|
DesCrypt(DesCrypt && other) = delete;
|
||||||
|
|
||||||
|
DesCrypt & operator=(const DesCrypt & other) = delete;
|
||||||
|
DesCrypt & operator=(DesCrypt && other) = delete;
|
||||||
|
|
||||||
class Key
|
class Key
|
||||||
{
|
{
|
||||||
friend class DesCrypt;
|
friend class DesCrypt;
|
||||||
public:
|
public:
|
||||||
|
Key(const Key & other) = delete;
|
||||||
|
Key(Key && other) = delete;
|
||||||
|
|
||||||
|
Key & operator=(const Key & other) = delete;
|
||||||
|
Key & operator=(Key && other) = delete;
|
||||||
|
|
||||||
template<typename InputIt>
|
template<typename InputIt>
|
||||||
Key(InputIt keyBegin, InputIt keyEnd)
|
Key(InputIt keyBegin, InputIt keyEnd)
|
||||||
{
|
{
|
||||||
@@ -245,6 +263,12 @@ public:
|
|||||||
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;
|
||||||
|
|
||||||
|
Encryptor(const Encryptor & other) = delete;
|
||||||
|
Encryptor(Encryptor && other) = delete;
|
||||||
|
|
||||||
|
Encryptor & operator=(const Encryptor & other) = delete;
|
||||||
|
Encryptor & operator=(Encryptor && other) = delete;
|
||||||
|
|
||||||
Encryptor(const Key & key)
|
Encryptor(const Key & key)
|
||||||
: Schedule_(Inner_::KeySchedule::Direction::Encrypt, key.Key_)
|
: Schedule_(Inner_::KeySchedule::Direction::Encrypt, key.Key_)
|
||||||
{ }
|
{ }
|
||||||
@@ -293,6 +317,12 @@ public:
|
|||||||
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;
|
||||||
|
|
||||||
|
Decryptor(const Decryptor & other) = delete;
|
||||||
|
Decryptor(Decryptor && other) = delete;
|
||||||
|
|
||||||
|
Decryptor & operator=(const Decryptor & other) = delete;
|
||||||
|
Decryptor & operator=(Decryptor && other) = delete;
|
||||||
|
|
||||||
Decryptor(const Key & key)
|
Decryptor(const Key & key)
|
||||||
: Schedule_(Inner_::KeySchedule::Direction::Decrypt, key.Key_)
|
: Schedule_(Inner_::KeySchedule::Direction::Decrypt, key.Key_)
|
||||||
{ }
|
{ }
|
||||||
|
|||||||
@@ -19,9 +19,23 @@ public:
|
|||||||
using Cipher = CipherT;
|
using Cipher = CipherT;
|
||||||
using Padder = PadderT;
|
using Padder = PadderT;
|
||||||
|
|
||||||
|
EcbMode() = delete;
|
||||||
|
|
||||||
|
EcbMode(const EcbMode & other) = delete;
|
||||||
|
EcbMode(EcbMode && other) = delete;
|
||||||
|
|
||||||
|
EcbMode & operator=(const EcbMode & other) = delete;
|
||||||
|
EcbMode & operator=(EcbMode && other) = delete;
|
||||||
|
|
||||||
class Encryptor
|
class Encryptor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Encryptor(const Encryptor & other) = delete;
|
||||||
|
Encryptor(Encryptor && other) = delete;
|
||||||
|
|
||||||
|
Encryptor & operator=(const Encryptor & other) = delete;
|
||||||
|
Encryptor & operator=(Encryptor && other) = delete;
|
||||||
|
|
||||||
Encryptor(const typename CipherT::Key & key)
|
Encryptor(const typename CipherT::Key & key)
|
||||||
: Encryptor_(key)
|
: Encryptor_(key)
|
||||||
, BlockBytesPacked_(0)
|
, BlockBytesPacked_(0)
|
||||||
@@ -115,6 +129,12 @@ public:
|
|||||||
class Decryptor
|
class Decryptor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Decryptor(const Decryptor & other) = delete;
|
||||||
|
Decryptor(Decryptor && other) = delete;
|
||||||
|
|
||||||
|
Decryptor & operator=(const Decryptor & other) = delete;
|
||||||
|
Decryptor & operator=(Decryptor && other) = delete;
|
||||||
|
|
||||||
Decryptor(const typename CipherT::Key & key)
|
Decryptor(const typename CipherT::Key & key)
|
||||||
: Decryptor_(key)
|
: Decryptor_(key)
|
||||||
, BlockBytesPacked_(0)
|
, BlockBytesPacked_(0)
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ public:
|
|||||||
Arc4Crypt()
|
Arc4Crypt()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
Arc4Crypt(const Arc4Crypt & other) = delete;
|
||||||
|
Arc4Crypt(Arc4Crypt && other) = delete;
|
||||||
|
|
||||||
|
Arc4Crypt & operator=(const Arc4Crypt & other) = delete;
|
||||||
|
Arc4Crypt & operator=(Arc4Crypt && other) = delete;
|
||||||
|
|
||||||
template<typename InputIt>
|
template<typename InputIt>
|
||||||
Arc4Crypt(InputIt keyBegin, InputIt keyEnd)
|
Arc4Crypt(InputIt keyBegin, InputIt keyEnd)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,8 +16,16 @@ class Arc4Gen
|
|||||||
public:
|
public:
|
||||||
Arc4Gen()
|
Arc4Gen()
|
||||||
: IsInitialized_(false)
|
: IsInitialized_(false)
|
||||||
|
, I_(0)
|
||||||
|
, J_(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
Arc4Gen(const Arc4Gen & other) = delete;
|
||||||
|
Arc4Gen(Arc4Gen && other) = delete;
|
||||||
|
|
||||||
|
Arc4Gen & operator=(const Arc4Gen & other) = delete;
|
||||||
|
Arc4Gen & operator=(Arc4Gen && other) = delete;
|
||||||
|
|
||||||
template<typename InputIt>
|
template<typename InputIt>
|
||||||
Arc4Gen(InputIt keyBegin, InputIt keyEnd)
|
Arc4Gen(InputIt keyBegin, InputIt keyEnd)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -175,6 +175,12 @@ public:
|
|||||||
ResetImpl();
|
ResetImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Md4Hasher(const Md4Hasher & other) = delete;
|
||||||
|
Md4Hasher(Md4Hasher && other) = delete;
|
||||||
|
|
||||||
|
Md4Hasher & operator=(const Md4Hasher & other) = delete;
|
||||||
|
Md4Hasher & operator=(Md4Hasher && other) = delete;
|
||||||
|
|
||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
ResetImpl();
|
ResetImpl();
|
||||||
|
|||||||
@@ -199,6 +199,12 @@ public:
|
|||||||
ResetImpl();
|
ResetImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Md5Hasher(const Md5Hasher & other) = delete;
|
||||||
|
Md5Hasher(Md5Hasher && other) = delete;
|
||||||
|
|
||||||
|
Md5Hasher & operator=(const Md5Hasher & other) = delete;
|
||||||
|
Md5Hasher & operator=(Md5Hasher && other) = delete;
|
||||||
|
|
||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
ResetImpl();
|
ResetImpl();
|
||||||
|
|||||||
@@ -169,6 +169,12 @@ public:
|
|||||||
ResetImpl();
|
ResetImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sha1Hasher(const Sha1Hasher & other) = delete;
|
||||||
|
Sha1Hasher(Sha1Hasher && other) = delete;
|
||||||
|
|
||||||
|
Sha1Hasher & operator=(const Sha1Hasher & other) = delete;
|
||||||
|
Sha1Hasher & operator=(Sha1Hasher && other) = delete;
|
||||||
|
|
||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
ResetImpl();
|
ResetImpl();
|
||||||
|
|||||||
+17
-11
@@ -1,10 +1,10 @@
|
|||||||
#ifndef CHAOS_MAC_HMAC_HPP
|
#ifndef CHAOS_MAC_HMAC_HPP
|
||||||
#define CHAOS_MAC_HMAC_HPP
|
#define CHAOS_MAC_HMAC_HPP
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include "Hash/Hasher.hpp"
|
#include "Hash/Hasher.hpp"
|
||||||
|
#include "Service/SeArray.hpp"
|
||||||
#include "Service/ChaosException.hpp"
|
#include "Service/ChaosException.hpp"
|
||||||
|
|
||||||
namespace Chaos::Mac::Hmac
|
namespace Chaos::Mac::Hmac
|
||||||
@@ -18,6 +18,12 @@ public:
|
|||||||
: IsInitialized_(false)
|
: IsInitialized_(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
Hmac(const Hmac & other) = delete;
|
||||||
|
Hmac(Hmac && other) = delete;
|
||||||
|
|
||||||
|
Hmac & operator=(const Hmac & other) = delete;
|
||||||
|
Hmac & operator=(Hmac && other) = delete;
|
||||||
|
|
||||||
template<typename InputIt>
|
template<typename InputIt>
|
||||||
Hmac(InputIt keyBegin, InputIt keyEnd)
|
Hmac(InputIt keyBegin, InputIt keyEnd)
|
||||||
{
|
{
|
||||||
@@ -46,14 +52,14 @@ public:
|
|||||||
Hasher_.Reset();
|
Hasher_.Reset();
|
||||||
|
|
||||||
KeyType opaddedKey = PadKey<OPAD_BYTE>(Key_);
|
KeyType opaddedKey = PadKey<OPAD_BYTE>(Key_);
|
||||||
Hasher_.Update(opaddedKey.begin(), opaddedKey.end());
|
Hasher_.Update(opaddedKey.Begin(), opaddedKey.End());
|
||||||
Hasher_.Update(innerDigest.begin(), innerDigest.end());
|
Hasher_.Update(innerDigest.begin(), innerDigest.end());
|
||||||
|
|
||||||
return Hasher_.Finish();
|
return Hasher_.Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using KeyType = std::array<uint8_t, HasherImpl::BlockSize>;
|
using KeyType = Service::SeArray<uint8_t, HasherImpl::BlockSize>;
|
||||||
|
|
||||||
static constexpr uint8_t OPAD_BYTE = 0x5c;
|
static constexpr uint8_t OPAD_BYTE = 0x5c;
|
||||||
static constexpr uint8_t IPAD_BYTE = 0x36;
|
static constexpr uint8_t IPAD_BYTE = 0x36;
|
||||||
@@ -75,12 +81,12 @@ private:
|
|||||||
static KeyType GenerateKey(InputIt keyBegin, InputIt keyEnd)
|
static KeyType GenerateKey(InputIt keyBegin, InputIt keyEnd)
|
||||||
{
|
{
|
||||||
KeyType key;
|
KeyType key;
|
||||||
key.fill(0);
|
key.Fill(0);
|
||||||
|
|
||||||
InputIt keyIt = keyBegin;
|
InputIt keyIt = keyBegin;
|
||||||
uint64_t idx = 0;
|
uint64_t idx = 0;
|
||||||
|
|
||||||
for (; keyIt != keyEnd && idx < key.size();
|
for (; keyIt != keyEnd && idx < key.Size();
|
||||||
++keyIt, ++idx)
|
++keyIt, ++idx)
|
||||||
{
|
{
|
||||||
key[idx] = *keyIt;
|
key[idx] = *keyIt;
|
||||||
@@ -90,17 +96,17 @@ private:
|
|||||||
{
|
{
|
||||||
HasherImpl keyHasher;
|
HasherImpl keyHasher;
|
||||||
|
|
||||||
keyHasher.Update(key.begin(), key.end());
|
keyHasher.Update(key.Begin(), key.End());
|
||||||
keyHasher.Update(keyIt, keyEnd);
|
keyHasher.Update(keyIt, keyEnd);
|
||||||
|
|
||||||
auto digest = keyHasher.Finish().GetRawDigest();
|
auto digest = keyHasher.Finish().GetRawDigest();
|
||||||
static_assert(digest.size() <= HasherImpl::BlockSize);
|
static_assert(digest.size() <= HasherImpl::BlockSize);
|
||||||
|
|
||||||
key.fill(0);
|
key.Fill(0);
|
||||||
idx = 0;
|
idx = 0;
|
||||||
|
|
||||||
for (auto it = digest.begin();
|
for (auto it = digest.begin();
|
||||||
it != digest.end() && idx < key.size();
|
it != digest.end() && idx < key.Size();
|
||||||
++it, ++idx)
|
++it, ++idx)
|
||||||
{
|
{
|
||||||
key[idx] = *it;
|
key[idx] = *it;
|
||||||
@@ -118,8 +124,8 @@ private:
|
|||||||
KeyType paddedKey;
|
KeyType paddedKey;
|
||||||
uint64_t idx = 0;
|
uint64_t idx = 0;
|
||||||
|
|
||||||
for (auto it = key.cbegin();
|
for (auto it = key.Begin();
|
||||||
it != key.cend() && idx < paddedKey.size();
|
it != key.End() && idx < paddedKey.Size();
|
||||||
++it, ++idx)
|
++it, ++idx)
|
||||||
{
|
{
|
||||||
paddedKey[idx] = (*it) ^ PAD_BYTE;
|
paddedKey[idx] = (*it) ^ PAD_BYTE;
|
||||||
@@ -135,7 +141,7 @@ private:
|
|||||||
Hasher_.Reset();
|
Hasher_.Reset();
|
||||||
|
|
||||||
KeyType ipaddedKey = PadKey<IPAD_BYTE>(Key_);
|
KeyType ipaddedKey = PadKey<IPAD_BYTE>(Key_);
|
||||||
Hasher_.Update(ipaddedKey.begin(), ipaddedKey.end());
|
Hasher_.Update(ipaddedKey.Begin(), ipaddedKey.End());
|
||||||
|
|
||||||
IsInitialized_ = true;
|
IsInitialized_ = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,14 @@ namespace Chaos::Padding
|
|||||||
class PadderIso7816
|
class PadderIso7816
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
PadderIso7816() = delete;
|
||||||
|
|
||||||
|
PadderIso7816(const PadderIso7816 & other) = delete;
|
||||||
|
PadderIso7816(PadderIso7816 && other) = delete;
|
||||||
|
|
||||||
|
PadderIso7816 & operator=(const PadderIso7816 & other) = delete;
|
||||||
|
PadderIso7816 & operator=(PadderIso7816 && other) = delete;
|
||||||
|
|
||||||
template<typename OutputIt>
|
template<typename OutputIt>
|
||||||
static void Pad(OutputIt begin, OutputIt end)
|
static void Pad(OutputIt begin, OutputIt end)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,6 +16,14 @@ namespace Chaos::Padding
|
|||||||
class PadderPkcs7
|
class PadderPkcs7
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
PadderPkcs7() = delete;
|
||||||
|
|
||||||
|
PadderPkcs7(const PadderPkcs7 & other) = delete;
|
||||||
|
PadderPkcs7(PadderPkcs7 && other) = delete;
|
||||||
|
|
||||||
|
PadderPkcs7 & operator=(const PadderPkcs7 & other) = delete;
|
||||||
|
PadderPkcs7 & operator=(PadderPkcs7 && other) = delete;
|
||||||
|
|
||||||
template<typename OutputIt>
|
template<typename OutputIt>
|
||||||
static void Pad(OutputIt begin, OutputIt end)
|
static void Pad(OutputIt begin, OutputIt end)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace Chaos::Service
|
namespace Chaos::Service
|
||||||
{
|
{
|
||||||
@@ -18,10 +19,28 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
SeArray(const SeArray & other) = delete;
|
SeArray(const SeArray & other) = delete;
|
||||||
SeArray(SeArray && other) = delete;
|
|
||||||
|
SeArray(SeArray && other) noexcept
|
||||||
|
{
|
||||||
|
Storage_ = std::move(other.Storage_);
|
||||||
|
other.EraseImpl();
|
||||||
|
}
|
||||||
|
|
||||||
SeArray & operator=(const SeArray & other) = default;
|
SeArray & operator=(const SeArray & other) = default;
|
||||||
SeArray & operator=(SeArray && other) = delete;
|
|
||||||
|
SeArray & operator=(SeArray && other) noexcept
|
||||||
|
{
|
||||||
|
if (this == &other)
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
EraseImpl();
|
||||||
|
Storage_ = std::move(other.Storage_);
|
||||||
|
other.EraseImpl();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
~SeArray()
|
~SeArray()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -110,9 +110,9 @@ TEST(PadIso7816Tests, PadOutIteratorUsageTest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<Padder PadderImpl, typename OutputIt>
|
template<Padder PadderImpl, typename OutputIt>
|
||||||
void PadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end)
|
void PadGeneric(OutputIt begin, OutputIt end)
|
||||||
{
|
{
|
||||||
padder.Pad(begin, end);
|
PadderImpl::Pad(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PadIso7816Tests, PadThroughBaseTest)
|
TEST(PadIso7816Tests, PadThroughBaseTest)
|
||||||
@@ -126,8 +126,7 @@ TEST(PadIso7816Tests, PadThroughBaseTest)
|
|||||||
0x80, 0x00, 0x00, 0x00, 0x00
|
0x80, 0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
|
|
||||||
const PadderIso7816 padder;
|
PadGeneric<PadderIso7816>(fact.begin(), fact.end());
|
||||||
PadGeneric(padder, fact.begin(), fact.end());
|
|
||||||
|
|
||||||
ASSERT_EQ(expected, fact);
|
ASSERT_EQ(expected, fact);
|
||||||
}
|
}
|
||||||
@@ -325,9 +324,9 @@ TEST(PadIso7816Tests, UnpadErrorTest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<Padder PadderImpl, typename OutputIt>
|
template<Padder PadderImpl, typename OutputIt>
|
||||||
auto ComputeUnpadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end)
|
auto ComputeUnpadGeneric(OutputIt begin, OutputIt end)
|
||||||
{
|
{
|
||||||
return padder.ComputeUnpad(begin, end);
|
return PadderImpl::ComputeUnpad(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PadIso7816Tests, ComputeUnpadThroughBaseTest)
|
TEST(PadIso7816Tests, ComputeUnpadThroughBaseTest)
|
||||||
@@ -335,8 +334,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;
|
auto result = ComputeUnpadGeneric<PadderIso7816>(data.begin(), data.end());
|
||||||
auto result = ComputeUnpadGeneric(padder, data.begin(), data.end());
|
|
||||||
|
|
||||||
ASSERT_TRUE(result.IsOkay_);
|
ASSERT_TRUE(result.IsOkay_);
|
||||||
ASSERT_EQ(5, result.PadSize_);
|
ASSERT_EQ(5, result.PadSize_);
|
||||||
|
|||||||
@@ -138,9 +138,9 @@ TEST(PadPkcs7Tests, PadOutIteratorUsageTest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<Padder PadderImpl, typename OutputIt>
|
template<Padder PadderImpl, typename OutputIt>
|
||||||
void PadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end)
|
void PadGeneric(OutputIt begin, OutputIt end)
|
||||||
{
|
{
|
||||||
padder.Pad(begin, end);
|
PadderImpl::Pad(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PadPkcs7Tests, PadThroughBaseTest)
|
TEST(PadPkcs7Tests, PadThroughBaseTest)
|
||||||
@@ -152,8 +152,7 @@ TEST(PadPkcs7Tests, PadThroughBaseTest)
|
|||||||
0x05, 0x05, 0x05, 0x05, 0x05
|
0x05, 0x05, 0x05, 0x05, 0x05
|
||||||
};
|
};
|
||||||
|
|
||||||
const PadderPkcs7 padder;
|
PadGeneric<PadderPkcs7>(fact.begin(), fact.end());
|
||||||
PadGeneric(padder, fact.begin(), fact.end());
|
|
||||||
|
|
||||||
ASSERT_EQ(expected, fact);
|
ASSERT_EQ(expected, fact);
|
||||||
}
|
}
|
||||||
@@ -348,9 +347,9 @@ TEST(PadPkcs7Tests, UnpadErrorTest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<Padder PadderImpl, typename OutputIt>
|
template<Padder PadderImpl, typename OutputIt>
|
||||||
auto ComputeUnpadGeneric(const PadderImpl & padder, OutputIt begin, OutputIt end)
|
auto ComputeUnpadGeneric(OutputIt begin, OutputIt end)
|
||||||
{
|
{
|
||||||
return padder.ComputeUnpad(begin, end);
|
return PadderImpl::ComputeUnpad(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PadPkcs7Tests, ComputeUnpadThroughBaseTest)
|
TEST(PadPkcs7Tests, ComputeUnpadThroughBaseTest)
|
||||||
@@ -358,8 +357,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;
|
auto result = ComputeUnpadGeneric<PadderPkcs7>(data.begin(), data.end());
|
||||||
auto result = ComputeUnpadGeneric(padder, data.begin(), data.end());
|
|
||||||
|
|
||||||
ASSERT_TRUE(result.IsOkay_);
|
ASSERT_TRUE(result.IsOkay_);
|
||||||
ASSERT_EQ(5, result.PadSize_);
|
ASSERT_EQ(5, result.PadSize_);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include "Service/SeArray.hpp"
|
#include "Service/SeArray.hpp"
|
||||||
|
|
||||||
@@ -290,3 +291,80 @@ TEST(SeArrayTests, CopyAssignTest)
|
|||||||
ASSERT_EQ(0, arr1[4]);
|
ASSERT_EQ(0, arr1[4]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(SeArrayTests, MoveAssignTest)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
SeArray<uint8_t, 2> arr1;
|
||||||
|
|
||||||
|
SeArray<uint8_t, 2> arr2;
|
||||||
|
arr2[0] = 0xaa;
|
||||||
|
arr2[1] = 0xbb;
|
||||||
|
|
||||||
|
arr1 = std::move(arr2);
|
||||||
|
|
||||||
|
ASSERT_EQ(0xaa, arr1[0]);
|
||||||
|
ASSERT_EQ(0xbb, arr1[1]);
|
||||||
|
|
||||||
|
ASSERT_EQ(0, arr2[0]);
|
||||||
|
ASSERT_EQ(0, arr2[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
SeArray<int32_t, 5> arr1;
|
||||||
|
arr1[0] = 0x33;
|
||||||
|
arr1[1] = 0x44;
|
||||||
|
arr1[2] = 0x55;
|
||||||
|
arr1[3] = 0x66;
|
||||||
|
arr1[4] = 0x77;
|
||||||
|
|
||||||
|
SeArray<int32_t, 5> arr2;
|
||||||
|
|
||||||
|
arr1 = std::move(arr2);
|
||||||
|
|
||||||
|
ASSERT_EQ(0, arr1[0]);
|
||||||
|
ASSERT_EQ(0, arr1[1]);
|
||||||
|
ASSERT_EQ(0, arr1[2]);
|
||||||
|
ASSERT_EQ(0, arr1[3]);
|
||||||
|
ASSERT_EQ(0, arr1[4]);
|
||||||
|
|
||||||
|
ASSERT_EQ(0, arr2[0]);
|
||||||
|
ASSERT_EQ(0, arr2[1]);
|
||||||
|
ASSERT_EQ(0, arr2[2]);
|
||||||
|
ASSERT_EQ(0, arr2[3]);
|
||||||
|
ASSERT_EQ(0, arr2[4]);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
SeArray<int32_t, 5> arr1;
|
||||||
|
arr1[0] = 0x33;
|
||||||
|
arr1[1] = 0x44;
|
||||||
|
arr1[2] = 0x55;
|
||||||
|
arr1[3] = 0x66;
|
||||||
|
arr1[4] = 0x77;
|
||||||
|
|
||||||
|
arr1 = std::move(arr1);
|
||||||
|
|
||||||
|
ASSERT_EQ(0x33, arr1[0]);
|
||||||
|
ASSERT_EQ(0x44, arr1[1]);
|
||||||
|
ASSERT_EQ(0x55, arr1[2]);
|
||||||
|
ASSERT_EQ(0x66, arr1[3]);
|
||||||
|
ASSERT_EQ(0x77, arr1[4]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SeArrayTests, MoveConstructTest)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
SeArray<int32_t, 2> arr1;
|
||||||
|
arr1[0] = 0x11;
|
||||||
|
arr1[1] = 0x22;
|
||||||
|
|
||||||
|
SeArray<int32_t, 2> arr2(std::move(arr1));
|
||||||
|
ASSERT_EQ(0x11, arr2[0]);
|
||||||
|
ASSERT_EQ(0x22, arr2[1]);
|
||||||
|
|
||||||
|
ASSERT_EQ(0, arr1[0]);
|
||||||
|
ASSERT_EQ(0, arr1[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user