| 56 | } |
| 57 | |
| 58 | bool lite::register_decryption_and_key( |
| 59 | std::string decrypt_name, const DecryptionFunc& func, |
| 60 | const std::vector<uint8_t>& key) { |
| 61 | LITE_LOCK_GUARD(decryption_static_data().map_mutex); |
| 62 | auto& global_map = decryption_static_data().decryption_methods; |
| 63 | if (global_map.find(decrypt_name) != global_map.end()) { |
| 64 | LITE_THROW(ssprintf( |
| 65 | "The decryption method %s is already registered.", |
| 66 | decrypt_name.c_str())); |
| 67 | return false; |
| 68 | } else { |
| 69 | auto key_pointer = std::make_shared<std::vector<uint8_t>>(key); |
| 70 | global_map[decrypt_name] = {func, key_pointer}; |
| 71 | LITE_LOG("Registered ecryption method %s.", decrypt_name.c_str()); |
| 72 | return true; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | bool lite::update_decryption_or_key( |
| 77 | std::string decrypt_name, const DecryptionFunc& func, |