| 74 | } |
| 75 | |
| 76 | bool lite::update_decryption_or_key( |
| 77 | std::string decrypt_name, const DecryptionFunc& func, |
| 78 | const std::vector<uint8_t>& key) { |
| 79 | LITE_LOCK_GUARD(decryption_static_data().map_mutex); |
| 80 | auto& global_map = decryption_static_data().decryption_methods; |
| 81 | if (global_map.find(decrypt_name) != global_map.end()) { |
| 82 | std::shared_ptr<std::vector<uint8_t>> key_pointer; |
| 83 | DecryptionFunc new_func; |
| 84 | if (func) { |
| 85 | new_func = func; |
| 86 | LITE_LOG("%s decryption function is updated.", decrypt_name.c_str()); |
| 87 | } else { |
| 88 | new_func = global_map[decrypt_name].first; |
| 89 | } |
| 90 | if (key.size()) { |
| 91 | key_pointer = std::make_shared<std::vector<uint8_t>>(key); |
| 92 | LITE_LOG("%s decryption key is updated.", decrypt_name.c_str()); |
| 93 | } else { |
| 94 | key_pointer = global_map[decrypt_name].second; |
| 95 | } |
| 96 | global_map[decrypt_name] = {new_func, key_pointer}; |
| 97 | return true; |
| 98 | } else { |
| 99 | LITE_THROW(ssprintf( |
| 100 | "The decryption method %s is not registered.", decrypt_name.c_str())); |
| 101 | return false; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | lite::ParseInfoStaticData& lite::parse_info_static_data() { |
| 106 | static lite::ParseInfoStaticData global_map; |