Beispiel #1
0
Container::Container(const path& location, const std::string& pw, VirtualDisk_Impl::volume_handle* volume, encryption_algorithm algo) : volume_(volume), 
passphrase_(pw.begin(), pw.end()), seed_(32), is_syncing(false), container_open_(false), has_callback_(false)
{
	using namespace CryptoPP;
	SHA256 shafunc;
	StringSource(pw.data(), true, new HashFilter(shafunc, new StringSink(pw_)));
	
	container_name_ = location.get_filename();
	container_name_.erase(container_name_.find_first_of('.'), container_name_.size());
	path_ = location;
	location.create_folderpath();
	algo_ = algo;
	if (enhanced_passphrase_.size())
	{
		std::vector<byte> tmp(std::begin(pw), std::end(pw));
		tmp.insert(std::end(tmp), std::begin(enhanced_passphrase_), std::end(enhanced_passphrase_));
		std::swap(tmp, enhanced_passphrase_);
	}
	else
	{
		for (byte b : pw)
		{
			enhanced_passphrase_.push_back(b);
		}
	}
}
Beispiel #2
0
void Container::init(const path& location, const std::string& pw, encryption_algorithm algo)
{
	using namespace CryptoPP;
	send_callback(VERBOSE, INIT_CONTAINER, location.std_str());
	SHA256 shafunc;
	StringSource(pw.data(), true, new HashFilter(shafunc, new StringSink(pw_)));
	
	if (enhanced_passphrase_.size())
	{
		std::vector<byte> tmp(std::begin(pw), std::end(pw));
		tmp.insert(std::end(tmp), std::begin(enhanced_passphrase_), std::end(enhanced_passphrase_));
		std::swap(tmp, enhanced_passphrase_);
	}
	else
	{
		for (byte b : pw)
		{
			enhanced_passphrase_.push_back(b);
		}
	}
	container_name_ = location.get_filename();
	container_name_.erase(container_name_.find_first_of('.'), container_name_.size());
	path_ = location; //fehler filename muss noch raus aus dem string
	location.create_folderpath();
	algo_ = algo;
}