wiretap: add read/write support for Decryption Secrets Block (DSB)
authorPeter Wu <peter@lekensteyn.nl>
Sat, 17 Nov 2018 12:56:12 +0000 (13:56 +0100)
committerAnders Broman <a.broman58@gmail.com>
Tue, 20 Nov 2018 05:12:37 +0000 (05:12 +0000)
commit52a667143929ace46929bfb6ad15b6a856cdbe77
tree97dfedc45dd07c47116ba06cb13457f04a5d48df
parentad21e3121f3307ee6cc2b4a2b296ef6dd83152ed
wiretap: add read/write support for Decryption Secrets Block (DSB)

Support reading and writing pcapng files with DSBs. A DSB may occur
multiple times but should appear before packets that need those
decryption secrets (so it cannot be moved to the end like NRB). The TLS
dissector will be updated in the future to make use of these secrets.
pcapng spec update: https://github.com/pcapng/pcapng/pull/54

As DSBs may be interleaved with packets, do not even try to read it in
pcapng_open (as is done for IDBs). Instead process them during the
sequential read, appending them to the 'wtap::dsbs' array.

Writing is more complicated, secrets may initially not be available when
'wtap_dumper' is created. As they may become available in 'wtap::dsbs'
as more packets are read, allow 'wtap_dumper::dsbs_growing' to reference
this array. This saves every user from checking/dumping DSBs.

If the wtap user needs to insert extra DSBs (while preserving existing
DSBs), they can set the 'wtap_dumper::dsbs_initial' field.

The test file was creating using a patched editcap (future patch) and
combined using mergecap (which required a change to preserve the DSBs).

Change-Id: I74e4ee3171bd852a89ea0f6fbae9e0f65ed6eda9
Ping-Bug: 15252
Reviewed-on: https://code.wireshark.org/review/30692
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
18 files changed:
epan/dissectors/file-pcapng.c
test/captures/tls12-dsb.pcapng [new file with mode: 0644]
test/keys/tls12-dsb-1.keys [new file with mode: 0644]
test/keys/tls12-dsb-2.keys [new file with mode: 0644]
test/suite_fileformats.py
wiretap/CMakeLists.txt
wiretap/file_access.c
wiretap/merge.c
wiretap/merge.h
wiretap/pcapng.c
wiretap/pcapng.h
wiretap/pcapng_module.h
wiretap/secrets-types.h [new file with mode: 0644]
wiretap/wtap-int.h
wiretap/wtap.c
wiretap/wtap.h
wiretap/wtap_opttypes.c
wiretap/wtap_opttypes.h