diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-11-18 18:11:42 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-11-20 05:14:35 +0000 |
commit | df7af28f39b5b104fb85f76ddd9b887a74cf2d63 (patch) | |
tree | adec02417c312fdd4c5f59eb6e45c11b785bc9b6 /wiretap | |
parent | e2e0fd1dbdb07f2a1bd8822ab86bcd7144025f97 (diff) |
Add new Secrets API and allow TLS to use pcapng decryption secrets
Add a new secrets API to the core, one that can outlive the lifetime of
a single capture file. Expose decryption secrets from wiretap through a
callback and let the secrets API route it to a dissector.
Bug: 15252
Change-Id: Ie2f1867bdfd265bad11fc58f1e8d8e7295c0d1e7
Reviewed-on: https://code.wireshark.org/review/30705
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/pcapng.c | 6 | ||||
-rw-r--r-- | wiretap/wtap-int.h | 1 | ||||
-rw-r--r-- | wiretap/wtap.c | 5 |
3 files changed, 12 insertions, 0 deletions
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index c330c60f11..378c6c97a6 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -2646,6 +2646,12 @@ pcapng_process_idb(wtap *wth, pcapng_t *pcapng, wtapng_block_t *wblock) static void pcapng_process_dsb(wtap *wth, wtapng_block_t *wblock) { + const wtapng_dsb_mandatory_t *dsb = (wtapng_dsb_mandatory_t*)wtap_block_get_mandatory_data(wblock->block); + + if (wth->add_new_secrets) { + wth->add_new_secrets(dsb->secrets_type, dsb->secrets_data, dsb->secrets_len); + } + /* Store DSB such that it can be saved by the dumper. */ g_array_append_val(wth->dsbs, wblock->block); } diff --git a/wiretap/wtap-int.h b/wiretap/wtap-int.h index 5a6005571e..9271ac39fa 100644 --- a/wiretap/wtap-int.h +++ b/wiretap/wtap-int.h @@ -69,6 +69,7 @@ struct wtap { */ wtap_new_ipv4_callback_t add_new_ipv4; wtap_new_ipv6_callback_t add_new_ipv6; + wtap_new_secrets_callback_t add_new_secrets; GPtrArray *fast_seek; }; diff --git a/wiretap/wtap.c b/wiretap/wtap.c index a9ec1e35bd..a19237209f 100644 --- a/wiretap/wtap.c +++ b/wiretap/wtap.c @@ -1258,6 +1258,11 @@ void wtap_set_cb_new_ipv6(wtap *wth, wtap_new_ipv6_callback_t add_new_ipv6) { wth->add_new_ipv6 = add_new_ipv6; } +void wtap_set_cb_new_secrets(wtap *wth, wtap_new_secrets_callback_t add_new_secrets) { + if (wth) + wth->add_new_secrets = add_new_secrets; +} + gboolean wtap_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { |