2015-10-27 22:19:06 +01:00
|
|
|
#include "DerivedKeyConfig.h"
|
|
|
|
|
|
|
|
using std::istream;
|
|
|
|
using std::ostream;
|
|
|
|
using boost::optional;
|
|
|
|
using boost::none;
|
|
|
|
|
|
|
|
namespace cpputils {
|
|
|
|
void DerivedKeyConfig::serialize(Serializer *target) const {
|
|
|
|
target->writeUint64(_N);
|
|
|
|
target->writeUint32(_r);
|
|
|
|
target->writeUint32(_p);
|
2015-11-11 02:49:33 +01:00
|
|
|
target->writeData(_salt);
|
2015-10-27 22:19:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
size_t DerivedKeyConfig::serializedSize() const {
|
|
|
|
return Serializer::DataSize(_salt) + sizeof(uint64_t) + sizeof(uint32_t) + sizeof(uint32_t);
|
|
|
|
}
|
|
|
|
|
2015-11-11 02:49:33 +01:00
|
|
|
DerivedKeyConfig DerivedKeyConfig::deserialize(Deserializer *source) {
|
2015-10-27 22:19:06 +01:00
|
|
|
uint64_t N = source->readUint64();
|
|
|
|
uint32_t r = source->readUint32();
|
|
|
|
uint32_t p = source->readUint32();
|
2015-11-11 02:49:33 +01:00
|
|
|
Data salt = source->readData();
|
2015-10-27 22:19:06 +01:00
|
|
|
return DerivedKeyConfig(std::move(salt), N, r, p);
|
|
|
|
}
|
|
|
|
}
|