mech_eap.git
8 years agoGAS: Retry full GAS query if comeback response is not received
Jouni Malinen [Sun, 20 Dec 2015 17:26:01 +0000 (19:26 +0200)]
GAS: Retry full GAS query if comeback response is not received

It is possible for a comeback response to get lost especially when going
through a large GAS exchange fragmented to multiple frames in an
environment with interference or other traffic. Make this less likely to
fail the full exchange by trying full GAS query again and using longer
wait time on the GAS comeback exchanges.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Modify gas_malformed_comeback_resp to allow GAS retries
Jouni Malinen [Sun, 20 Dec 2015 19:06:21 +0000 (21:06 +0200)]
tests: Modify gas_malformed_comeback_resp to allow GAS retries

This is in preparation of a wpa_supplicant change to allow GAS retries
which can result in the previous test case design showing failures due
to "unexpected" management frames (GAS Initial Request from the retry).

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoGAS server: Replenish temporary STA entry timeout on comeback request
Jouni Malinen [Sun, 20 Dec 2015 17:23:58 +0000 (19:23 +0200)]
GAS server: Replenish temporary STA entry timeout on comeback request

Previously, the five second timeout was added at the beginning of the
full GAS query and it was not replenished during fragmented exchanges.
This could result in timing out a query if it takes significant time to
go through the possibly multiple fragments and long comeback delay.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoGAS: Shorten the duration of the wait for GAS comeback response
Matti Gottlieb [Thu, 10 Dec 2015 10:56:09 +0000 (12:56 +0200)]
GAS: Shorten the duration of the wait for GAS comeback response

When exchanging GAS frames with the AP, the initial response from the AP
may take a while to come, since the AP may need to fetch the info from a
server. The next fragments/comeback response frames should take much
less time since the AP already has all of the info, so the wait time
for these frames can be reduced.

In addition, some drivers, e.g., mac80211, try to combine ROC based flows,
to improve medium utilization. For example, if the requested ROC fits
entirely in a previous requested ROC they can be combined. Thus, reducing
the wait time for the next frames can improve medium utilization.

Shorten the duration of GAS comeback to improve medium utilization and
overall GAS exchange times.

Signed-off-by: Matti Gottlieb <matti.gottlieb@intel.com>
8 years agoGAS: Clear offchannel_tx_started when ending remain-on-channel
Jouni Malinen [Sun, 20 Dec 2015 17:37:06 +0000 (19:37 +0200)]
GAS: Clear offchannel_tx_started when ending remain-on-channel

