From 9ef2c4a87d6fa816639b610313b67b98e983388a Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Thu, 16 Jun 2022 10:17:00 -0400 Subject: Add support for new version 2 trustcaches Thanks to Linus Henze for reversing the new format https://gist.github.com/LinusHenze/4cd5d7ef057a144cda7234e2c247c056 --- info.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'info.c') diff --git a/info.c b/info.c index 4f74d62..b4249b1 100644 --- a/info.c +++ b/info.c @@ -77,8 +77,10 @@ tcinfo(int argc, char **argv) for (uint32_t i = 0; i < cache.num_entries; i++) { if (cache.version == 0) print_hash(cache.hashes[i], true); - else + else if (cache.version == 1) print_hash(cache.entries[i].cdhash, true); + else if (cache.version == 2) + print_hash(cache.entries2[i].cdhash, true); } goto done; } @@ -87,10 +89,12 @@ tcinfo(int argc, char **argv) fprintf(stderr, "no entry %i\n", entrynum); exit(1); } - if (cache.version == 1) { - print_entry(cache.entries[entrynum - 1]); - } else if (cache.version == 0) { + if (cache.version == 0) { print_hash(cache.hashes[entrynum - 1], true); + } else if (cache.version == 1) { + print_entry(cache.entries[entrynum - 1]); + } else if (cache.version == 2) { + print_entry2(cache.entries2[entrynum - 1]); } } else { print_entries(cache); @@ -121,6 +125,8 @@ print_entries(struct trust_cache cache) print_hash(cache.hashes[i], true); else if (cache.version == 1) print_entry(cache.entries[i]); + else if (cache.version == 2) + print_entry2(cache.entries2[i]); } } @@ -150,6 +156,32 @@ print_entry(struct trust_cache_entry1 entry) printf("[%i]\n", entry.hash_type); } +void +print_entry2(struct trust_cache_entry2 entry) +{ + print_hash(entry.cdhash, false); + + switch (entry.flags) { + case CS_TRUST_CACHE_AMFID: + printf(" CS_TRUST_CACHE_AMFID "); + break; + case CS_TRUST_CACHE_ANE: + printf(" CS_TRUST_CACHE_ANE "); + break; + case CS_TRUST_CACHE_AMFID|CS_TRUST_CACHE_ANE: + printf(" CS_TRUST_CACHE_AMFID|CS_TRUST_CACHE_ANE "); + break; + case 0: + printf(" [none] "); + break; + default: + printf(" [%i] ", entry.flags); + break; + } + + printf("[%i] [%i]\n", entry.hash_type, entry.category); +} + void print_hash(uint8_t cdhash[CS_CDHASH_LEN], bool newline) { -- cgit v1.2.3-56-ge451