mech_eap.git
8 years agoNFC: Add a hardcoded limit on maximum NDEF payload length
Jouni Malinen [Wed, 8 Jul 2015 14:00:28 +0000 (17:00 +0300)]
NFC: Add a hardcoded limit on maximum NDEF payload length

While this is already enforced in practice due to the limits on the
maximum control interface command length and total_length bounds
checking here, this explicit check on payload_length value may help
static analyzers understand the code better. (CID 122668)

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agowpa_supplicant: Fix a typo in wpa_scan_result_compar()
Hahn, Maital [Wed, 8 Jul 2015 13:13:11 +0000 (13:13 +0000)]
wpa_supplicant: Fix a typo in wpa_scan_result_compar()

A typo in wpa_scan_result_compar() caused wrong scan results sorting
(and wrong roaming decision). This fixes a copy-paste regression
introduced by commit a1b790eb9d7514d1a6e0582a07f695a1564caa59 ('Select
AP based on estimated maximum throughput').

Signed-off-by: Maital Hahn <maitalm@ti.com>
8 years agotests: Few trivial cleanups to P2PS tests
Andrei Otcheretianski [Thu, 2 Jul 2015 13:14:55 +0000 (16:14 +0300)]
tests: Few trivial cleanups to P2PS tests

Remove unused variables and replace split(" ") with just split().

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
8 years agotests: Wait for scan to complete on all interfaces in reset()
Andrei Otcheretianski [Thu, 2 Jul 2015 13:14:53 +0000 (16:14 +0300)]
tests: Wait for scan to complete on all interfaces in reset()

When WpaSupplicant executes reset() it waits until all the ongoing scans
are completed. However, it checks the status of the wlanX interface
only. If a dedicated P2P device interface is used, scan may be still
running on the P2P Device interface, e.g., due to P2P_FIND. This might
affect subsequent tests.

Fix this by waiting until the scan is done both on wlanX and P2P
Device interfaces.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
8 years agotests: Additional invalid NDEF records
Jouni Malinen [Tue, 7 Jul 2015 19:43:39 +0000 (22:43 +0300)]
tests: Additional invalid NDEF records

These are regression tests for NDEF message parsing issues with payload
length validation.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoNFC: Fix payload length validation in NDEF record parser
Jouni Malinen [Tue, 7 Jul 2015 18:57:28 +0000 (21:57 +0300)]
NFC: Fix payload length validation in NDEF record parser

It was possible for the 32-bit record->total_length value to end up
wrapping around due to integer overflow if the longer form of payload
length field is used and record->payload_length gets a value close to
2^32. This could result in ndef_parse_record() accepting a too large
payload length value and the record type filter reading up to about 20
bytes beyond the end of the buffer and potentially killing the process.
This could also result in an attempt to allocate close to 2^32 bytes of
heap memory and if that were to succeed, a buffer read overflow of the
same length which would most likely result in the process termination.
In case of record->total_length ending up getting the value 0, there
would be no buffer read overflow, but record parsing would result in an
infinite loop in ndef_parse_records().

Any of these error cases could potentially be used for denial of service
attacks over NFC by using a malformed NDEF record on an NFC Tag or
sending them during NFC connection handover if the application providing
the NDEF message to hostapd/wpa_supplicant did no validation of the
received records. While such validation is likely done in the NFC stack
that needs to parse the NFC messages before further processing,
hostapd/wpa_supplicant better be prepared for any data being included
here.

Fix this by validating record->payload_length value in a way that
detects integer overflow. (CID 122668)

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoP2PS: Save intended interface address after P2PS PD
Andrei Otcheretianski [Thu, 2 Jul 2015 07:45:08 +0000 (10:45 +0300)]
P2PS: Save intended interface address after P2PS PD

One possible outcome of the P2PS PD is P2P GO/P2P Client. In this case,
one peer becomes a P2P GO and the P2P Client joins it. Since multiple
GOs may run simultaneously on the same P2P Device, the P2P Client should
join using the intended interface address.

To be able to find the device by the intended interface address, save it
during the PD.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Max Stepanov <Max.Stepanov@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
8 years agoP2PS: Set intended interface address correctly for new group
Andrei Otcheretianski [Thu, 2 Jul 2015 07:45:07 +0000 (10:45 +0300)]
P2PS: Set intended interface address correctly for new group

If a device may be an explicit GO, it adds the GO details in the PD
Request. First, we try to reuse an active GO. If it is not present, we
try to reuse a non-active persistent group. In the latter case, if a
dedicated P2P interface is needed, the intended address should be that
of the pending interface. However, the wpas_get_go_info() provided the
ssid->bssid address, which is the address of the P2P device. This might
result in an incorrect intended interface attribute in the PD Request in
case a separate group interface is used.

Fix this by setting group_iface variable to true only if a dedicated
interface should be used and set the attribute accordingly.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Max Stepanov <Max.Stepanov@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
8 years agoP2PS: Add PD Response validation
Andrei Otcheretianski [Thu, 2 Jul 2015 07:45:06 +0000 (10:45 +0300)]
P2PS: Add PD Response validation

Validate the PD Response frame contents more thoroughly when it is used
for P2PS.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Max Stepanov <Max.Stepanov@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
8 years agoP2PS: Add intended iface address during PD for persistent group
Andrei Otcheretianski [Thu, 2 Jul 2015 07:45:05 +0000 (10:45 +0300)]
P2PS: Add intended iface address during PD for persistent group

When persistent group is used and the peer is GO in this group,
intended interface attribute should be added to PD request/response.
Not doing so violates the spec.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Max Stepanov <Max.Stepanov@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
8 years agoP2PS: Fix P2PS-PROV-DONE event on GO
Andrei Otcheretianski [Thu, 2 Jul 2015 07:45:04 +0000 (10:45 +0300)]
P2PS: Fix P2PS-PROV-DONE event on GO

If after P2PS PD the device should become a GO it sends P2PS-PROV-DONE
event which contains the GO interface name. If the GO isn't running yet
the device may use pending interface name. However, when the GO is
started, pending interface name will be removed.

Fix the GO interface name in P2PS-PROV-DONE event by copying the
interface name instead of saving the pointer.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
8 years agoP2PS: Use wpas_p2p_create_iface() to check if dedicated iface is needed
Andrei Otcheretianski [Thu, 2 Jul 2015 07:45:03 +0000 (10:45 +0300)]
P2PS: Use wpas_p2p_create_iface() to check if dedicated iface is needed

Call wpas_p2p_create_iface() instead of just checking p2p_no_group_iface
config value. Not doing so, resulted in an incorrect behavior when the
driver sets WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE flag.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
8 years agoP2PS: Save wps_prov_info on the responder side
Andrei Otcheretianski [Thu, 2 Jul 2015 07:45:02 +0000 (10:45 +0300)]
P2PS: Save wps_prov_info on the responder side

When device A sends PD response to device B, device A should save
wps_prov_info for device B. Not doing so would result in a redundant and
incorrect PD flow, e.g., when upon PROV-DISC-DONE event device B starts
a GO and device A should join it.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
8 years agoP2PS: Validate WPS config methods more accurately in PD Request
Andrei Otcheretianski [Thu, 2 Jul 2015 07:45:01 +0000 (10:45 +0300)]
P2PS: Validate WPS config methods more accurately in PD Request

In case of a P2PS PD, allow keypad, display, and P2PS WPS config
methods. For a legacy PD, allow keypad, display, and pushbutton methods.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
8 years agoP2P: Refactor p2p_process_prov_disc_resp() function
Max Stepanov [Thu, 2 Jul 2015 07:45:00 +0000 (10:45 +0300)]
P2P: Refactor p2p_process_prov_disc_resp() function

Add 'else if' to P2PS status verification to prevent a redundant
condition checking. The first 'if' condition is true only if
  status == P2P_SC_SUCCESS || status == P2P_SC_SUCCESS_DEFERRED.
while the second condition checks:
  status != P2P_SC_SUCCESS &&
  status != P2P_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE &&
  status != P2P_SC_SUCCESS_DEFERRED
Thus, the two conditions are mutually exclusive and 'else if' can be
used if this case.

Signed-off-by: Max Stepanov <Max.Stepanov@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
8 years agoP2P: Delete redundant comparison in p2p_process_prov_disc_resp()
Max Stepanov [Thu, 2 Jul 2015 07:45:00 +0000 (10:45 +0300)]
P2P: Delete redundant comparison in p2p_process_prov_disc_resp()

Delete redundant comparison of msg.wps_config_methods with
dev->req_config_methods in p2p_process_prov_disc_resp() since it's
already done early in this function. Also, the second comparison
doesn't make too much sense: it can happen after a possible
p2p_reset_pending_pd() call setting dev->req_config_methods to 0.

Signed-off-by: Max Stepanov <Max.Stepanov@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
8 years agoP2PS: Fix adv_id and adv_mac params of P2P-PROV-DISC-FAILURE
Max Stepanov [Thu, 2 Jul 2015 07:44:59 +0000 (10:44 +0300)]
P2PS: Fix adv_id and adv_mac params of P2P-PROV-DISC-FAILURE

When wpa_supplicant receives a PD Response with reject status it
generated P2P-PROV-DISC-FAILURE event without adv_id and adv_mac
parameters. Fix this by adding these parameters to the
wpas_prov_disc_fail() function call.

Signed-off-by: Max Stepanov <Max.Stepanov@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
8 years agohostap: Fix send_mlme() after 'freq' parameter addition
Dan Williams [Tue, 7 Jul 2015 15:49:54 +0000 (10:49 -0500)]
hostap: Fix send_mlme() after 'freq' parameter addition

This fixes the incomplete driver_hostap.c change from commit
5d180a77392690b141d95609d8c8692317712b4f ('drivers: Add freq parameter
to send_mlme() function') that did not take into account the internal
callers.

Signed-off-by: Dan Williams <dcbw@redhat.com>
8 years agotests: IEEE 802.1X and HELD state
Jouni Malinen [Tue, 7 Jul 2015 16:23:47 +0000 (19:23 +0300)]
tests: IEEE 802.1X and HELD state

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoSend EAPOL-Start on HELD->CONNECTING transition
Jouni Malinen [Tue, 7 Jul 2015 16:22:11 +0000 (19:22 +0300)]
Send EAPOL-Start on HELD->CONNECTING transition

Previously, only CONNECTING->CONNECTING case ended up sending out an
EAPOL-Start frame to avoid sending the unnecessary initial EAPOL-Start.
However, this optimization prevented new EAPOL-Start from being
initiated when leaving the HELD state. Allow that case to trigger
immediate EAPOL-Start transmission to speed up connection.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agopkcs11: Don't ask for a new PIN on TLS handshake failure
Mike Gerow [Mon, 6 Jul 2015 21:26:57 +0000 (14:26 -0700)]
pkcs11: Don't ask for a new PIN on TLS handshake failure

The only time the PIN should fail is when we initialize the TLS
connection, so it doesn't really make sense to get rid of the PIN just
because some other part of the handshake failed.

This is a followup to commit fd4fb28179a0b750dff4d38a72a7bf89a2c49813
('OpenSSL: Try to ensure we don't throw away the PIN unnecessarily').

Signed-off-by: Mike Gerow <gerow@google.com>
8 years agotests: Add Undefined Behavior Sanitizer (ubsan) configuration
Jouni Malinen [Tue, 7 Jul 2015 14:00:12 +0000 (17:00 +0300)]
tests: Add Undefined Behavior Sanitizer (ubsan) configuration

This allows hostapd and wpa_supplicant to be built for hwsim test cases
with ubsan functinality from the recent gcc/clang compiler versions.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoDATA_TEST_TX: Avoid ubsan warning on 0x80<<24 not fitting in int
Jouni Malinen [Tue, 7 Jul 2015 13:21:36 +0000 (16:21 +0300)]
DATA_TEST_TX: Avoid ubsan warning on 0x80<<24 not fitting in int

Use unsigned constant instead of signed to avoid warning with the LSB
being set in an int.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoAvoid misaligned IPv4 header accesses in DATA_TEST_* commands
Jouni Malinen [Tue, 7 Jul 2015 13:01:46 +0000 (16:01 +0300)]
Avoid misaligned IPv4 header accesses in DATA_TEST_* commands

The IPv4 header after the Ethernet header is not 32-bit aligned and the
previous version ended up accessing 32-bit members at misaligned
addresses.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoAvoid ubsan warning on 0x80<<24 not fitting in int in WPA_GET_BE32/LE32
Jouni Malinen [Tue, 7 Jul 2015 12:54:31 +0000 (15:54 +0300)]
Avoid ubsan warning on 0x80<<24 not fitting in int in WPA_GET_BE32/LE32

Use a typecast to make this shift unsigned so that the MSB fits within
the range of allowed values.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agondisc_snoop: Avoid misaligned read of IPv6 address
Jouni Malinen [Tue, 7 Jul 2015 12:51:05 +0000 (15:51 +0300)]
ndisc_snoop: Avoid misaligned read of IPv6 address

The IPv6 address in the frame buffer may not be 32-bit aligned, so use a
local copy to align this before reading the address with 32-bit reads
(s6_addr32[]).

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP-TTLS: Avoid ubsan warning on 0x80<<24 not fitting in int
Jouni Malinen [Tue, 7 Jul 2015 12:41:51 +0000 (15:41 +0300)]
EAP-TTLS: Avoid ubsan warning on 0x80<<24 not fitting in int

Use a typecast to make this unsigned so that the MSB fits within the
range of allowed values.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoradiotap: Avoid ubsan warning on 1<<31
Jouni Malinen [Tue, 7 Jul 2015 12:39:08 +0000 (15:39 +0300)]
radiotap: Avoid ubsan warning on 1<<31

Use the BIT() macro and unsigned int to avoid ubsan warning on 1<<31 not
fitting in an int.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoNFC: Avoid misaligned read of an NDEF field
Jouni Malinen [Tue, 7 Jul 2015 12:33:55 +0000 (15:33 +0300)]
NFC: Avoid misaligned read of an NDEF field

The 32-bit version of payload length field may not be 32-bit aligned in
the message buffer, so use WPA_GET_BE32() to read it instead of ntohl().

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotrace: Use explicit alignment requirements to avoid misalignment
Jouni Malinen [Tue, 7 Jul 2015 10:04:08 +0000 (13:04 +0300)]
trace: Use explicit alignment requirements to avoid misalignment

64-bit builds with CONFIG_WPA_TRACE=y resulted in the wpabuf pointers
getting misaligned (only 32-bit aligned) and that would result in reads
and writes of unaligned size_t values. Avoid this by indicating explicit
alignment requirement for wpabuf_trace to 8 octets (i.e., there will be
extra four octets of padding in case of 64-bit builds).

Similarly, struct os_alloc_trace resulted in some potential misalignment
cases, e.g., when CONFIG_ACS=y uses a 'long double' variable within
struct hostapd_channel_data. Avoid misalignment issues with explicit
alignment indication.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agodrivers: Use unsigned arguments for sta_set_flags()
Jouni Malinen [Tue, 7 Jul 2015 09:33:38 +0000 (12:33 +0300)]
drivers: Use unsigned arguments for sta_set_flags()

Since BIT() is now returning unsigned int, these functions need to match
that to avoid compiler warnings.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoMake BIT() unsigned int instead of int
Jouni Malinen [Tue, 7 Jul 2015 09:33:03 +0000 (12:33 +0300)]
Make BIT() unsigned int instead of int

This is needed to avoid ubsan warnings on BIT(31).

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoInclude stddef.h to use the standard offsetof()
Jouni Malinen [Tue, 7 Jul 2015 09:24:57 +0000 (12:24 +0300)]
Include stddef.h to use the standard offsetof()

src/utils/list.h ended up defining a local version of offsetof() due to
stddef.h not getting included. This resulted in unnecessary warnings
from ubsan related to "dereferencing" of a NULL pointer.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoRADIUS DAS: Avoid compiler warning on abs()
Jouni Malinen [Tue, 7 Jul 2015 09:14:47 +0000 (12:14 +0300)]
RADIUS DAS: Avoid compiler warning on abs()

The input parameter ended up being converted to long int instead of int,
so use an explicit typecase to get rid of the compiler warning.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoERP: Avoid mixing of enum types
Jouni Malinen [Tue, 7 Jul 2015 09:09:09 +0000 (12:09 +0300)]
ERP: Avoid mixing of enum types

Use explicit typecasting to avoid implicit conversion warnings in cases
where enum eap_erp_type is used in functions taking an EapType argument.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoD-Bus: Fix dont_quote const declaration
Jouni Malinen [Tue, 7 Jul 2015 09:07:06 +0000 (12:07 +0300)]
D-Bus: Fix dont_quote const declaration

Commit 38279bdb35c1b0c248289752197ebddd2fdd52ef ('D-Bus: Coding style
cleanup') handled the dbus_new_handlers.c change properly, but misplaced
the second 'const' in dbus_old_handlers.c in a way that resulted in
duplicated const rather than marking the actual value const.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: WPA2-PSK-FT AP over DS protocol testing
Jouni Malinen [Wed, 1 Jul 2015 21:33:20 +0000 (00:33 +0300)]
tests: WPA2-PSK-FT AP over DS protocol testing

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: WPA2-PSK-FT and OOM
Jouni Malinen [Wed, 1 Jul 2015 21:08:28 +0000 (00:08 +0300)]
tests: WPA2-PSK-FT and OOM

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: WPA2-PSK-FT AP with GCMP-256 cipher
Jouni Malinen [Wed, 1 Jul 2015 20:53:03 +0000 (23:53 +0300)]
tests: WPA2-PSK-FT AP with GCMP-256 cipher

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoFT: Allow CCMP-256 and GCMP-256 as group ciphers
Jouni Malinen [Wed, 1 Jul 2015 20:51:31 +0000 (23:51 +0300)]
FT: Allow CCMP-256 and GCMP-256 as group ciphers

The FT-specific check for valid group cipher in wpa_ft_gen_req_ies() was
not up-to-date with the current list of supported ciphers. Fix this by
using a generic function to determine validity of the cipher. In
practice, this adds support for using CCMP-256 and GCMP-256 as the group
cipher with FT.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: IEEE 802.1X connection and EAPOL-Key protocol tests
Jouni Malinen [Wed, 1 Jul 2015 18:04:06 +0000 (21:04 +0300)]
tests: IEEE 802.1X connection and EAPOL-Key protocol tests

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: IEEE 802.1X and EAPOL-Start retransmissions
Jouni Malinen [Wed, 1 Jul 2015 15:37:29 +0000 (18:37 +0300)]
tests: IEEE 802.1X and EAPOL-Start retransmissions

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP server and OOM
Jouni Malinen [Tue, 30 Jun 2015 21:42:09 +0000 (00:42 +0300)]
tests: EAP server and OOM

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: WPA2-Enterprise connection using MAC ACL
Jouni Malinen [Tue, 30 Jun 2015 21:34:27 +0000 (00:34 +0300)]
tests: WPA2-Enterprise connection using MAC ACL

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-TLS and unknown OCSP signer
Jouni Malinen [Tue, 30 Jun 2015 19:05:37 +0000 (22:05 +0300)]
tests: EAP-TLS and unknown OCSP signer

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Invalid OCSP data (parsing failure)
Jouni Malinen [Tue, 30 Jun 2015 19:01:05 +0000 (22:01 +0300)]
tests: Invalid OCSP data (parsing failure)

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Invalid openssl_ciphers value
Jouni Malinen [Tue, 30 Jun 2015 18:55:59 +0000 (21:55 +0300)]
tests: Invalid openssl_ciphers value

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoOpenSSL: Merge error returns
Jouni Malinen [Tue, 30 Jun 2015 18:48:22 +0000 (21:48 +0300)]
OpenSSL: Merge error returns

These similar error cases can use a single return statement.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Remove unused tls_capabilities()
Jouni Malinen [Tue, 30 Jun 2015 18:40:48 +0000 (21:40 +0300)]
TLS: Remove unused tls_capabilities()

This mechanism to figure out TLS library capabilities has not been used
since commit fd2f2d0489635d590930bc0945fbc438ba1387e2 ('Remove
EAP-TTLSv1 and TLS/IA') (Sep 2011).

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-FAST/MSCHAPv2 and server OOM
Jouni Malinen [Tue, 30 Jun 2015 18:36:12 +0000 (21:36 +0300)]
tests: EAP-FAST/MSCHAPv2 and server OOM

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: DH parameter file DSA conversion and error cases
Jouni Malinen [Mon, 29 Jun 2015 19:45:03 +0000 (22:45 +0300)]
tests: DH parameter file DSA conversion and error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-TLS with PKCS12 that includes additional certificates
Jouni Malinen [Mon, 29 Jun 2015 19:25:43 +0000 (22:25 +0300)]
tests: EAP-TLS with PKCS12 that includes additional certificates

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-TLS and OOM
Jouni Malinen [Mon, 29 Jun 2015 19:17:07 +0000 (22:17 +0300)]
tests: EAP-TLS and OOM

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-TLS and server checking CRL
Jouni Malinen [Mon, 29 Jun 2015 19:09:27 +0000 (22:09 +0300)]
tests: EAP-TLS and server checking CRL

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoms_funcs: Merge similar return cases
Jouni Malinen [Mon, 29 Jun 2015 17:55:20 +0000 (20:55 +0300)]
ms_funcs: Merge similar return cases

There is no need to have separate return statements for these corner
cases that are unlikely to be hit in practice.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agohw_features: Merge similar return case in check_40mhz_2g4()
Jouni Malinen [Mon, 29 Jun 2015 17:44:12 +0000 (20:44 +0300)]
hw_features: Merge similar return case in check_40mhz_2g4()

There is no need to have separate return statements for these corner
cases that are unlikely to be hit in practice.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-SIM and OOM
Jouni Malinen [Sun, 28 Jun 2015 21:50:21 +0000 (00:50 +0300)]
tests: EAP-SIM and OOM

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: WPA2-Enterprise connection using EAP-IKEv2 and OOM
Jouni Malinen [Sun, 28 Jun 2015 21:41:14 +0000 (00:41 +0300)]
tests: WPA2-Enterprise connection using EAP-IKEv2 and OOM

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: WPA2-Enterprise connection using EAP-PSK and OOM
Jouni Malinen [Sun, 28 Jun 2015 19:09:12 +0000 (22:09 +0300)]
tests: WPA2-Enterprise connection using EAP-PSK and OOM

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: SAE and no random numbers available
Jouni Malinen [Sun, 28 Jun 2015 18:56:40 +0000 (21:56 +0300)]
tests: SAE and no random numbers available

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: WPA2-PSK AP and no random numbers available
Jouni Malinen [Sun, 28 Jun 2015 18:41:56 +0000 (21:41 +0300)]
tests: WPA2-PSK AP and no random numbers available

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoReject the initial 4-way handshake if initial GTK setup fails
Jouni Malinen [Sun, 28 Jun 2015 18:40:37 +0000 (21:40 +0300)]
Reject the initial 4-way handshake if initial GTK setup fails

This makes the AP/Authenticator design more robust against unexpected
failures in random number generation.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoAdd backtrace-based error path testing mechanism
Jouni Malinen [Sun, 28 Jun 2015 18:35:43 +0000 (21:35 +0300)]
Add backtrace-based error path testing mechanism

The new TEST_FAIL and GET_FAIL control interface commands can be used
similarly to the earlier TEST_ALLOC_FAIL/GET_ALLOC_FAIL design. The new
version is more generic framework allowing any function to be annotated
for failure testing with the TEST_FAIL() macro. This mechanism is only
available in builds with CONFIG_WPA_TRACE_BFD=y and
CONFIG_TESTING_OPTIONS=y. For other builds, the TEST_FAIL() macro is
defined to return 0 to allow the compiler to remove the test code from
normal production builds.

As the first test site, allow os_get_random() to be marked for failing
based on call backtrace.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Concurrent P2P autonomous GO on 5 GHz and HT40 co-ex
Jouni Malinen [Sun, 28 Jun 2015 15:16:52 +0000 (18:16 +0300)]
tests: Concurrent P2P autonomous GO on 5 GHz and HT40 co-ex

This verifies that 20/40 MHz co-ex scan does not force MCC with PRI/SEC
channel switch.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoP2P: Do not allow 40 MHz co-ex PRI/SEC switch to force MCC
Jouni Malinen [Sun, 28 Jun 2015 15:14:58 +0000 (18:14 +0300)]
P2P: Do not allow 40 MHz co-ex PRI/SEC switch to force MCC

Do not allow 40 MHz co-ex PRI/SEC switch to force us to change our PRI
channel if we have an existing connection on the selected PRI channel
since doing multi-channel concurrency is likely to cause more harm than
using different PRI/SEC selection in environment with multiple BSSes on
these two channels with mixed 20 MHz or PRI channel selection.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoP2PS: Fix attribute addition in p2p_buf_add_service_instance()
Stepanov, Max [Tue, 23 Jun 2015 13:47:59 +0000 (13:47 +0000)]
P2PS: Fix attribute addition in p2p_buf_add_service_instance()

Fix a condition when Advertised Service Info Attribute is added to
a probe response in p2p_buf_add_service_instance(). The issue is
that a 'found' value is increased even if 'test' and 'adv->hash' hashes
are different. As result 'found' may have a non-zero value when an
attribute data length is 0. In this cause an empty attribute is about to
be added. Fixing it by eliminating 'found' and checking 'total_len'
containing a real number of bytes added to Advertised Service Info
Attribute.

This fixes an issue from commit 50a9efe713df135e98f2229f67faa1a3d7243693
('P2PS: Fix Probe Response frame building in error cases').

Signed-off-by: Max Stepanov <Max.Stepanov@intel.com>
8 years agoP2PS: Fix p2p_find last parameter handling
Stepanov, Max [Tue, 23 Jun 2015 13:52:22 +0000 (13:52 +0000)]
P2PS: Fix p2p_find last parameter handling

In p2p_find command line processing a loop searching for multiple
'seek=' parameters modifies cmd buffer adding '\0' terminators.
The 'freq=' parameter is handled after that and can be
lost if a 'freq=' follows 'seek=' in a command line.
Fix it by moving a handling of 'freq=' parameter to be processed
before 'seek=' handling loop.

Signed-off-by: Max Stepanov <Max.Stepanov@intel.com>
8 years agoAP: Increase maximum value accepted for cwmin/cwmax
Jouni Malinen [Sat, 27 Jun 2015 20:34:49 +0000 (23:34 +0300)]
AP: Increase maximum value accepted for cwmin/cwmax

The cwmin/cwmax parameters were limited more than is needed. Allow the
full range (0..15 for wmm_ac_??_{cwmin,cwmax} and 1..32767 for
tx_queue_data?_{cwmin,cwmax}) to be used.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Use 16 instead of 13 as the cwmin/cwmax invalid case
Jouni Malinen [Sat, 27 Jun 2015 20:24:15 +0000 (23:24 +0300)]
tests: Use 16 instead of 13 as the cwmin/cwmax invalid case

This is needed to allow the parser to accept 15 which is actually a
valid value.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoSAE: Reject FFC commit-element with value p-1
Jouni Malinen [Sat, 27 Jun 2015 18:20:14 +0000 (21:20 +0300)]
SAE: Reject FFC commit-element with value p-1

The current P802.11 description of SAE uses "1 < element < p" as the
required range. However, this is not correct and does not match the
Dragonfly description of "1 < element < p-1". SAE definition will need
to change here. Update the implementation to reject p-1 based on the
correct rule here.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Check GAS and ANQP completion events in gas_fragment
Jouni Malinen [Sat, 27 Jun 2015 14:13:24 +0000 (17:13 +0300)]
tests: Check GAS and ANQP completion events in gas_fragment

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoP2PS: Do not reply to ProbeReq on another channel when starting Listen
Jouni Malinen [Sat, 27 Jun 2015 14:10:19 +0000 (17:10 +0300)]
P2PS: Do not reply to ProbeReq on another channel when starting Listen

It was possible for the P2PS Probe Response frame to go out on the
channel on which a Probe Request frame was reported even when we are
just about to start Listen mode on another channel. This could result in
the peer device using incorrect channel for us. Fix this by skipping the
response in this special case while waiting for Listen mode to start.

This showed up as a hwsim test failure with test sequence "gas_fragment
p2ps_connect_display_method_nonautoaccept" in cases where the dev[0]
Listen channel was not same as the AP operating frequency in the GAS
test.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: SAE and invalid commit-scalar value 1
Jouni Malinen [Sat, 27 Jun 2015 09:51:15 +0000 (12:51 +0300)]
tests: SAE and invalid commit-scalar value 1

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoSAE: Reject commit-scalar value 1
Jouni Malinen [Sat, 27 Jun 2015 09:41:40 +0000 (12:41 +0300)]
SAE: Reject commit-scalar value 1

IEEE Std 802.11-2012 description of SAE does not require this, i.e., it
describes the requirement as 0 < scalar < r for processing the Commit
message. However, this is not correct and will be changes to 1 < scalar
< r to match the Dragonfly description so that a trivial secret case
will be avoided explicitly.

This is not much of an issue for the locally generated commit-scalar
since it would be very unlikely to get the value of 1. For Commit
message processing, a peer with knowledge of the password could
potentially force the exchange to expose key material without this
check.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Use the new CTRL-EVENT-NETWORK-NOT-FOUND in ap_open_select_any
Jouni Malinen [Sat, 27 Jun 2015 08:09:22 +0000 (11:09 +0300)]
tests: Use the new CTRL-EVENT-NETWORK-NOT-FOUND in ap_open_select_any

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoSend CTRL-EVENT-NETWORK-NOT-FOUND if no suitable network was found
Dmitry Shmidt [Fri, 19 Jun 2015 17:33:50 +0000 (10:33 -0700)]
Send CTRL-EVENT-NETWORK-NOT-FOUND if no suitable network was found

This provides more information to upper layer programs on what happens
with connection attempts in cases where the enabled networks are not
found in scan results.

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
8 years agoD-Bus: Fix typos in debug print
Purushottam Kushwaha [Wed, 24 Jun 2015 05:45:22 +0000 (05:45 +0000)]
D-Bus: Fix typos in debug print

Signed-off-by: Purushottam Kushwaha <p.kushwaha@samsung.com>
8 years agoAndroid: Fix nl80211 build if BOARD_*_PRIVATE_LIB is unspecified
Kevin Cernekee [Sat, 20 Jun 2015 00:22:30 +0000 (17:22 -0700)]
Android: Fix nl80211 build if BOARD_*_PRIVATE_LIB is unspecified

wpa_supplicant has stub functions if the external p2p symbols are
unavailable, but the build still fails if the
wpa_driver_nl80211_driver_cmd symbol is missing.  Fix this by leaving the
function pointer NULL.  This is safe because wpa_drv_driver_cmd() performs
a NULL check.

Signed-off-by: Kevin Cernekee <cernekee@google.com>
8 years agoAndroid: Rename ANDROID_P2P_STUB to ANDROID_LIB_STUB
Kevin Cernekee [Sat, 20 Jun 2015 00:22:29 +0000 (17:22 -0700)]
Android: Rename ANDROID_P2P_STUB to ANDROID_LIB_STUB

If BOARD_HOSTAPD_PRIVATE_LIB is not used on an Android build, we will
need to replace both the p2p functions *and* wpa_driver_nl80211_driver_cmd
in order to successfully link.  Let's make the name more generic so it is
more obvious what it is used for.

Suggested-by: Dmitry Shmidt <dimitrysh@google.com>
Signed-off-by: Kevin Cernekee <cernekee@google.com>
8 years agoD-Bus: Add documentation for wpas_dbus_signal_peer_groups_changed()
Maneesh Jain [Mon, 22 Jun 2015 04:25:02 +0000 (09:55 +0530)]
D-Bus: Add documentation for wpas_dbus_signal_peer_groups_changed()

This is needed to add this function into Doxygen documentation.

Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
8 years agoD-Bus: Fix typo in dbus signal function documentation
Maneesh Jain [Mon, 22 Jun 2015 04:13:50 +0000 (09:43 +0530)]
D-Bus: Fix typo in dbus signal function documentation

Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
8 years agoD-Bus: Add function documentation for wpas_dbus_unregister_interface()
Maneesh Jain [Mon, 22 Jun 2015 04:08:39 +0000 (09:38 +0530)]
D-Bus: Add function documentation for wpas_dbus_unregister_interface()

This is needed to add this function into Doxygen documentation.

Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
8 years agoD-Bus: Add function documentation for wpas_dbus_register_interface()
Maneesh Jain [Mon, 22 Jun 2015 04:05:08 +0000 (09:35 +0530)]
D-Bus: Add function documentation for wpas_dbus_register_interface()

This is needed to add this function into Doxygen documentation.

Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
8 years agoD-Bus: Fix wpas_dbus_signal_p2p_invitation_result() documentation
Maneesh Jain [Mon, 22 Jun 2015 03:48:34 +0000 (09:18 +0530)]
D-Bus: Fix wpas_dbus_signal_p2p_invitation_result() documentation

Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
8 years agoradius: Fix NULL dereference issue on allocation failure
Maneesh Jain [Mon, 22 Jun 2015 03:32:15 +0000 (09:02 +0530)]
radius: Fix NULL dereference issue on allocation failure

In case memory allocation fails, data->pac_opaque_encr_key may be NULL
and lead to possible crash.

Signed-off-by: Maneesh Jain <maneesh.jain@samsung.com>
8 years agoOpenSSL: Handle EC_POINT_is_on_curve() error case
Jouni Malinen [Fri, 26 Jun 2015 12:29:29 +0000 (15:29 +0300)]
OpenSSL: Handle EC_POINT_is_on_curve() error case

Even though this OpenSSL function is documented as returning "1 if point
if on the curve and 0 otherwise", it can apparently return -1 on some
error cases. Be prepared for that and check explicitly against 1 instead
of non-zero.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoSAE: Use random "password" in extra hunting-and-pecking loops
Jouni Malinen [Fri, 26 Jun 2015 08:44:22 +0000 (11:44 +0300)]
SAE: Use random "password" in extra hunting-and-pecking loops

If PWE is discovered before the minimum number of loops (k) is reached,
the extra iterations use a random "password" to further obfuscate the
cost of discovering PWE.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoSAE: Add side-channel protection to PWE derivation with ECC
Jouni Malinen [Thu, 25 Jun 2015 08:35:39 +0000 (11:35 +0300)]
SAE: Add side-channel protection to PWE derivation with ECC

This replaces the earlier IEEE Std 802.11-2012 algorithm with the design
from P802.11-REVmc/D4.0. Things brings in a blinding technique for
determining whether the pwd-seed results in a suitable PWE value.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agocrypto: Add functions for computing the Legendre symbol and EC y^2
Jouni Malinen [Thu, 25 Jun 2015 08:33:34 +0000 (11:33 +0300)]
crypto: Add functions for computing the Legendre symbol and EC y^2

These are needed to implement side-channel protection for SAE PWE
derivation for ECC.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: sae_groups to include Brainpool EC groups
Jouni Malinen [Thu, 25 Jun 2015 19:19:00 +0000 (22:19 +0300)]
tests: sae_groups to include Brainpool EC groups

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoOpenSSL: Add support for Brainpool Elliptic Curves
Jouni Malinen [Thu, 25 Jun 2015 19:17:28 +0000 (22:17 +0300)]
OpenSSL: Add support for Brainpool Elliptic Curves

This allows the IKE groups 27-30 (RFC 6932) to be used with OpenSSL
1.0.2 and newer. For now, these get enabled for SAE as configurable
groups (sae_groups parameter), but the new groups are not enabled by
default.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoSAE: Increase security parameter k to 40 based on Dragonfly recommendation
Jouni Malinen [Wed, 24 Jun 2015 17:47:08 +0000 (20:47 +0300)]
SAE: Increase security parameter k to 40 based on Dragonfly recommendation

draft-irtf-cfrg-dragonfly recommends implementation to set the security
parameter, k, to a value of at least 40. This will make PWE generation
take significantly more resources, but makes it more likely to hide
timing differences due to different number of loops needed to find a
suitable PWE.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoSAE: Fix PWE generation to use minimum loop count (k) properly
Jouni Malinen [Wed, 24 Jun 2015 17:42:48 +0000 (20:42 +0300)]
SAE: Fix PWE generation to use minimum loop count (k) properly

The implementation did not match the comment, i.e., only k-1 rounds were
required instead of k.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Try heavier SAE groups in sae_groups
Jouni Malinen [Thu, 25 Jun 2015 08:56:51 +0000 (11:56 +0300)]
tests: Try heavier SAE groups in sae_groups

This changes the sae_groups test case design to try with every group and
skip triggering test failure for the heavier ones that are likely to
fail in some VM setups under load. This provides more testing coverage
by not limiting the test based on lowest common setup.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: SAE with number of different passwords
Jouni Malinen [Wed, 24 Jun 2015 17:39:07 +0000 (20:39 +0300)]
tests: SAE with number of different passwords

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: SAE anti clogging protocol testing
Jouni Malinen [Tue, 23 Jun 2015 20:05:27 +0000 (23:05 +0300)]
tests: SAE anti clogging protocol testing

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoSAE: Merge sae_derive_commit() error case return statements
Jouni Malinen [Tue, 23 Jun 2015 19:38:38 +0000 (22:38 +0300)]
SAE: Merge sae_derive_commit() error case return statements

These error cases have the exact same outcome, so a single return
statement can be used.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoSAE: Merge sae_get_rand() error case return statements
Jouni Malinen [Tue, 23 Jun 2015 19:35:09 +0000 (22:35 +0300)]
SAE: Merge sae_get_rand() error case return statements

These error cases have the exact same outcome, so a single return
statement can be used.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: SAE reflection attack
Jouni Malinen [Tue, 23 Jun 2015 19:31:39 +0000 (22:31 +0300)]
tests: SAE reflection attack

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoSAE: Verify that own/peer commit-scalar and COMMIT-ELEMENT are different
Jouni Malinen [Tue, 23 Jun 2015 19:30:15 +0000 (22:30 +0300)]
SAE: Verify that own/peer commit-scalar and COMMIT-ELEMENT are different

This check explicitly for reflection attack and stops authentication
immediately if that is detected instead of continuing to the following
4-way handshake that would fail due to the attacker not knowing the key
from the SAE exchange.

Signed-off-by: Jouni Malinen <j@w1.fi>