logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

New DeviceKey-Based Tuya Encrypted KV Decryption Method (BK7252U/TR6260/W800/LN8825B/RTL8720CM)

divadiow 1809 41

TL;DR

  • A new Tuya encrypted KV decryption method targets vault-style flash backups on BK7252U, TR6260, W800, LN8825B, and RTL8720CM.
  • It decrypts a wrapped key-record page first, extracts a 16-byte DeviceKey, then derives the vault key by bytewise addition with a BaseKey.
  • The vault data lives in fixed 4KB encrypted pages, and decrypted pages must match the 0x98761234 header and checksum or CRC.
  • When p_key is NULL, Tuya builds the BaseKey from two embedded 16-byte constants containing "HHRRQbyemofrtytf", yielding 9090a4a4a2c4f2cadadecce4e8f2e8cc.
  • The method successfully decoded vault KV on W800, TR6260, BK7252U, LN8825B, and RTL8720CM, but the recovered JSON does not include the pin assignments seen in BK7231N/T dumps.
Generated by the language model.
ADVERTISEMENT
📢 Listen (AI):
📢 Listen (AI):

Topic summary

✨ The discussion addresses the challenge of decrypting the key vault (KV) in Tuya flash backups for certain older platforms such as BK7252U, TR6260, and W800. Unlike the known decryption method for BK7231N/T and some RTL chipsets, which relies on a platform-specific seed key (KEY_PART_1), these older platforms do not use the same seed-driven approach for vault KV decryption. Extensive analysis involving SDK examination, brute-force attempts with millions of key combinations, and reverse engineering of libraries using csky tools revealed that the vault KV path on these devices is independent of the BK7231N/T-style seed key. This indicates a fundamentally different encryption scheme for these platforms, necessitating alternative decryption strategies beyond the known BK7231N/T and RTL8720CM methods.
Generated by the language model.

FAQ

TL;DR: New method decrypts Tuya vault KV across 5 chip families and 11 sample dumps; "device-key centred and two-stage." [Elektroda, divadiow, post #21808089]

Why it matters: It finally explains why older Tuya platforms wouldn’t decrypt and gives a reproducible path to recover JSON from encrypted KV.

Who this is for: firmware hackers, repairers, and tool authors wondering how to decrypt Tuya KV on BK7252U/TR6260/W800/LN8825B/RTL8720CM without the old seed trick.

Quick facts:

Quick Facts

What changed versus the older BK7231N/T seed-based method?

Older BK7231N/T extractions used a platform seed (e.g., 8720) to decrypt specific blobs. The new finding shows some platforms use a device-key-centered, two-stage vault: first decrypt a wrapped key-record page to reveal a 16‑byte DeviceKey, then derive the vault key and decrypt 4KB pages. [Elektroda, divadiow, post #21808089]

Which chips and example dumps are confirmed to decrypt with this method?

Confirmed families include BK7252U, TR6260, W800, LN8825B, and RTL8720CM. The author lists 11 specific FlashDumps paths that successfully decode, covering doorbells, LED controllers, hubs, and downlights. Tooling validated page headers and checksums, yielding plaintext JSON. [Elektroda, divadiow, post #21808089]

How is the DerivedKey computed for vault pages?

Combine a 16‑byte BaseKey with the 16‑byte DeviceKey using bytewise addition modulo 256. In code terms: DerivedKey[i] = (BaseKey[i] + DeviceKey[i]) & 0xFF for i=0..15. This key decrypts fixed-size vault pages. [Elektroda, divadiow, post #21808089]

Where does the default BaseKey come from when p_key is NULL?

Tuya’s DB init logic constructs a 16‑byte BaseKey by adding two embedded 16‑byte constants. Both constants equal the ASCII seed “HHRRQbyemofrtytf,” so the bytes are doubled, yielding hex 9090a4a4…e8cc. “NULL-key branch” lives in libtuya_iot.a. [Elektroda, divadiow, post #21808089]

How do I verify that page decryption worked?

Each decrypted vault page should show a known header magic (example 0x98761234) and pass an integrity check (checksum or CRC). If either fails, your BaseKey/DeviceKey or page boundary is wrong. “Magic + CRC proves correctness.” [Elektroda, divadiow, post #21808089]

What JSON data can I actually recover?

You can carve plaintext JSON after decryption. Examples include uuid, psk_key, auth_key, SmartLife AP SSID, version fields, region, and tokens. The sample BK7252U JSON shows multiple objects and redundant blocks. Dedupe identical objects during export. [Elektroda, divadiow, post #21808089]

Does this method reveal GPIO pin assignments like BK7231N dumps did?

No. The decoded vaults lack the pin assignment info seen on BK7231N extractions. Practical value is JSON recovery, not pin mapping. Plan alternative pin discovery if needed. [Elektroda, divadiow, post #21808089]

How do I use the Python/tkinter tool to decrypt a dump? (3 steps)

  1. Load the flash dump and select the key-record region to unwrap the DeviceKey.
  2. Choose BaseKey (NULL default or custom) and decrypt vault pages.
  3. Export plaintext JSON and optionally dedupe or save decrypted blobs. “Swap” handles a secondary region in LN8825B. [Elektroda, divadiow, post #21808089]

What is the “key record” and how do I decrypt it?

It’s a dedicated flash page (often 4KB) wrapping per-device key material, including the 16‑byte DeviceKey. Decrypt it first using the fixed wrapper mechanism. After unwrapping, read DeviceKey to derive the vault key. [Elektroda, divadiow, post #21808089]

What is Tuya in this FAQ’s context?

Here, “Tuya” refers to the vendor ecosystem whose firmware stores an encrypted key-value vault and initializes DB keys as described. We focus on how its prebuilt library derives and applies BaseKey and DeviceKey during KV decryption. [Elektroda, divadiow, post #21808089]

Should this land in Easy Flasher?

Yes, a maintainer encouraged adding it. One open issue remains: the separate “missing key” puzzle investigated in Ghidra is still unsolved. Integrate the vault workflow, but track that gap. [Elektroda, p.kaczmarek2, post #21808335]

What are common failure modes or edge cases to watch for?

Edge cases include wrong page alignment, incorrect BaseKey in NULL vs caller-supplied paths, and non-matching magic or CRC. Also, expect no GPIO pin maps in recovered JSON. Some platforms outside the listed set may use different layouts. [Elektroda, divadiow, post #21808089]
Generated by the language model.
ADVERTISEMENT