diff options
author | Peter Wu <peter@lekensteyn.nl> | 2020-07-09 23:31:46 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2020-07-10 05:11:26 +0000 |
commit | 1cbaaf3e8dbaaaa36dad33480f5c0fcaaa808912 (patch) | |
tree | 5b2fbf5900cb0af6c5172a3a1c01b72097148c25 /tools | |
parent | 5d313ecb2d9ddb566b594cb8c827db74dab0efa4 (diff) |
tls: Update list of CT logs to 2020-05-29
Avoid string literals while at it to avoid -Wpointer-sign warnings with
GCC 10. This has the additional benefit of avoiding storing the trailing
NUL byte after the data, resulting in a tiny reduction in binary size.
This compound literal syntax is supported since C99 which is permitted
by doc/README.developer.
Change-Id: I35f4d3a46aa78e12915d92136f1de0891131bede
Reviewed-on: https://code.wireshark.org/review/37818
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/make-tls-ct-logids.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/make-tls-ct-logids.py b/tools/make-tls-ct-logids.py index ee5672d839..9b30fb1832 100755 --- a/tools/make-tls-ct-logids.py +++ b/tools/make-tls-ct-logids.py @@ -21,13 +21,17 @@ CT_JSON_URL = 'https://www.gstatic.com/ct/log_list/v2/all_logs_list.json' # File to be patched SOURCE_FILE = "epan/dissectors/packet-tls-utils.c" +# Maximum elements per line in the value array. 11 is chosen because it results +# in output consistent with clang-format. +BYTES_PER_LINE = 11 + def escape_c(s): return s.replace('\\', '\\\\').replace('"', '\\"') def byteshex(b): - return "".join("\\x%02x" % b for b in bytearray(b)) + return " ".join("0x%02x," % b for b in bytearray(b)) def process_json(obj, lastmod): @@ -39,10 +43,12 @@ def process_json(obj, lastmod): desc = entry["description"] pubkey_der = b64decode(entry["key"]) key_id = sha256(pubkey_der).digest() - lines += ' { ' - lines += '"%s"\n' % byteshex(key_id[:16]) - lines += ' "%s", %d,\n' % (byteshex(key_id[16:]), len(key_id)) - lines += ' "%s" },\n' % escape_c(desc) + lines += ' { (const guint8[]){\n' + for offset in range(0, len(key_id), BYTES_PER_LINE): + lines += ' %s\n' % \ + byteshex(key_id[offset:offset+BYTES_PER_LINE]) + lines += ' },\n' + lines += ' %d, "%s" },\n' % (len(key_id), escape_c(desc)) lines += " { NULL, 0, NULL }\n" lines += "};\n" return lines |