Commit 2c0d0ae370f72fbe6248feed7ea0635303e3dc5a ('GAS: End
remain-on-channel due to delayed GAS comeback request') started ending
the remain-on-channel operation between the initial request and the
following comeback request. However, it did not check or update the
offchannel_tx_started variable. While this alone would not necessarily
be problematic, this makes it more difficult to optimize wait time for
offchannel TX operations, so make sure the internal tracking variable
gets updated.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-PEAP phase1 TLS flags
Jouni Malinen [Sun, 20 Dec 2015 15:36:51 +0000 (17:36 +0200)]
tests: EAP-PEAP phase1 TLS flags

This adds some more test coverage for phase1 parameters that had not
previously been included in any of the test cases.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-TTLS with unsupported Phase 2 EAP method in configuration
Jouni Malinen [Sun, 20 Dec 2015 15:33:03 +0000 (17:33 +0200)]
tests: EAP-TTLS with unsupported Phase 2 EAP method in configuration

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP-TTLS/PEAP/FAST: Reject unsupported Phase 2 method in configuration
Jouni Malinen [Sun, 20 Dec 2015 15:32:10 +0000 (17:32 +0200)]
EAP-TTLS/PEAP/FAST: Reject unsupported Phase 2 method in configuration

Instead of using default list of methods, reject a configuration with an
unsupported EAP method at the time the main TLS method is being
initialized.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP-TLS: Merge common error paths
Jouni Malinen [Sun, 20 Dec 2015 15:25:04 +0000 (17:25 +0200)]
EAP-TLS: Merge common error paths

There is no need to keep these identical error paths separate.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-TLS and TLS Message Length in unfragmented packets
Jouni Malinen [Sun, 20 Dec 2015 15:12:15 +0000 (17:12 +0200)]
tests: EAP-TLS and TLS Message Length in unfragmented packets

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-TLS and config blob missing
Jouni Malinen [Sun, 20 Dec 2015 15:07:25 +0000 (17:07 +0200)]
tests: EAP-TLS and config blob missing

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Speed up TNC test cases with the use of a single channel scan
Jouni Malinen [Sun, 20 Dec 2015 14:58:33 +0000 (16:58 +0200)]
tests: Speed up TNC test cases with the use of a single channel scan

There is no need for these test cases to run a full scan.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: TNC PEAP-SoH local error cases
Jouni Malinen [Sun, 20 Dec 2015 14:56:42 +0000 (16:56 +0200)]
tests: TNC PEAP-SoH local error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP-PEAP peer: Fix a memory leak on an error path
Jouni Malinen [Sun, 20 Dec 2015 14:55:28 +0000 (16:55 +0200)]
EAP-PEAP peer: Fix a memory leak on an error path

If memory allocation for adding SoH response fails, the SoH response was
not freed properly on the error path.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: TNC TTLS local error cases
Jouni Malinen [Sun, 20 Dec 2015 11:43:41 +0000 (13:43 +0200)]
tests: TNC TTLS local error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoDrop any pending EAPOL RX frame when starting a new connection
Jouni Malinen [Sun, 20 Dec 2015 11:40:59 +0000 (13:40 +0200)]
Drop any pending EAPOL RX frame when starting a new connection

Such a pending frame cannot be valid anymore, so drop it instead of
risking of using an unexpected EAPOL frame after association if a
previous association received one at the end and the new association can
happen within 100 ms.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Fix scan result clearing in ssid_hidden*
Jouni Malinen [Sun, 20 Dec 2015 10:59:19 +0000 (12:59 +0200)]
tests: Fix scan result clearing in ssid_hidden*

These test cases were supposed to clear the cfg80211 and wpa_supplicant
scan caches in the end to avoid causing issues to the following test
cases. This did not work properly after introduction of the support for
aborting a pending scan. Fix this by using the flush_scan_cache()
function and waiting within the test case until the final scan operation
completes.

This issue was triggered by ssid_hidden/ssid_hidden2 followed by
ext_password_interworking (though, not every time).

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-TTLS/MSCHAP with password hash
Jouni Malinen [Sun, 20 Dec 2015 10:46:45 +0000 (12:46 +0200)]
tests: EAP-TTLS/MSCHAP with password hash

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-TTLS local error cases
Jouni Malinen [Sun, 20 Dec 2015 09:55:18 +0000 (11:55 +0200)]
tests: EAP-TTLS local error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoWPA: Explicitly clear the buffer used for decrypting Key Data
Jouni Malinen [Sun, 20 Dec 2015 08:52:30 +0000 (10:52 +0200)]
WPA: Explicitly clear the buffer used for decrypting Key Data

When AES-WRAP was used to protect the EAPOL-Key Key Data field, this was
decrypted using a temporary heap buffer with aes_unwrap(). That buffer
was not explicitly cleared, so it was possible for the group keys to
remain in memory unnecessarily until the allocated area was reused.
Clean this up by clearing the temporary allocation explicitly before
freeing it.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-PEAP local error cases
Jouni Malinen [Sat, 19 Dec 2015 19:04:39 +0000 (21:04 +0200)]
tests: EAP-PEAP local error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-PEAP version forcing
Jouni Malinen [Sat, 19 Dec 2015 18:59:14 +0000 (20:59 +0200)]
tests: EAP-PEAP version forcing

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP-PEAP peer: Check SHA1 result when deriving Compond_MAC
Jouni Malinen [Sat, 19 Dec 2015 18:34:27 +0000 (20:34 +0200)]
EAP-PEAP peer: Check SHA1 result when deriving Compond_MAC

This handles a mostly theoretical case where hmac_sha1_vector() might
fail for some reason.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-PEAP session resumption with crypto binding
Jouni Malinen [Sat, 19 Dec 2015 18:23:51 +0000 (20:23 +0200)]
tests: EAP-PEAP session resumption with crypto binding

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP-PEAP server: Add support for fast-connect crypto binding
Jouni Malinen [Sat, 19 Dec 2015 18:22:43 +0000 (20:22 +0200)]
EAP-PEAP server: Add support for fast-connect crypto binding

IPMK and CMK are derived from TK when using TLS session resumption with
PEAPv0 crypto binding. The EAP-PEAP peer implementation already
supported this, but the server side did not.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-PEAP with peap_outer_success=0
Jouni Malinen [Sat, 19 Dec 2015 18:05:50 +0000 (20:05 +0200)]
tests: EAP-PEAP with peap_outer_success=0

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP-PEAP peer: Remove unused return value and error path
Jouni Malinen [Sat, 19 Dec 2015 17:54:56 +0000 (19:54 +0200)]
EAP-PEAP peer: Remove unused return value and error path

eap_peap_parse_phase1() returned 0 unconditionally, so there was no need
for that return value or the code path that tried to address the error
case.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoHS 2.0: Remove duplicate icon entries
Jouni Malinen [Sat, 19 Dec 2015 16:53:27 +0000 (18:53 +0200)]
HS 2.0: Remove duplicate icon entries

Only one of the icon entries with a matching BSSID and file name can be
fetched from wpa_supplicant and as such, there is no need to maintain
the old data if it was not explicitly deleted before running a new fetch
for the same BSSID and icon. Remove older duplicated entries whenever
completing a pending icon fetch to optimize memory use.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoHS 2.0: Convert icon storage to use dl_list
Jouni Malinen [Sat, 19 Dec 2015 16:49:32 +0000 (18:49 +0200)]
HS 2.0: Convert icon storage to use dl_list

This simplifies the list operations quite a bit.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: REQ_HS20_ICON and DEL_HS20_ICON
Jouni Malinen [Fri, 18 Dec 2015 15:46:51 +0000 (17:46 +0200)]
tests: REQ_HS20_ICON and DEL_HS20_ICON

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoHS 2.0: Add a command to retrieve icon with in-memory storage
Jan Nordqvist [Fri, 11 Dec 2015 01:01:46 +0000 (17:01 -0800)]
HS 2.0: Add a command to retrieve icon with in-memory storage

This adds a new command based Hotspot 2.0 icon retrieval option.

In short, here is the new command sequence:
1. REQ_HS20_ICON <bssid> <file-name>
2. event: RX-HS20-ICON <bssid> <file-name> <size>
3. GET_HS20_ICON <bssid> <file-name> <offset> <size>
   (if needed, repeat with larger offset values until full icon is
   fetched)
5. DEL_HS20_ICON <bssid> <file-name>

REQ_HS20_ICON is a new command that is analogous to HS20_ICON_REQUEST
with the slight difference that an entry to store the icon in memory is
prepared. The RX-HS20-ICON event has been augmented with BSSID,
file-name and size, and GET_HS20_ICON is used to retrieve a chunk of up
to <size> bytes of icon data at offset <offset>. Each chunk is returned
as a base64 encoded fragment, preceded by "HS20-ICON-DATA", BSSID, and
file-name as well as the starting offset of the data.

If there is no entry prepared for the icon when the ANQP result comes
back, hs20_process_icon_binary_file falls back to legacy behavior.

Finally the DEL_HS20_ICON command deletes (all) icons associated with
BSSID and file-name (there could be several if retries are used and they
have different dialog tokens).

Signed-off-by: Jan Nordqvist <jannq@google.com>
8 years agotests: Add rfkill tests for P2P Device operations
Ilan Peer [Thu, 17 Dec 2015 13:54:12 +0000 (15:54 +0200)]
tests: Add rfkill tests for P2P Device operations

Add a couple of tests for rfkill with P2P Device operations
(with and without P2P Device interface).

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
8 years agorfkill: Match only the correct expected wiphy rfkill
Johannes Berg [Thu, 17 Dec 2015 13:54:11 +0000 (15:54 +0200)]
rfkill: Match only the correct expected wiphy rfkill

On systems that have multiple WLAN rfkill instances, the rfkill code
can become confused into thinking that the device was unblocked when
in fact it wasn't, because it only matches on the WLAN type.

Since it then stores the new (unblocked) state from the wrong rfkill
instance, it will never retry the failing IFF_UP operation and the
user has to toggle rfkill again, or otherwise intervene manually, in
this case to get back to operational state.

Fix this by using the existing (but unused) ifname argument when the
rfkill instance is created to match to a specific rfkill index only.

As a P2P Device interface does not have a netdev interface associated
with it, use the name of a sibling interface to initialize the rfkill
context for the P2P Device interface. For nl80211, as the wiphy index
is known only after getting the driver capabilities from the kernel,
move the initialization of the rfkill object to
wpa_driver_nl80211_finish_drv_init().

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
8 years agonl80211: Handle rfkill for P2P Device interface
Ilan Peer [Thu, 17 Dec 2015 13:54:10 +0000 (15:54 +0200)]
nl80211: Handle rfkill for P2P Device interface

The rfkill processing in nl80211 driver assumes that the
INTERFACE_ENABLED/DISABLED will be also issued, so does not do much in
the rfkill callbacks. However, as a P2P Device interface is not
associated with a network interface, these events are not issued for it.

Handle rfkill events for the P2P_DEVICE interface by faking the
INTERFACE_ENABLED/DISABLED.

Signed-off-by: Moshe Benji <Moshe.Benji@intel.com>
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
8 years agotests: Prepare ap_open_out_of_memory for modified rfkill init path
Jouni Malinen [Fri, 18 Dec 2015 20:22:25 +0000 (22:22 +0200)]
tests: Prepare ap_open_out_of_memory for modified rfkill init path

The rfkill initialization will be moved out from
wpa_driver_nl80211_drv_init() which would break one step in this OOM
test case due to the memory allocation not existing anymore. Fix this by
skipping that OOM step to avoid causing false failures with the
following commits.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: wpa_supplicant SIGNAL_MONITOR command
Jouni Malinen [Fri, 18 Dec 2015 19:01:42 +0000 (21:01 +0200)]
tests: wpa_supplicant SIGNAL_MONITOR command

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agowpa_supplicant: Add SIGNAL_MONITOR command
Dmitry Shmidt [Wed, 16 Dec 2015 22:18:18 +0000 (14:18 -0800)]
wpa_supplicant: Add SIGNAL_MONITOR command

SIGNAL_MONITOR THRESHOLD=DD HYSTERESIS=DD command will request signal
strength monitoring events based on there having been requested amount
of drop in the signal strength. The threshold value is the RSSI
threshold in dBm for the event to be sent. 0 threshold can be used to
disable monitoring. The hysteresis value is RSSI hysteresis in dB to
specify the minimum amount of change before a consecutive event is
reported.

With nl80211 driver interface, these values map to the
NL80211_CMD_SET_CQM command with NL80211_ATTR_CQM_RSSI_THOLD and
NL80211_ATTR_CQM_RSSI_HYST attributes to the driver.

This command cannot be used when bgscan module is in use since that
depends on being able to control the connection monitoring parameters.

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
8 years agoGAS: End remain-on-channel due to delayed GAS comeback request
Matti Gottlieb [Thu, 10 Dec 2015 10:56:08 +0000 (12:56 +0200)]
GAS: End remain-on-channel due to delayed GAS comeback request

During the sequence of exchanging GAS frames with the AP, the AP can
request to come back in X amount of time and resend the GAS request.

Previously, wpa_supplicant did not terminate the remain-on-channel
session, but rather waited until the requested comeback delay had
expired, and then tried to send the GAS frame (potentially to save the
time that is required to schedule a new remain on channel flow).

This might cause unnecessary idle time (can be close to 1000 ms) in
which the device might be off-channel. Ending the current
remain-on-channel session and then rescheduling makes better usage of
the time in this case.

End remain-on-channel session due to receiving a delayed GAS comeback
request from the AP.

Signed-off-by: Matti Gottlieb <matti.gottlieb@intel.com>
8 years agoTDLS: Ignore incoming TDLS Setup Response retries
Arik Nemtsov [Thu, 10 Dec 2015 10:56:07 +0000 (12:56 +0200)]
TDLS: Ignore incoming TDLS Setup Response retries

The Setup Response timer is relatively fast (500 ms) and there are
instances where it fires on the responder side after the initiator has
already sent out the TDLS Setup Confirm frame. Prevent the processing of
this stale TDLS Setup Response frame on the initiator side.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
8 years agohlr_auc_gw: Simplify string parsers with str_token()
Jouni Malinen [Fri, 18 Dec 2015 18:13:39 +0000 (20:13 +0200)]
hlr_auc_gw: Simplify string parsers with str_token()

The helper function allows these string parsers to be made much simpler.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agohlr_auc_gw: Fix a typo in an error message
Jouni Malinen [Fri, 18 Dec 2015 17:56:21 +0000 (19:56 +0200)]
hlr_auc_gw: Fix a typo in an error message

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agohlr_auc_gw: Remove unnecessary assignment
Jouni Malinen [Fri, 18 Dec 2015 17:55:01 +0000 (19:55 +0200)]
hlr_auc_gw: Remove unnecessary assignment

The pos variable is not used after the final parsed item, so no need to
set it here.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Detect invitation GO issues more quickly
Jouni Malinen [Fri, 18 Dec 2015 14:14:55 +0000 (16:14 +0200)]
tests: Detect invitation GO issues more quickly

This speeds up and clarifies error reporting for cases where the GO
fails to start in invitation.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agowpa_cli: Send ALL_STA command to the correct interface
Eliad Peller [Thu, 10 Dec 2015 10:56:06 +0000 (12:56 +0200)]
wpa_cli: Send ALL_STA command to the correct interface

wpa_ctrl_command_sta(), called by the "ALL_STA" handler, didn't consider
ifname_prefix, resulting in various commands being sent to the global
control interface, rather than the specified interface when IFNAME=
prefix was used.

This in turn caused the unexpected "UNKNOWN COMMAND" result be
considered as valid station, resulting in infinite loop while trying to
get all stations.

Fix it by considering ifname_prefix, similarly to _wpa_ctrl_command().

Signed-off-by: Eliad Peller <eliadx.peller@intel.com>
8 years agoDisconnect before trying to switch to a different network
Ayala Beker [Thu, 10 Dec 2015 10:56:05 +0000 (12:56 +0200)]
Disconnect before trying to switch to a different network

Previously, when wpa_supplicant received bgscan results with a preferred
network, it connected to that network without disconnecting from the
previous one. This might result in an inconsistent state of upper
layers.

Fix this by disconnecting from the current AP before connecting to the
new one when the network profile changes and there is an existing
connection.

Signed-off-by: Ayala Beker <ayala.beker@intel.com>
8 years agoAvoid network selection from scan during connection
Arik Nemtsov [Thu, 10 Dec 2015 10:56:04 +0000 (12:56 +0200)]
Avoid network selection from scan during connection

If scan results arrive during the connection process, the network
selection function was called, interrupting the current connection.
While a regular scan is mutually exclusive with connection establishment
via the nature of radio work, there's no such protection for scheduled
scan. Prevent network selection while a connection is in progress.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
8 years agoutils: Fix NULL pointer dereference with unexpected kernel behavior
Ayala Beker [Thu, 10 Dec 2015 10:56:03 +0000 (12:56 +0200)]
utils: Fix NULL pointer dereference with unexpected kernel behavior

Fix mostly theoretical NULL pointer dereference in
wpa_debug_open_linux_tracing() if /proc/mounts were to return a
malformed line.

Signed-off-by: Ayala Beker <ayala.beker@intel.com>
8 years agoP2P: Fix possible NULL pointer dereference
Ayala Beker [Thu, 10 Dec 2015 10:56:02 +0000 (12:56 +0200)]
P2P: Fix possible NULL pointer dereference

Fix wpas_p2p_invite() to call p2p_set_own_pref_freq_list() after the
NULL check, to avoid NULL pointer dereference if P2P initialization were
to have failed or P2P module getting deinitialized.

Signed-off-by: Ayala Beker <ayala.beker@intel.com>
8 years agotests: vm: Honor EPATH in uevent.sh
Johannes Berg [Fri, 11 Dec 2015 16:44:23 +0000 (17:44 +0100)]
tests: vm: Honor EPATH in uevent.sh

This is useful for testing CRDA since it means you can use EPATH to
redirect the test scripts to a different crda binary.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
8 years agotests: EAP-TTLS with invalid phase2 parameter values
Jouni Malinen [Thu, 17 Dec 2015 22:05:07 +0000 (00:05 +0200)]
tests: EAP-TTLS with invalid phase2 parameter values

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP-TTLS peer: Fix parsing auth= and autheap= phase2 params
Pali Rohár [Sun, 6 Dec 2015 11:01:32 +0000 (12:01 +0100)]
EAP-TTLS peer: Fix parsing auth= and autheap= phase2 params

This patch fixes an issue with an invalid phase2 parameter value
auth=MSCHAPv2 getting interpreted as auth=MSCHAP (v1) which could
degrade security (though, only within a protected TLS tunnel). Now when
invalid or unsupported auth= phase2 parameter combinations are
specified, EAP-TTLS initialization throws an error instead of silently
doing something.

More then one auth= phase2 type cannot be specified and also both auth= and
autheap= options cannot be specified.

Parsing phase2 type is case sensitive (as in other EAP parts), so phase2
parameter auth=MSCHAPv2 is invalid. Only auth=MSCHAPV2 is correct.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
[Use cstr_token() to get rid of unnecessary allocation; cleanup]
Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoatheros: Unify memory processing functions
Matt Woods [Sat, 12 Dec 2015 10:25:42 +0000 (10:25 +0000)]
atheros: Unify memory processing functions

There are two types of memory processing functions in the file
atheros_driver.c, such as memory and os_memory. Unify the processing
functions into one type which has the prefix "os_".

Signed-off-by: Matt Woods <matt.woods@aliyun.com>
8 years agotests: TDLS with VHT 80, 80+80, and 160
Jouni Malinen [Thu, 17 Dec 2015 17:26:40 +0000 (19:26 +0200)]
tests: TDLS with VHT 80, 80+80, and 160

This adds more coverage for TDLS testing for a case where the direct
link should use various VHT channel bandwidths.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agomesh: Fix VHT Operation information in peering messages
Jouni Malinen [Thu, 17 Dec 2015 16:37:19 +0000 (18:37 +0200)]
mesh: Fix VHT Operation information in peering messages

The full VHT channel information was not set in the hostapd data
structures which resulted in incorrect information (all zeros) being
used when building the VHT Operation element for peering messages while
the actual driver mode was set with the full details. We did not seem to
use the VHT information from peering messages, so this does not change
behavior with another wpa_supplicant-based mesh implementation. Anyway,
these elements should match the ones used in Beacon frames.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: Verify SIGNAL_POLL values in ap_vht80
Jouni Malinen [Thu, 17 Dec 2015 10:54:50 +0000 (12:54 +0200)]
tests: Verify SIGNAL_POLL values in ap_vht80

This confirms that the station recognized and negotiated 80 MHz
channel use with VHT.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: Run OCSP test cases with internal TLS library
Jouni Malinen [Thu, 17 Dec 2015 09:31:37 +0000 (11:31 +0200)]
tests: Run OCSP test cases with internal TLS library

There is no sufficient OCSP support to go through these test cases.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Report OCSP rejection cases when no valid response if found
Jouni Malinen [Thu, 17 Dec 2015 09:45:48 +0000 (11:45 +0200)]
TLS: Report OCSP rejection cases when no valid response if found

This adds a CTRL-EVENT-EAP-TLS-CERT-ERROR and CTRL-EVENT-EAP-STATUS
messages with 'bad certificate status response' for cases where no valid
OCSP response was received, but the network profile requires OCSP to be
used.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Process OCSP SingleResponse(s)
Jouni Malinen [Wed, 16 Dec 2015 23:45:51 +0000 (01:45 +0200)]
TLS: Process OCSP SingleResponse(s)

This completes OCSP stapling support on the TLS client side. Each
SingleResponse value is iterated until a response matching the server
certificate is found. The validity time of the SingleResponse is
verified and certStatus good/revoked is reported if all validation step
succeed.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Store DER encoded version of Subject DN for X.509 certificates
Jouni Malinen [Thu, 17 Dec 2015 09:27:31 +0000 (11:27 +0200)]
TLS: Store DER encoded version of Subject DN for X.509 certificates

This is needed for OCSP issuerNameHash matching.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Share digest OID checkers from X.509
Jouni Malinen [Thu, 17 Dec 2015 09:19:18 +0000 (11:19 +0200)]
TLS: Share digest OID checkers from X.509

These will be used by the OCSP implementation.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Support longer X.509 serialNumber values
Jouni Malinen [Wed, 16 Dec 2015 23:41:45 +0000 (01:41 +0200)]
TLS: Support longer X.509 serialNumber values

This extends the old support from 32 or 64 bit value to full 20 octets
maximum (RFC 5280, 4.1.2.2).

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: OCSP certificate signed OCSP response using key ID
Jouni Malinen [Wed, 16 Dec 2015 22:48:59 +0000 (00:48 +0200)]
tests: OCSP certificate signed OCSP response using key ID

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Parse and validate BasicOCSPResponse
Jouni Malinen [Wed, 16 Dec 2015 22:38:40 +0000 (00:38 +0200)]
TLS: Parse and validate BasicOCSPResponse

This adds the next step in completing TLS client support for OCSP
stapling. The BasicOCSPResponse is parsed, a signing certificate is
found, and the signature is verified. The actual sequence of OCSP
responses (SignleResponse) is not yet processed in this commit.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Make key-lifetime-in-memory more robust for GTK check
Jouni Malinen [Mon, 14 Dec 2015 15:23:47 +0000 (17:23 +0200)]
tests: Make key-lifetime-in-memory more robust for GTK check

The decrypted copy of a GTK from EAPOL-Key is cleared from memory only
after having sent out CTRL-EVENT-CONNECTED. As such, there was a race
condition on the test case reading the wpa_supplicant process memory
after the connection. This was unlikely to occur due to the one second
sleep, but even with that, it would be at least theorically possible to
hit this race under heavy load (e.g., when using large number of VMs to
run parallel testing). Avoid this by running a PING command to make sure
wpa_supplicant has returned to eloop before reading the process memory.
This should make it less likely to report false positives on GTK being
found in memory.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: Add more memory details on key-lifetime-in-memory
Jouni Malinen [Mon, 14 Dec 2015 13:47:38 +0000 (15:47 +0200)]
tests: Add more memory details on key-lifetime-in-memory

This makes it easier to see where in memory the key was found and what
there is in memory around that location.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoTLS: Parse OCSPResponse to extract BasicOCSPResponse
Jouni Malinen [Mon, 14 Dec 2015 10:31:35 +0000 (12:31 +0200)]
TLS: Parse OCSPResponse to extract BasicOCSPResponse

This adds the next step for OCSP stapling. The received OCSPResponse is
parsed to get the BasicOCSPResponse. This commit does not yet process
the BasicOCSPResponse.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Parse CertificateStatus message
Jouni Malinen [Sun, 13 Dec 2015 21:11:32 +0000 (23:11 +0200)]
TLS: Parse CertificateStatus message

This allows the internal TLS client implementation to accept
CertificateStatus message from the server when trying to use OCSP
stapling. The actual OCSPResponse is not yet processed in this commit,
but the CertificateStatus message is accepted to allow the TLS handshake
to continue.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Add status_request ClientHello extension if OCSP is requested
Jouni Malinen [Sun, 13 Dec 2015 20:46:25 +0000 (22:46 +0200)]
TLS: Add status_request ClientHello extension if OCSP is requested

This allows the internal TLS implementation to request server
certificate status using OCSP stapling. This commit is only adding code
to add the request. The response is not yet used.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Parse ServerHello extensions
Jouni Malinen [Sun, 13 Dec 2015 20:45:35 +0000 (22:45 +0200)]
TLS: Parse ServerHello extensions

This prints the received ServerHello extensions into the debug log and
allows handshake to continue even if such extensions are included.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Run PKCS#12 tests with internal TLS crypto
Jouni Malinen [Sun, 13 Dec 2015 18:54:20 +0000 (20:54 +0200)]
tests: Run PKCS#12 tests with internal TLS crypto

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Add minimal support for PKCS #12
Jouni Malinen [Sun, 13 Dec 2015 18:52:43 +0000 (20:52 +0200)]
TLS: Add minimal support for PKCS #12

This allows the internal TLS implementation to parse a private key and a
certificate from a PKCS #12 file protected with
pbeWithSHAAnd3-KeyTripleDES-CBC.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Extend PKCS #5 to support PKCS #12 style key decryption
Jouni Malinen [Sun, 13 Dec 2015 18:50:08 +0000 (20:50 +0200)]
TLS: Extend PKCS #5 to support PKCS #12 style key decryption

This adds support for decrypting private keys protected with the old
PKCS #12 mechanism using OID pbeWithSHAAnd3-KeyTripleDES-CBC.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Fix and complete ASN.1 tag list
Jouni Malinen [Sun, 13 Dec 2015 20:10:46 +0000 (22:10 +0200)]
TLS: Fix and complete ASN.1 tag list

One of the unused defines had incorrect value and couple of tags were
missing.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: External server certificate chain validation
Jouni Malinen [Sat, 12 Dec 2015 16:16:19 +0000 (18:16 +0200)]
tests: External server certificate chain validation

This tests tls_ext_cert_check=1 behavior with EAP-TLS, EAP-TTLS,
EAP-PEAP, and EAP-FAST.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP peer: External server certificate chain validation
Jouni Malinen [Sat, 12 Dec 2015 16:16:54 +0000 (18:16 +0200)]
EAP peer: External server certificate chain validation

This adds support for optional functionality to validate server
certificate chain in TLS-based EAP methods in an external program.
wpa_supplicant control interface is used to indicate when such
validation is needed and what the result of the external validation is.

This external validation can extend or replace the internal validation.
When ca_cert or ca_path parameter is set, the internal validation is
used. If these parameters are omitted, only the external validation is
used. It needs to be understood that leaving those parameters out will
disable most of the validation steps done with the TLS library and that
configuration is not really recommend.

By default, the external validation is not used. It can be enabled by
addingtls_ext_cert_check=1 into the network profile phase1 parameter.
When enabled, external validation is required through the CTRL-REQ/RSP
mechanism similarly to other EAP authentication parameters through the
control interface.

The request to perform external validation is indicated by the following
event:
CTRL-REQ-EXT_CERT_CHECK-<id>:External server certificate validation needed for SSID <ssid>

Before that event, the server certificate chain is provided with the
CTRL-EVENT-EAP-PEER-CERT events that include the cert=<hexdump>
parameter. depth=# indicates which certificate is in question (0 for the
server certificate, 1 for its issues, and so on).

