Commit Graph

216 Commits

Author SHA1 Message Date
Michael Mann 57ef06e242 *_stdup_printf -> strdup for "single string only" formatting.
Done for performance improvements.

This could probably be done in checkAPIs.pl, but this was just
a quick manual check with grepping.

Change-Id: I91ff102cb528bb00fa2f65489de53890e7e46f2d
Reviewed-on: https://code.wireshark.org/review/15751
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
2016-06-06 06:03:58 +00:00
Jim Young 4b66b32fb3 Resolve false positive ERROR: NO ARRAY found in ei array entries
The enhanced checkhf.pl in https://code.wireshark.org/review/#/c/15717/
validates ei items in addition to href items.   This patch addresses the
false positive ERRORS reported by the enhanced checkhf.pl for a "cosmetic"
issue (missing space after { in ei array entries).

Change-Id: I87876ce2cfa4b0e11cb22f457bd9ab025d939e5c
Reviewed-on: https://code.wireshark.org/review/15739
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-06-05 22:31:37 +00:00
Alexis La Goutte 9c23220abb dtls: fix 'data' was marked unused but was used [-Werror,-Wused-but-marked-unused]
Change-Id: I919192b14159fd70bb7bf182507f1e42c3167721
Reviewed-on: https://code.wireshark.org/review/14983
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-18 10:28:08 +00:00
Peter Wu a5b8439453 dtls: Fix ClientCertificateVerify dissection
Pass the reassembled fragment instead of the current record.

Bug: 11477
Change-Id: Id49fac8fa3f9e1b1904a75ab6c7512306f2071b0
Reviewed-on: https://code.wireshark.org/review/14727
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-03-31 12:23:50 +00:00
Adam Schwalm 2b2fc64447 Fix incorrect table being used to store Session Tickets
A regression was introduced at f4580ac9ed where an additional
hash table was introduced to store TLS Session Tickets separately
from Session IDs. However, the New Session Ticket dissector was
still storing the the Session Ticket in the ID table, causing lookups
to fail.

Change-Id: Iff49202f50afb8cb6ef62c774f6155682b8e48a6
Reviewed-on: https://code.wireshark.org/review/14499
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-03-20 16:57:41 +00:00
Michael Mann e37275bfde Associate dissector tables and heuristic subdissector lists with a protocol.
This will make it easier to determine protocol dependencies.

Some LLC OUI dissector tables didn't have an associated protocol, so they were left without one (-1 used)

Change-Id: I6339f16476510ef3f393d6fb5d8946419bfb4b7d
Reviewed-on: https://code.wireshark.org/review/14446
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-03-17 00:05:17 +00:00
Guy Harris bc5a0374bf Add the packet number to the packet_info structure, and use it.
That removes most of the uses of the frame number field in the
frame_data structure.

Change-Id: Ie22e4533e87f8360d7c0a61ca6ffb796cc233f22
Reviewed-on: https://code.wireshark.org/review/13509
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-24 03:41:28 +00:00
Michael Mann 31a54708f4 new_register_dissector -> register_dissector for dissector directory.
Change-Id: Ie39ef054a4a942687bd079f3a4d8c2cc55d5f22c
Reviewed-on: https://code.wireshark.org/review/12485
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-12-09 12:38:06 +00:00
Michael Mann 2bbbb4879c register_dissector -> new_register_dissector
Change-Id: Ic368dd8e83cf39e0c934da0ae2744778e2d54ce6
Reviewed-on: https://code.wireshark.org/review/12050
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-23 13:09:55 +00:00
Peter Wu 4002f98413 ssl,dtls: use ProtocolVersion from Server Hello
A DTLS capture from Jitsi Videobridge for Windows x64 (v519) using a
(patched?) BouncyCastle 1.51.0 exposed the odd behavior where the
ProtocolVersion from the record layer was always fixed to DTLSv1.2 while
the server agrees to use DTLSv1.0.

This resulted in a Malformed packet dissection of the ServerKeyExchange
message which mistakenly expects a SignatureAndHash field. Fix this
by using the protocol version from the ServerHello. Keep the fallback
in case a capture starts in the middle of a SSL conversation.

(Also display "DTLS" instead of "SSL" when the version is not yet
determined for DTLS packets.)

Bug: 11709
Change-Id: I0719977e3b2208da1960121b01dc109fa76bfcb6
Reviewed-on: https://code.wireshark.org/review/11821
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2015-11-16 21:47:43 +00:00
Peter Wu c90990068f ssl,dtls: use a single field to track ProtocolVersion
The SslSession struct contains a "version" field for displaying
purposes in the protocol column while the SslDecryptSession struct
has a "version_netorder" field for use in TLS hash functions (for
secrets calculations).

As these are strongly associated with each other, remove the
version_netorder field and its associated constants, let the SslSession
version field store this value instead. All SSL_VER_* are renamed to
appropriate *_VERSION macros (via search & replace), SSL_VER_UNKNOWN
is kept though.

The PCT and SSLv2 protocols had no wire value (*_VERSION), so
SSL_VER_PCT and SSL_VER_SSLv2 are assigned with some arbitrary values.

Warning: external plugins using the ssl_set_master_secret function
must now pass the wire version (TLSV1_VERSION) instead of the (now
removed) internal macros (SSL_VER_TLSv1).

Change-Id: Icd8ef15adae9c62eb21eab1c3b812166e451936f
Reviewed-on: https://code.wireshark.org/review/11820
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2015-11-16 21:45:50 +00:00
Alexis La Goutte 51f59e1655 DTLS: fix no previous prototype for 'dtls_dissector_add/delete' [-Wmissing-prototypes]
Change-Id: Ib2be8c4ebbaf8492fe76632fae2b5076a44f74ce
Reviewed-on: https://code.wireshark.org/review/11653
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-09 12:42:38 +00:00
Michael Mann f4921c10e6 Add support for registering protocols (dissectors) over DTLS.
This is intentionally broken off of SSL to avoid confusion when UDP is involved.

Change-Id: Icfd3054be6aed2ebbd850a608efbc24f1a8f3831
Reviewed-on: https://code.wireshark.org/review/11612
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-07 14:12:43 +00:00
Michael Mann 3aefd3b5b2 Create real dissector tables for SSL and DTLS to use.
Since ssl_dissector_[add|delete] only take TCP dissectors, remove the parameter and just use it within the "internal" ssl_association_add call.

Change-Id: I0fdf941389934c20cbacf910250e17520614e706
Reviewed-on: https://code.wireshark.org/review/11591
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-07 14:11:01 +00:00
Peter Wu e0cf8b6ccf ssl: add expert info for session resumption
Add expert info to the Change Cipher Spec tree when session resumption
is detected. This can be used as hint that decryption using a RSA key
file will not succeed because of missing key material.

The name of this expert info is "ssl.resumed" or "dtls.resumed" and the
expert info message is "This session reuses previously negotiated keys
(Session resumption)".

Change-Id: I4a83edb13417631c97d6cfc4a57e2086bd217878
Reviewed-on: https://code.wireshark.org/review/11583
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-11-07 07:40:32 +00:00
Guy Harris ff9f9fc431 Don't include "file.h" if you don't need it.
It ends up dragging in libwireshark headers, which programs not linking
with libwireshark shouldn't do.  In particular, including
<epan/address.h> causes some functions that refer to libwireshark
functions to be defined if the compiler doesn't handle "static inline"
the way GCC does, and you end up requiring libwireshark even though you
shouldn't require it.

Move plurality() to wsutil/str_util.h, so that non-libwireshark code can
get it without include epan/packet.h.  Fix includes as necessary.

Change-Id: Ie4819719da4c2b349f61445112aa419e99b977d3
Reviewed-on: https://code.wireshark.org/review/11545
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-11-04 08:46:30 +00:00
Peter Wu 07ceb2c6dc ssl-utils: add versions to ssl debug log
Add Wireshark/GnuTLS/Libgcrypt versions to the debug log file. Remove
ssl_lib_init since it didn't do anything useful (the debug file was not
open yet so it would write... nothing).

