KeyPackageOperator.h
#ifndef GPGFRONTEND_KEYPACKAGEOPERATOR_H
#define GPGFRONTEND_KEYPACKAGEOPERATOR_H
#include "core/GpgFrontendCore.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
namespace GpgFrontend {
class GPGFRONTEND_CORE_EXPORT KeyPackageOperator {
public:
static bool GeneratePassphrase(const std::filesystem::path &phrase_path,
std::string &phrase);
static std::string GenerateKeyPackageName();
static bool GenerateKeyPackage(const std::filesystem::path &key_package_path,
const std::string &key_package_name,
KeyIdArgsListPtr &key_ids, std::string &phrase,
bool secret);
static bool ImportKeyPackage(const std::filesystem::path &key_package_path,
const std::filesystem::path &phrase_path,
GpgFrontend::GpgImportInformation &import_info);
private:
static std::string generate_key_package_name() {
std::random_device rd_;
auto mt_ = std::mt19937(rd_());
std::uniform_int_distribution<int> dist(999, 99999);
auto file_string = boost::format("KeyPackage_%1%") % dist(mt_);
return file_string.str();
}
};
} // namespace GpgFrontend
#endif // GPGFRONTEND_KEYPACKAGEOPERATOR_H
GpgFrontend::FileOperator::WriteFileStd
static bool WriteFileStd(const std::filesystem::path &file_name, const std::string &data)
write file content using std struct
Definition: FileOperator.cpp:69
GpgFrontend::KeyPackageOperator::generate_key_package_name
static std::string generate_key_package_name()
generate key package name
Definition: KeyPackageOperator.h:96
GpgFrontend::KeyPackageOperator::ImportKeyPackage
static bool ImportKeyPackage(const std::filesystem::path &key_package_path, const std::filesystem::path &phrase_path, GpgFrontend::GpgImportInformation &import_info)
import key package
Definition: KeyPackageOperator.cpp:71
GpgFrontend
Definition: CoreCommonUtil.cpp:29
GpgFrontend::KeyPackageOperator::GenerateKeyPackageName
static std::string GenerateKeyPackageName()
generate the name of the key package
Definition: KeyPackageOperator.cpp:115
GpgFrontend::SingletonFunctionObject< PassphraseGenerator >::GetInstance
static PassphraseGenerator & GetInstance(int channel=GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL)
Get the Instance object.
Definition: GpgFunctionObject.h:170
GpgFrontend::PassphraseGenerator::Generate
std::string Generate(int len)
generate passphrase
Definition: PassphraseGenerator.h:60
GpgFrontend::KeyPackageOperator::GenerateKeyPackage
static bool GenerateKeyPackage(const std::filesystem::path &key_package_path, const std::string &key_package_name, KeyIdArgsListPtr &key_ids, std::string &phrase, bool secret)
generate key package
Definition: KeyPackageOperator.cpp:46
GpgFrontend::KeyPackageOperator::GeneratePassphrase
static bool GeneratePassphrase(const std::filesystem::path &phrase_path, std::string &phrase)
generate passphrase for key package and save it to file
Definition: KeyPackageOperator.cpp:39
GpgFrontend::FileOperator::ReadFileStd
static bool ReadFileStd(const std::filesystem::path &file_name, std::string &data)
read file content using std struct
Definition: FileOperator.cpp:55
GpgFrontend::GpgKeyImportExporter::ImportKey
GpgImportInformation ImportKey(StdBypeArrayPtr inBuffer)
Definition: GpgKeyImportExporter.cpp:42
GpgFrontend::KeyPackageOperator
give the possibility to import or export a key package
Definition: KeyPackageOperator.h:41
GpgFrontend::GpgImportInformation
Definition: GpgKeyImportExporter.h:57