Commit Graph

128 Commits

Author SHA1 Message Date
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
Ambarish Malpani d2c0600609 Make SSL certificates available to tshark as bytes via the dtls/ssl.handshake.certificate key.
Changed the entries so that users have access to the whole certificate in
tshark. This allows developers to process the certs in custom ways

Change-Id: I113d60b2b3f12c6b15a644ec02bbebf7134f0ece
Reviewed-on: https://code.wireshark.org/review/5119
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-11-05 18:39:36 +00:00
Alexis La Goutte e7c11beedd Fix error: not a Doxygen trailing comment found by Clang (-Wdocumentation)
Change-Id: Ieff4b888b39c8da82f00b00e0609d89d1203aef9
Reviewed-on: https://code.wireshark.org/review/3891
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-08-28 11:35:01 +00:00
Bill Meier 43afcb4b18 Remove unneeded #include <epan/prefs.h>; As needed: Add editor-modelines & adjust whitespaxcce.
Change-Id: I6f79357e0f3906f6ccc5b68eb451b69b68636335
Reviewed-on: https://code.wireshark.org/review/3613
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-08-15 14:44:15 +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 2944d8b97c ssl: clarify meaning of StringInfo, cleanup PRFs, master_secret
It was not clear whether the data_len member of StringInfo refers to
the allocated memory (as was done for session_ticket) or the length
of the actual data. This is clarified in a comment. To keep the
invariant "data_len refers to the length of meaningful data", some
code has been moved just in case some intermediate code fails:

 - Setting session_ticket.data_len vs tvb_memcpy to session_ticket.data.
 - PRF functions would expect the data length as input to a paramter
   named "out". This is highly confusing, so another parameter has been
   added to signify the requested length, "out_len". This also helps
   holding up the invariant.
 - For prf() calls, out.data_len does not need to be initialized but
   passed as parameter.

Other PRF-related changes:

 - Change the PRF functions to return a boolean instead of an int.
 - tls_hash: return void as it cannot fail and remove related error
   handling from callers. Fix a memleak of label_seed if tls_hash was
   successful.
 - tls_hash: add comments to clarify its functionality, whitespace.
 - ssl3_generate_export_iv could not fail, so make it void. Also added
   an out_len param to pass the target length.
 - In prf(), replaced if-conditions for SSL version by a switch.
 - In ssl_generate_keyring_material, the scope of some variable has been
   tightened.
 - ssl_session_init: explicitly set data_len to 0. This is strictly not
   necessary as the callers have already zeroed out the memory, but that
   has not been documented.

Other changes related to master_secret (ssl_save_session[_ticket]):

 - Initialize master_secret.data_len to 0 in ssl_session_init as the
   master_secret is unusable at that point.
 - Remove the hack that tests whether master_secret.data is non-empty.
 - Replace hardcoded master_secret length (48) from wmem_alloc0().
 - Introduce macro for master secret length, use this in
   SslDecryptSession, for parsing from keyfile and converting pre-master
   secret to master secret (prf).
 - Use (master_secret + 1) to refer to the part after the struct rather
   than adding the size manually to a gchar-casted master_secret.

Change-Id: Ie1ea448db54e828b904568224486147a3d962522
Reviewed-on: https://code.wireshark.org/review/3030
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-07-24 05:33:50 +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 057ded827d ssl-utils: stop exporting some symbols
Client/Server hello and Hello extensions are now dissected inside
ssl-utils, no need to export them for the SSL or DTLS dissectors.

Change-Id: I8f2405199f21616743fe74959f07cfa839565527
Reviewed-on: https://code.wireshark.org/review/3022
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-07-23 17:09:25 +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
Peter Wu 2c772e3825 ssl: move decoder init from ClientKeyExchange to ChangeCipherSpec
My previous change removed master-key retrieval in the Server Hello.
This broke decryption when ClientKeyExchange is missing. That was done
because decryption is only needed after ChangeCipherSpec.

This patch moves the remaining initialization in ClientKeyExchange to
ChangeCipherSpec. In theory this could fix decryption of DTLS traffic
when an abbreviated handshake is used (and thus keyring material is
never generated in ClientKeyExchange since it is not called).