Match more (EC)DH(E) cipher suites and try to improve the message.

Add the human-readable name besides numeric cipher suite IDs.

Change-Id: I84a33d270f91e90efc55371475b231b483fd24c9
Reviewed-on: https://code.wireshark.org/review/11403
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-10-29 18:49:26 +00:00
Martin Kaiser 7a9237fb21 [ssl] dissect handshake messages even if we have no tree
this is to make sure that all expert info we see in the
main window will also appear in the expert info window

the sample capture from bug 11561 shows this problem:
without this patch, the expert info with severity 'error'
don't show up in the expert info window

Change-Id: Ia71ae7e248f57bf1344cf722ac57e74c517828d5
Reviewed-on: https://code.wireshark.org/review/11246
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-10-27 21:47:57 +00:00
Peter Wu 36079a1eb5 ssl-utils: allow gcrypt without GnuTLS, improve structure
Fix distinction between HAVE_LIBGNUTLS and HAVE_LIBGCRYPT. If GnuTLS is
unavailable, then the only missing feature is decryption using an RSA
private key file. Regardless of GnuTLS, allow SSL decryption (e.g. using
a SSL key log file or a PSK configured via preferences).

This change has no functional effect when GnuTLS and gcrypt are both
available (or not). Additionally, decryption is possible if only
libgcrypt is available.