The result of the external validation is provided with the following
command:
CTRL-RSP-EXT_CERT_CHECK-<id>:<good|bad>

It should be noted that this is currently enabled only for OpenSSL (and
BoringSSL/LibreSSL). Due to the constraints in the library API, the
validation result from external processing cannot be reported cleanly
with TLS alert. In other words, if the external validation reject the
server certificate chain, the pending TLS handshake is terminated
without sending more messages to the server.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Fix wpas_ctrl_country and dbus_country with valid db.txt
Jouni Malinen [Sat, 12 Dec 2015 10:45:30 +0000 (12:45 +0200)]
tests: Fix wpas_ctrl_country and dbus_country with valid db.txt

init=CORE was previously used due to invalid db.txt data for 00. For
now, allow both it and the new init=USER after fixed db.txt.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-FAST local error cases
Jouni Malinen [Sat, 12 Dec 2015 10:07:51 +0000 (12:07 +0200)]
tests: EAP-FAST local error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP-FAST peer: Fix PAC parser error messages
Jouni Malinen [Sat, 12 Dec 2015 10:00:28 +0000 (12:00 +0200)]
EAP-FAST peer: Fix PAC parser error messages

Do not override the parsing error with the "PAC block not terminated
with END" message if the reason for the END line not yet being seen is
in failure to parse an earlier line.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP-FAST: Check T-PRF result in MSK/EMSK derivation
Jouni Malinen [Sat, 12 Dec 2015 09:20:05 +0000 (11:20 +0200)]
EAP-FAST: Check T-PRF result in MSK/EMSK derivation