It also avoids saving a session ticket with an empty key which can
happen when no RSA key is present, but the NewSessionTicket message
is received. This could lead to garbage decryption.

Change-Id: If0f475232c270b1d7b006c1f9af0e8d8098c6b65
Reviewed-on: https://code.wireshark.org/review/3019
Reviewed-by: Hauke Mehrtens <hauke@hauke-m.de>
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-07-15 23:07:10 +00:00
Peter Wu aecbb98365 ssl: unify common Hello dissection to ssl-utils
Based on DTLS code with changes merged from SSL. Changes:

 - Ignore large Session IDs, this was not harmful though since the
   backing storage was 256 bytes in size.
 - {ssl,dtls}.handshake.random: fixed description, it is not used like
   a SSLv2 random challenge.
 - dtls: also debug print client/server for random
 - SSL: the common dissector now returns an offset rather than dissected
   length.
 - dtls: display actual Session ID bytes in the UI rather than the text
   "Session ID (32 bytes)". The length field is already visible in the
   preceding field.

Also changed is the handling of key material generation. The SSL
dissector previously generated key material based on the Session ID,
Session Ticket or a key logfile. (DTLS did not have this functionality.)
As decryption is needed only after ChangeCipherSpec, I have removed it
from the ServerHello handling. This will break decryption when a
ClientKeyExchange message is missing, but it will be restored proper in
a next patch.

(By the way, there was an inverted if-condition bug in DTLS that could
break decryption by not restoring the master key matching a SID. This
is gone in the refactoring because the faulty code is removed.)

Change-Id: Ida3de88adefe3f7691f85936c496977426c4d96e
Reviewed-on: https://code.wireshark.org/review/3018
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Hauke Mehrtens <hauke@hauke-m.de>
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-07-15 23:07:05 +00:00
Peter Wu 71ebdb67ad ssl: move CertificateRequest to ssl-utils
Except for field/expert_info names, a redundant subtree assignment,
a different !tree check, a type confusion in DTLS (proto_tree *ti),
a check against a different DTLS/TLS version and a (void) retval cast,
the functions are exactly the same. Extract them to ssl-utils.

Change-Id: I2ca7089fe2cd23212ef78656506cb53768f55927
Reviewed-on: https://code.wireshark.org/review/2986
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-07-11 04:36:51 +00:00
Peter Wu ba6d2e7cc8 ssl: move Certificate handshake dissection to ssl-utils
There are no dissection differences between DTLS and SSL, so move to
ssl-utils. While at it, skip dissection when the tree is NULL, remove
the plural from certificates length (the length is always larger than
ome), fix type of "ti" for dtls, get rid of "failsafe" subtree
assignment in ssl, get rid of tvb_ensure_bytes_exist in ssl.

Unrelated changes: fix param (tvb vs sub_tvb) for DTLS KeyExchange
handshake messages.

Change-Id: Iecaa45a7a601e55a52aa16180cf219a122fbe95a
Reviewed-on: https://code.wireshark.org/review/2985
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-07-11 04:35:40 +00:00
Peter Wu 7248c24afc ssl: add missing valid handshake types
The DTLS dissector duplicated a handshake types check, this has been
eliminated. Convert HandshakeType and ContentType to enums to get the
benefit of compiler-checked switch cases. Move these checks to
ssl-utils.

Two default cases could never be reached since the dissector returns
immediately on an invalid ContentType.

Also fixed misleading debugging messages.

Change-Id: I07a2062564e073004dcc0401cd82538e5659fa0c
Reviewed-on: https://code.wireshark.org/review/2978
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-07-11 04:32:15 +00:00
Peter Wu 4224e353f9 ssl-utils: add missing ett registration
Fixes the dissector bug warning:
"epan/proto.c:4657: failed assertion "idx >= 0 && idx < num_tree_types"

Add some comments to avoid future mistakes, add folding markers and fix
alignment of curves hf.

