2015-10-27 22:19:06 +01:00
|
|
|
#pragma once
|
|
|
|
#ifndef MESSMER_CPPUTILS_CRYPTO_KDF_KEYCONFIG_H
|
|
|
|
#define MESSMER_CPPUTILS_CRYPTO_KDF_KEYCONFIG_H
|
|
|
|
|
|
|
|
#include "../../data/Data.h"
|
|
|
|
#include "../../data/Serializer.h"
|
|
|
|
#include "../../data/Deserializer.h"
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
namespace cpputils {
|
|
|
|
|
|
|
|
class DerivedKeyConfig {
|
|
|
|
public:
|
|
|
|
DerivedKeyConfig(Data salt, uint64_t N, uint32_t r, uint32_t p)
|
|
|
|
: _salt(std::move(salt)),
|
|
|
|
_N(N), _r(r), _p(p) { }
|
|
|
|
|
2015-11-11 02:49:33 +01:00
|
|
|
DerivedKeyConfig(const DerivedKeyConfig &rhs)
|
|
|
|
:_salt(rhs._salt.copy()),
|
|
|
|
_N(rhs._N), _r(rhs._r), _p(rhs._p) { }
|
|
|
|
|
2015-10-27 22:19:06 +01:00
|
|
|
DerivedKeyConfig(DerivedKeyConfig &&rhs) = default;
|
|
|
|
|
2015-11-11 02:49:33 +01:00
|
|
|
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;
|
|
|
|
|
2015-10-27 22:19:06 +01:00
|
|
|
const Data &salt() const {
|
|
|
|
return _salt;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t N() const {
|
|
|
|
return _N;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t r() const {
|
|
|
|
return _r;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t p() const {
|
|
|
|
return _p;
|
|
|
|
}
|
|
|
|
|
|
|
|
void serialize(Serializer *destination) const;
|
|
|
|
|
|
|
|
size_t serializedSize() const;
|
|
|
|
|
2015-11-11 02:49:33 +01:00
|
|
|
static DerivedKeyConfig deserialize(Deserializer *source);
|
2015-10-27 22:19:06 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Data _salt;
|
|
|
|
uint64_t _N;
|
|
|
|
uint32_t _r;
|
|
|
|
uint32_t _p;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|