Commit graph

314 commits

Author SHA1 Message Date
Adil Saeed Musthafa
0660f31ba0 wlantest: Adjust kdk_len according to RSNX capability
This is needed to derive the PTK correct when Secure LTF support is used
and the additional KDK component needs to be taken into account.

Signed-off-by: Adil Saeed Musthafa <quic_adilm@quicinc.com>
2023-03-09 16:08:03 +02:00
Jouni Malinen
4994fa9e59 wlantest: Parse Multi-Link element in (re)association frames
Print the details from the Multi-Link elements from the association
exchange.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2023-02-13 21:34:58 +02:00
Jouni Malinen
c1ce0c3587 wlantest: Use AP MLD address in CCMP/GCMP AAD for A3
Commit b20991da69 ("wlantest: MLD MAC Address in CCMP/GCMP AAD/nonce")
updated AAD and nonce construction to use MLD addresses in AAD for A1
and A2. IEEE P802.11be has additional cases where A3 in AAD is set to
the AP MLD address, so cover those as well.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2023-01-10 12:38:59 +02:00
Jouni Malinen
5c86622175 wlantest: Select BSS more carefully for MLO EAPOL-Key cases
Prefer a BSS entry that has a matching STA entry when processing
EAPOL-Key frames. This avoids issues where some combination of MLD
and/or link addresses are used in a sequence that could end up
generating two separate STA entries for the same non-AP MLD.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2023-01-10 12:00:59 +02:00
Jouni Malinen
0ba17557ea wlantest: Print BSSID for EAPOL-Key frames
The BSSID (RA/TA) might differ from SA/DA for the AP, so print it as
well in the debug entry for EAPOL-Key frames.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2023-01-10 11:50:40 +02:00
Jouni Malinen
40a42613e6 FT: Simplify FTE parsing for FT-SAE-EXT-KEY using MIC Length subfield
Commit 25b52e5f83 ("FT: Extend FTE parsing for FT-SAE-EXT-KEY") used
possible MIC length iteration to try to figure out the length of the MIC
field in FTE. That was the only option available at the time, but FTE is
now being extended in IEEE 802.11-REVme to explicitly indicate the
length of the MIC field for the new FT-SAE-EXT-KEY AKM to make this
easier.

Use the new design from the approved comment resolution (*) in
REVme/D2.0 ballot CID 3135 to simplify implementation. This gets rid of
the need to pass in key length and the somewhat strange need_{r0kh,r1kh}
parameters to wpa_ft_parse_ies().

(*)
https://mentor.ieee.org/802.11/dcn/22/11-22-1991-02-000m-proposed-resolutions-to-some-lb270-comments.docx

Signed-off-by: Jouni Malinen <j@w1.fi>
2022-11-20 11:43:53 +02:00
Jouni Malinen
153739b4ff wlantest: Clone new PTK to all potentially matching STA entries for MLO
It is possible for there to be multiple STA entries (e.g., one for each
BSS) when a sniffer capture contains multiple associations using MLO.
For such cases, the new PTK information needs to be updated to all
existing STA entries to be able to find the latest TK when decrypting
following frames since the other STA entries might be located first when
trying to figure out how to decrypt a frame.

