2016-04-26 02:42:17 +02:00
|
|
|
#ifndef MESSMER_CRYFS_TEST_CRYFS_FILESYSTEM_CRYTESTBASE_H
|
|
|
|
#define MESSMER_CRYFS_TEST_CRYFS_FILESYSTEM_CRYTESTBASE_H
|
|
|
|
|
|
|
|
#include <cryfs/filesystem/CryDevice.h>
|
2017-07-18 23:49:51 +02:00
|
|
|
#include <blockstore/implementations/inmemory/InMemoryBlockStore2.h>
|
2016-04-26 02:42:17 +02:00
|
|
|
#include <cpp-utils/tempfile/TempFile.h>
|
|
|
|
#include <cpp-utils/crypto/kdf/Scrypt.h>
|
2016-06-22 02:36:29 +02:00
|
|
|
#include "../../testutils/TestWithFakeHomeDirectory.h"
|
2016-04-26 02:42:17 +02:00
|
|
|
|
2016-06-22 02:36:29 +02:00
|
|
|
class CryTestBase : public TestWithFakeHomeDirectory {
|
2016-04-26 02:42:17 +02:00
|
|
|
public:
|
|
|
|
CryTestBase(): _configFile(false), _device(nullptr) {
|
2017-07-18 23:49:51 +02:00
|
|
|
auto fakeBlockStore = cpputils::make_unique_ref<blockstore::inmemory::InMemoryBlockStore2>();
|
2016-06-27 01:53:10 +02:00
|
|
|
_device = std::make_unique<cryfs::CryDevice>(configFile(), std::move(fakeBlockStore), 0x12345678);
|
2016-04-26 02:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cryfs::CryConfigFile configFile() {
|
|
|
|
cryfs::CryConfig config;
|
|
|
|
config.SetCipher("aes-256-gcm");
|
2017-09-05 01:43:43 +02:00
|
|
|
config.SetEncryptionKey(cpputils::AES256_GCM::EncryptionKey::CreateKey(cpputils::Random::PseudoRandom()).ToString());
|
2016-04-26 02:42:17 +02:00
|
|
|
config.SetBlocksizeBytes(10240);
|
|
|
|
return cryfs::CryConfigFile::create(_configFile.path(), std::move(config), "mypassword", cpputils::SCrypt::TestSettings);
|
|
|
|
}
|
|
|
|
|
|
|
|
cryfs::CryDevice &device() {
|
|
|
|
return *_device;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
cpputils::TempFile _configFile;
|
|
|
|
std::unique_ptr<cryfs::CryDevice> _device;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|