| 70 | } |
| 71 | |
| 72 | int LITE_register_decryption_and_key( |
| 73 | const char* decrypt_name, const LiteDecryptionFunc func, |
| 74 | const uint8_t* key_data, size_t key_size) { |
| 75 | LITE_CAPI_BEGIN(); |
| 76 | LITE_ASSERT(decrypt_name && key_data && func, "The ptr pass to LITE api is null"); |
| 77 | std::vector<uint8_t> key; |
| 78 | for (size_t i = 0; i < key_size; i++) { |
| 79 | key.push_back(key_data[i]); |
| 80 | } |
| 81 | auto decrypt_func = [func](const void* input_data, size_t input_size, |
| 82 | const std::vector<uint8_t>& key) { |
| 83 | auto size = func(input_data, input_size, key.data(), key.size(), nullptr); |
| 84 | std::vector<uint8_t> output(size, 0); |
| 85 | func(input_data, input_size, key.data(), key.size(), output.data()); |
| 86 | return output; |
| 87 | }; |
| 88 | lite::register_decryption_and_key(decrypt_name, decrypt_func, key); |
| 89 | LITE_CAPI_END(); |
| 90 | } |
| 91 | |
| 92 | int LITE_update_decryption_or_key( |
| 93 | const char* decrypt_name, const LiteDecryptionFunc func, |