| 587 | } |
| 588 | |
| 589 | static 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 | |
| 613 | static 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 | { |
no test coverage detected