Further changes to make ssl-utils more maintainable and documented:
 - Group related functions, add markers and documentation. The following
   functions are moved (with no further modifications):
   - ssl_data_realloc, ssl_data_copy: related to StringInfo.
   - ssl_change_cipher, ssl_create_flow: related to the decryption of a
     session.
   - ssl_decompress_record: related to Record Decompression.
   - ssl_lib_init: moved to an arbitrary place.
   - ssl_set_server: moved closer to ssl_packet_from_server.
   - ssl_is_valid_content_type, ssl_is_valid_handshake_type: move closer
     to dissection code.
   - ssl_dissect_hnd_hello_ext_status_request,
     ssl_dissect_hnd_hello_ext_status_request_v2,
     ssl_dissect_hnd_hello_ext_elliptic_curves,
     ssl_dissect_hnd_hello_ext_ec_point_formats: move to TLS extensions.
 - Remove unused forward declaration of _gcry_rsa_decrypt.
 - ssl-packet-utils.h:
   - Remove ssl_equal, ssl_hash. These are only used in
     packet-ssl-utils.c.
   - ssl_private_key_equal, ssl_private_key_hash,
     ssl_common_register_options: inline when decryption is not
     possible.
   - Remove ws_symbol_export.h, enable SSL debug log when libgcrypt is
     compiled in (instead of depending on GnuTLS).
 - Move/merge stub code when GnuTLS or libgcrypt are not available:
   - ssl_find_cipher: move.
   - ssl_cipher_setiv: move.
   - ssl_generate_pre_master_secret, ssl_generate_keyring_material: move.

Compile-tested all combinations:
 - no GnuTLS, no libgcrypt: CentOS 6.
 - no GnuTLS, has libgcrypt: CentOS 6. Passes all decryption tests
   except for the ones that need a RSA private key file.
 - has GnuTLS, no libgcrypt: Arch Linux.
 - has GnuTLS, has libgcrypt: Arch Linux. The decryption tests pass.
(GnuTLS support is useless without gcrypt, but included for completeness.)

Change-Id: I727248937331f8788de8ed78248bb33296206096
Reviewed-on: https://code.wireshark.org/review/11052
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2015-10-16 09:27:47 +00:00
Peter Wu 877fd03cbf ssl-utils: load RSA keys based on their modulus+exponent
Load RSA private keys based on their public key instead of relying on
the user to specify a valid address and port mapping. This is more
reliable and prepares for simplification of the SSL Keys dialog.

After this change, the "address" part of the UAT dialog will be ignored
when loading the private key. The port+protocol mapping is still
imported, but should probably be removed too.

