Make DerivedKeyConfig copyable and assignable
This commit is contained in:
parent
c1734dd93e
commit
4cf886c91f
@ -7,21 +7,21 @@ using boost::none;
|
||||
|
||||
namespace cpputils {
|
||||
void DerivedKeyConfig::serialize(Serializer *target) const {
|
||||
target->writeData(_salt);
|
||||
target->writeUint64(_N);
|
||||
target->writeUint32(_r);
|
||||
target->writeUint32(_p);
|
||||
target->writeData(_salt);
|
||||
}
|
||||
|
||||
size_t DerivedKeyConfig::serializedSize() const {
|
||||
return Serializer::DataSize(_salt) + sizeof(uint64_t) + sizeof(uint32_t) + sizeof(uint32_t);
|
||||
}
|
||||
|
||||
DerivedKeyConfig DerivedKeyConfig::load(Deserializer *source) {
|
||||
Data salt = source->readData();
|
||||
DerivedKeyConfig DerivedKeyConfig::deserialize(Deserializer *source) {
|
||||
uint64_t N = source->readUint64();
|
||||
uint32_t r = source->readUint32();
|
||||
uint32_t p = source->readUint32();
|
||||
Data salt = source->readData();
|
||||
return DerivedKeyConfig(std::move(salt), N, r, p);
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,22 @@ namespace cpputils {
|
||||
: _salt(std::move(salt)),
|
||||
_N(N), _r(r), _p(p) { }
|
||||
|
||||
DerivedKeyConfig(const DerivedKeyConfig &rhs)
|
||||
:_salt(rhs._salt.copy()),
|
||||
_N(rhs._N), _r(rhs._r), _p(rhs._p) { }
|
||||
|
||||
DerivedKeyConfig(DerivedKeyConfig &&rhs) = default;
|
||||
|
||||
DerivedKeyConfig &operator=(const DerivedKeyConfig &rhs) {
|
||||
_salt = rhs._salt.copy();
|
||||
_N = rhs._N;
|
||||
_r = rhs._r;
|
||||
_p = rhs._p;
|
||||
return *this;
|
||||
}
|
||||
|
||||
DerivedKeyConfig &operator=(DerivedKeyConfig &&rhs) = default;
|
||||
|
||||
const Data &salt() const {
|
||||
return _salt;
|
||||
}
|
||||
@ -37,7 +51,7 @@ namespace cpputils {
|
||||
|
||||
size_t serializedSize() const;
|
||||
|
||||
static DerivedKeyConfig load(Deserializer *source);
|
||||
static DerivedKeyConfig deserialize(Deserializer *source);
|
||||
|
||||
private:
|
||||
Data _salt;
|
||||
|
Loading…
x
Reference in New Issue
Block a user