In addition to the PTK, copy the MLD MAC addresses to the other STA and
BSS entries to make sure the latest values are used when trying to
decrypt frames.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-11-09 22:55:35 +02:00
Jouni Malinen
a76a314c15 FT: Extend PMK-R0 derivation for FT-SAE-EXT-KEY
Provide AKM to the helper function to cover the SHA512-based derivation
case.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-10-16 17:43:11 +03:00
Jouni Malinen
25b52e5f83 FT: Extend FTE parsing for FT-SAE-EXT-KEY
Provide AKM, key length, and information about needed subelements to the
parser function so that the variable length MIC field cases can be
recognized for FT-SAE-EXT-KEY. Knowledge about R0KH-ID/R1KH-ID being
needed is required to be able to iterate over possible MIC field lengths
for the case where the AP does not yet know the correct key length at
the beginning of FT protocol.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-10-16 17:17:49 +03:00
Jouni Malinen
4f58afee9a FT: Extend MIC derivation for FT-SAE-EXT-KEY
Provide AKM to the helper function so that the new SHA256 and SHA512
options can be covered for FT-SAE-EXT-KEY.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-10-16 17:07:54 +03:00
Jouni Malinen
7f20a0a0bc wlantest: Key derivation for SAE-EXT-KEY
Extend wlantest capabilities to cover the new SAE-EXT-KEY AKM and
variable length MIC field and key lengths for it based on the used SAE
group.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-10-12 22:33:27 +03:00
Jouni Malinen
18f75df416 wlantest: Learn group keys for other MLO affiliated links
Update bss entries for all affiliated links whenever learning
GTK/IGTK/BIGTK from EAPOL-Key msg 3/4 or group msg 1/2.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-29 13:13:19 +03:00
Jouni Malinen
228420e2d9 wlantest: Find a STA entry based on MLO affiliated link addresses
Allow a single STA entry to be found for a non-AP MLD regardless of
which link MAC address was used to transmit/receive it.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-29 13:08:37 +03:00
Jouni Malinen
5d5c2cb2be wlantest: Recognize SAE case for moving from State 1 to 2
Update STA state tracking for SAE authentication as well as the previous
covered Open System algorithm.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-29 11:59:54 +03:00
Jouni Malinen
ac6baf0bcd wlantest: Use RSNE from MLO Link KDE, if present, for validation
Check the Beacon/Probe Response frame RSNE against the RSNE within the
MLO Link KDE for the current affiliated link instead of RSNE when
processing the EAPOL-Key msg 3/4 Key Data field.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-29 11:50:28 +03:00
Jouni Malinen
8c1231c05a wlantest: Print the TA of a Beacon frame for which there is no BIGTK
This makes the debug message more useful for determining whether an
expected BIGTK has been derived.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-29 00:03:27 +03:00
Jouni Malinen
26cf43dd5d wlantest: Learn GTK/IGTK/BIGTK for the current link in MLO case
Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-29 00:00:45 +03:00
Jouni Malinen
e2a434d57d wlantest: Use wpa_parse_kde_ies() directly
Make this easier to understand by using the appropriately named function
to parse KDEs/IEs in the Key Data field of EAPOL-Key frames instead of
using the wrapper function that is there just to provide the old
function name for wpa_supplicant.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-28 23:07:08 +03:00
Jouni Malinen
dc8a756ce4 wlantest: Verify Beacon frame MME even after Probe Response reception
rx_mgmt_beacon() was skipping all steps after a Probe Response frame
from the AP had been processed. This is expected for the parts that were
updating the bss entry information, but the checks for beacon protection
should not be skipped in this manner.

Skip onlu the updating parts while checking that beacon protection is
used correctly to make this more useful.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-28 23:02:31 +03:00
Sergey Matyukevich
0c7b3814ca Use a less generic name for IEEE802.11 CRC-32 routine
Hostapd uses 'crc32' name for IEEE802.11 CRC-32 routine. This name is
too generic. Buildroot autobuilder detected build configuration that
failed to build due to the naming conflict: static linking with openssl
using zlib-ng as a zlib provider, e.g. see:
- http://autobuild.buildroot.net/results/9901df820d3afa4cde78e8ad6d62cb8ce7e69fdb/
- http://autobuild.buildroot.net/results/ac19975f0bf77f4a8ca574c374092ba81cd5a332/