Change-Id: I4d7a2bfcf63d17e66e336ef770759f20510fc176
Reviewed-on: https://code.wireshark.org/review/10766
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-10-07 04:09:42 +00:00
Peter Wu 40ff4ffee8 ssl-utils: simplify private key storage, fix resource leaks
The certificate and GnuTLS private key are never used except for
reporting in the log file. Remove the unused certificate-related code
from the PKCS#12 file parsing. Report an immediate error instead of
opening key file if GnuTLS is disabled.

Made ssl_load_key and ssl_load_pkcs12 static, they are not used outside
the SSL dissector. If for some reason the PKCS#12 bag contains multiple
private keys, then the previous one would be overwritten (leaking
memory). Fix this by returning the first private key found.

Simplify key_hash (dtls_key_hash/ssl_key_hash) memory management, now
the table automatically frees keys/values when items are removed.

Fix memory leaks:
 - ssldecrypt_uat_fld_password_chk_cb: release ssl_load_pkcs12 memory.
 - ssl_load_key: avoid leaking gnutls_x509_privkey_t on error.
 - ssl_load_pkcs12: fix ssl_pkey leak on error path.

Change-Id: I5db6fecb0d74e5c78796392aeb17e3eb7985a2ef
Reviewed-on: https://code.wireshark.org/review/10764
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-10-07 04:04:59 +00:00
Michal Pazdera 9f171ee584 Multiple SSL content in one packet fix
When SSL packet contains multiple encrypted contents the WS shows only the
last record due the wrong indexing of the structure where the decrypted
contents are stored. Should use tvb_raw_offset(tvb)+offset instead of
offset as I think was intended.

Added the same fix for DTLS.

Bug: 11523
Change-Id: I0a977a0e6ebe7c45e526fa5152b8614463abd4fa
Reviewed-on: https://code.wireshark.org/review/10528
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Peter Wu <peter@lekensteyn.nl>
2015-09-25 14:33:57 +00:00
Peter Wu 134572289e dtls: remove unneeded private key file lookup
The comment was valid, the private key is already looked during the
ClientHello message (using ssl_find_private_key) and since the key is
only used during the key exchange, it is not needed to look it up that
early.

Verified with the test suite (DTLS Decryption).

Change-Id: Ia084a40d98cd74c77e9f1659ac57eeb8d44e59b6
Reviewed-on: https://code.wireshark.org/review/10529
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2015-09-14 10:10:18 +00:00
Peter Wu 3ce60ed112 dtls: do not try to add a zero-length fragment
fragment_add does not like adding zero-length fragments, it causes a
zero-length memcpy to NULL.

According to RFC 6347, fragment_offset=0 and fragment_length=length is
an unfragmented message, so fragment>0 and fragment_length=length=0 is a
fragmented message.

An empty fragment does not extend a previous message, so ignore it.
Such fragments are produced by at least GnuTLS 3.3.7[1], so raise a
warning instead of an error.

Caught by ubsan:

    epan/tvbuff.c:783:10: runtime error: null pointer passed as argument 1, which is declared to never be null

    #0 0x7f5319f6ed64 in tvb_memcpy epan/tvbuff.c:783
    ...
    #13 0x7f5319f27e2b in fragment_add epan/reassemble.c:1394
    #14 0x7f531a5c70a4 in dissect_dtls_handshake epan/dissectors/packet-dtls.c:1257

 [1]: http://comments.gmane.org/gmane.network.gnutls.general/3582

Change-Id: I70bf16d2fb64793d0deaabe612147e238b743b2e
Ping-Bug: 11358
Reviewed-on: https://code.wireshark.org/review/9689
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2015-08-23 16:48:04 +00:00
Guy Harris 170def9511 Fix escaping of strings in UATs.
Not only must characters that aren't printable ASCII characters be
escaped, backslashes must be escaped (as backslash is an escape
introducer) and double-quotes must be escaped (as double-quotes
encapsulate strings).

