This is an old revision of the document!
====== Joshua Oreman: 802.11 wireless development ====== ===== Journal Week 5 ===== ==== Monday, 22 June ==== Had a very long meeting with the mentors this morning. Things discussed: * Encryption thoughts: use ''netX/key'' for the encryption key setting, to avoid interfering with the iSCSI ''password'' option set using NVO or DHCP. Use gPXE's existing AES implementation, and write the core RC4 code as a gPXE crypto-subsystem cipher instead of keeping it wireless-specific. Use end-user-understandable names (WEP, WPA, WPA2, as opposed to RC4, RC4/TKIP, AES/CCMP) for configuration options. * Michael and I spent about two hours hashing out the correct behavior as related to my TCP fix. My patch did one thing wrong (ignored TCP sequence number wraparound) and one thing right by accident (returned early for duplicate ACKs, thus not stopping the retransmission timer and causing ''tcp_xmit()'' to do nothing). Michael corrected it and made its mode of operation clearer, and verified using artificially-duplicated frames on rtl8139 that it fixed the problem. He also pointed me to a Wikipedia article describing almost the exact issue: [[http://en.wikipedia.org/wiki/Sorcerer's_Apprentice_Syndrome|Sorcerer's Apprentice Syndrome]]. Because TCP does not automatically reply to ACKs, the problem on gPXE could only be caused by receiving two ACKs in a row for the same packet. In any event, it's fixed now, and should be in mainline soon. * ROM size issues: rtl8185.rom is about 500 bytes shy of the effective 64k limit. It may be possible to use a bit more than 64k, with a 128k EEPROM, but total option ROM size is limited to 128k and we don't want to starve other devices that need ROM space (e.g. RAID cards). [Most wireless cards don't have Option ROMs, but it's possible to use the ROM socket on another card, such as a r8169 (64k space) or e1000 (128k space?).] * Some interesting preliminary discussion about the possibility of [[..:notes:modules|loading part of gPXE as a module]]. If I do any work on this it'll be after encryption, and won't impact gPXE's current uses. I did not get any coding done today to speak of; I worked rather fervently to get wireless done by the end of last week, and I needed some time to recharge. :-) Encryption support will commence tomorrow. ==== Tuesday, 23 June ==== WEP support is done and some of my supporting changes from early last week have been merged in. Current state-of-the-branches, in logical order of application: * **Merged** in gPXE mainline: * [[http://git.etherboot.org/?p=gpxe.git;a=commit;h=743ebc2f4b056673efb26f294ab39a661d77d1a8| [nvs] Add init function for Atmel 93C66 EEPROM]] (was [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=18e6470d06d8846d531d97d881be6f1278bd2f15|18e6470...]]) * [[http://git.etherboot.org/?p=gpxe.git;a=commit;h=eb3ca2a36f0c613aea5c2f02762bc608d5ec785c| [netdevice] Add netdev argument to link-layer push and pull handlers]] (was [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=d429b31ac28760004e753dc79178400d507975e2|d429b31...]]) * [[http://git.etherboot.org/?p=gpxe.git;a=commit;h=f8448735b09af59760eb10fa4c8e759274d0830c| [image] Modify imgfree command to accept an argument]] (was [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=a9a0567225493046f70e6252e21ab5c6d8219e87|a9a0567...]]) * Merged with significant modifications: * [[http://git.etherboot.org/?p=gpxe.git;a=commit;h=558c1a45fe30ffe3d6c67b2321e0fc973f13e9b7| [tcp] Improve robustness in the presence of duplicated received packets]] and following commits * [[http://git.etherboot.org/?p=gpxe.git;a=commit;h=a310d00d37f8362b48913972927bfb78e7d7586d| [netdevice] Add mechanism for reporting detailed link status codes]] (was [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=4602299f4b96f7692766553d5972066dfd567b4e|4602299...]]) [//6/24//] * More merged: [//6/24//] * [[http://git.etherboot.org/?p=gpxe.git;a=commit;h=4125216a2f88c1e4c9fd33931d1249b8afc2f923| [ifmgmt] Move link-up status messages from autoboot() to iflinkwait()]] (was [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=30df822acbf6a207201f111d886effa0e4fc97d3|30df822...]]) * [[http://git.etherboot.org/?p=gpxe.git;a=commit;h=62549983274af297c65fed369d9f5a2ea795cd99| [dhcp] Await link-up before starting DHCP]] (was [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=6d63a4a5f928b46422e2eb79837a8aba103e5bb7|6d63a4a...]]) * [[http://git.etherboot.org/?p=gpxe.git;a=commit;h=15ce2fb851067eb64543859737e2d42f8a271ed6| [hci] Expose ifcommon_exec() in a local header so wireless commands can use it]] (was [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=22c261e77bda0984f4cb052037008f487a4bcaa6|22c261e...]]) * The three big commits on mainline-review, needing updates against recent modifications by Michael and I: (//as of 6/24, updated and ready for review//) * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=42a0c88f51e1f264821ffbf07cbc31ff3e8c47ca| [802.11] Add support for 802.11 devices with software MAC layer]] * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=5d8f27b800e4a8ed1ae07c58992774cb7eb64e53| [rtl818x] Add driver for Realtek 8180/8185 wireless cards]] * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=dad63b2de90bd50efada44b747200c2e7f7b302f| [iwmgmt] Add user-level 802.11 management commands and common error tables]] * Patches to those three, based on discussion with Michael and bug-hunting: (//as of 6/24, included in the above three//) * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=650e7435c813a9ed33727613dea6a1628727d93f| [802.11] Automatically retry association if it fails]] * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=980c569f0929bbe33d91ae51c13caa432d538085| [iwmgmt] Remove iwassoc; do not display association error in iwstat]] * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=60a483bc65a8d76aeac78122a391afaedca87c32| [802.11] Add measure of link quality based on received beacons]] * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=85d58caa58f942b6ec2dab79d3dc0a6e7b832c57| [iwmgmt] Print link quality in iwstat output]] * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=567214147fa3c059485011163f2abc0ae574040a| [802.11] Remove spurious assert()]] * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=d255c2e33c1cdd4e1cb9c814ea54045cdfb9d25c| [802.11] Properly handle return code of fetch_setting()]] I will update the above list as things change this week. After we've decided what to do with the non-802.11 commits (up to "Make DHCP wait for link-up"), I'll reformat all the mainline-ready 802.11 code into three commits like the three I committed on Saturday, rebased off the then-current gPXE trunk. * New encryption commits on branch **wireless**, not ready for mainline review yet: * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=cf92b5abf1b6c6b038daa00f5c975d35a301e27c| [digest] Add generic CRC32 function]] * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=65713460717fd710d6dcf0eebdd8826cd0489514| [cipher] Add the ARC4 stream cipher]] * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=d16c336a8ec188fa24e0fe4d52cde377482da776| [802.11] Add core support for encryption hooks]] * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=aa4b9767418c373a1e8294222b1b328daa03f4a2| [802.11] Add support for WEP-protected networks]] * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=5bbb35902dae90b187a5d0bf026fd130ba9ef0b8| [802.11] Add errortab entry for the error returned by unsuccessful decryption]] * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=bc416e6e2216d9c2075c9ccaf11f1398b393f12f| [config] Move linker massaging for 802.11 options to new file config_80211.o]] * [[http://git.etherboot.org/?p=people/oremanj/gpxe.git;a=commit;h=b319881e68c287127bb765db2226c4b01c6ec266| [config] Add 802.11 encryption options to config/general.h]] Encryption is looking like it will be at least reasonably elegant to support. Of course, WEP is the easiest of the three methods in use; WPA may well have me tearing out my hair by this time tomorrow :-) The WEP code has been tested with hostapd and seems to work very well. ==== Wednesday, 24 June ==== Spent all day researching the security protocols used in WPA-based setups. They're over an order of magnitude more complicated than WEP, taking up about 70 pages in the IEEE 802.11-2007 standard, with reference needed to 802.1X-2004 and various RFCs. The bits I will need to implement include: * Algorithmic: * Generation of pairwise master key (PMK) from passphrase salted with SSID * Generation of pairwise transient key (PTK) from PMK and nonces * The Michael message integrity code for TKIP (WPA) frames * TKIP key mixing stages (the encryption is just ARC4) * CCMP (CTR [counter mode] with CBC-MAC [cipher-block chaining message authentication code] protocol, used in WPA2) encryption and encapsulation * NIST AES key wrap for 4-Way Handshake frames on CCMP networks * HMAC-MD5 and HMAC-SHA1, for 4-Way Handshake MIC [I think gPXE already has implementations of these] * Protocol: * EAPOL decapsulation (packets of EtherType 0x888E with defined header format) * Processing of 4-Way Handshake contained in EAPOL frames * Processing of Group Key Handshake contained in EAPOL frames and rekeyed occasionally I've got a busy week and a half ahead of me!