Pass the error return from sha1_t_prf() to callers.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP-FAST peer: Fix error path handling for Session-Id
Jouni Malinen [Sat, 12 Dec 2015 09:12:32 +0000 (11:12 +0200)]
EAP-FAST peer: Fix error path handling for Session-Id

It was possible to hit a NULL pointer dereference if Session-Id
derivation failed due to a memory allocation failure.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoOpenSSL: Support new API for HMAC/EVP_MD_CTX in OpenSSL 1.1.x-pre1
Jouni Malinen [Thu, 10 Dec 2015 16:11:39 +0000 (18:11 +0200)]
OpenSSL: Support new API for HMAC/EVP_MD_CTX in OpenSSL 1.1.x-pre1

The EVP_MD_CTX and HMAC_CTX definitions are now hidden from applications
using OpenSSL. Fix compilation issues with OpenSSL 1.1.x-pre1 by using
the new API for allocating these structures.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: FT PTK rekeying triggered by AP/station after roam
Jouni Malinen [Wed, 9 Dec 2015 22:05:10 +0000 (00:05 +0200)]
tests: FT PTK rekeying triggered by AP/station after roam

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoFT: Fix FTIE generation for EAPOL-Key msg 3/4
Jouni Malinen [Wed, 9 Dec 2015 22:12:59 +0000 (00:12 +0200)]
FT: Fix FTIE generation for EAPOL-Key msg 3/4