Change-Id: Ibcb57bfeb09a9777324682704a86f1ce260d345e
Reviewed-on: https://code.wireshark.org/review/2642
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-06-25 17:16:26 +00:00
Peter Wu e22d3c9b74 ssl: fix ClientKeyExchange, fix TLSv1.2 SKE for DH
Since DTLS and TLS do not differ in handling ClientKeyExchange and
ServerKeyExchange, its dissection got moved to ssl-utils. The code is
based on the SSL dissector, with header field names adjusted to the
DTLS ones (those got capitalized). Besides a version difference (for
signatures), the header field and function names, the DTLS and SSL code
are equal (this is verified).

This patch refactors the dissectors for DHE_RSA and ECDHE to make use of
a common function to dissect the signed_params field. All offset
tracking is also removed in favor of exception handling by the
proto_tree_add_item function. Occurrences of proto_tree_add_uint are
also replaced by proto_tree_add_item for simplicity.

After those changes, the SKE dissector for DH key exchanges is updated
to handle the mandatory signature field in TLSv1.2, using the newly
added function. (bug 9208)

Another bug occurred after the length check removal, pre-TLS and
OpenSSL's old DTLS implemenation do not include a vector length in
the CKE. This is now also fixed. (bug 10222)

Other minor changes: comments added/corrected, renamed
keyex_dh -> keyex_dhe (includes DHE_RSA and DHE_DSS).

Bug: 9208
Bug: 10222
Change-Id: I76e835d56a65c91facce46840d79c1c48ce8d5dd
Reviewed-on: https://code.wireshark.org/review/2542
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-06-23 23:31:40 +00:00
Marc Bevand 3bf635b0cc Update TLS extensions
Add better reference to IANA list of all extensions.
Add newer "channel_id" extension (0x7550) as used by current Chrome versions.

Change-Id: Ia5b2515c557fbaf42d320ede918120f83b2e02dd
Reviewed-on: https://code.wireshark.org/review/1924
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-06-02 21:16:35 +00:00
Hauke Mehrtens a8e6d128ab ssl/dtls: add support for Raw Public keys
Instead of X.509 certificates now also Raw public keys are supported
and shown correctly.

This is described in this draft:
https://tools.ietf.org/html/draft-ietf-tls-oob-pubkey-11

Change-Id: Ibe7610aace31a19791b02e71ccd8d9ceb8cf979d
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Reviewed-on: https://code.wireshark.org/review/1372
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-05-30 17:55:06 +00:00
Hauke Mehrtens 584b81372b ssl-utils: dissect the certificate type TLS extension
This analyses the certificate type extensions and then stores the
certificate type in the ssl session. This way we can later show the
certificate in the correct from.

This is described in this draft:
https://tools.ietf.org/html/draft-ietf-tls-oob-pubkey-11

Change-Id: Ifdda165807bc29f1fc138da000a9a538ecd18b6e
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Reviewed-on: https://code.wireshark.org/review/1371
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-05-30 17:54:55 +00:00
Hauke Mehrtens a7a4aa9a74 ssl: add SslSession structure
This structure is used to store information about a SSL session which
is not only needed for decrypting the session, but also to show nice
dissection information.

In an other patch I will add some more members to the struct because
the old way of passing them to the function does not scale.

Change-Id: I88e7f2896e0364a41d4538752dad291de83bfbca
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Reviewed-on: https://code.wireshark.org/review/1819
Reviewed-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-05-30 14:19:59 +00:00
Hauke Mehrtens 3ce020a5fc ssl-utils: fix TLS number of padding extension
The padding extension got the number 21 (0x15) by the IANA and not 20
(0x14), see this list for details:
https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml

The number 20 is assigned to the server certificate type extension.

Change-Id: I17271a3a336bcf5a323f15da3a5301115ca4cb45
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Reviewed-on: https://code.wireshark.org/review/1822
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
2014-05-27 20:56:02 +00:00
Alexis La Goutte 57e380af36 SSL/TLS: Add Padding Extension (20)
http://tools.ietf.org/html/draft-agl-tls-padding-03

Change-Id: I181718edf5b5f297aaf2e247524dfce069c90cce
Reviewed-on: https://code.wireshark.org/review/1703
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-05-20 19:15:37 +00:00
Hauke Mehrtens 338269fe41 ssl/dtls: add keyfile support to dtls
This moves the keyfile and psk options from the ssl code into ssl-utils
and then uses them also for dtls.

