]> git.ipfire.org Git - thirdparty/hostap.git/log
thirdparty/hostap.git
5 years agotests: Avoid confusing "DETACH failed" exception prints in D-Bus tests
Jouni Malinen [Mon, 15 Apr 2019 17:13:28 +0000 (20:13 +0300)] 
tests: Avoid confusing "DETACH failed" exception prints in D-Bus tests

dbus_p2p_go_neg_init, dbus_p2p_group_idle_timeout, and
dbus_p2p_group_termination_by_go could end up print a "DETACH failed"
exception as a warning from WpaSupplicant.__del__ for the dev1 instance
used within the TestDbusP2p class. This did not cause the test cases to
fail, but the output is a bit confusing, so clean this up be explicitly
closing the control interface monitor sockets and furthermore by
ignoring the "DETACH failed" exception within __del__.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoRemove hwsim_test
Jouni Malinen [Mon, 15 Apr 2019 09:44:41 +0000 (12:44 +0300)] 
Remove hwsim_test

This external tool was used for testing data connectivity with
mac80211_hwsim. However, the last user for it was removed in 2014 by
commit 1131a1c8d29c ("tests: Replace last remaining hwsim_test uses with
DATA_TEST"), so there is not point in maintaining this forgotten test
tool in the repository anymore.

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: Unsupported WNM Action
Jouni Malinen [Sun, 14 Apr 2019 14:34:54 +0000 (17:34 +0300)] 
tests: Unsupported WNM Action

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: WNM Collocated Interference Reporting errors
Jouni Malinen [Sun, 14 Apr 2019 14:32:03 +0000 (17:32 +0300)] 
tests: WNM Collocated Interference Reporting errors

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: WNM BSS Transition Management and steering timeout
Jouni Malinen [Sun, 14 Apr 2019 14:21:13 +0000 (17:21 +0300)] 
tests: WNM BSS Transition Management and steering timeout

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: WNM BSS Transition Management query - TM disabled on AP
Jouni Malinen [Sun, 14 Apr 2019 14:00:23 +0000 (17:00 +0300)] 
tests: WNM BSS Transition Management query - TM disabled on AP

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: WNM Sleep Mode disabled on AP
Jouni Malinen [Sun, 14 Apr 2019 13:56:00 +0000 (16:56 +0300)] 
tests: WNM Sleep Mode disabled on AP

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: Use helper function for starting WNM AP
Jouni Malinen [Sun, 14 Apr 2019 13:44:14 +0000 (16:44 +0300)] 
tests: Use helper function for starting WNM AP

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: WNM Sleep Mode - RSN with OCV - local failure
Jouni Malinen [Sun, 14 Apr 2019 13:02:54 +0000 (16:02 +0300)] 
tests: WNM Sleep Mode - RSN with OCV - local failure

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: nl80211 freq reporting in station mode
Jouni Malinen [Sun, 14 Apr 2019 09:41:26 +0000 (12:41 +0300)] 
tests: nl80211 freq reporting in station mode

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agonl80211: Update assoc_freq and bss->freq based on real association info
Jouni Malinen [Sun, 14 Apr 2019 09:37:41 +0000 (12:37 +0300)] 
nl80211: Update assoc_freq and bss->freq based on real association info

Move event.assoc_info.freq selection to be after the
nl80211_get_assoc_ssid() call so that the current cfg80211 information
on the operating channel can be used should anything unexpected have
happened between the association request and completion of association.
Furthermore, update bss->freq based on assoc_freq to make that
information a bit more useful for station mode. It was already updated
after channel switches during association, but not at the beginning of
association.

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agonl80211: Clear bss->freq on station mode disconnection
Jouni Malinen [Sun, 14 Apr 2019 09:33:37 +0000 (12:33 +0300)] 
nl80211: Clear bss->freq on station mode disconnection

This fixes some issues where bss->freq could have been used to replace
the current operating channel when sending out a management frame.
bss->freq has not been consistently used to track the current operating
channel in station mode, so it should not be trusted for this type of
uses. Clearing it makes this a bit more robust by at least avoiding the
cases of information from past association being used.

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: eap_pwd_perform_confirm_exchange() local failure
Jouni Malinen [Sat, 13 Apr 2019 15:35:47 +0000 (18:35 +0300)] 
tests: eap_pwd_perform_confirm_exchange() local failure

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: eap_pwd_perform_commit_exchange() local failures
Jouni Malinen [Sat, 13 Apr 2019 15:34:38 +0000 (18:34 +0300)] 
tests: eap_pwd_perform_commit_exchange() local failures

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: EAP-pwd commit request error cases
Jouni Malinen [Sat, 13 Apr 2019 15:21:57 +0000 (18:21 +0300)] 
tests: EAP-pwd commit request error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agoRemove the unused crypto_ec_cofactor() function
Jouni Malinen [Sat, 13 Apr 2019 14:33:15 +0000 (17:33 +0300)] 
Remove the unused crypto_ec_cofactor() function

All users of this wrapper function were removed, so the wrapper can be
removed as well.

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agoEAP-pwd: Remove unused checks for cofactor > 1 cases
Jouni Malinen [Sat, 13 Apr 2019 14:30:22 +0000 (17:30 +0300)] 
EAP-pwd: Remove unused checks for cofactor > 1 cases

None of the ECC groups supported in the implementation had a cofactor
greater than 1, so these checks are unreachable and for all cases, the
cofactor is known to be 1. Furthermore, RFC 5931 explicitly disallow use
of ECC groups with cofactor larger than 1, so this checks cannot be
needed for any curve that is compliant with the RFC.

Remove the unneeded group cofactor checks to simplify the
implementation.

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: EAP-pwd rejection of groups 25, 26, and 27
Jouni Malinen [Sat, 13 Apr 2019 14:16:04 +0000 (17:16 +0300)] 
tests: EAP-pwd rejection of groups 25, 26, and 27

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agoEAP-pwd: Disallow ECC groups with a prime under 256 bits
Jouni Malinen [Sat, 13 Apr 2019 14:20:57 +0000 (17:20 +0300)] 
EAP-pwd: Disallow ECC groups with a prime under 256 bits

Based on the SAE implementation guidance update to not allow ECC groups
with a prime that is under 256 bits, reject groups 25, 26, and 27 in
EAP-pwd.

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: Remove testing of EAP-pwd groups 25, 26, and 27
Jouni Malinen [Sat, 13 Apr 2019 14:17:09 +0000 (17:17 +0300)] 
tests: Remove testing of EAP-pwd groups 25, 26, and 27

This is in preparation of disallowing all use of these groups. Negative
test case for the groups will be added in a separate commit after the
implementation has been changed.

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: EAP-pwd local failure in crypto_bignum_rand()
Jouni Malinen [Sat, 13 Apr 2019 14:00:55 +0000 (17:00 +0300)] 
tests: EAP-pwd local failure in crypto_bignum_rand()

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agoOpenSSL: Fix server side openssl_ecdh_curves configuration with 1.0.2
Jouni Malinen [Sat, 13 Apr 2019 13:53:19 +0000 (16:53 +0300)] 
OpenSSL: Fix server side openssl_ecdh_curves configuration with 1.0.2

It looks like SSL_CTX_set1_curves_list() command alone is not sufficient
to enable ECDH curve selection with older OpenSSL versions for TLS
server, so enable automatic selection first and specify the exact list
of curves after that.

This fixes failures in openssl_ecdh_curves test case when hostapd uses
OpenSSL 1.0.2.

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: EAP-pwd eap_pwd_get_element() local failures
Jouni Malinen [Sat, 13 Apr 2019 10:15:31 +0000 (13:15 +0300)] 
tests: EAP-pwd eap_pwd_get_element() local failures

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: EAP-pwd compute_password_element() local failures
Jouni Malinen [Sat, 13 Apr 2019 10:01:04 +0000 (13:01 +0300)] 
tests: EAP-pwd compute_password_element() local failures

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: CONFIG_TLS=linux build of wpa_supplicant
Jouni Malinen [Sat, 13 Apr 2019 09:57:42 +0000 (12:57 +0300)] 
tests: CONFIG_TLS=linux build of wpa_supplicant

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: crypto_hash_finish() failure in eap_pwd_kdf()
Jouni Malinen [Sat, 13 Apr 2019 09:53:42 +0000 (12:53 +0300)] 
tests: crypto_hash_finish() failure in eap_pwd_kdf()

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: EAP-EKE rejection of unsupported DH groups 2 and 5
Jouni Malinen [Sat, 13 Apr 2019 09:20:24 +0000 (12:20 +0300)] 
tests: EAP-EKE rejection of unsupported DH groups 2 and 5

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: Make regdom clearing in WNM tests more robust
Jouni Malinen [Sat, 13 Apr 2019 09:06:25 +0000 (12:06 +0300)] 
tests: Make regdom clearing in WNM tests more robust

It looks like the scan operation could end up reverting regdom back to
the previously configured one, so configure 00 country before starting
the disconnect-and-stop-scan operation to give some more time for the
regdom to be cleared.

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: Show ifname in country code not cleared messages
Jouni Malinen [Sat, 13 Apr 2019 09:06:09 +0000 (12:06 +0300)] 
tests: Show ifname in country code not cleared messages

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: Update rrm_beacon_req_last_frame_indication to match implementation
Avraham Stern [Wed, 3 Apr 2019 17:38:49 +0000 (20:38 +0300)] 
tests: Update rrm_beacon_req_last_frame_indication to match implementation

The last beacon report indication was set in all the beacon report
elements in the last frame of the beacon report, while it should be set
only in the last beacon report element of the last frame. This is now
fixed in wpa_supplicant, so update the test case expectation to match
the fixed behavior.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
5 years agoRRM: Set last beacon report indication in the last element only
Avraham Stern [Wed, 3 Apr 2019 17:38:49 +0000 (20:38 +0300)] 
RRM: Set last beacon report indication in the last element only

The last beacon report indication was set in all the beacon report
elements in the last frame of the beacon report, while it should be
set only in the last beacon report element of the last frame.

Fixes: ecef0687dc33 ("RRM: Support for Last Beacon Report Indication subelement")
Signed-off-by: Avraham Stern <avraham.stern@intel.com>
5 years agoDocument BSS expiration configurables
Ben Greear [Wed, 10 Apr 2019 21:01:17 +0000 (14:01 -0700)] 
Document BSS expiration configurables

Help the user be aware of the options to configure when
wpa_supplicant will remove a BSS due to expiration.

Signed-off-by: Ben Greear <greearb@candelatech.com>
5 years agobsd: Fix a typo in error message
Ryo ONODERA [Sat, 13 Apr 2019 00:50:56 +0000 (09:50 +0900)] 
bsd: Fix a typo in error message

When SIOCG80211 failed, show error message with SIOCG80211
instead of SIOCS80211.

Signed-off-by: Ryo ONODERA <ryo@tetera.org>
5 years agotests: Fix trace-cmd recording with python3
Johannes Berg [Fri, 12 Apr 2019 11:20:19 +0000 (13:20 +0200)] 
tests: Fix trace-cmd recording with python3

The change to python3 broke trace-cmd recording, two
strings need to be bytes instead. Fix that.

Also add a flush() that seems to be needed now.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
5 years agoRemove unnecessary copying of SSID and BSSID for external_auth
Jouni Malinen [Fri, 12 Apr 2019 17:38:08 +0000 (20:38 +0300)] 
Remove unnecessary copying of SSID and BSSID for external_auth

The external authentication command and event does not need to copy the
BSSID/SSID values into struct external_auth since those values are used
before returning from the call. Simplify this by using const u8 * to
external data instead of the array with a copy of the external data.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agohostapd: Support external authentication offload in AP mode
Srinivas Dasari [Mon, 18 Mar 2019 09:34:04 +0000 (15:04 +0530)] 
hostapd: Support external authentication offload in AP mode

Extend commit 5ff39c1380d9 ("SAE: Support external authentication
offload for driver-SME cases") to support external authentication
with drivers that implement AP SME by notifying the status of
SAE authentication to the driver after SAE handshake as the
driver acts as a pass through for the SAE Authentication frames.

Signed-off-by: Srinivas Dasari <dasaris@codeaurora.org>
5 years agonl80211: External authentication in driver-based AP SME mode
Srinivas Dasari [Mon, 25 Feb 2019 12:22:05 +0000 (17:52 +0530)] 
nl80211: External authentication in driver-based AP SME mode

This extends driver interface to nl80211 by introducing the following
changes,
1. Register for Authenication frames in driver-based AP SME mode.
2. Advertise NL80211_ATTR_EXTERNAL_AUTH_SUPPORT in set_ap when
   offloaded SAE authentication is supported.
3. Extend the NL80211_CMD_EXTERNAL_AUTH interface to also send PMKID
   so that the drivers can respond to the PMKSA cached connection
   attempts from the stations avoiding the need to contact user space
   for all PMKID-based connections.
4. Send external auth status to driver only if it is a driver based
   SME solution.

Signed-off-by: Srinivas Dasari <dasaris@codeaurora.org>
5 years agoReset beacon_set_done on disabling interface
nakul kachhwaha [Wed, 3 Apr 2019 07:02:59 +0000 (12:32 +0530)] 
Reset beacon_set_done on disabling interface

beacon_set_done did not get reset to zero on disabling interface using
DISABLE control interface command and the subsequent ENABLE command will
caused configuration of Beacon/Probe Response/Association Response frame
IEs twice. The unnecessary two step configuration can be avoided by
resetting beacon_set_done on DISABLE so that ENABLE can bring up the
interface in a single step with fully updated IEs.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoEAP-pwd: Get rid of unnecessary allocation of temporary buffer
Jouni Malinen [Fri, 5 Apr 2019 09:45:16 +0000 (12:45 +0300)] 
EAP-pwd: Get rid of unnecessary allocation of temporary buffer

Binary presentations of element and scalar can be written directly to
the allocated commit message buffer instead of having to first write
them into temporary buffers just to copy them to the actual message
buffer.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoEAP-pwd: Enforce 1 < rand,mask < r and rand+mask mod r > 1
Jouni Malinen [Fri, 5 Apr 2019 09:37:21 +0000 (12:37 +0300)] 
EAP-pwd: Enforce 1 < rand,mask < r and rand+mask mod r > 1

RFC 5931 has these conditions as MUST requirements, so better follow
them explicitly even if the rand,mask == 0 or rand+mask == 0 or 1 cases
are very unlikely to occur in practice while generating random values
locally.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: EAP-pwd protocol tests for invalid EAP-pwd-Commit
Jouni Malinen [Tue, 2 Apr 2019 19:12:53 +0000 (22:12 +0300)] 
tests: EAP-pwd protocol tests for invalid EAP-pwd-Commit

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: SAE commit invalid scalar/element
Jouni Malinen [Tue, 2 Apr 2019 10:36:58 +0000 (13:36 +0300)] 
tests: SAE commit invalid scalar/element

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: SAE and confirm after invalid commit
Jouni Malinen [Wed, 6 Mar 2019 01:02:21 +0000 (03:02 +0200)] 
tests: SAE and confirm after invalid commit

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: Module tests for const_time_*() functions
Jouni Malinen [Fri, 1 Mar 2019 11:24:48 +0000 (13:24 +0200)] 
tests: Module tests for const_time_*() functions

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoEAP-pwd: Check element x,y coordinates explicitly
Jouni Malinen [Thu, 4 Apr 2019 23:12:50 +0000 (02:12 +0300)] 
EAP-pwd: Check element x,y coordinates explicitly

This adds an explicit check for 0 < x,y < prime based on RFC 5931,
2.8.5.2.2 requirement. The earlier checks might have covered this
implicitly, but it is safer to avoid any dependency on implicit checks
and specific crypto library behavior. (CVE-2019-9498 and CVE-2019-9499)

Furthermore, this moves the EAP-pwd element and scalar parsing and
validation steps into shared helper functions so that there is no need
to maintain two separate copies of this common functionality between the
server and peer implementations.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoEAP-pwd client: Verify received scalar and element
Mathy Vanhoef [Sun, 31 Mar 2019 15:43:44 +0000 (17:43 +0200)] 
EAP-pwd client: Verify received scalar and element

When processing an EAP-pwd Commit frame, the server's scalar and element
(elliptic curve point) were not validated. This allowed an adversary to
bypass authentication, and act as a rogue Access Point (AP) if the
crypto implementation did not verify the validity of the EC point.

Fix this vulnerability by assuring the received scalar lies within the
valid range, and by checking that the received element is not the point
at infinity and lies on the elliptic curve being used. (CVE-2019-9499)

The vulnerability is only exploitable if OpenSSL version 1.0.2 or lower
is used, or if LibreSSL or wolfssl is used. Newer versions of OpenSSL
(and also BoringSSL) implicitly validate the elliptic curve point in
EC_POINT_set_affine_coordinates_GFp(), preventing the attack.

Signed-off-by: Mathy Vanhoef <mathy.vanhoef@nyu.edu>
5 years agoEAP-pwd server: Detect reflection attacks
Mathy Vanhoef [Sun, 31 Mar 2019 15:26:01 +0000 (17:26 +0200)] 
EAP-pwd server: Detect reflection attacks

When processing an EAP-pwd Commit frame, verify that the peer's scalar
and elliptic curve element differ from the one sent by the server. This
prevents reflection attacks where the adversary reflects the scalar and
element sent by the server. (CVE-2019-9497)

The vulnerability allows an adversary to complete the EAP-pwd handshake
as any user. However, the adversary does not learn the negotiated
session key, meaning the subsequent 4-way handshake would fail. As a
result, this cannot be abused to bypass authentication unless EAP-pwd is
used in non-WLAN cases without any following key exchange that would
require the attacker to learn the MSK.

Signed-off-by: Mathy Vanhoef <mathy.vanhoef@nyu.edu>
5 years agoEAP-pwd server: Verify received scalar and element
Mathy Vanhoef [Sun, 31 Mar 2019 15:13:06 +0000 (17:13 +0200)] 
EAP-pwd server: Verify received scalar and element

When processing an EAP-pwd Commit frame, the peer's scalar and element
(elliptic curve point) were not validated. This allowed an adversary to
bypass authentication, and impersonate any user if the crypto
implementation did not verify the validity of the EC point.

Fix this vulnerability by assuring the received scalar lies within the
valid range, and by checking that the received element is not the point
at infinity and lies on the elliptic curve being used. (CVE-2019-9498)

The vulnerability is only exploitable if OpenSSL version 1.0.2 or lower
is used, or if LibreSSL or wolfssl is used. Newer versions of OpenSSL
(and also BoringSSL) implicitly validate the elliptic curve point in
EC_POINT_set_affine_coordinates_GFp(), preventing the attack.

Signed-off-by: Mathy Vanhoef <mathy.vanhoef@nyu.edu>
5 years agoSAE: Fix confirm message validation in error cases
Jouni Malinen [Tue, 5 Mar 2019 21:43:25 +0000 (23:43 +0200)] 
SAE: Fix confirm message validation in error cases

Explicitly verify that own and peer commit scalar/element are available
when trying to check SAE confirm message. It could have been possible to
hit a NULL pointer dereference if the peer element could not have been
parsed. (CVE-2019-9496)

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoSAE: Use constant time operations in sae_test_pwd_seed_ffc()
Jouni Malinen [Sat, 2 Mar 2019 14:05:56 +0000 (16:05 +0200)] 
SAE: Use constant time operations in sae_test_pwd_seed_ffc()

Try to avoid showing externally visible timing or memory access
differences regardless of whether the derived pwd-value is smaller than
the group prime.

This is related to CVE-2019-9494.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoSAE: Use const_time selection for PWE in FFC
Jouni Malinen [Sat, 2 Mar 2019 10:45:33 +0000 (12:45 +0200)] 
SAE: Use const_time selection for PWE in FFC

This is an initial step towards making the FFC case use strictly
constant time operations similarly to the ECC case.
sae_test_pwd_seed_ffc() does not yet have constant time behavior,
though.

This is related to CVE-2019-9494.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoSAE: Mask timing of MODP groups 22, 23, 24
Jouni Malinen [Sat, 2 Mar 2019 10:24:09 +0000 (12:24 +0200)] 
SAE: Mask timing of MODP groups 22, 23, 24

These groups have significant probability of coming up with pwd-value
that is equal or greater than the prime and as such, need for going
through the PWE derivation loop multiple times. This can result in
sufficient timing different to allow an external observer to determine
how many rounds are needed and that can leak information about the used
password.

Force at least 40 loop rounds for these MODP groups similarly to the ECC
group design to mask timing. This behavior is not described in IEEE Std
802.11-2016 for SAE, but it does not result in different values (i.e.,
only different timing), so such implementation specific countermeasures
can be done without breaking interoperability with other implementation.

Note: These MODP groups 22, 23, and 24 are not considered sufficiently
strong to be used with SAE (or more or less anything else). As such,
they should never be enabled in runtime configuration for any production
use cases. These changes to introduce additional protection to mask
timing is only for completeness of implementation and not an indication
that these groups should be used.

This is related to CVE-2019-9494.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoSAE: Avoid branches in is_quadratic_residue_blind()
Jouni Malinen [Tue, 26 Feb 2019 17:34:38 +0000 (19:34 +0200)] 
SAE: Avoid branches in is_quadratic_residue_blind()

Make the non-failure path in the function proceed without branches based
on r_odd and in constant time to minimize risk of observable differences
in timing or cache use. (CVE-2019-9494)

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoSAE: Minimize timing differences in PWE derivation
Jouni Malinen [Tue, 26 Feb 2019 11:05:09 +0000 (13:05 +0200)] 
SAE: Minimize timing differences in PWE derivation

The QR test result can provide information about the password to an
attacker, so try to minimize differences in how the
sae_test_pwd_seed_ecc() result is used. (CVE-2019-9494)

Use heap memory for the dummy password to allow the same password length
to be used even with long passwords.

Use constant time selection functions to track the real vs. dummy
variables so that the exact same operations can be performed for both QR
test results.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoEAP-pwd: Use constant time and memory access for finding the PWE
Jouni Malinen [Tue, 26 Feb 2019 09:59:45 +0000 (11:59 +0200)] 
EAP-pwd: Use constant time and memory access for finding the PWE

This algorithm could leak information to external observers in form of
timing differences or memory access patterns (cache use). While the
previous implementation had protection against the most visible timing
differences (looping 40 rounds and masking the legendre operation), it
did not protect against memory access patterns between the two possible
code paths in the masking operations. That might be sufficient to allow
an unprivileged process running on the same device to be able to
determine which path is being executed through a cache attack and based
on that, determine information about the used password.

Convert the PWE finding loop to use constant time functions and
identical memory access path without different branches for the QR/QNR
cases to minimize possible side-channel information similarly to the
changes done for SAE authentication. (CVE-2019-9495)

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoOpenSSL: Use constant time selection for crypto_bignum_legendre()
Jouni Malinen [Thu, 7 Mar 2019 22:24:12 +0000 (00:24 +0200)] 
OpenSSL: Use constant time selection for crypto_bignum_legendre()

Get rid of the branches that depend on the result of the Legendre
operation. This is needed to avoid leaking information about different
temporary results in blinding mechanisms.

This is related to CVE-2019-9494 and CVE-2019-9495.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoAdd helper functions for constant time operations
Jouni Malinen [Wed, 27 Feb 2019 16:38:30 +0000 (18:38 +0200)] 
Add helper functions for constant time operations

These functions can be used to help implement constant time operations
for various cryptographic operations that must minimize externally
observable differences in processing (both in timing and also in
internal cache use, etc.).

This is related to CVE-2019-9494 and CVE-2019-9495.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoOpenSSL: Use constant time operations for private bignums
Jouni Malinen [Tue, 26 Feb 2019 09:43:03 +0000 (11:43 +0200)] 
OpenSSL: Use constant time operations for private bignums

This helps in reducing measurable timing differences in operations
involving private information. BoringSSL has removed BN_FLG_CONSTTIME
and expects specific constant time functions to be called instead, so a
bit different approach is needed depending on which library is used.

The main operation that needs protection against side channel attacks is
BN_mod_exp() that depends on private keys (the public key validation
step in crypto_dh_derive_secret() is an exception that can use the
faster version since it does not depend on private keys).

crypto_bignum_div() is currently used only in SAE FFC case with not
safe-prime groups and only with values that do not depend on private
keys, so it is not critical to protect it.

crypto_bignum_inverse() is currently used only in SAE FFC PWE
derivation. The additional protection here is targeting only OpenSSL.
BoringSSL may need conversion to using BN_mod_inverse_blinded().

This is related to CVE-2019-9494 and CVE-2019-9495.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: Test cases for X.509 certificate checking
Jouni Malinen [Tue, 9 Apr 2019 10:22:57 +0000 (13:22 +0300)] 
tests: Test cases for X.509 certificate checking

This makes it easier to test various X.509 certificate validation steps
with the server certificate being generated and signed using pyOpenSSL
dynamically.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoExtend domain_match and domain_suffix_match to allow list of values
Jouni Malinen [Tue, 9 Apr 2019 13:18:19 +0000 (16:18 +0300)] 
Extend domain_match and domain_suffix_match to allow list of values

These wpa_supplicant network profile parameters could be used to specify
a single match string that would be used against the dNSName items in
subjectAltName or CN. There may be use cases where more than one
alternative match string would be useful, so extend these to allow a
semicolon delimited list of values to be used (e.g.,
"example.org;example.com"). If any of the specified values matches any
of the dNSName/CN values in the server certificate, consider the
certificate as meeting this requirement.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agowolfSSL: Fix dNSName matching with domain_match and domain_suffix_match
Jouni Malinen [Tue, 9 Apr 2019 13:22:13 +0000 (16:22 +0300)] 
wolfSSL: Fix dNSName matching with domain_match and domain_suffix_match

Incorrect gen->type value was used to check whether subjectAltName
contained dNSName entries. This resulted in all domain_match and
domain_suffix_match entries failing to find a match and rejecting the
server certificate. Fix this by checking against the correct type
definition for dNSName.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: Fix build without CONFIG_SAE
Jouni Malinen [Tue, 9 Apr 2019 13:17:25 +0000 (16:17 +0300)] 
tests: Fix build without CONFIG_SAE

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: ERP enabled on RADIUS server and peer and no wildcard user
Jouni Malinen [Mon, 8 Apr 2019 21:12:35 +0000 (00:12 +0300)] 
tests: ERP enabled on RADIUS server and peer and no wildcard user

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoRADIUS server: Accept ERP keyName-NAI as user identity
Jouni Malinen [Mon, 8 Apr 2019 21:10:20 +0000 (00:10 +0300)] 
RADIUS server: Accept ERP keyName-NAI as user identity

Previously the EAP user database had to include a wildcard entry for ERP
to work since the keyName-NAI as User-Name in Access-Request would not
be recognized without such wildcard entry (that could point to any EAP
method). This is not ideal, so add a separate check to allow any stored
ERP keyName-NAI to be used for ERP without any requirement for the EAP
user database to contain a matching entry.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: scan_multi_bssid_check_ie to allow for Multi BSSID Index IE
Jouni Malinen [Mon, 8 Apr 2019 20:44:45 +0000 (23:44 +0300)] 
tests: scan_multi_bssid_check_ie to allow for Multi BSSID Index IE

cfg80211 was modified to allow the Multiple BSSID Index element to be
included in the IEs for a nontransmitted BSS. Update the validation step
in this test case to allow that different with the IEs in the Beacon
frame (transmitted BSS).

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoFix a typo in the Multiple BSSID Index element ID define
Jouni Malinen [Mon, 8 Apr 2019 20:42:12 +0000 (23:42 +0300)] 
Fix a typo in the Multiple BSSID Index element ID define

This was not used anywhere, so just rename the define to fix the typo.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoDPP: Fix a regression in non-DPP, non-OpenSSL builds
Jouni Malinen [Mon, 8 Apr 2019 15:07:28 +0000 (18:07 +0300)] 
DPP: Fix a regression in non-DPP, non-OpenSSL builds

Inclusion of common/dpp.h into hostapd/main.c brought in an undesired
unconditional dependency on OpenSSL header files even for builds where
DPP is not enabled. Fix this by making the dpp.h contents, and in
particular the inclusion of openssl/x509.h, conditional on CONFIG_DPP.

Fixes: 87d8435cf9fd ("DPP: Common configurator/bootstrapping data management")
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoSAE: Reject unsuitable groups based on REVmd changes
Jouni Malinen [Mon, 8 Apr 2019 15:01:07 +0000 (18:01 +0300)] 
SAE: Reject unsuitable groups based on REVmd changes

The rules defining which DH groups are suitable for SAE use were
accepted into IEEE 802.11 REVmd based on this document:
https://mentor.ieee.org/802.11/dcn/19/11-19-0387-02-000m-addressing-some-sae-comments.docx

Enforce those rules in production builds of wpa_supplicant and hostapd.
CONFIG_TESTING_OPTIONS=y builds can still be used to select any o the
implemented groups to maintain testing coverage.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: Change most SAE test cases to use suitable groups
Jouni Malinen [Mon, 8 Apr 2019 14:59:17 +0000 (17:59 +0300)] 
tests: Change most SAE test cases to use suitable groups

Reduce testing dependency on the unsuitable groups so that a test case
against a production build would not fail the test case unnecessarily.
This is in preparation of making production builds
(CONFIG_TESTING_OPTIONS not defined) of wpa_supplicant hostapd disable
all DH groups that have been indicated as being unsuitable.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoAP: Avoid NULL use with snprintf string
Andrei Otcheretianski [Wed, 3 Apr 2019 15:17:16 +0000 (18:17 +0300)] 
AP: Avoid NULL use with snprintf string

identity_buf may be NULL here. Handle this case explicitly by printing
"N/A" instead relying on snprintf converting this to "(null)" or some
other value based on unexpected NULL pointer.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
5 years agotests: Skip DPP configuration test
Andrei Otcheretianski [Wed, 3 Apr 2019 15:17:15 +0000 (18:17 +0300)] 
tests: Skip DPP configuration test

Skip wpas_config_file_key_mgmt if DPP is not supported.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
5 years agoscan: Use normal scans after connection failure
Ilan Peer [Wed, 3 Apr 2019 15:17:13 +0000 (18:17 +0300)] 
scan: Use normal scans after connection failure

In case of connection attempt failure, set 'normal_scans'
to zero, as otherwise it is possible that scheduled scan
would be used and not normal scan, which might delay the
next connection attempt.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
5 years agotests: Flush correct iface in P2PS stale group removal tests
Andrei Otcheretianski [Wed, 3 Apr 2019 15:17:17 +0000 (18:17 +0300)] 
tests: Flush correct iface in P2PS stale group removal tests

FLUSH should be done on P2P device interface, otherwise the networks are
not removed. Fix that.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
5 years agohostapd: Reduce minimum beacon interval from 15 to 10 TUs
Brendan Jackman [Fri, 5 Apr 2019 12:36:42 +0000 (12:36 +0000)] 
hostapd: Reduce minimum beacon interval from 15 to 10 TUs

Very short beacon intervals can be useful for certain scenarios such
as minimising association time on PBSSs. Linux supports a minimum of
10[1] so let's reduce the minimum to match that.

[1] https://elixir.bootlin.com/linux/latest/ident/cfg80211_validate_beacon_int

Signed-off-by: Brendan Jackman <brendan.jackman@bluwireless.co.uk>
5 years agoOWE: Fix a possible memory leak on error path
Ilan Peer [Wed, 3 Apr 2019 12:16:15 +0000 (15:16 +0300)] 
OWE: Fix a possible memory leak on error path

Properly handle the case where OWE IE is allocated, but
there is no space left to add it in the WPA IE buffer.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
5 years agocrypto: Fix unreachable code in tls_prf_sha1_md5()
Ilan Peer [Wed, 3 Apr 2019 12:16:14 +0000 (15:16 +0300)] 
crypto: Fix unreachable code in tls_prf_sha1_md5()

While commit 1c156e783d35 ("Fixed tls_prf() to handle keys with
odd length") added support for keys with odd length, the function
never reached this code as the function would return earlier in
case the key length was odd. Fix this by removing the first check
for the key length.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
5 years agotests: ERP/FILS with external hostapd process as RADIUS server
Jouni Malinen [Sat, 6 Apr 2019 13:47:38 +0000 (16:47 +0300)] 
tests: ERP/FILS with external hostapd process as RADIUS server

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agotests: SAE test vector from IEEE P802.11-REVmd/D2.1, Annex J.10
Jouni Malinen [Sat, 6 Apr 2019 10:26:15 +0000 (13:26 +0300)] 
tests: SAE test vector from IEEE P802.11-REVmd/D2.1, Annex J.10

Signed-off-by: Jouni Malinen <j@w1.fi>
5 years agoAdd a QCA vendor attribute to carry the reason for roaming
Sunil Dutt [Fri, 29 Mar 2019 12:47:53 +0000 (18:17 +0530)] 
Add a QCA vendor attribute to carry the reason for roaming

This commit introduces an attribute
QCA_WLAN_VENDOR_ATTR_ROAM_AUTH_REASON to carry the roam reason code
through QCA_NL80211_VENDOR_SUBCMD_KEY_MGMT_ROAM_AUTH event.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agonl80211: Add SAE, FT-SAE, FT-EAP-SHA384 AKMs in connect request
Ankita Bajaj [Mon, 1 Apr 2019 10:18:41 +0000 (15:48 +0530)] 
nl80211: Add SAE, FT-SAE, FT-EAP-SHA384 AKMs in connect request

This is needed for full MAC drivers that use NL80211_CMD_CONNECT
for issuing connect request.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoP2P: Enable HE for both 2G and 5G bands
Peng Xu [Thu, 4 Apr 2019 23:03:20 +0000 (16:03 -0700)] 
P2P: Enable HE for both 2G and 5G bands

Previously HE was only enabled for a 2G P2P GO. This change enables HE
for both 2G and 5G P2P GO.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoMBO: Update connect params with new MBO attributes to driver
Ankita Bajaj [Tue, 2 Apr 2019 09:02:50 +0000 (14:32 +0530)] 
MBO: Update connect params with new MBO attributes to driver

MBO attributes Non-preferred channel list and Cellular capabilities are
updated using WNM-Notification Request frame to the current connected
BSS. These same attributes need to be added in the (Re)Association
Request frame sent by the station when roaming, including the case where
the driver/firmware takes care of SME/MLME operations during roaming, so
we need to update the MBO IE to the driver.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoMBO: Always include Non-preferred Channel Report attribute in AssocReq
Ankita Bajaj [Fri, 5 Apr 2019 09:07:40 +0000 (14:37 +0530)] 
MBO: Always include Non-preferred Channel Report attribute in AssocReq

Include the Non-preferred Channel Report attribute in (Re)Association
Request frames even when the MBO STA has no non-preferred channels in
any operating classes. In case of no non-preferred channels the
attribute length field shall be set to zero and the Operating Class,
Channel List, Preference and Reason Code fields shall not be included.
This indicates to the MBO AP that the MBO STA has no non-preferred
channels access all supported operating classes.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoDPP: Move GAS encapsulation into dpp_build_conf_req()
Jouni Malinen [Wed, 3 Apr 2019 16:09:59 +0000 (19:09 +0300)] 
DPP: Move GAS encapsulation into dpp_build_conf_req()

Avoid duplicated code in each user of dpp_build_conf_req() by moving the
common encapsulation case into this helper function.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoSAE: Fix commit message override with external authentication
Jouni Malinen [Fri, 29 Mar 2019 21:04:35 +0000 (23:04 +0200)] 
SAE: Fix commit message override with external authentication

Do not add duplicate Transaction Sequence and Status Code fields when
using test functionality to override SAE commit message.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: sigma_dut controlled AP with PSK, SAE, FT
Jouni Malinen [Thu, 28 Mar 2019 20:09:45 +0000 (22:09 +0200)] 
tests: sigma_dut controlled AP with PSK, SAE, FT

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoPrefer FT-SAE over FT-PSK if both are enabled
Jouni Malinen [Thu, 28 Mar 2019 01:27:35 +0000 (03:27 +0200)] 
Prefer FT-SAE over FT-PSK if both are enabled

FT-SAE is considered stronger than FT-PSK, so prefer it over FT-PSK
similarly to how SAE is preferred over WPA-PSK.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoAdd more debug prints on suite selector selection
Jouni Malinen [Thu, 28 Mar 2019 00:58:00 +0000 (02:58 +0200)] 
Add more debug prints on suite selector selection

This makes it a bit easier to figure out why wpa_supplicant selects a
specific cipher/AKM for association.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: WPA2-EAP-FT with SHA384 using REASSOCIATE
Jouni Malinen [Wed, 27 Mar 2019 23:12:59 +0000 (01:12 +0200)] 
tests: WPA2-EAP-FT with SHA384 using REASSOCIATE

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoSuite B: Prefer FT-EAP-SHA384 over WPA-EAP-SUITE-B-192
Jouni Malinen [Wed, 27 Mar 2019 23:13:57 +0000 (01:13 +0200)] 
Suite B: Prefer FT-EAP-SHA384 over WPA-EAP-SUITE-B-192

If both of these AKMs are enabled in the wpa_supplicant network profile
and the target AP advertises support for both, prefer the FT version
over the non-FT version to allow FT to be used.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: WPA2-FT-SAE AP and PMKSA caching for initial MD association
Jouni Malinen [Wed, 27 Mar 2019 02:04:16 +0000 (04:04 +0200)] 
tests: WPA2-FT-SAE AP and PMKSA caching for initial MD association

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoSAE: Fix PMKSA cache entry search for FT-SAE case
Jouni Malinen [Wed, 27 Mar 2019 02:03:12 +0000 (04:03 +0200)] 
SAE: Fix PMKSA cache entry search for FT-SAE case

Previously, PMKSA cache entries were search for AKM=SAE and that did not
find an entry that was created with FT-SAE when trying to use FT-SAE
again. That resulted in having to use full SAE authentication instead of
the faster PMKSA caching alternative.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoAdd AKM info in the debug message noting PMKSA caching entry addition
Jouni Malinen [Wed, 27 Mar 2019 02:02:19 +0000 (04:02 +0200)] 
Add AKM info in the debug message noting PMKSA caching entry addition

This is useful for debugging issues where an expected PMKSA cache entry
is not found.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoFT-SAE: Use PMK as XXKey in AP when SAE PMKSA caching is used
vamsi krishna [Tue, 26 Mar 2019 14:49:02 +0000 (20:19 +0530)] 
FT-SAE: Use PMK as XXKey in AP when SAE PMKSA caching is used

When connected using FT-SAE key mgmt, use PMK from PMKSA cache as XXKey
for PMK-R0 and PMK-R1 derivations. This fixes an issue where FT key
hierarchy could not be established due to missing (not yet configured)
XXKey when using SAE PMKSA caching for the initial mobility domain
association.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoFT-SAE: Enable external auth support for FT-SAE also
vamsi krishna [Tue, 26 Mar 2019 14:29:59 +0000 (19:59 +0530)] 
FT-SAE: Enable external auth support for FT-SAE also

Extend the external authentication support to FT-SAE mode connections
also in addition to SAE mode connections.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agonl80211: Do not add WMM parameters when updating an existing STA entry
Jouni Malinen [Wed, 27 Mar 2019 01:14:02 +0000 (03:14 +0200)] 
nl80211: Do not add WMM parameters when updating an existing STA entry

In the case of the driver not supporting full AP mode STA state (i.e.,
not adding a STA entry before association), the QoS parameters are not
allowed to be modified when going through (re)association exchange for a
STA entry that has not been removed from the kernel. cfg80211 would
reject such command to update STA flags, so do not add the WMM parameter
in this case.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoFT/RRB: Pad RRB messages to at least minimum Ethernet frame length
Jouni Malinen [Tue, 26 Mar 2019 20:26:07 +0000 (22:26 +0200)] 
FT/RRB: Pad RRB messages to at least minimum Ethernet frame length

Ethernet frames have minimum length of 64 octets and shorter frames may
end up getting arbitrary padding in the end. This would result in the
FT/RRB receiver rejecting the frame as an incorrectly protected one.
Work around this by padding the message so that it is never shorter than
the minimum Ethernet frame.

Unfortunately, this padding is apparently not enough with all Ethernet
devices and it is still possible to see extra two octet padding at the
end of the message even if larger frames are used (e.g., showed up with
128 byte frames). For now, work around this by trying to do AES-SIV
decryption with two octets shorter frame (ignore last two octets) if the
first attempt fails.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agoFT/RRB: Add more debug prints for RRB message encryption/decryptiom
Jouni Malinen [Tue, 26 Mar 2019 17:12:20 +0000 (19:12 +0200)] 
FT/RRB: Add more debug prints for RRB message encryption/decryptiom

This is needed to make it easier to understand what could be going wrong
in RRB communication.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: sigma_dut controlled SAE association with Password Identifier/FT
Jouni Malinen [Tue, 26 Mar 2019 04:52:28 +0000 (06:52 +0200)] 
tests: sigma_dut controlled SAE association with Password Identifier/FT

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
5 years agotests: SAE + FT-SAE configuration
Jouni Malinen [Tue, 26 Mar 2019 04:35:33 +0000 (06:35 +0200)] 
tests: SAE + FT-SAE configuration

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>