fix(vaults): verify vault content keys per KID from the fragment map

Map each KID to its fragments from the ciphertext moov/moof (tenc, seig, ISM duration clock) and decode up to three windows per KID that never cross into another KID, so a clear lead cannot hide a wrong key and only the failing KID is flagged. Decode every frame (wrong-key HEVC keyframes decode clean), re-judge mid-GOP starts on keyframes, time out every FFmpeg run, and refuse to store a flagged pair again in SQLite.
This commit is contained in:
imSp4rky
2026-09-18 01:10:14 -06:00
parent cf2906f120
commit b30e6d7cbe
10 changed files with 921 additions and 41 deletions
+11
View File
@@ -68,6 +68,9 @@ class SQLite(Vault):
if isinstance(kid, UUID):
kid = kid.hex
if self.is_bad_key(kid.replace("-", ""), key):
return False
conn = self.conn_factory.get()
cursor = conn.cursor()
@@ -107,6 +110,14 @@ class SQLite(Vault):
if any(isinstance(kid, UUID) for kid, key_ in kid_keys.items()):
kid_keys = {kid.hex if isinstance(kid, UUID) else kid: key_ for kid, key_ in kid_keys.items()}
self.create_bad_keys_table()
bad = set(self.conn_factory.get().execute("SELECT lower(`kid`), lower(`key_`) FROM `bad_keys`").fetchall())
kid_keys = {
kid: key_
for kid, key_ in kid_keys.items()
if ((kid.hex if isinstance(kid, UUID) else kid.replace("-", "").lower()), key_.lower()) not in bad
}
if not kid_keys:
return 0