This is the last missing part for bug 9499 from my side.

Change-Id: Ie2fe5bc565eabe1e6ce62498c985b8a36e913b0f
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Reviewed-on: https://code.wireshark.org/review/1369
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-04-27 18:00:21 +00:00
Peter Wu c7cbdb4f22 Change ssl_find_private_key to void
No caller checks its return value (which is always 0).

Change-Id: I18461ee6e5d369722c8c2b2ea1e409423aa5d631
Reviewed-on: https://code.wireshark.org/review/1365
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-04-26 15:34:38 +00:00
Stig Bjørlykke 2afa065d62 Fix compilation if not HAVE_LIBGNUTLS and not HAVE_LIBGCRYPT
This was introduced in the previous compilation fix.

Change-Id: I4ec652a2708d90f35f3f00ec2c3261acb3e68397
Reviewed-on: https://code.wireshark.org/review/1074
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-04-11 20:31:21 +00:00
Stig Bjørlykke b642a280cb Fix compilation if HAVE_LIBGNUTLS but not HAVE_LIBGCRYPT.
Also fixed a comment for a #endif for the same defines.

Change-Id: Icbbf619dbaeb1d4d154a5f1a8273f252d35c6981
Reviewed-on: https://code.wireshark.org/review/1070
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-04-11 14:07:39 +00:00
Hauke Mehrtens 0af279a6f6 ssl-utils: add detection of Supplemental Data
This adds basic detection of Supplemental Data as defined in RFC4680.

Change-Id: I8dac99bf243a6bd176585d1fe70f82abcae70c7f
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Reviewed-on: https://code.wireshark.org/review/967
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-04-05 23:19:50 +00:00
Martin Kaiser aac1e0a06a add the (not yet official) TLS channel_id extension that's used by Chrome
Change-Id: Ib8779b0db790a78fff8bd1970a7240bbd8f49f75
Reviewed-on: https://code.wireshark.org/review/537
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Martin Kaiser <wireshark@kaiser.cx>
2014-03-06 22:02:51 +00:00
Alexis La Goutte 296591399f Remove all $Id$ from top of file
(Using sed : sed -i '/^ \* \$Id\$/,+1 d')

Fix manually some typo (in export_object_dicom.c and crc16-plain.c)

Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8
Reviewed-on: https://code.wireshark.org/review/497
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-04 14:27:33 +00:00
Pascal Quantin 5fc9db83cf SSL: dynamically allocate session ticket storage area to avoid buffer overflow
Fixes bug 9825

Change-Id: I20ae65331ec11b2f6774054df4c026fd5fa76d3a
Reviewed-on: https://code.wireshark.org/review/447
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-03-03 15:36:21 +00:00
Alexis La Goutte 9f96c730d8 Fix indent (Remove tabs and use 4 spaces)
Change-Id: Ide85336be3dca4059619bb91707bfc49e25af63d
Reviewed-on: https://code.wireshark.org/review/108
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2014-02-04 13:05:07 +00:00
Anders Broman f0fb43a621 From alexeyv:
Add decryption for resumed TLS sessions with a session ticket.

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5963

svn path=/trunk/; revision=54860
2014-01-20 20:26:04 +00:00
Evan Huus 0fc3f9c05c Designated initializers are not standard C90, just list all the '-1's without
their field names.

svn path=/trunk/; revision=54424
2013-12-23 21:30:44 +00:00
Alexis La Goutte 7b75159f1e From Hauke Mehrtens via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9498
ssl: move TLS ext dissect code to packet-ssl-utils.c

This moves the code used to parse the TLS extension into packet-
ssl-utils.c and adds an architecture that this code could be used by
dtls in the next patch. This patch should not change anything in the
functionality.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

svn path=/trunk/; revision=54418
2013-12-23 20:42:28 +00:00
Alexis La Goutte 719cc1ea30 From Hauke Mehrtens via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9499
DLTS: add cipher version for OpenSSL pre 0.9.8f