When constructing a string to hand to uat_load_str(), escape pathnames,
as they are likely to contain backslashes on Windows, could contain
backslashes on UN*X, and could contain quotes on UN*X and possibly
Windows.  (Arguably, we should escape all the string arguments

Bug: 11372
Change-Id: I594840327fa41895130903c3c612ba97d6c29df3
Reviewed-on: https://code.wireshark.org/review/9716
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-07-20 17:02:59 +00:00
Michael Mann 21e5a950ad Remove all preferences related to enabling/disabling heuristic dissectors.
The preferences are still supported for backwards compatibility, but the heuristic_protos file has final say on the "preference" to enable/disable a heuristic dissector.

Also add parameter to heur_dissector_add() for the "default" enable/disable of a heuristic dissector. With this parameter, a few more (presumably weak) heuristic dissectors have been "registered" but of course default to being disabled.

Change-Id: I51bebb2146ef3fbb8418d4f5c7f2cb2b58003a22
Reviewed-on: https://code.wireshark.org/review/9610
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Hadriel Kaplan <hadrielk@yahoo.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-07-17 17:12:22 +00:00
Pascal Quantin 0801cd399f DTLS: fix compilation without libgcrypt or libgnutls
Change-Id: I571f1ddaaa9579af65d558afc7162493a7393703
Reviewed-on: https://code.wireshark.org/review/9661
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-07-16 17:29:33 +00:00
Pascal Quantin 79774329d7 Simply code for export of PDUs coming from heuristic dissectors
Let's use the newly introduced find_heur_dissector_by_unique_short_name() function

Change-Id: I5781b9b2f1ab679da07e97755b71840b4b3a9361
Reviewed-on: https://code.wireshark.org/review/9645
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-07-15 18:30:57 +00:00
Michael Mann be7d295fbf Add "user presentable" and "unique string ids" to heuristic table entries.
This allows better presentation of heuristic dissectors to the end user.

Change-Id: I2ff3985ab914e83c2989880cc0c7b9904045b3f6
Reviewed-on: https://code.wireshark.org/review/9602
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-07-12 03:14:38 +00:00
Peter Wu 3ad976896a ssl,dtls: split init/cleanup routines
Minor functional change: instead of an empty hash table, now the
ssl_session_hash and ssl_crandom_hash structures point will be set to
NULL when files are closed.

API change: drop the ssl_keylog_file parameter from ssl_common_init,
add a new ssl_common_cleanup parameter instead.

Change-Id: I65efe71f8347fe9685359f8ed70cfb9673712421
Reviewed-on: https://code.wireshark.org/review/9226
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-07-03 23:38:26 +00:00
Pascal Quantin cdc7d25004 Add ability to export PDUs for heuristic dissectors also
Change-Id: I1bf1aa9794f9b4f106edffd4986fc0b1014522fa
Reviewed-on: https://code.wireshark.org/review/9099
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-06-25 00:10:13 +00:00
Michael Mann c6b0a61ab3 Remove proto_tree_add_text from packet-ssl-utils.c
Change-Id: I64998e93e8d72faa76e0e7809abfd9ccae10ab36
Reviewed-on: https://code.wireshark.org/review/8653
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-05-26 15:14:23 +00:00
Andreas Schultz a596361228 DTLS: use addresses_ports_reassembly_table_functions
When capturing two consecutive DTLS session to the same server,
fragments for the second session report a error:

> [Reassembly error, protocol DTLS: New fragment overlaps old data (retransmission?)]

It turns out that the DTLS dissector uses the addresses_reassembly_table_functions
which takes only the IP addresses into account and not the ports.
Changing that to the addresses_ports_reassembly_table_functions
fixes the bogus error message.

Change-Id: If317314dca4b1d46e802bac54c07c89c7a73e24e
Reviewed-on: https://code.wireshark.org/review/7824
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-03-26 14:48:55 +00:00
Peter Wu 70d34eee2b ssl,dtls: fix CertificateVerify dissection for TLSv1.2
TLSv1.2 gained an additional SignatureAndHashAlgorithm field for fields
marked with the digitally-signed attribute. This was already implemented
before for ServerKeyExchange, let's reuse that.

Note that the SignatureAndHashAlgorithm tree and fields (hash algo,
signature algo) are repurposed in a different context, but since the
structure is the same it is kept like this.

By the way, add support for DTLSv1.2 too. RFC 6347 section 4.2.6
suggests that the implementation is the same (as far as the dissector is
concerned).

Also update the comments and remove the additional "Signature with
client's private key" subtree since the CertificateVerify message has no
other items.

Bug: 11045
Change-Id: I025901b85e607f04d60357ff14187cc13db2ae5d
Reviewed-on: https://code.wireshark.org/review/7650
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-03-12 12:48:00 +00:00
Michael Mann b7ef891af8 Replace tvb_get_ptr calls with a better API choice.
Just reduces the overall tvb_get_ptr usage count in the dissector directory.

Change-Id: I455dc4cc9b082ecccdd254a2e5121f3353b5a812
Reviewed-on: https://code.wireshark.org/review/7491
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-03-03 09:02:25 +00:00
Peter Wu 93ed72642b ssl,dtls,ssl-utils: Prepare for STARTTLS handling
All STARTTLS-like dissectors (protocols which can switch to SSL/TLS
after a protocol command) currently fail to get called after decryption.
The reason for this is that the port is not registered for SSL
dissection via ssl_dissector_add. Besides this, the MySQL dissector
breaks in the event of multiple segments because it does not properly
set desegmentation.

The call path TCP | App | SSL | App is a bad, error-prone pattern which
requires duplication of required functionality in dissectors. This patch
enables to bypass the App (TCP | SSL | App) by registering a SSL as
conversation dissector after a STARTTLS switch.

Logical overview of changes:

 - Move srv_addr, srv_ptype and srv_port to SslSession and adjust the
   users. This allows passing SslSession around which will never be null
   unlike SslDecryptSession. This is needed for looking up the packet
   direction (server or client) before calling a subdissector.
 - Add app_handle to store the dissector and last_nontls_frame the
   frame that initiated STARTTLS.
 - The same app_handle is now used to store the dissector handle from
   a ssl association.
 - Moved conversation data (SslDecryptSession) to ssl-utils to avoid
   code duplication. Merge ssl_session_init into it. The new
   ssl_session_get() is needed for STARTTLS frame/handle storage.
 - Introduce new "ssl_starttls_ack" function to signal the last non-TLS
   packet.
 - Ensure that match_uint is set before calling the conversation
   dissector. This ensures that dissectors using match_uint to check
   the direction of a packet (client vs. server) see the TCP port
   instead of the IP proto. At least the MySQL and SMTP dissectors
   require such special treatment.
 - Move epan/conversation.h outside HAVE_LIBGNUTLS, remove from dtls
   (as it is already included by ssl-utils).
 - Various comment/debug string updates. Remove outdated comment before
   SSL association lookup.

Besides setting match_uint and caching the app_handle, existing
dissectors should not be affected by this patch. Follow-up patches
will update existing dissectors to use the new ssl_starttls_ack
interface.

Bug: 9515
Change-Id: I795d16b6a901e672a5d89e922adc7e5bbcda0333
Reviewed-on: https://code.wireshark.org/review/6872
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-02-09 14:00:38 +00:00
Michael Mann 7967ef9510 Remove emem APIs from UAT functionality.
Change-Id: I009c09f25d170e5c9aaaef713eaacb3252817856
Reviewed-on: https://code.wireshark.org/review/6460
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Evan Huus <eapache@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-12 14:25:12 +00:00
Evan Huus 3a9869d81a Remove/replace ep_strsplit()
Change-Id: I4a803d83844d937804849b2ad3b067381c9b96d0
Reviewed-on: https://code.wireshark.org/review/6448
Petri-Dish: Evan Huus <eapache@gmail.com>
Reviewed-by: Evan Huus <eapache@gmail.com>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-01-10 01:56:08 +00:00
Stephen Fisher ae6df38436 packet-dtls.c still needs conversation.h
Change-Id: I1e6a55c41cbab74790880da2b3691cd7d82bc276
Reviewed-on: https://code.wireshark.org/review/6004
Reviewed-by: Stephen Fisher <sfisher@sdf.org>
2014-12-23 00:23:31 +00:00
Martin Mathieson 596669f921 First batch of unincludes. Last attempt...
Change-Id: I3681462aeb98ca62ed3ec5eb226b2553317391a9
Reviewed-on: https://code.wireshark.org/review/5997
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2014-12-22 21:03:13 +00:00
Bill Meier b5d7b7ab6e Cleanup use of #includes in non-generated epan/dissector/*.c
Specifically:
- Set packet.h to be the first wireshark #include after
   config.h and "system" #includes.
   packet.h added as an #include in some cases when missing.
- Remove some #includes included (directly/indirectly) in
   packet.h. E.g., glib.h.
   (Done only for those files including packet.h).
- As needed, move "system" #includes to be after config.h and
   before wireshark #includes.
- Rework various #include file specifications for consistency.
- Misc.

Change-Id: Ifaa1a14b50b69fbad38ea4838a49dfe595c54c95
Reviewed-on: https://code.wireshark.org/review/5923
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-12-21 05:46:22 +00:00
Guy Harris 2b006ad30e Have a heur_dissector_list_t be an opaque handle.
This allows dissector lists to be looked up by name, so they can be
shared by multiple dissectors.

(This means that there's no "udplite" heuristic dissector list, but
there shouldn't be one - protocols can run atop UDP or UDPLite equally
well, and they share a port namespace and uint dissector table, so they
should share a heuristic dissector table as well.)

Change-Id: Ifb2d2c294938c06d348a159adea7a57db8d770a7
Reviewed-on: https://code.wireshark.org/review/5936
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-21 04:14:24 +00:00
Dave Tapuska 6dbb97da10 SSL: Implement Extended Master Secret
Store all handshake mesages in a buffer so that we can hash them
correctly when generating the master secret.

This change does not work correctly for DTLS retransmitted packets; that
are in the handshake as they will be hashed twice; which is bad. Looking
for ideas to implement this.

Bug: 10686
Change-Id: Ied01d4cc37b4270f325070a8d1630d3123577a0d
Reviewed-on: https://code.wireshark.org/review/5168
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-11-24 09:22:12 +00:00
Bill Meier 01b093c24d Add editor modelines; Adjust whitespace as needed.
Change-Id: I434da226c842298f4fb2a4335d06d51e164af2af
Reviewed-on: https://code.wireshark.org/review/4394
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-09-30 23:17:01 +00:00
Peter Wu a69a63f5d1 ssl: fix SSL keylog file live-capture use case
Patch "ssl,dtls: simplify keyfile handling" did not account for the use
case where packets are captured and decrypted on the fly using
SSLKEYLOGFILE.

This patch restores that functionality by reading additional lines from
the keylog file when needed (to preserve the benefit of not having to
read the full file) and by watching the open file for deletions.

"Deletion" is detected by comparing st_dev and st_ino. Since these may
be useless on Windows, the size is also checked.

Change-Id: Ieadaef1426a9270587293db28f4dda33b3d17334
Reviewed-on: https://code.wireshark.org/review/3190
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Evan Huus <eapache@gmail.com>
Petri-Dish: Evan Huus <eapache@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-07-31 11:09:07 +00:00
Peter Wu 7939d32ce2 ssl,dtls: simplify keyfile handling
Previously, the keylog file would be fully parsed when an encrypted
pre-master secret is encountered or in the ChangeCipherSpec stage. There
was also a lot of duplication in the key logfile parsing.

This patch simplifies the key logfile parsing by using regular
expressions. Rather than scanning the key logfile for a specific key,
do this scan once at ssl init and save the results to a hashtable. The
map for session ID/tickets to master keys already existed, another one
for client random to master key and encrypted pre-master to pre-master
was added. This could later also be wired to the "Export SSL Keys"
menu item for improved reliability (when no session ID or tickets are
available, the client random could be used).

The ssl_{save,restore}_session{,_ticket} functions have been converted
to a single function that looks up a key (sid / client random / encr.
pre-master) to a (pre-)master secret.

Other minor changes: return booleans for some functions that can only
fail/pass. Remove some functions from the ssl-utils header that have
become private a few commits ago. Remove some outstanding issues
from the comments in packet-ssl as they are already done, add myself
to the ssl-utils header.

These changes pass the test suite and the sample Session Ticket-enabled
capture from https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5963

On-the-fly decryption are broken with this patch since keylog files are
read once at the start of a capture. This will be solved in a future
patch.

Change-Id: Idb343abe161950b5f3ff61bee093d0f4ef9655bd
Reviewed-on: https://code.wireshark.org/review/3057
Reviewed-by: Evan Huus <eapache@gmail.com>
Petri-Dish: Evan Huus <eapache@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-07-31 11:08:18 +00:00
Peter Wu fc983cfca2 ssl,dtls: move Finished dissection to ssl-utils
Change-Id: Ib4bd5712cb85cd2671f67fe035747b88d5b4f186
Reviewed-on: https://code.wireshark.org/review/3034
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Hauke Mehrtens <hauke@hauke-m.de>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-07-24 05:29:52 +00:00
Peter Wu 5e3b04449a ssl,dtls: move Session Ticket to ssl-utils
Changes:

 - dtls: also support saving session tickets.
 - Drop the length check and let proto_tree_add_item throw exceptions
   on length errors.
 - Use proto_tree_add_item instead of proto_tree_add_uint.
 - Drop "TLS" from header field descriptions, the RFC does not name it
   as such and DTLS can also use it (a draft is in progress that extends
   DTLS with Session Tickets,
   draft-hummen-dtls-extended-session-resumption-01).

Change-Id: I11195217368b7200821d11289b1c5870a1ffe637
Reviewed-on: https://code.wireshark.org/review/3029
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-07-23 20:50:38 +00:00
Peter Wu ee231c5263 ssl,dtls: move ClientHello to ssl-utils
Changes to ClientHello dissection:

 - Move ssl_find_private_key (and its pre-req, ssl_set_server) outside
   ssl_dissect_hnd_cli_hello. It has not really something to do with
   dissection, but state tracking and decoder param feeding.
 - dtls: add expert info for bad cipher suites len.
 - ssl: remove bad cipher suites len text label which is also
   available as expert info. Attach expert info to a the length proto
   item (which is converted to use add_item instead of add_uint).
 - Remove `if (tree || ssl)` since expert info seems not to apply
   otherwise (this also needs changes in common and handshake
   dissection).
 - ssl: remove tvb_ensure_bytes_exist so we can dissect more
   compression methods and cipher suites.
 - Since DTLS has an additional Cookie field which TLS does not have,
   pass these additional header fields through a struct whose type is
   defined in ssl-utils.

Change-Id: I41bef04c1c3353e582e30f561d1d246a744e1d60
Reviewed-on: https://code.wireshark.org/review/3021
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-07-23 17:09:01 +00:00
Peter Wu aa09feaf52 ssl,dtls: move ServerHello to ssl-utils
Changes to ServerHello:

 - Get rid of session parameter as the SslDecryptSession already
   provides a reference to SslSession. Done for the new
   ssl_dissect_hnd_srv_hello and ssl_dissect_hnd_hello_ext functions.
 - No need to generate the keyring here, decryption is only needed after
   ChangeCipherSpec and the keyring will be generated there provided
   that there are enough params (cipher, version, master-secret, etc.)
 - Get rid of labels and goto in favor of if/else.
 - DTLS: SSL_HAVE_SESSION_KEY is implicitly set when
   ssl_generate_keyring_material succeeds, no need to set it. Remove it.
 - Remove `if (tree || ssl)` since expert info seems not to apply
   otherwise (this also needs changes in common and handshake
   dissection). (Expert info from the TLS extensions, not the
   ServerHello itself.)

Other changes:

 - ClientHello: renamed some fields shared with ServerHello.

Change-Id: I466b905d990489e03250bac97bf9d862ff82ce6c
Reviewed-on: https://code.wireshark.org/review/3020
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-07-23 17:08:06 +00:00