This FTIE needs to be an exact copy of the one in (Re)Association
Response frame. Copy the stored element rather than building a new copy
that would not have the correct MIC value. This is needed to fix PTK
rekeying after FT protocol run.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoFT: Fix sm->assoc_resp_ftie storing on the AP side
Jouni Malinen [Wed, 9 Dec 2015 22:11:00 +0000 (00:11 +0200)]
FT: Fix sm->assoc_resp_ftie storing on the AP side

The FTIE from (Re)Association Response frame was copied before
calculating the MIC. This resulted in incorrect value being used when
comparing the EAPOL-Key msg 2/4 value in case PTK rekeying was used
after FT protocol run. Fix this by storing the element after the MIC
field has been filled in.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoFT: Fix FTIE generation for 4-way handshake after FT protocol run
Jouni Malinen [Wed, 9 Dec 2015 22:06:06 +0000 (00:06 +0200)]
FT: Fix FTIE generation for 4-way handshake after FT protocol run

wpa_insert_pmkid() did not support cases where the original RSN IE
included any PMKIDs. That case can happen when PTK rekeying through
4-way handshake is used after FT protocol run. Such a 4-way handshake
used to fail with wpa_supplicant being unable to build the EAPOL-Key msg
2/4.

Fix this by extending wpa_insert_pmkid() to support removal of the old
PMKIDs, if needed.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: Make pmksa_cache_opportunistic_connect more robust
Jouni Malinen [Sun, 6 Dec 2015 18:31:18 +0000 (20:31 +0200)]
tests: Make pmksa_cache_opportunistic_connect more robust