Use a less generic name ieee80211_crc32 for IEEE802.11 CRC-32 routine
to avoid such naming conflicts.

Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
2022-09-16 21:39:47 +03:00
Jouni Malinen
b20991da69 wlantest: MLD MAC Address in CCMP/GCMP AAD/nonce
Use the MLD MAC Address instead of link address in CCMP/GCMP AAD/nonce
construction when processing an individually addressed Data frame with
FromDS=1 or ToDS=1 between an AP MLD and non-AP MLD.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-05 23:08:43 +03:00
Jouni Malinen
0cc6f985d1 wlantest: Recognize additional not-Robust Action categories
Do not complain about unprotected Action frames for additional
categories that have been defined as not being Robust.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-05 22:06:31 +03:00
Jouni Malinen
d82adf1192 wlantest: Use link BSS entry instead of AP MLD entry for EAPOL-Key frames
SA/DA in EAPOL-Key frames might not be the BSSID when MLO is used. Check
for these cases to avoid adding unexpected BSS entries for AP MLD
instead of the per-link BSS entry. This is needed to be able to find the
derived keys when decrypting protected frames.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-05 21:47:49 +03:00
Jouni Malinen
32592935fe wlantest: Distinguish EAPOL-Key msg 4/4 from 2/4 based on Key Nonce
IEEE P802.11be adds the MAC Address KDE into the EAPOL-Key msg 4/4 when
MLO is used and as such, the previously used check for Key Data Length
value 0 is not sufficient for recognizing the EAPOL-Key msg 4/4 anymore.
Also check for an all zero Key Nonce value since that field is supposed
to be zero in EAPOL-Key msg 4/4 and it has to be a random value in
EAPOL-Key msg 2/4.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-05 21:16:44 +03:00
Jouni Malinen
b5db77840f wlantest: Use MLD MAC addresses, if known, as AA/SA in PTK derivation
When MLO is used, the MLD MAC addresses of the AP MLD and non-AP MLD are
used as the Authenticator and Supplicant addresses. Update PTK
derivation to use this information to work with MLO.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-05 21:10:35 +03:00
Jouni Malinen
fb448ee2b2 wlantest: Learn MLD MAC address from EAPOL-Key msg 1/4 and 2/4
IEEE P802.11be indicates the MLD MAC addresses, i.e., the Authenticator
and Supplicant addresses, in the MAC Address KDE in EAPOL-Key msg 1/4
and 2/4. Learn those addresses so that wlantest can be extended to
support MLO.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-09-05 21:08:24 +03:00
Jouni Malinen
ce7bdb54e5 wlantest: Extend Management frame decryption to support GCMP and CCMP-256
Data frame processing had already been extended to support additional
cipher suites, but Robust Management frame processing was still using a
hardcoded cipher suite (CCMP-128). Extend it to support GCMP-128,
GCMP-256, and CCMP-256 as well.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-08-29 21:46:09 +03:00
Jouni Malinen
cc046a1ff8 wlantest: Extend protected Data frame checks for GCMP and CCMP-256
The same rules that apply to CCMP-128 apply also for GCMP-128, CCMP-256,
and GCMP-256 here.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
2022-08-29 21:31:52 +03:00
Gokul Sivakumar
a9ec233624 wlantest: Add the missing command line option -W to the usage text
Signed-off-by: Gokul Sivakumar <gokulkumar792@gmail.com>
2021-12-11 21:54:39 +02:00
Gokul Sivakumar
2ac53e48d5 wlantest: Delete each entry from the WEP list before freeing the entry
To be consistent with how all the other dl lists like passphrase, PMK,
and PTK lists are freed, delete each entry from the WEP list before
freeing the entry.

Signed-off-by: Gokul Sivakumar <gokulkumar792@gmail.com>
2021-12-11 21:53:40 +02:00
Gokul Sivakumar
d9d0b94e3b wlantest: Replace the duplicate functions with reuse of cli.h
The definitions of max_args, get_cmd_arg_num(), and tokenize_cmd() are
already shared by the hostapd_cli and wpa_cli commands by including the
cli.h header. So follow the same for wlantest_cli and remove the
duplicate function defitions.

Signed-off-by: Gokul Sivakumar <gokulkumar792@gmail.com>
2021-12-11 21:50:41 +02:00
Gokul Sivakumar
daea5ceada wlantest: Add new cli "help" command
Having a help cli command to view all the supported commands is helpful
when running the wlantest_cli manually instead via the python test
scripts.