OpenSSL pre 0.9.8f uses the TLS version 0x0100 and is not completely
compatible with DTLS 1.0 or 1.2. One difference is that the encrypted
pre master from TLS 1.0 does not have an own length, which is needed by
TLS and DTLS 1.0, this makes decrypting impossible. This patch makes it
possible for the code to distinguish between this OpenSSL version and
real DTLS 1.0, because they are not using the same code any more. This
is needed to fix the snakeoil-dtls test.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

svn path=/trunk/; revision=54043
2013-12-13 14:06:18 +00:00
Alexis La Goutte ec32b614f6 From Peter Wu
ssl-utils: remove SIG, rename mode and formatting

The changes seem huge, but actually involve a few structural changes
that do not change functionality, but aim to make maintenance easier and
lines shorter. The following changes were made:

 1. Remove the "sig" field and `SIG_*` constants as they are not used
    anywhere.
 2. Convert `SSL_CIPHER_MODE_*` macros to an enum, change the type in
    SslCipherSuite, change the field terminator in cipher_suites and
    drop the `SSL_CIPHER_` prefix to make it shorter.
 3. Add whitespace to align the cipher suites and convert the numbers to
    hex to match common usage (e.g. IANA docs). Done with the awk script
    below.

AWK script that takes the lines with `,KEX_` and applies changes (3):

    #!/usr/bin/gawk -f
    BEGIN { FS="[, {]+" }
    {
        split($0, c, "}, *");
        comment="";if(c[2])comment="   "c[2];
        sub("}", "", $10); # comment }
        printf("    {0x%04X,%-12s%-16s%2d,%3d,%3d,%-11s %-22s},%s\n",
               strtonum($2),
               $3 ",", # Key exchange
               # $4 is SIG_ - remove
               $5 ",", # Cipher
               $6, # blocksize
               $7, # keysize
               $8, # export keysize
               $9 ",", # Digest
               $10, # mode
               comment);
    }

Signed-off-by: Peter Wu <lekensteyn@gmail.com>

svn path=/trunk/; revision=54039
2013-12-13 11:30:24 +00:00
Bill Meier 37f60fa2d6 In one or more of the files:
- Create/use some extended value-strings;
 - Remove some unneeded initializers;
 - 'offset++' --> 'offset += 1' for consistency;
 - Set editor modelines 'tab-width' to 8 (not 4);
 - tabs --> spaces (to match editor modelines);
 - Rework/add whitespace.

svn path=/trunk/; revision=53998
2013-12-12 23:11:04 +00:00
Michael Mann 6c5a93d7d1 Fix invalid read and correct PSK upper bound. Bug 9512 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9512)
From Peter Wu.

svn path=/trunk/; revision=53843
2013-12-08 02:12:48 +00:00
Michael Mann 0f05597ab1 DTLS decryption enhancements. Bug 9499 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9499)
From Hauke Mehrtens

1. dtls: set ssl_set_server() in DTLS dissector so wireshark knows if this is client or server
2. SSL: add decrypt support for CCM and CCM_8 Ciphers per rfc 6655
3. dtls: add psk decrypt support

svn path=/trunk/; revision=53836
2013-12-08 00:58:06 +00:00
Alexis La Goutte e069d1c9ea From Peter Wu
Add RFC6066 CertificateUrl TLS extension

This is not supported by OpenSSL or NSS, the extension itself seems
unsafe, but some implementations seem to support it[1].

Untested, no capture available.

 [1]: http://www.ietf.org/mail-archive/web/tls/current/msg02535.html

svn path=/trunk/; revision=53417
2013-11-18 20:27:04 +00:00
Alexis La Goutte 123e3d9203 From Peter Wu
Add status_request_v2 TLS extension dissection (RFC6961)

Besides adding status_request_v2 support, this patch moves the
Certificate Status Type from the OCSP Status subtree to its parent
(the extension tree). This is needed because this type applies to all
OCSPResponse fields.

The check for "tree != NULL" seems unnecessary here, it was not
clarified in the original patch so I removed it.

From me
Fix typo
Remove unneeded tvb_ensure_bytes_exist
Use proto_tree_add_item

