diff --git a/crypto/kdf/DerivedKeyConfig.cpp b/crypto/kdf/DerivedKeyConfig.cpp index 12bd0440..5883cf0b 100644 --- a/crypto/kdf/DerivedKeyConfig.cpp +++ b/crypto/kdf/DerivedKeyConfig.cpp @@ -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); } } diff --git a/crypto/kdf/DerivedKeyConfig.h b/crypto/kdf/DerivedKeyConfig.h index 3b4549a0..5e71aa8a 100644 --- a/crypto/kdf/DerivedKeyConfig.h +++ b/crypto/kdf/DerivedKeyConfig.h @@ -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;