$ wlantest_cli help
commands:
  ping = test connection to wlantest
  terminate = terminate wlantest
  list_bss = get BSS list
  list_sta <BSSID> = get STA list
  flush = drop all collected BSS data
  clear_sta_counters <BSSID> <STA> = clear STA counters
  clear_bss_counters <BSSID> = clear BSS counters
  get_sta_counter <counter> <BSSID> <STA> = get STA counter value
  get_bss_counter <counter> <BSSID> = get BSS counter value
  inject <frame> <prot> <sender> <BSSID> <STA/ff:ff:ff:ff:ff:ff>
  send <prot> <raw frame as hex dump>
  version = get wlantest version
  add_passphrase <passphrase> = add a known passphrase
  add_wepkey <WEP key> = add a known WEP key
  info_sta <field> <BSSID> <STA> = get STA information
  info_bss <field> <BSSID> = get BSS information
  clear_tdls_counters <BSSID> <STA1> <STA2> = clear TDLS counters
  get_tdls_counter <counter> <BSSID> <STA1> <STA2> = get TDLS counter value
  get_bss_counter <counter> <BSSID> = get BSS counter value
  relog = re-open log-file (allow rolling logs)
  get_tx_tid <BSSID> <STA> <TID> = get STA TX TID counter value
  get_rx_tid <BSSID> <STA> <TID> = get STA RX TID counter value
  help = show this usage help

$ wlantest_cli help add_passphrase
commands:
  add_passphrase <passphrase> = add a known passphrase

Signed-off-by: Gokul Sivakumar <gokulkumar792@gmail.com>
2021-12-11 21:44:21 +02:00
Gokul Sivakumar
30cf0d107f wlantest: Properly free allocated memory on error exit paths
In the cases when a failure is experienced, the value "-1" was returned
from the main() function without doing any cleanup or deinit.

For example, if wlantest was started with the following set of command
line arguments then later when returning after a failure from main()
function, the memory allocated as part of handling the "-p" getopt
command line option was not freed. To fix memory leaks in this case,
properly free the previously allocated memory with the help of
wlantest_deinit() before returning from main().

$ sudo valgrind --leak-check=full --show-leak-kinds=all --verbose \
> --track-origins=yes --log-file=valgrind-out.txt \
> ./wlantest -i hwsim0 -dd -c -p "asdfasdfasdfasdf" -W "abcd"
Invalid WEP key 'abcd'

Memory leak reported by Valgrind when running wlantest as mentioned above.

==513454== HEAP SUMMARY:
==513454==     in use at exit: 128 bytes in 1 blocks
==513454==   total heap usage: 4 allocs, 3 frees, 5,720 bytes allocated
==513454==
==513454== Searching for pointers to 1 not-freed blocks
==513454== Checked 76,936 bytes
==513454==
==513454== 128 bytes in 1 blocks are definitely lost in loss record 1 of 1
==513454==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==513454==    by 0x1396CA: os_zalloc (in /home/ubuntu/hostap/wlantest/wlantest)
==513454==    by 0x10C345: add_passphrase (wlantest.c:125)
==513454==    by 0x10C345: main (wlantest.c:425)
==513454==
==513454== LEAK SUMMARY:
==513454==    definitely lost: 128 bytes in 1 blocks
==513454==    indirectly lost: 0 bytes in 0 blocks
==513454==      possibly lost: 0 bytes in 0 blocks
==513454==    still reachable: 0 bytes in 0 blocks
==513454==         suppressed: 0 bytes in 0 blocks
==513454==
==513454== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Signed-off-by: Gokul Sivakumar <gokulkumar792@gmail.com>
2021-12-11 21:37:06 +02:00
Jouni Malinen
22828b6dba wlantest: Fix PMK length and passphrase-based key derivation for FT
The change to support variable length PMK in wlantest missed couple of
places where the PMK length did not get used or set properly. In
particular, this ended up breaking FT key derivation for the case where
a passphrase was used to derive a potential per-BSS PMK. Fix this by
setting and using the PMK length properly.

Fixes: 6c29d95a90 ("wlantest: Support variable length PMK")
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
2021-10-14 16:28:02 +03:00
Arowa Suliman
7b365376fd Replace "dummy" with "stub" in wlantest injection
Replace the word "dummy" with the inclusive word "stub".

Signed-off-by: Arowa Suliman <arowa@chromium.org>
2021-10-11 20:53:11 +03:00
Arowa Suliman
ed5e1b7223 Replace "dummy" with "stub" in comments/documentation
Replace the word "dummy" with the inclusive word "stub".