svn path=/trunk/; revision=53416
2013-11-18 20:26:55 +00:00
Alexis La Goutte 954584d31b From Peter Wu
Add TLS StatusRequest (RFC6066) ClientHello extension recognition

Only empty Responder ID lists and empty Request Extensions are
implemented. I could not really find existing clients or servers that
populate these.

This status_request extension has a different signature for a
ClientHello and ServerHello, in the latter the extension_data field
must be empty. Therefore an additional parameter is added to
dissect_ssl3_hnd_hello_ext.

From me :
Fix typo

svn path=/trunk/; revision=53415
2013-11-18 20:26:46 +00:00
Alexis La Goutte 22f57a900b From Peter Wu
Support for EncryptedExtensions handshake type (a.k.a. NextProtocol)

Based on https://tools.ietf.org/html/draft-agl-tls-nextprotoneg-04

From me
Fix warning found by fix-encoding-args

svn path=/trunk/; revision=53414
2013-11-18 20:26:37 +00:00
Alexis La Goutte 23f9100542 From Peter Wu via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9144 [PATCH] Update TLS Ciphers
Really add support for AEAD ciphers (GCM)

GCM uses counter mode with authentication tags (the latter is currently
not supported). As for the key material, there is no MAC (because the
auth tag is supposed to verify the authenticity).

Finally, correct the GCM cipher suite definitions: IV block size of
4 bytes and GCM instead of CBC mode.

svn path=/trunk/; revision=52150
2013-09-19 20:27:12 +00:00
Alexis La Goutte a87da76132 From Peter Wu via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9144 [PATCH] Update TLS Ciphers
Use IV from record for CBC mode, add padding/IV length check

Add summary of RFCs to make it more obvious why certain parts (IV, MAC,
padding) are used. Merge DTLS and TLS blocks for extracting IV. This
saves an unnecessary memmove() because the input pointer is, well, just
a local variable and can therefore be incremented.

Validate padding and IV lengths before using it. A crash could occur
if the explicit IV is missing (this would make memmove write before its
buffer). The missing padding check had as implication that a misleading
error is returning with a negative length (not exploitable).

Use IV from record for CBC mode, previously it decrypted the first block
incorrectly and then threw this "decrypted" IV away. Now it extracts the
IV and uses this for decrypting the first fragment block. (remember that
CBC xor's the output of the block cipher with the previous ciphertext
(or IV for the first block)).

This is a preparation for GCM which does not have a MAC. The skip_mac
branch is necessary to make the compiler happy in this patch, 'mac'
could otherwise be uninitialised.

svn path=/trunk/; revision=52149
2013-09-19 20:27:05 +00:00
Alexis La Goutte f4a4271320 From Peter Wu via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9144 [PATCH] Update TLS Ciphers
Drop export_cipher and dig_len, cleaner digest access

Removed dig_len as this magic number is dependent on dig. The digests
variable is converted from a string to a structure holding the digest
name and length because of its close dependency.

Introduce another struct+function to get rid of the magic number 0x40
(DIG_MD5).

Removed export_cipher bit as this is dependent on eff_bits < bits.
Verified with:
grep ,KEX_ packet-ssl-utils.c | awk -F, '{bits=$6!=$7;ex=$9;
if ((bits && !ex) || (!bits && ex))print $6, $7, $8, "###", $0}'.

Removed space before SIG_RSA for cipher 51 for consistency with others.

svn path=/trunk/; revision=52147
2013-09-19 20:26:50 +00:00
Alexis La Goutte 219d17145f From Peter Wu via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9144 [PATCH] Update TLS Ciphers
Add more TLS cipher suites (SEED, AES-GCM, ECC)

- cipher suites from `RFC 5246 - TLS 1.2`
- cipher suites 150-155 are taken from: RFC 4162 - SEED for TLS
- cipher suites 156-167 are taken from: RFC 5288 - AES-GCM Cipher suites
- cipher suites 49153-49177 are taken from: RFC 4492 - ECC for TLS
- cipher suites 49195-49202 are taken from RFC 5289 - ECC with SHA256/384 and AES GCM

svn path=/trunk/; revision=52049
2013-09-15 06:59:07 +00:00