This test case could fail if the cfg80211 scan cache brought in a BSS
entry from an earlier test case and a new scan did not get executed
prior to the ROAM command. Fix this by forcing the scan to go through
prior to roaming to AP2

This issue showed up with the following test case sequence:
connect_cmd_roam pmksa_cache_opportunistic_connect

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoAP: Use more readable version of management group cipher in error cases
Jouni Malinen [Sun, 6 Dec 2015 18:01:05 +0000 (20:01 +0200)]
AP: Use more readable version of management group cipher in error cases

This makes it easier to interpret AP side debug log for a case where a
station specifies in unsupported management group cipher.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: WPA2 AP processing of RSN IE differences
Jouni Malinen [Sun, 6 Dec 2015 17:33:36 +0000 (19:33 +0200)]
tests: WPA2 AP processing of RSN IE differences

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoAdd TEST_ASSOC_IE for WPA/RSN IE testing on AP side
Jouni Malinen [Sun, 6 Dec 2015 17:30:59 +0000 (19:30 +0200)]
Add TEST_ASSOC_IE for WPA/RSN IE testing on AP side

The new wpa_supplicant control interface command "TEST_ASSOC_IE
<hexdump>" can now be used to override the WPA/RSN IE for Association
Request frame and following 4-way handshake to allow protocol testing of
AP side processing of WPA/RSN IE.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Write GTK locations into debug log in key_lifetime_in_memory
Jouni Malinen [Sun, 6 Dec 2015 15:48:43 +0000 (17:48 +0200)]
tests: Write GTK locations into debug log in key_lifetime_in_memory

