mech_eap.git
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>
8 years agotests: PKCS #8 private key with PKCS #5 v1.5 and v2.0 format
Jouni Malinen [Sat, 5 Dec 2015 18:24:53 +0000 (20:24 +0200)]
tests: PKCS #8 private key with PKCS #5 v1.5 and v2.0 format

This verifies client private key use in encrypted PKCS #8 format with
PKCS #5 v1.5 format using pbeWithMD5AndDES-CBC and PKCS #5 v2.0 format
using PBES2 with des-ede3-cbc.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Add support for PKCS #5 v2.0 PBES2
Jouni Malinen [Sat, 5 Dec 2015 18:23:12 +0000 (20:23 +0200)]
TLS: Add support for PKCS #5 v2.0 PBES2

This extends the internal TLS support for PKCS #5 v2.0 PBES2 private key
format with des-ede3-cbc encryption and PBKDF2 SHA-1.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: P2P persistent group formation, re-invocation, and cancel
Jouni Malinen [Fri, 4 Dec 2015 21:15:11 +0000 (23:15 +0200)]
tests: P2P persistent group formation, re-invocation, and cancel

Verify that P2P_CANCEL gets rejected on fully re-invoked persistent
group. This did not work properly before the last couple of commits and
before this week, the P2P_CANCEL on a separate group interface in P2p
Client role could result in use of freed memory and process termination.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoP2P: Fix re-invoked client interface completion on data connection
Jouni Malinen [Fri, 4 Dec 2015 21:11:10 +0000 (23:11 +0200)]
P2P: Fix re-invoked client interface completion on data connection

