2017-09-23 21:17:05 +02:00
|
|
|
#pragma once
|
|
|
|
#ifndef MESSMER_CRYFS_LOCALSTATE_LOCALSTATEMETADATA_H_
|
|
|
|
#define MESSMER_CRYFS_LOCALSTATE_LOCALSTATEMETADATA_H_
|
|
|
|
|
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
#include <boost/optional.hpp>
|
|
|
|
#include <iostream>
|
2017-09-30 09:49:24 +02:00
|
|
|
#include <cpp-utils/crypto/hash/Hash.h>
|
2017-09-23 21:17:05 +02:00
|
|
|
|
|
|
|
namespace cryfs {
|
|
|
|
|
|
|
|
class LocalStateMetadata final {
|
|
|
|
public:
|
|
|
|
|
2018-02-03 17:33:59 +01:00
|
|
|
static LocalStateMetadata loadOrGenerate(const boost::filesystem::path &statePath, const cpputils::Data& encryptionKey, bool allowReplacedFilesystem);
|
2017-09-23 21:17:05 +02:00
|
|
|
|
|
|
|
uint32_t myClientId() const;
|
|
|
|
|
|
|
|
private:
|
2017-09-30 09:49:24 +02:00
|
|
|
const uint32_t _myClientId;
|
|
|
|
const cpputils::hash::Hash _encryptionKeyHash;
|
2017-09-23 21:17:05 +02:00
|
|
|
|
|
|
|
static boost::optional<LocalStateMetadata> _load(const boost::filesystem::path &metadataFilePath);
|
|
|
|
static LocalStateMetadata _deserialize(std::istream& stream);
|
2017-09-30 09:49:24 +02:00
|
|
|
static LocalStateMetadata _generate(const boost::filesystem::path &metadataFilePath, const cpputils::Data& encryptionKey);
|
2017-09-23 21:17:05 +02:00
|
|
|
void _save(const boost::filesystem::path &metadataFilePath) const;
|
|
|
|
void _serialize(std::ostream& stream) const;
|
|
|
|
|
2017-09-30 09:49:24 +02:00
|
|
|
LocalStateMetadata(uint32_t myClientId, cpputils::hash::Hash encryptionKey);
|
2017-09-23 21:17:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
inline uint32_t LocalStateMetadata::myClientId() const {
|
|
|
|
return _myClientId;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|