It looks like it is possible for the GTK to be found from memory every
now and then. This makes these test cases fail. Write the memory
addresses in which the GTK was found to the log to make it somewhat
easier to try to figure out where the key can be left in memory.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Make dbus_wps_oom more robust
Jouni Malinen [Sun, 6 Dec 2015 15:10:06 +0000 (17:10 +0200)]
tests: Make dbus_wps_oom more robust

It was possible for the BSSs object property change signal to be
generated during the OOM test case for Get(). If that happened, the
signal was not sent out, but the following Get(BSSs) operation succeeded
unexpectedly which resulted in a test failure. Make this less likely to
happen by waiting 50 ms between the scan and Get(BSSs) operation. This
should be sufficient to cover most cases since wpa_supplicant uses 5 ms
timeout for D-Bus property changed updates.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Make ap_max_num_sta_no_probe_resp more robust
Jouni Malinen [Sun, 6 Dec 2015 11:35:40 +0000 (13:35 +0200)]
tests: Make ap_max_num_sta_no_probe_resp more robust

It was possible for the AP's Beacon frame to be seen by dev[0] when
running a scan. This is not an error case. Make this test case more
robust by verifying with a sniffer whether a Probe Response frame was
sent to unexpected STA.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoFST: Print debug entry on MB IE update based on EVENT_AUTH
Jouni Malinen [Sun, 6 Dec 2015 10:53:24 +0000 (12:53 +0200)]
FST: Print debug entry on MB IE update based on EVENT_AUTH

