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