Signed-off-by: Arowa Suliman <arowa@chromium.org>
2021-10-11 20:52:50 +03:00
Jouni Malinen
ced15c8ba8 wlantest: TKIP frame reassembly for Michael MIC check in fragmented case
Reassemble the full MSDU when processing TKIP protected fragmented
frames so that the Michael MIC can be validated once the last fragment
has been received.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
2021-05-11 21:13:56 +03:00
Jouni Malinen
3332657d69 wlantest: Report decrypted TKIP frames even if cannot check Michael MIC
This can be useful for debugging, so return successfully decrypted TKIP
frame even if the Michael MIC cannot be verified (fragment reassembly
not yet supported) or if the Michael MIC value is incorrect. Add a note
in the frame to point out that the Michael MIC was not verified or is
incorrect.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
2021-05-11 21:13:56 +03:00
Jouni Malinen
73f65cc6c4 wlantest: Support HT Control field in QoS Data frames
Extend Data frame processing (and decryption) to handle +HTC frames by
skipping the HT Control field at the end of the frame header. While this
is not an exact match of the rules in IEEE Std 802.11-2020 for when the
HT Control field is present in frames (e.g., no check of the TXVECTOR
value), this is good enough to cover the most likely used cases.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
2021-05-06 23:32:54 +03:00
Jouni Malinen
2950851ace Rename the Frame Control field subfield Order define to +HTC
This moves the implementation closer to the current IEEE 802.11 standard
since B15 of Frame Control field was renamed to +HTC to match it newer
uses.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
2021-05-06 12:12:51 +03:00
Jouni Malinen
e90ededb4b wlantest: Skip Mesh Control field from the beginning of payload
This allows correct processing of Data frames with Mesh Control field by
finding the LLC/SNAP header after that field.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
2021-03-09 20:20:24 +02:00
Jouni Malinen
503901e72d wlantest: Check all configured TKs if no matching GTK is known
This allows group-addressed frames to be decrypted by listing all
possible GTKs in the PTK file.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
2021-03-09 17:29:48 +02:00
Jouni Malinen
32360ad498 wlantest: Fix broadcast EAPOL-Key frame handling
This resulted in an attempt to dereference a NULL pointer since sta_addr
is not known in this type of a case.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
2021-02-27 20:27:06 +02:00
Brian Norris
1e537a2756 wlantest: Avoid unaligned iphdr pointers
Buffers passed to rx_data_ip() may not be naturally-aligned, and so we
get unpredictable behavior when we cast that to an IP header. In
particular, this code may crash on ARM.

Signed-off-by: Brian Norris <briannorris@chromium.org>
2021-02-13 23:07:34 +02:00
Jouni Malinen
6a12acbb78 wlantest: Add new key_mgmt and rsn_capab values for BSS/STA debug prints
Signed-off-by: Jouni Malinen <j@w1.fi>
2021-02-07 13:57:03 +02:00
Jouni Malinen
136bbf15c3 wlantest: Add more details about protected FTM frames
Signed-off-by: Jouni Malinen <j@w1.fi>
2021-02-07 13:11:34 +02:00
Jouni Malinen
b9fd8191a5 wlantest: Recognize the FTM bit in the CCMP Key ID octet
This previously reserved bit is now used in FTM to help select the
appropriate replay counter. Silence the warning about use of a reserved
bit for this. wlantest does not yet support the actual replay counter
processing for FTM.

Signed-off-by: Jouni Malinen <j@w1.fi>
2021-02-07 12:30:03 +02:00
Jouni Malinen
f56eec7c1a wlantest: Process Action No Ack frames like Action frames
Signed-off-by: Jouni Malinen <j@w1.fi>
2021-02-07 12:00:12 +02:00
Jouni Malinen
56a04ae1a1 wlantest: Support TK list for Management frame decryption
Use the TKs from the PTK file (-T command line argument) to try to
decrypt encrypted Management frames if no BSS/STA key can be found based
on addresses.

Signed-off-by: Jouni Malinen <j@w1.fi>
2021-02-07 11:37:58 +02:00
Ilan Peer
d87f4aea11 FILS: Extend the fils_pmk_to_ptk() function to also derive KDK
Extend the fils_pmk_to_ptk() to also derive Key Derivation
Key (KDK) which can later be used for secure LTF measurements.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
2021-01-25 18:36:40 +02:00