This was already working for the case where a separate group interface
is used due to the recent commit
328f49acfe961a212e89e750516d2e2cc320765f ('P2P: Complete group formation
on client data connection'). However, the case of no separate group
interface was used did not clear the interface state properly on data
connection. Fix this by setting the group formation information in
wpas_start_p2p_client().

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoP2P: Fix P2P_CANCEL for p2p_in_invitation case
Jouni Malinen [Fri, 4 Dec 2015 20:49:59 +0000 (22:49 +0200)]
P2P: Fix P2P_CANCEL for p2p_in_invitation case

Commit f05cee9714ae87d315d893699a536b60a5aa73a9 ('P2P: Clear
p2p_in_invitation on cancel') added a wpas_p2p_cancel() case to call
wpas_p2p_group_formation_failed() if wpa_s->p2p_in_invitation is set.
This is done in a loop going through wpa_s->next pointers. However, the
call here can result in removing the interface and freeing wpa_s. The
following attempt to read wpa_s->next is from freed memory and that can
result in process termination when using a separate P2P group interface
and issuing P2P_CANCEL on a group that was started through re-invocation
of a persistent group.

The recent commit 328f49acfe961a212e89e750516d2e2cc320765f ('P2P:
Complete group formation on client data connection') "fixed" this by
accident since wpa_s->p2p_in_invitation gets cleared in the sequence
that could hit this issue and this results in P2P_CANCEL getting
rejected. However, the real bug here is in the loop that continues after
possible wpa_s instance deletion. Fix that by breaking out of the loop.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: Make tests using multi_check() more robust
Jouni Malinen [Fri, 4 Dec 2015 19:03:43 +0000 (21:03 +0200)]
tests: Make tests using multi_check() more robust

It was possible for a cached scan entry in cfg80211 from an earlier test
case to show up while verifying that the disabled AP does not show up in
scan results. This could result in invalid test failures, e.g., when
running test cases "ap_require_ht ap_multi_bss_config" multiple times
(depends a bit on timing). Make this less likely to occur by explicitly
clearing the scan cache and by stopping wlan1 from trying to associate
before stopping ap_required_ht* test cases.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoEST: Comment out X509_REQ_print calls on Android with BoringSSL
Jouni Malinen [Fri, 4 Dec 2015 16:26:06 +0000 (18:26 +0200)]
EST: Comment out X509_REQ_print calls on Android with BoringSSL

These were restored into BoringSSL in June 2015, but not all Android
branches include those changes. To fix the build, comment these call out
on Android for now if hs20-osu-client is built against BoringSSL. These
are used only for debugging purposes, so this is fine for Hotspot 2.0
functionality.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoEST: Add CSR generation support with BoringSSL
Jouni Malinen [Fri, 4 Dec 2015 14:25:21 +0000 (16:25 +0200)]
EST: Add CSR generation support with BoringSSL

This completes EST support with hs20-osu-client when built with
BoringSSL instead of OpenSSL.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoEST: Implement pkcs7_to_cert() with BoringSSL
Jouni Malinen [Fri, 4 Dec 2015 13:38:50 +0000 (15:38 +0200)]
EST: Implement pkcs7_to_cert() with BoringSSL

This adds one more step in completing hs20-osu-client support when using
BoringSSL instead of OpenSSL. EST client can now parse the cacerts file.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoHTTP (curl): OCSP with BoringSSL
Jouni Malinen [Fri, 4 Dec 2015 12:06:53 +0000 (14:06 +0200)]
HTTP (curl): OCSP with BoringSSL

This adds experimental support for using OCSP with libcurl that is built
against BoringSSL. This needs small modifications to libcurl to allow
CURLOPT_SSL_VERIFYSTATUS to be used to call
SSL_enable_ocsp_stapling(connssl->handle) in ossl_connect_step1().

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoBoringSSL: Move OCSP implementation into a separate file
Jouni Malinen [Fri, 4 Dec 2015 12:04:31 +0000 (14:04 +0200)]
BoringSSL: Move OCSP implementation into a separate file

This makes it easier to share the OCSP implementation needed for
BoringSSL outside tls_openssl.c. For now, this is mainly for
http_curl.c.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoBoringSSL: Support new SHA_CTX definition for EAP-SIM PRF
Jouni Malinen [Fri, 4 Dec 2015 09:26:29 +0000 (11:26 +0200)]
BoringSSL: Support new SHA_CTX definition for EAP-SIM PRF

BoringSSL modified the struct sha_state_st (SHA_CTX) definition by
converting h0..h4 with h[5] array. This broke wpa_supplicant/hostapd
build with EAP-SIM enabled. BoringSSL restored the old version for
ANDROID builds, but only the new version is currently defined for
non-Android cases. For now, fix this by having matching selection in
fips_prf_openssl.c based on OPENSSL_IS_BORINGSSL and ANDROID defines.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoOpenSSL: Fix build with current OpenSSL master branch snapshot
Jouni Malinen [Thu, 3 Dec 2015 21:53:35 +0000 (23:53 +0200)]
OpenSSL: Fix build with current OpenSSL master branch snapshot

OpenSSL 1.1.x will apparently go out with "SSLeay" renamed in the API to
"OpenSSL", which broke the build here for fetching the version of the
running OpenSSL library when wpa_supplicant/hostapd is built against the
current OpenSSL snapshot.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Fix ap_wps_er_multi_add_enrollee cleanup steps
Jouni Malinen [Wed, 2 Dec 2015 16:19:39 +0000 (18:19 +0200)]
tests: Fix ap_wps_er_multi_add_enrollee cleanup steps

Only one of the ERs was stopped at the end of the test case and this
could result in the following test case failing, e.g., when executing
this test case sequence: ap_wps_er_multi_add_enrollee ap_wps_upnp.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: Remove forgotten print from gas_anqp_oom_hapd
Jouni Malinen [Wed, 2 Dec 2015 11:32:59 +0000 (13:32 +0200)]
tests: Remove forgotten print from gas_anqp_oom_hapd

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: Make autogo_join_auto_go_neg more robust
Jouni Malinen [Tue, 1 Dec 2015 22:40:17 +0000 (00:40 +0200)]
tests: Make autogo_join_auto_go_neg more robust

It was possible for this test case to fail if the single attempt of
discovering the peer as part of the scan for join failed. This test case
was useful in combination with another test case:
ap_hs20_fetch_osu autogo_join_auto_go_neg

However, there is now an explicit test case (discovery_after_gas) for
this, so autogo_join_auto_go_neg can be made more robust without losing
testing coverage.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: P2P device discovery after fragmented GAS/ANQP exchange
Jouni Malinen [Tue, 1 Dec 2015 22:14:47 +0000 (00:14 +0200)]
tests: P2P device discovery after fragmented GAS/ANQP exchange

This verifies cfg80211/mac80211 offchannel TX cancellation steps.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agonl80211: Cancel all pending TX frame cookies
Jouni Malinen [Tue, 1 Dec 2015 22:12:32 +0000 (00:12 +0200)]
nl80211: Cancel all pending TX frame cookies

These needs to be cancelled so that the kernel driver does not get left
with all old entries blocking other offchannel operations.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: EAP-EKE local error cases
Jouni Malinen [Mon, 30 Nov 2015 22:46:35 +0000 (00:46 +0200)]
tests: EAP-EKE local error cases

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoEAP-EKE peer: Fix memory leak on error path
Jouni Malinen [Mon, 30 Nov 2015 22:20:25 +0000 (00:20 +0200)]
EAP-EKE peer: Fix memory leak on error path

If DHComponent_P derivation fails (local crypto operation failure), the
message buffer was not freed.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Fix p2p_go_move_scm_peer_does_not_support to clear avoid freqs
Jouni Malinen [Mon, 30 Nov 2015 20:06:54 +0000 (22:06 +0200)]
tests: Fix p2p_go_move_scm_peer_does_not_support to clear avoid freqs

The P2P channel list on dev[1] at the end of
p2p_go_move_scm_peer_does_not_support was empty because all of the 2.4
GHz band got disabled by the simulated avoid frequencies driver event.
That channel list needs to be cleared prior to resetting regulatory
domain back to world roaming to get the P2P channel list updated
properly for the following test cases.

This was triggered by the following test case sequence:
p2p_go_move_scm_peer_does_not_support persistent_group_and_role_change

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: P2P group formation timeout with cfg80211 P2P Device
Jouni Malinen [Mon, 30 Nov 2015 19:38:23 +0000 (21:38 +0200)]
tests: P2P group formation timeout with cfg80211 P2P Device

Verify that both the GO and P2P Client processing of P2P group formation
timeout removes the correct group.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoP2P: Complete group formation on client data connection
Jouni Malinen [Mon, 30 Nov 2015 19:35:16 +0000 (21:35 +0200)]
P2P: Complete group formation on client data connection

This was already the case in the GO role where the first client
connection is waited before marking
wpa_s->p2p_go_group_formation_completed = 1 and clearing
wpa_s->global->p2p_group_formation. However, in the P2P Client role,
that was done already at the completion of the WPS exchange. This can be
problematic since group formation timeout may still try to clear the
group and with wpa_s->global->p2p_group_formation == NULL, the correct
group interface may not be found.

Fix this by postponing clearing of wpa_s->global->p2p_group_formation on
the P2P Client side until the data connection has been completed and
group is declared started.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoRevert "tests: Dynamic hwsim p2ps_channel_active_go_and_station_different_mcc"
Jouni Malinen [Mon, 30 Nov 2015 17:58:07 +0000 (19:58 +0200)]
Revert "tests: Dynamic hwsim p2ps_channel_active_go_and_station_different_mcc"

This reverts commit 78fdab307e4f10275795a196489a4894b0b437d3. This test
case needs MCC support on two stations, so the earlier attempt to handle
this with one dynamic interface is not sufficient.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Show vm-run.sh command line for re-running failure sequences
Jouni Malinen [Mon, 30 Nov 2015 17:42:56 +0000 (19:42 +0200)]
tests: Show vm-run.sh command line for re-running failure sequences

Now that vm-run.sh supports a long list of test cases without crashing
the VM kernel, there is no need to use the "parallel-vm.py -1 1 <tests>"
workaround. Print the re-run example commands with vm-run.sh instead. In
addition, add the --long argument if it was specified for the test run
to avoid skipping test cases in the re-run case.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: Force concurrent exchange in ap_wps_er_multi_add_enrollee
Jouni Malinen [Mon, 30 Nov 2015 14:58:47 +0000 (16:58 +0200)]
tests: Force concurrent exchange in ap_wps_er_multi_add_enrollee

This makes it more likely for the two ERs to go through WPS UPnP
exchange in parallel. This was already happening every now and then and
resulted in failures. However, now that there is support for multiple
concurrent exchanges, it is useful to have this test case hit that
possibility more frequently.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoWPS: Support parallel UPnP WPS protocol runs
Jouni Malinen [Mon, 30 Nov 2015 14:57:11 +0000 (16:57 +0200)]
WPS: Support parallel UPnP WPS protocol runs

This allows multiple external registrars to execute a WPS protocol run
with a WPS AP over UPnP. Previously, hostapd supported only a single WPS
peer entry at a time and if multiple ERs tried to go through a WPS
protocol instance concurrently, only one such exchange could succeed.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: wpa_supplicant sched_scan_plans parsing
Jouni Malinen [Mon, 30 Nov 2015 12:01:40 +0000 (14:01 +0200)]
tests: wpa_supplicant sched_scan_plans parsing

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoAllow sched_scan_plans to be updated at runtime
Jouni Malinen [Mon, 30 Nov 2015 12:00:41 +0000 (14:00 +0200)]
Allow sched_scan_plans to be updated at runtime

This allows the control interface SET command to be used to update the
sched_scan_plans parameter at runtime. In addition, an empty string can
be used to clear the previously configured plan.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agotests: Allow passing more arguments to vm-run.sh
Johannes Berg [Mon, 30 Nov 2015 10:59:09 +0000 (11:59 +0100)]
tests: Allow passing more arguments to vm-run.sh

The script is currently limited by the maximum kernel command line
length and if that's exceeded the kernel panics at boot. Fix this by
writing the arguments to a file and reading it in the VM.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
8 years agoAdd support for configuring scheduled scan plans
Avraham Stern [Tue, 17 Nov 2015 13:08:24 +0000 (15:08 +0200)]
Add support for configuring scheduled scan plans

Add the option to configure scheduled scan plans in the config file.
Each scan plan specifies the interval between scans and the number
of scan iterations. The last plan will run infinitely and thus
specifies only the interval between scan iterations.

usage:
sched_scan_plans=<interval:iterations> <interval2:iterations2> ... <interval>

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
8 years agonl80211: Add support for multiple scan plans for scheduled scan
Avraham Stern [Tue, 17 Nov 2015 13:08:23 +0000 (15:08 +0200)]
nl80211: Add support for multiple scan plans for scheduled scan

Add 'scan plans' to driver scan parameters for scheduled scan.
Each 'scan plan' specifies the number of iterations to run the scan
request and the interval between iterations. When a scan plan
finishes (i.e., it was run for the specified number of iterations),
the next scan plan is executed. The last scan plan will run
infinitely.

The maximum number of supported scan plans, the maximum number of
iterations for a single scan plan and the maximum scan interval
are advertised by the driver.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
8 years agotests: Extend scan_dfs to cover US-disallowed channels 12 and 13
Jouni Malinen [Mon, 30 Nov 2015 09:59:45 +0000 (11:59 +0200)]
tests: Extend scan_dfs to cover US-disallowed channels 12 and 13

Verify that active scanning is not used in US regulatory domain on 2.4
GHz channels 12 and 13.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
8 years agoP2P: Make p2p_go_configured() more robust against unexpected calls
Jouni Malinen [Sun, 29 Nov 2015 23:25:24 +0000 (01:25 +0200)]
P2P: Make p2p_go_configured() more robust against unexpected calls

A hwsim test sequence was able to hit a SIGSEGV in
p2p_go_save_group_common_freqs() called by p2p_go_configured() callback
in a case where a non-P2P AP mode operation is started in wpa_supplicant
(wpas_ap_wep test case). This callback should not have happened for
non-P2P case and the debug logs did not make it clear how this could
happen. In addition, it is unclear how this could be reproduced.

To avoid this type of issues, clear the wpa_s->ap_configured_cb pointer
as soon as the first call to the function happens. In addition, verify
that wpa_s->go_params is available before processing the GO configured
callback.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: EAP-TLS with SHA512/SHA384 signature
Jouni Malinen [Sun, 29 Nov 2015 22:39:38 +0000 (00:39 +0200)]
tests: EAP-TLS with SHA512/SHA384 signature

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: ap_wpa2_eap_fast_prf_oom with internal TLS implementation
Jouni Malinen [Sun, 29 Nov 2015 21:57:39 +0000 (23:57 +0200)]
tests: ap_wpa2_eap_fast_prf_oom with internal TLS implementation

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS client: Fix session_resumed status after TLS session ticket use
Jouni Malinen [Sun, 29 Nov 2015 21:52:30 +0000 (23:52 +0200)]
TLS client: Fix session_resumed status after TLS session ticket use

conn->session_resumed was not set to 1 after successful use of a TLS
session ticket with EAP-FAST. This resulted in the wpa_supplicant STATUS
tls_session_reused showing incorrect value (0 instead of 1) when
EAP-FAST PAC was used. Fix this by setting conn->session_resumed = 1
when TLS handshake using the session ticket succeeds.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoFix tls_connection_prf() regression with CONFIG_TLS=internal
Jouni Malinen [Sun, 29 Nov 2015 21:40:54 +0000 (23:40 +0200)]
Fix tls_connection_prf() regression with CONFIG_TLS=internal

Commit af851914f810978909dd8598ab88030fe43d0051 ('Make
tls_connection_get_keyblock_size() internal to tls_*.c') broke
tls_connection_prf() with the internal TLS implementation when using
skip_keyblock=1. In practice, this broke EAP-FAST. Fix this by deriving
the correct number of PRF bytes before skipping the keyblock.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoTLS: Add support for extKeyUsage X.509v3 extension
Jouni Malinen [Sun, 29 Nov 2015 19:53:23 +0000 (21:53 +0200)]
TLS: Add support for extKeyUsage X.509v3 extension

If the server/client certificate includes the extKeyUsage extension,
verify that the listed key purposes include either the
anyExtendedKeyUsage wildcard or id-kp-serverAuth/id-kp-clientAuth,
respectively.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Skip ap_wpa2_eap_ttls_dh_params_dsa with internal TLS
Jouni Malinen [Sun, 29 Nov 2015 19:09:44 +0000 (21:09 +0200)]
tests: Skip ap_wpa2_eap_ttls_dh_params_dsa with internal TLS

DH DSA parameters are not yet supported.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Skip PKCS#12 tests with internal TLS client implementation
Jouni Malinen [Sun, 29 Nov 2015 19:07:39 +0000 (21:07 +0200)]
tests: Skip PKCS#12 tests with internal TLS client implementation

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoAdd TEST_FAIL() support for internal hash functions
Jouni Malinen [Sun, 29 Nov 2015 19:01:33 +0000 (21:01 +0200)]
Add TEST_FAIL() support for internal hash functions

md4_vector(), md5_vector(), sha1_vector(), and sha256_vector() already
supported TEST_FAIL() with the OpenSSL crypto implementation, but the
same test functionality is needed for the internal crypto implementation
as well.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Skip dbus_connect_eap if altsubject_match is not supported
Jouni Malinen [Sun, 29 Nov 2015 18:57:26 +0000 (20:57 +0200)]
tests: Skip dbus_connect_eap if altsubject_match is not supported

This test case fails with the current internal TLS client implementation
since the needed altsubject_match parameter is not yet supported.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agoFix memory leak on NFC DH generation error path
Jouni Malinen [Sun, 29 Nov 2015 18:53:20 +0000 (20:53 +0200)]
Fix memory leak on NFC DH generation error path

It was possible for some NFC DH generation error paths to leak memory
since the old private/public key was not freed if an allocation failed.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Fix wpas_ctrl_oom with the internal TLS implementation
Jouni Malinen [Sun, 29 Nov 2015 18:43:44 +0000 (20:43 +0200)]
tests: Fix wpas_ctrl_oom with the internal TLS implementation

One of the OOM cases does not apply for internal crypto implementation.

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Fix wpas_ctrl_network without SAE
Jouni Malinen [Sun, 29 Nov 2015 18:38:34 +0000 (20:38 +0200)]
tests: Fix wpas_ctrl_network without SAE

Signed-off-by: Jouni Malinen <j@w1.fi>
8 years agotests: Skip domain_match and domain_suffix_match with internal TLS
Jouni Malinen [Sun, 29 Nov 2015 18:35:05 +0000 (20:35 +0200)]
tests: Skip domain_match and domain_suffix_match with internal TLS

The internal TLS client in wpa_supplicant does not yet support the
functionality needed for these test cases.

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