MCPcopy Create free account
hub / github.com/AGWA/git-crypt / load_key

Function load_key

commands.cpp:589–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

587}
588
589static void load_key (Key_file& key_file, const char* key_name, const char* key_path =0, const char* legacy_path =0)
590{
591 if (legacy_path) {
592 std::ifstream key_file_in(legacy_path, std::fstream::binary);
593 if (!key_file_in) {
594 throw Error(std::string("Unable to open key file: ") + legacy_path);
595 }
596 key_file.load_legacy(key_file_in);
597 } else if (key_path) {
598 std::ifstream key_file_in(key_path, std::fstream::binary);
599 if (!key_file_in) {
600 throw Error(std::string("Unable to open key file: ") + key_path);
601 }
602 key_file.load(key_file_in);
603 } else {
604 std::ifstream key_file_in(get_internal_key_path(key_name).c_str(), std::fstream::binary);
605 if (!key_file_in) {
606 // TODO: include key name in error message
607 throw Error("Unable to open key file - have you unlocked/initialized this repository yet?");
608 }
609 key_file.load(key_file_in);
610 }
611}
612
613static bool decrypt_repo_key (Key_file& key_file, const char* key_name, uint32_t key_version, const std::vector<std::string>& secret_keys, const std::string& keys_path)
614{

Callers 5

cleanFunction · 0.85
smudgeFunction · 0.85
diffFunction · 0.85
add_gpg_userFunction · 0.85
export_keyFunction · 0.85

Calls 4

ErrorClass · 0.85
get_internal_key_pathFunction · 0.85
load_legacyMethod · 0.80
loadMethod · 0.80

Tested by

no test coverage detected