This is more consistent with all the other callers of
wpas_fst_update_mbie().

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: D-Bus vendor element operations
Jouni Malinen [Sun, 6 Dec 2015 10:41:31 +0000 (12:41 +0200)]
tests: D-Bus vendor element operations

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agodbus: Add support for vendor specific elements
Avichal Agarwal [Fri, 4 Dec 2015 05:27:27 +0000 (10:57 +0530)]
dbus: Add support for vendor specific elements

The new methods are
1. VendorElemAdd "i" "ay" i=integer ay=array of bytes
2. VendorElemGet "i" i=integer (output array of bytes)
3. VendorElemRem "i" "ay" i=integer ay=array of bytes

These provide functionality similar to the control interface commands
VENDOR_ELEM_ADD, VENDOR_ELEM_GET, and VENDOR_ELEM_REMOVE.

Signed-off-by: Avichal Agarwal <avichal.a@samsung.com>
Signed-off-by: Purushottam Kushwaha <p.kushwaha@samsung.com>
Signed-off-by: Kyeong-Chae Lim <kcya.lim@samsung.com>
Signed-off-by: Mayank Haarit <mayank.h@samsung.com>
Signed-off-by: Dilshad Ahmad <dilshad.a@samsung.com>
[VendorElemGet to return array of bytes instead of string; cleanup]
Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-PSK local error cases
Jouni Malinen [Sun, 6 Dec 2015 09:13:12 +0000 (11:13 +0200)]
tests: EAP-PSK local error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-IKEv2 local error cases
Jouni Malinen [Sat, 5 Dec 2015 20:04:00 +0000 (22:04 +0200)]
tests: EAP-IKEv2 local error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP-IKEv2: Check HMAC SHA1/MD5 result
Jouni Malinen [Sat, 5 Dec 2015 19:49:04 +0000 (21:49 +0200)]
EAP-IKEv2: Check HMAC SHA1/MD5 result

Make the IKEv2 helper functions return a possible error return from the
HMAC routines.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: WPS and fragment ack OOM
Jouni Malinen [Sat, 5 Dec 2015 19:35:45 +0000 (21:35 +0200)]
tests: WPS and fragment ack OOM

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoUse proper build config for parsing proxy_arp
Matt Woods [Sat, 5 Dec 2015 07:20:58 +0000 (07:20 +0000)]
Use proper build config for parsing proxy_arp

In the definition of struct hostapd_bss_config, proxy_arp isn't affected
by the macro CONFIG_HS20. In addition, proxy_arp is not described in the
section of Hotspot 2.0 in the file hostapd.conf. The item proxy_arp
should be decided its action area by the macro CONFIG_PROXYARP which is
used to select whether the needed function gets included in the build.

Signed-off-by: Matt Woods <matt.woods@aliyun.com>