wireshark/epan/dissectors/packet-tls.h
John Thacker dcbd3874d3 tls: add support for DESEGMENT_UNTIL_FIN, sequence numbers
Add a tlsinfo struct that is similar to tcpinfo, and carries
the sequence number (within the TLS stream) and the end of
stream notification (from the TCP FIN or close_notify alerts)
in addition to the session app handle pointer already used
by TLS heuristic dissectors.

Have HTTP use the end of stream notification in order to
handle DESEGMENT_UNTIL_FIN the same way it does when HTTP
is directly over TCP. Also have HTTP use the sequence number
in order to reduce chunked processing from O(N^2) to O(N)
similar to done over TCP.

Update all the TLS heuristic dissectors that set the app
handle to use the new structure.

Note the workaround for the issue #15159 - the TLS dissector
has to report to the TCP dissector that desegmentation at FIN
is required, so that the TCP dissector will know to call the
TLS dissector at FIN. However, the TLS dissector does not request
that the TCP dissector resend bytes belonging to records that
TLS has already desegmented (and decrypted, if possible), to
avoid decrypting twice (and upsetting the decoder state.)

This can mean the TCP dissector calling the TLS dissector to
desegment at FIN with a zero byte payload. In such as case, the
TLS dissector artificially returns "1" byte dissected to avoid
indicating rejecting the payload and having the TLS (and subdissector)
layers removed. (TCP ignores the value returned when desegmenting
at FIN.)

Fix #9154. Fix #14382.
2022-11-01 10:03:35 +00:00

68 lines
2.5 KiB
C

/* packet-tls.h
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PACKET_TLS_H__
#define __PACKET_TLS_H__
#include "ws_symbol_export.h"
#include <epan/packet.h>
struct tlsinfo {
guint32 seq; /* The sequence number within the TLS stream. */
gboolean is_reassembled;
gboolean end_of_stream; /* TCP FIN, close_notify, etc. */
/* The app handle for the session, set by heuristic dissectors
* to be called in the future. */
dissector_handle_t *app_handle;
};
/** Maps Session-ID to pre-master secrets. */
WS_DLL_PUBLIC GHashTable *ssl_session_hash;
/** Maps Client Random to pre-master secrets. */
WS_DLL_PUBLIC GHashTable *ssl_crandom_hash;
WS_DLL_PUBLIC void ssl_dissector_add(guint port, dissector_handle_t handle);
WS_DLL_PUBLIC void ssl_dissector_delete(guint port, dissector_handle_t handle);
WS_DLL_PUBLIC void ssl_set_master_secret(guint32 frame_num, address *addr_srv, address *addr_cli,
port_type ptype, guint32 port_srv, guint32 port_cli,
guint32 version, gint cipher, const guchar *_master_secret,
const guchar *_client_random, const guchar *_server_random,
guint32 client_seq, guint32 server_seq);
/**
* Retrieves Libgcrypt identifiers for the current TLS cipher. Only valid after
* the Server Hello has been processed and if the current conversation has TLS.
* Alternatively, this conversation lookup can be skipped if the current cipher
* ('cipher_suite') is provided (non-zero).
*/
extern gboolean
tls_get_cipher_info(packet_info *pinfo, guint16 cipher_suite, int *cipher_algo, int *cipher_mode, int *hash_algo);
/**
* Computes the TLS 1.3 "TLS-Exporter(label, context_value, key_length)" value.
* On success, the secret is in "out" (free with "wmem_free(NULL, out)").
*/
gboolean
tls13_exporter(packet_info *pinfo, gboolean is_early,
const char *label, guint8 *context,
guint context_length, guint key_length, guchar **out);
gint
tls13_get_quic_secret(packet_info *pinfo, gboolean is_from_server, int type, guint secret_min_len, guint secret_max_len, guint8 *secret_out);
/**
* Returns the application-layer protocol name (ALPN) for the current TLS
* session, or NULL if unavailable.
*/
const char *
tls_get_alpn(packet_info *pinfo);
#endif /* __PACKET_TLS_H__ */