fix #2: do not discard trailing zero in decrypted ekey.
This commit is contained in:
parent
2908525c5c
commit
74ba5156df
@ -26,14 +26,8 @@ std::string_view span2ss(std::span<T> span) {
|
|||||||
return std::string_view(reinterpret_cast<char*>(span.data()), span.size());
|
return std::string_view(reinterpret_cast<char*>(span.data()), span.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_trailing_zeros(std::vector<uint8_t>& vec) {
|
|
||||||
auto it = std::find_if(vec.rbegin(), vec.rend(), [](uint8_t value) { return value != 0; });
|
|
||||||
vec.erase(it.base(), vec.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<uint8_t> decrypt_ekey_v1(std::string_view ekey) {
|
std::vector<uint8_t> decrypt_ekey_v1(std::string_view ekey) {
|
||||||
std::vector<uint8_t> result = b64_decode(reinterpret_cast<const uint8_t*>(ekey.data()), ekey.size());
|
std::vector<uint8_t> result = b64_decode(reinterpret_cast<const uint8_t*>(ekey.data()), ekey.size());
|
||||||
remove_trailing_zeros(result);
|
|
||||||
|
|
||||||
uint32_t tea_key[4] = {
|
uint32_t tea_key[4] = {
|
||||||
0x69005600 | static_cast<uint32_t>(result[0] << 16) | (result[1]),
|
0x69005600 | static_cast<uint32_t>(result[0] << 16) | (result[1]),
|
||||||
|
Loading…
Reference in New Issue
Block a user