aboutsummaryrefslogtreecommitdiffstats
path: root/info.c
diff options
context:
space:
mode:
authorCameron Katri <me@cameronkatri.com>2022-06-16 10:17:00 -0400
committerCameron Katri <me@cameronkatri.com>2022-06-16 10:21:50 -0400
commit9ef2c4a87d6fa816639b610313b67b98e983388a (patch)
treef3c5d259a3e0b87c5301ddf23b3185b4de9fbe9f /info.c
parent6a5be2524f0d31a601687e8b5d09b9af92848dac (diff)
downloadtrustcache-9ef2c4a87d6fa816639b610313b67b98e983388a.tar.gz
trustcache-9ef2c4a87d6fa816639b610313b67b98e983388a.tar.zst
trustcache-9ef2c4a87d6fa816639b610313b67b98e983388a.zip
Add support for new version 2 trustcachesHEADmain
Thanks to Linus Henze for reversing the new format https://gist.github.com/LinusHenze/4cd5d7ef057a144cda7234e2c247c056
Diffstat (limited to 'info.c')
-rw-r--r--info.c40
1 files changed, 36 insertions, 4 deletions
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]);
}
}
@@ -151,6 +157,32 @@ print_entry(struct trust_cache_entry1 entry)
}
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)
{
for (size_t j = 0; j < CS_CDHASH_LEN; j++) {