├── hostapd ├── src ├── hostapd.deny ├── hostapd.radius_clients ├── hostapd.accept ├── hostapd.vlan ├── logwatch │ ├── hostapd.conf │ ├── README │ └── hostapd ├── hostapd.sim_db ├── hostapd.wpa_psk ├── eap_register.h ├── dump_state.h ├── config_file.h ├── hlr_auc_gw.milenage_db ├── ctrl_iface.h ├── wired.conf ├── nt_password_hash.c ├── hostapd.8 ├── bsd_hostapd.conf └── hostapd_cli.1 ├── .gitignore ├── wpa_supplicant ├── src ├── dbus │ ├── .gitignore │ ├── fi.w1.wpa_supplicant1.service │ ├── fi.epitest.hostap.WPASupplicant.service │ ├── dbus_common.h │ ├── dbus_common_i.h │ ├── dbus-wpa_supplicant.conf │ └── Makefile ├── pf │ ├── wpa_supplicant.PO │ ├── wpa_supplicant.PR │ ├── wpa_supplicant.PS │ ├── wpa_supplicant.IAB │ ├── wpa_supplicant.IAD │ ├── wpa_supplicant.IMB │ ├── wpa_supplicant.IMD │ ├── wpa_supplicant.PRI │ ├── wpa_supplicant.WK3 │ ├── wpa_supplicant.PFI │ └── wpa_supplicant.SearchResults ├── wpas_glue.h ├── blacklist.h ├── main_none.c ├── main_symbian.cpp ├── win_example.reg ├── ibss_rsn.h ├── config_none.c ├── scan.h ├── wpa_passphrase.c ├── main_winmain.c ├── bgscan.h └── ap.h ├── src ├── tls │ ├── .gitignore │ ├── Makefile │ ├── pkcs5.h │ ├── pkcs8.h │ ├── rsa.h │ ├── pkcs1.h │ ├── bignum.h │ ├── tlsv1_cred.h │ ├── tlsv1_server.h │ ├── tlsv1_server_i.h │ ├── tlsv1_record.h │ └── tlsv1_client.h ├── crypto │ ├── .gitignore │ ├── fips_prf_nss.c │ ├── fips_prf_cryptoapi.c │ ├── fips_prf_gnutls.c │ ├── dh_group5.h │ ├── crypto_none.c │ ├── md5_i.h │ ├── aes.h │ ├── sha1_i.h │ ├── dh_groups.h │ ├── sha256.h │ ├── des_i.h │ ├── dh_group5.c │ ├── aes-encblock.c │ ├── Makefile │ ├── random.h │ ├── md5.h │ ├── milenage.h │ ├── sha1.h │ ├── rc4.c │ ├── aes-ctr.c │ ├── crypto_internal-modexp.c │ ├── fips_prf_internal.c │ ├── aes_wrap.h │ ├── aes-wrap.c │ ├── fips_prf_openssl.c │ ├── aes-unwrap.c │ ├── sha1-tprf.c │ └── aes-cbc.c ├── radius │ ├── .gitignore │ └── Makefile ├── utils │ ├── .gitignore │ ├── Makefile │ ├── uuid.h │ ├── base64.h │ ├── edit.h │ ├── ip_addr.h │ ├── radiotap_iter.h │ ├── includes.h │ ├── uuid.c │ ├── ip_addr.c │ ├── pcsc_funcs.h │ ├── edit_simple.c │ └── trace.h ├── drivers │ ├── .gitignore │ ├── Makefile │ ├── rfkill.h │ ├── netlink.h │ ├── linux_ioctl.h │ ├── MobileApple80211.h │ ├── driver_ndis.h │ └── driver_none.c ├── common │ ├── rtw_version.h │ ├── Makefile │ ├── version.h │ ├── eapol_common.h │ ├── privsep_commands.h │ └── ieee802_11_common.h ├── ap │ ├── Makefile │ ├── authsrv.h │ ├── tkip_countermeasures.h │ ├── wpa_auth_glue.h │ ├── ctrl_iface_ap.h │ ├── wmm.h │ ├── ieee802_11_auth.h │ ├── beacon.h │ ├── iapp.h │ ├── p2p_hostapd.h │ ├── ap_mlme.h │ ├── accounting.h │ ├── wpa_auth_ie.h │ ├── preauth_auth.h │ ├── vlan_init.h │ ├── hw_features.h │ ├── pmksa_cache_auth.h │ ├── utils.c │ └── wps_hostapd.h ├── wps │ ├── Makefile │ ├── upnp_xml.h │ ├── http.h │ ├── wps_upnp.h │ ├── http_server.h │ ├── http_client.h │ └── wps_dev_attr.h ├── rsn_supp │ ├── Makefile │ ├── wpa_ie.h │ └── preauth.h ├── eap_common │ ├── Makefile │ ├── chap.h │ ├── eap_peap_common.h │ ├── chap.c │ ├── eap_common.h │ ├── eap_wsc_common.h │ ├── eap_wsc_common.c │ ├── eap_ikev2_common.h │ ├── eap_psk_common.c │ ├── eap_ttls.h │ ├── eap_gpsk_common.h │ ├── eap_psk_common.h │ └── eap_peap_common.c ├── eap_server │ ├── Makefile │ ├── tncs.h │ ├── ikev2.h │ └── eap_methods.h ├── eapol_auth │ └── Makefile ├── eapol_supp │ └── Makefile ├── l2_packet │ └── Makefile ├── p2p │ └── Makefile ├── eap_peer │ ├── Makefile │ ├── mschapv2.h │ ├── tncc.h │ ├── ikev2.h │ └── eap_fast_pac.h ├── lib.rules └── Makefile └── scripts ├── hostapd.conf └── init /hostapd/src: -------------------------------------------------------------------------------- 1 | ../src -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /wpa_supplicant/src: -------------------------------------------------------------------------------- 1 | ../src -------------------------------------------------------------------------------- /src/tls/.gitignore: -------------------------------------------------------------------------------- 1 | libtls.a 2 | -------------------------------------------------------------------------------- /src/crypto/.gitignore: -------------------------------------------------------------------------------- 1 | libcrypto.a 2 | -------------------------------------------------------------------------------- /src/radius/.gitignore: -------------------------------------------------------------------------------- 1 | libradius.a 2 | -------------------------------------------------------------------------------- /src/utils/.gitignore: -------------------------------------------------------------------------------- 1 | libutils.a 2 | -------------------------------------------------------------------------------- /wpa_supplicant/dbus/.gitignore: -------------------------------------------------------------------------------- 1 | libwpadbus.a 2 | -------------------------------------------------------------------------------- /src/drivers/.gitignore: -------------------------------------------------------------------------------- 1 | build.wpa_supplicant 2 | build.hostapd 3 | -------------------------------------------------------------------------------- /src/common/rtw_version.h: -------------------------------------------------------------------------------- 1 | #ifndef RTW_VERSION_H 2 | #define RTW_VERSION "rtw_r7475.20130812_beta" 3 | #endif 4 | -------------------------------------------------------------------------------- /wpa_supplicant/pf/wpa_supplicant.PO: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenssegers/RTL8188-hostapd/HEAD/wpa_supplicant/pf/wpa_supplicant.PO -------------------------------------------------------------------------------- /wpa_supplicant/pf/wpa_supplicant.PR: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenssegers/RTL8188-hostapd/HEAD/wpa_supplicant/pf/wpa_supplicant.PR -------------------------------------------------------------------------------- /wpa_supplicant/pf/wpa_supplicant.PS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenssegers/RTL8188-hostapd/HEAD/wpa_supplicant/pf/wpa_supplicant.PS -------------------------------------------------------------------------------- /wpa_supplicant/pf/wpa_supplicant.IAB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenssegers/RTL8188-hostapd/HEAD/wpa_supplicant/pf/wpa_supplicant.IAB -------------------------------------------------------------------------------- /wpa_supplicant/pf/wpa_supplicant.IAD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenssegers/RTL8188-hostapd/HEAD/wpa_supplicant/pf/wpa_supplicant.IAD -------------------------------------------------------------------------------- /wpa_supplicant/pf/wpa_supplicant.IMB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenssegers/RTL8188-hostapd/HEAD/wpa_supplicant/pf/wpa_supplicant.IMB -------------------------------------------------------------------------------- /wpa_supplicant/pf/wpa_supplicant.IMD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenssegers/RTL8188-hostapd/HEAD/wpa_supplicant/pf/wpa_supplicant.IMD -------------------------------------------------------------------------------- /wpa_supplicant/pf/wpa_supplicant.PRI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenssegers/RTL8188-hostapd/HEAD/wpa_supplicant/pf/wpa_supplicant.PRI -------------------------------------------------------------------------------- /wpa_supplicant/pf/wpa_supplicant.WK3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenssegers/RTL8188-hostapd/HEAD/wpa_supplicant/pf/wpa_supplicant.WK3 -------------------------------------------------------------------------------- /src/ap/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo Nothing to be made. 3 | 4 | clean: 5 | rm -f *~ *.o *.d 6 | 7 | install: 8 | @echo Nothing to be made. 9 | -------------------------------------------------------------------------------- /src/wps/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo Nothing to be made. 3 | 4 | clean: 5 | rm -f *~ *.o *.d 6 | 7 | install: 8 | @echo Nothing to be made. 9 | -------------------------------------------------------------------------------- /src/common/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo Nothing to be made. 3 | 4 | clean: 5 | rm -f *~ *.o *.d 6 | 7 | install: 8 | @echo Nothing to be made. 9 | -------------------------------------------------------------------------------- /src/rsn_supp/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo Nothing to be made. 3 | 4 | clean: 5 | rm -f *~ *.o *.d 6 | 7 | install: 8 | @echo Nothing to be made. 9 | -------------------------------------------------------------------------------- /wpa_supplicant/dbus/fi.w1.wpa_supplicant1.service: -------------------------------------------------------------------------------- 1 | [D-BUS Service] 2 | Name=fi.w1.wpa_supplicant1 3 | Exec=/sbin/wpa_supplicant -u 4 | User=root 5 | -------------------------------------------------------------------------------- /src/eap_common/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo Nothing to be made. 3 | 4 | clean: 5 | rm -f *~ *.o *.d 6 | 7 | install: 8 | @echo Nothing to be made. 9 | -------------------------------------------------------------------------------- /src/eap_server/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo Nothing to be made. 3 | 4 | clean: 5 | rm -f *~ *.o *.d 6 | 7 | install: 8 | @echo Nothing to be made. 9 | -------------------------------------------------------------------------------- /src/eapol_auth/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo Nothing to be made. 3 | 4 | clean: 5 | rm -f *~ *.o *.d 6 | 7 | install: 8 | @echo Nothing to be made. 9 | -------------------------------------------------------------------------------- /src/eapol_supp/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo Nothing to be made. 3 | 4 | clean: 5 | rm -f *~ *.o *.d 6 | 7 | install: 8 | @echo Nothing to be made. 9 | -------------------------------------------------------------------------------- /src/l2_packet/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo Nothing to be made. 3 | 4 | clean: 5 | rm -f *~ *.o *.d 6 | 7 | install: 8 | @echo Nothing to be made. 9 | -------------------------------------------------------------------------------- /wpa_supplicant/dbus/fi.epitest.hostap.WPASupplicant.service: -------------------------------------------------------------------------------- 1 | [D-BUS Service] 2 | Name=fi.epitest.hostap.WPASupplicant 3 | Exec=/sbin/wpa_supplicant -u 4 | User=root 5 | -------------------------------------------------------------------------------- /hostapd/hostapd.deny: -------------------------------------------------------------------------------- 1 | # List of MAC addresses that are not allowed to authenticate (IEEE 802.11) 2 | # with the AP. 3 | 00:20:30:40:50:60 4 | 00:ab:cd:ef:12:34 5 | 00:00:30:40:50:60 6 | -------------------------------------------------------------------------------- /hostapd/hostapd.radius_clients: -------------------------------------------------------------------------------- 1 | # RADIUS client configuration for the RADIUS server 2 | 10.1.2.3 secret passphrase 3 | 192.168.1.0/24 another very secret passphrase 4 | 0.0.0.0/0 radius 5 | -------------------------------------------------------------------------------- /src/drivers/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo Nothing to be made. 3 | 4 | clean: 5 | rm -f *~ *.o *.d 6 | rm -f build.wpa_supplicant build.hostapd 7 | 8 | install: 9 | @echo Nothing to be made. 10 | -------------------------------------------------------------------------------- /src/p2p/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo Nothing to be made. 3 | 4 | clean: 5 | for d in $(SUBDIRS); do make -C $$d clean; done 6 | rm -f *~ *.o *.d 7 | 8 | install: 9 | @echo Nothing to be made. 10 | -------------------------------------------------------------------------------- /src/eap_peer/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo Nothing to be made. 3 | 4 | clean: 5 | rm -f *~ *.o *.so *.d 6 | 7 | install: 8 | if ls *.so >/dev/null 2>&1; then \ 9 | install -d $(DESTDIR)$(LIBDIR)/wpa_supplicant && \ 10 | cp *.so $(DESTDIR)$(LIBDIR)/wpa_supplicant \ 11 | ; fi 12 | -------------------------------------------------------------------------------- /hostapd/hostapd.accept: -------------------------------------------------------------------------------- 1 | # List of MAC addresses that are allowed to authenticate (IEEE 802.11) 2 | # with the AP. Optional VLAN ID can be assigned for clients based on the 3 | # MAC address if dynamic VLANs (hostapd.conf dynamic_vlan option) are used. 4 | 00:11:22:33:44:55 5 | 00:66:77:88:99:aa 6 | 00:00:22:33:44:55 1 7 | -------------------------------------------------------------------------------- /src/lib.rules: -------------------------------------------------------------------------------- 1 | ifndef CC 2 | CC=gcc 3 | endif 4 | 5 | ifndef CFLAGS 6 | CFLAGS = -MMD -O2 -Wall -g 7 | endif 8 | 9 | CFLAGS += -I.. -I../utils 10 | 11 | 12 | Q=@ 13 | E=echo 14 | ifeq ($(V), 1) 15 | Q= 16 | E=true 17 | endif 18 | 19 | %.o: %.c 20 | $(Q)$(CC) -c -o $@ $(CFLAGS) $< 21 | @$(E) " CC " $< 22 | -------------------------------------------------------------------------------- /hostapd/hostapd.vlan: -------------------------------------------------------------------------------- 1 | # VLAN ID to network interface mapping 2 | 1 vlan1 3 | 2 vlan2 4 | 3 vlan3 5 | 100 guest 6 | # Optional wildcard entry matching all VLAN IDs. The first # in the interface 7 | # name will be replaced with the VLAN ID. The network interfaces are created 8 | # (and removed) dynamically based on the use. 9 | * vlan# 10 | -------------------------------------------------------------------------------- /hostapd/logwatch/hostapd.conf: -------------------------------------------------------------------------------- 1 | # Logwatch configuration for hostapd 2 | # 3 | # Copyright 2005 Henrik Brix Andersen 4 | # Distributed under the terms of the GNU General Public License v2 5 | # Alternatively, this file may be distributed under the terms of the BSD License 6 | 7 | Title = "hostapd" 8 | LogFile = messages 9 | *OnlyService = hostapd 10 | *RemoveHeaders 11 | -------------------------------------------------------------------------------- /src/radius/Makefile: -------------------------------------------------------------------------------- 1 | all: libradius.a 2 | 3 | clean: 4 | rm -f *~ *.o *.d libradius.a 5 | 6 | install: 7 | @echo Nothing to be made. 8 | 9 | 10 | include ../lib.rules 11 | 12 | CFLAGS += -DCONFIG_IPV6 13 | 14 | LIB_OBJS= \ 15 | radius.o \ 16 | radius_client.o \ 17 | radius_server.o 18 | 19 | libradius.a: $(LIB_OBJS) 20 | $(AR) crT $@ $? 21 | 22 | -include $(OBJS:%.o=%.d) 23 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS=ap common crypto drivers eapol_auth eapol_supp eap_common eap_peer eap_server l2_packet p2p radius rsn_supp tls utils wps 2 | 3 | all: 4 | for d in $(SUBDIRS); do [ -d $$d ] && $(MAKE) -C $$d; done 5 | 6 | clean: 7 | for d in $(SUBDIRS); do [ -d $$d ] && $(MAKE) -C $$d clean; done 8 | rm -f *~ 9 | 10 | install: 11 | for d in $(SUBDIRS); do [ -d $$d ] && $(MAKE) -C $$d install; done 12 | -------------------------------------------------------------------------------- /src/common/version.h: -------------------------------------------------------------------------------- 1 | #ifndef VERSION_H 2 | #define VERSION_H 3 | 4 | #ifndef VERSION_STR_POSTFIX 5 | #define VERSION_STR_POSTFIX "" 6 | #endif /* VERSION_STR_POSTFIX */ 7 | 8 | #include "rtw_version.h" 9 | 10 | #ifdef RTW_VERSION 11 | #define VERSION_STR "0.8.x" VERSION_STR_POSTFIX "_" RTW_VERSION 12 | #else 13 | #define VERSION_STR "0.8.x" VERSION_STR_POSTFIX 14 | #endif 15 | 16 | #endif /* VERSION_H */ 17 | -------------------------------------------------------------------------------- /wpa_supplicant/pf/wpa_supplicant.PFI: -------------------------------------------------------------------------------- 1 | OP 2 |  !"#$%&'()*QRH+,-@.IS/01234TUJ56789VW:;<=XYK>?Z[ABC\]LD^_MN`EFGabcdef -------------------------------------------------------------------------------- /hostapd/hostapd.sim_db: -------------------------------------------------------------------------------- 1 | # Example GSM authentication triplet file for EAP-SIM authenticator 2 | # IMSI:Kc:SRES:RAND 3 | # IMSI: ASCII string (numbers) 4 | # Kc: hex, 8 octets 5 | # SRES: hex, 4 octets 6 | # RAND: hex, 16 octets 7 | 234567898765432:A0A1A2A3A4A5A6A7:D1D2D3D4:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 8 | 234567898765432:B0B1B2B3B4B5B6B7:E1E2E3E4:BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB 9 | 234567898765432:C0C1C2C3C4C5C6C7:F1F2F3F4:CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 10 | -------------------------------------------------------------------------------- /hostapd/logwatch/README: -------------------------------------------------------------------------------- 1 | Logwatch is a utility for analyzing system logs and provide a human 2 | readable summary. This directory has a configuration file and a log 3 | analyzer script for parsing hostapd system log entries for logwatch. 4 | These files can be installed by copying them to following locations: 5 | 6 | /etc/log.d/conf/services/hostapd.conf 7 | /etc/log.d/scripts/services/hostapd 8 | 9 | More information about logwatch is available from http://www.logwatch.org/ 10 | -------------------------------------------------------------------------------- /scripts/hostapd.conf: -------------------------------------------------------------------------------- 1 | # Basic configuration 2 | 3 | interface=wlan0 4 | ssid=wifi 5 | channel=1 6 | #bridge=br0 7 | 8 | # WPA and WPA2 configuration 9 | 10 | macaddr_acl=0 11 | auth_algs=1 12 | ignore_broadcast_ssid=0 13 | wpa=3 14 | wpa_passphrase=YourPassPhrase 15 | wpa_key_mgmt=WPA-PSK 16 | wpa_pairwise=TKIP 17 | rsn_pairwise=CCMP 18 | 19 | # Hardware configuration 20 | 21 | driver=rtl871xdrv 22 | ieee80211n=1 23 | hw_mode=g 24 | device_name=RTL8192CU 25 | manufacturer=Realtek 26 | -------------------------------------------------------------------------------- /wpa_supplicant/pf/wpa_supplicant.SearchResults: -------------------------------------------------------------------------------- 1 | ---- scan2 Matches (4 in 2 files) ---- 2 | Driver_i.h (d:\rtl8712\linux_92c\wpa_supplicant_hostapd-0.8\wpa_supplicant): if (wpa_s->driver->scan2) 3 | Driver_i.h (d:\rtl8712\linux_92c\wpa_supplicant_hostapd-0.8\wpa_supplicant): return wpa_s->driver->scan2(wpa_s->drv_priv, params); 4 | Wpa_priv.c (d:\rtl8712\linux_92c\wpa_supplicant_hostapd-0.8\wpa_supplicant): if (iface->driver->scan2) 5 | Wpa_priv.c (d:\rtl8712\linux_92c\wpa_supplicant_hostapd-0.8\wpa_supplicant): iface->driver->scan2(iface->drv_priv, ¶ms); 6 | -------------------------------------------------------------------------------- /hostapd/hostapd.wpa_psk: -------------------------------------------------------------------------------- 1 | # List of WPA PSKs. Each line, except for empty lines and lines starting 2 | # with #, must contain a MAC address and PSK separated with a space. 3 | # Special MAC address 00:00:00:00:00:00 can be used to configure PSKs that 4 | # anyone can use. PSK can be configured as an ASCII passphrase of 8..63 5 | # characters or as a 256-bit hex PSK (64 hex digits). 6 | 00:00:00:00:00:00 secret passphrase 7 | 00:11:22:33:44:55 another passphrase 8 | 00:22:33:44:55:66 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef 9 | 00:00:00:00:00:00 another passphrase for all STAs 10 | -------------------------------------------------------------------------------- /hostapd/eap_register.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP method registration 3 | * Copyright (c) 2004-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef EAP_REGISTER_H 16 | #define EAP_REGISTER_H 17 | 18 | int eap_server_register_methods(void); 19 | 20 | #endif /* EAP_REGISTER_H */ 21 | -------------------------------------------------------------------------------- /hostapd/dump_state.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / State dump 3 | * Copyright (c) 2002-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef DUMP_STATE_H 16 | #define DUMP_STATE_H 17 | 18 | int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx); 19 | 20 | #endif /* DUMP_STATE_H */ 21 | -------------------------------------------------------------------------------- /hostapd/config_file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / Configuration file parser 3 | * Copyright (c) 2003-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef CONFIG_FILE_H 16 | #define CONFIG_FILE_H 17 | 18 | struct hostapd_config * hostapd_config_read(const char *fname); 19 | 20 | #endif /* CONFIG_FILE_H */ 21 | -------------------------------------------------------------------------------- /src/ap/authsrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Authentication server setup 3 | * Copyright (c) 2002-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef AUTHSRV_H 16 | #define AUTHSRV_H 17 | 18 | int authsrv_init(struct hostapd_data *hapd); 19 | void authsrv_deinit(struct hostapd_data *hapd); 20 | 21 | #endif /* AUTHSRV_H */ 22 | -------------------------------------------------------------------------------- /src/tls/Makefile: -------------------------------------------------------------------------------- 1 | all: libtls.a 2 | 3 | clean: 4 | rm -f *~ *.o *.d libtls.a 5 | 6 | install: 7 | @echo Nothing to be made. 8 | 9 | 10 | include ../lib.rules 11 | 12 | CFLAGS += -DCONFIG_INTERNAL_LIBTOMMATH 13 | CFLAGS += -DCONFIG_CRYPTO_INTERNAL 14 | 15 | LIB_OBJS= \ 16 | asn1.o \ 17 | bignum.o \ 18 | pkcs1.o \ 19 | pkcs5.o \ 20 | pkcs8.o \ 21 | rsa.o \ 22 | tlsv1_client.o \ 23 | tlsv1_client_read.o \ 24 | tlsv1_client_write.o \ 25 | tlsv1_common.o \ 26 | tlsv1_cred.o \ 27 | tlsv1_record.o \ 28 | tlsv1_server.o \ 29 | tlsv1_server_read.o \ 30 | tlsv1_server_write.o \ 31 | x509v3.o 32 | 33 | 34 | libtls.a: $(LIB_OBJS) 35 | $(AR) crT $@ $? 36 | 37 | -include $(OBJS:%.o=%.d) 38 | -------------------------------------------------------------------------------- /src/ap/tkip_countermeasures.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / TKIP countermeasures 3 | * Copyright (c) 2002-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef TKIP_COUNTERMEASURES_H 16 | #define TKIP_COUNTERMEASURES_H 17 | 18 | void michael_mic_failure(struct hostapd_data *hapd, const u8 *addr, int local); 19 | 20 | #endif /* TKIP_COUNTERMEASURES_H */ 21 | -------------------------------------------------------------------------------- /src/crypto/fips_prf_nss.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FIPS 186-2 PRF for NSS 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | #include 17 | 18 | #include "common.h" 19 | #include "crypto.h" 20 | 21 | 22 | int fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x, size_t xlen) 23 | { 24 | return -1; 25 | } 26 | -------------------------------------------------------------------------------- /src/eap_common/chap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CHAP-MD5 (RFC 1994) 3 | * Copyright (c) 2007-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef CHAP_H 16 | #define CHAP_H 17 | 18 | #define CHAP_MD5_LEN 16 19 | 20 | int chap_md5(u8 id, const u8 *secret, size_t secret_len, const u8 *challenge, 21 | size_t challenge_len, u8 *response); 22 | 23 | #endif /* CHAP_H */ 24 | -------------------------------------------------------------------------------- /src/tls/pkcs5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PKCS #5 (Password-based Encryption) 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef PKCS5_H 16 | #define PKCS5_H 17 | 18 | u8 * pkcs5_decrypt(const u8 *enc_alg, size_t enc_alg_len, 19 | const u8 *enc_data, size_t enc_data_len, 20 | const char *passwd, size_t *data_len); 21 | 22 | #endif /* PKCS5_H */ 23 | -------------------------------------------------------------------------------- /src/utils/Makefile: -------------------------------------------------------------------------------- 1 | all: libutils.a 2 | 3 | clean: 4 | rm -f *~ *.o *.d libutils.a 5 | 6 | install: 7 | @echo Nothing to be made. 8 | 9 | 10 | include ../lib.rules 11 | 12 | #CFLAGS += -DWPA_TRACE 13 | CFLAGS += -DCONFIG_IPV6 14 | 15 | LIB_OBJS= \ 16 | base64.o \ 17 | common.o \ 18 | ip_addr.o \ 19 | radiotap.o \ 20 | trace.o \ 21 | uuid.o \ 22 | wpa_debug.o \ 23 | wpabuf.o 24 | 25 | # Pick correct OS wrapper implementation 26 | LIB_OBJS += os_unix.o 27 | 28 | # Pick correct event loop implementation 29 | LIB_OBJS += eloop.o 30 | 31 | # Pick correct edit implementation 32 | LIB_OBJS += edit.o 33 | 34 | #LIB_OBJS += pcsc_funcs.o 35 | 36 | libutils.a: $(LIB_OBJS) 37 | $(AR) crT $@ $? 38 | 39 | -include $(OBJS:%.o=%.d) 40 | -------------------------------------------------------------------------------- /src/utils/uuid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Universally Unique IDentifier (UUID) 3 | * Copyright (c) 2008, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef UUID_H 16 | #define UUID_H 17 | 18 | #define UUID_LEN 16 19 | 20 | int uuid_str2bin(const char *str, u8 *bin); 21 | int uuid_bin2str(const u8 *bin, char *str, size_t max_len); 22 | int is_nil_uuid(const u8 *uuid); 23 | 24 | #endif /* UUID_H */ 25 | -------------------------------------------------------------------------------- /src/crypto/fips_prf_cryptoapi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FIPS 186-2 PRF for Microsoft CryptoAPI 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "crypto.h" 19 | 20 | 21 | int fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x, size_t xlen) 22 | { 23 | /* FIX: how to do this with CryptoAPI? */ 24 | return -1; 25 | } 26 | -------------------------------------------------------------------------------- /src/tls/pkcs8.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PKCS #8 (Private-key information syntax) 3 | * Copyright (c) 2006-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef PKCS8_H 16 | #define PKCS8_H 17 | 18 | struct crypto_private_key * pkcs8_key_import(const u8 *buf, size_t len); 19 | struct crypto_private_key * 20 | pkcs8_enc_key_import(const u8 *buf, size_t len, const char *passwd); 21 | 22 | #endif /* PKCS8_H */ 23 | -------------------------------------------------------------------------------- /src/eap_common/eap_peap_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP-PEAP common routines 3 | * Copyright (c) 2008, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef EAP_PEAP_COMMON_H 16 | #define EAP_PEAP_COMMON_H 17 | 18 | void peap_prfplus(int version, const u8 *key, size_t key_len, 19 | const char *label, const u8 *seed, size_t seed_len, 20 | u8 *buf, size_t buf_len); 21 | 22 | #endif /* EAP_PEAP_COMMON_H */ 23 | -------------------------------------------------------------------------------- /src/crypto/fips_prf_gnutls.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FIPS 186-2 PRF for libgcrypt 3 | * Copyright (c) 2004-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | #include 17 | 18 | #include "common.h" 19 | #include "crypto.h" 20 | 21 | 22 | int fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x, size_t xlen) 23 | { 24 | /* FIX: how to do this with libgcrypt? */ 25 | return -1; 26 | } 27 | -------------------------------------------------------------------------------- /src/ap/wpa_auth_glue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / WPA authenticator glue code 3 | * Copyright (c) 2002-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef WPA_AUTH_GLUE_H 16 | #define WPA_AUTH_GLUE_H 17 | 18 | int hostapd_setup_wpa(struct hostapd_data *hapd); 19 | void hostapd_reconfig_wpa(struct hostapd_data *hapd); 20 | void hostapd_deinit_wpa(struct hostapd_data *hapd); 21 | 22 | #endif /* WPA_AUTH_GLUE_H */ 23 | -------------------------------------------------------------------------------- /src/utils/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Base64 encoding/decoding (RFC1341) 3 | * Copyright (c) 2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef BASE64_H 16 | #define BASE64_H 17 | 18 | unsigned char * base64_encode(const unsigned char *src, size_t len, 19 | size_t *out_len); 20 | unsigned char * base64_decode(const unsigned char *src, size_t len, 21 | size_t *out_len); 22 | 23 | #endif /* BASE64_H */ 24 | -------------------------------------------------------------------------------- /hostapd/hlr_auc_gw.milenage_db: -------------------------------------------------------------------------------- 1 | # Parameters for Milenage (Example algorithms for AKA). 2 | # The example Ki, OPc, and AMF values here are from 3GPP TS 35.208 v6.0.0 3 | # 4.3.20 Test Set 20. SQN is the last used SQN value. 4 | # These values can be used for both UMTS (EAP-AKA) and GSM (EAP-SIM) 5 | # authentication. In case of GSM/EAP-SIM, AMF and SQN values are not used, but 6 | # dummy values will need to be included in this file. 7 | 8 | # IMSI Ki OPc AMF SQN 9 | 232010000000000 90dca4eda45b53cf0f12d7c9c3bc6a89 cb9cccc4b9258e6dca4760379fb82581 61df 000000000000 10 | 11 | # These values are from Test Set 19 which has the AMF separation bit set to 1 12 | # and as such, is suitable for EAP-AKA' test. 13 | 555444333222111 5122250214c33e723a5dd523fc145fc0 981d464c7c52eb6e5036234984ad0bcf c3ab 16f3b3f70fc1 14 | -------------------------------------------------------------------------------- /src/crypto/dh_group5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Diffie-Hellman group 5 operations 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef DH_GROUP5_H 16 | #define DH_GROUP5_H 17 | 18 | void * dh5_init(struct wpabuf **priv, struct wpabuf **publ); 19 | struct wpabuf * dh5_derive_shared(void *ctx, const struct wpabuf *peer_public, 20 | const struct wpabuf *own_private); 21 | void dh5_free(void *ctx); 22 | 23 | #endif /* DH_GROUP5_H */ 24 | -------------------------------------------------------------------------------- /src/wps/upnp_xml.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UPnP XML helper routines 3 | * Copyright (c) 2000-2003 Intel Corporation 4 | * Copyright (c) 2006-2007 Sony Corporation 5 | * Copyright (c) 2008-2009 Atheros Communications 6 | * Copyright (c) 2009, Jouni Malinen 7 | * 8 | * See wps_upnp.c for more details on licensing and code history. 9 | */ 10 | 11 | #ifndef UPNP_XML_H 12 | #define UPNP_XML_H 13 | 14 | #include "http.h" 15 | 16 | void xml_data_encode(struct wpabuf *buf, const char *data, int len); 17 | void xml_add_tagged_data(struct wpabuf *buf, const char *tag, 18 | const char *data); 19 | char * xml_get_first_item(const char *doc, const char *item); 20 | struct wpabuf * xml_get_base64_item(const char *data, const char *name, 21 | enum http_reply_code *ret); 22 | 23 | #endif /* UPNP_XML_H */ 24 | -------------------------------------------------------------------------------- /src/crypto/crypto_none.c: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant / Empty template functions for crypto wrapper 3 | * Copyright (c) 2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "crypto.h" 19 | 20 | 21 | int md4_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac) 22 | { 23 | return 0; 24 | } 25 | 26 | 27 | void des_encrypt(const u8 *clear, const u8 *key, u8 *cypher) 28 | { 29 | } 30 | -------------------------------------------------------------------------------- /src/wps/http.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HTTP for WPS 3 | * Copyright (c) 2000-2003 Intel Corporation 4 | * Copyright (c) 2006-2007 Sony Corporation 5 | * Copyright (c) 2008-2009 Atheros Communications 6 | * Copyright (c) 2009, Jouni Malinen 7 | * 8 | * See wps_upnp.c for more details on licensing and code history. 9 | */ 10 | 11 | #ifndef HTTP_H 12 | #define HTTP_H 13 | 14 | enum http_reply_code { 15 | HTTP_OK = 200, 16 | HTTP_BAD_REQUEST = 400, 17 | UPNP_INVALID_ACTION = 401, 18 | UPNP_INVALID_ARGS = 402, 19 | HTTP_NOT_FOUND = 404, 20 | HTTP_PRECONDITION_FAILED = 412, 21 | HTTP_INTERNAL_SERVER_ERROR = 500, 22 | HTTP_UNIMPLEMENTED = 501, 23 | UPNP_ACTION_FAILED = 501, 24 | UPNP_ARG_VALUE_INVALID = 600, 25 | UPNP_ARG_VALUE_OUT_OF_RANGE = 601, 26 | UPNP_OUT_OF_MEMORY = 603 27 | }; 28 | 29 | #endif /* HTTP_H */ 30 | -------------------------------------------------------------------------------- /wpa_supplicant/wpas_glue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant - Glue code to setup EAPOL and RSN modules 3 | * Copyright (c) 2003-2008, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef WPAS_GLUE_H 16 | #define WPAS_GLUE_H 17 | 18 | int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s); 19 | int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s); 20 | void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s, 21 | struct wpa_ssid *ssid); 22 | 23 | #endif /* WPAS_GLUE_H */ 24 | -------------------------------------------------------------------------------- /src/crypto/md5_i.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MD5 internal definitions 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef MD5_I_H 16 | #define MD5_I_H 17 | 18 | struct MD5Context { 19 | u32 buf[4]; 20 | u32 bits[2]; 21 | u8 in[64]; 22 | }; 23 | 24 | void MD5Init(struct MD5Context *context); 25 | void MD5Update(struct MD5Context *context, unsigned char const *buf, 26 | unsigned len); 27 | void MD5Final(unsigned char digest[16], struct MD5Context *context); 28 | 29 | #endif /* MD5_I_H */ 30 | -------------------------------------------------------------------------------- /src/crypto/aes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AES functions 3 | * Copyright (c) 2003-2006, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef AES_H 16 | #define AES_H 17 | 18 | #define AES_BLOCK_SIZE 16 19 | 20 | void * aes_encrypt_init(const u8 *key, size_t len); 21 | void aes_encrypt(void *ctx, const u8 *plain, u8 *crypt); 22 | void aes_encrypt_deinit(void *ctx); 23 | void * aes_decrypt_init(const u8 *key, size_t len); 24 | void aes_decrypt(void *ctx, const u8 *crypt, u8 *plain); 25 | void aes_decrypt_deinit(void *ctx); 26 | 27 | #endif /* AES_H */ 28 | -------------------------------------------------------------------------------- /src/ap/ctrl_iface_ap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Control interface for shared AP commands 3 | * Copyright (c) 2004-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef CTRL_IFACE_AP_H 16 | #define CTRL_IFACE_AP_H 17 | 18 | int hostapd_ctrl_iface_sta_first(struct hostapd_data *hapd, 19 | char *buf, size_t buflen); 20 | int hostapd_ctrl_iface_sta(struct hostapd_data *hapd, const char *txtaddr, 21 | char *buf, size_t buflen); 22 | int hostapd_ctrl_iface_sta_next(struct hostapd_data *hapd, const char *txtaddr, 23 | char *buf, size_t buflen); 24 | 25 | #endif /* CTRL_IFACE_AP_H */ 26 | -------------------------------------------------------------------------------- /src/utils/edit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Command line editing and history 3 | * Copyright (c) 2010, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef EDIT_H 16 | #define EDIT_H 17 | 18 | int edit_init(void (*cmd_cb)(void *ctx, char *cmd), 19 | void (*eof_cb)(void *ctx), 20 | char ** (*completion_cb)(void *ctx, const char *cmd, int pos), 21 | void *ctx, const char *history_file); 22 | void edit_deinit(const char *history_file, 23 | int (*filter_cb)(void *ctx, const char *cmd)); 24 | void edit_clear_line(void); 25 | void edit_redraw(void); 26 | 27 | #endif /* EDIT_H */ 28 | -------------------------------------------------------------------------------- /src/crypto/sha1_i.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA1 internal definitions 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef SHA1_I_H 16 | #define SHA1_I_H 17 | 18 | struct SHA1Context { 19 | u32 state[5]; 20 | u32 count[2]; 21 | unsigned char buffer[64]; 22 | }; 23 | 24 | void SHA1Init(struct SHA1Context *context); 25 | void SHA1Update(struct SHA1Context *context, const void *data, u32 len); 26 | void SHA1Final(unsigned char digest[20], struct SHA1Context *context); 27 | void SHA1Transform(u32 state[5], const unsigned char buffer[64]); 28 | 29 | #endif /* SHA1_I_H */ 30 | -------------------------------------------------------------------------------- /src/drivers/rfkill.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Linux rfkill helper functions for driver wrappers 3 | * Copyright (c) 2010, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef RFKILL_H 16 | #define RFKILL_H 17 | 18 | struct rfkill_data; 19 | 20 | struct rfkill_config { 21 | void *ctx; 22 | char ifname[IFNAMSIZ]; 23 | void (*blocked_cb)(void *ctx); 24 | void (*unblocked_cb)(void *ctx); 25 | }; 26 | 27 | struct rfkill_data * rfkill_init(struct rfkill_config *cfg); 28 | void rfkill_deinit(struct rfkill_data *rfkill); 29 | int rfkill_is_blocked(struct rfkill_data *rfkill); 30 | 31 | #endif /* RFKILL_H */ 32 | -------------------------------------------------------------------------------- /wpa_supplicant/dbus/dbus_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wpa_supplicant D-Bus control interface - common definitions 3 | * Copyright (c) 2006, Dan Williams and Red Hat, Inc. 4 | * Copyright (c) 2009, Witold Sowa 5 | * Copyright (c) 2009, Jouni Malinen 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * Alternatively, this software may be distributed under the terms of BSD 12 | * license. 13 | * 14 | * See README and COPYING for more details. 15 | */ 16 | 17 | #ifndef DBUS_COMMON_H 18 | #define DBUS_COMMON_H 19 | 20 | struct wpas_dbus_priv; 21 | struct wpa_global; 22 | 23 | struct wpas_dbus_priv * wpas_dbus_init(struct wpa_global *global); 24 | void wpas_dbus_deinit(struct wpas_dbus_priv *priv); 25 | 26 | #endif /* DBUS_COMMON_H */ 27 | -------------------------------------------------------------------------------- /src/eap_common/chap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CHAP-MD5 (RFC 1994) 3 | * Copyright (c) 2007-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "crypto/crypto.h" 19 | #include "chap.h" 20 | 21 | int chap_md5(u8 id, const u8 *secret, size_t secret_len, const u8 *challenge, 22 | size_t challenge_len, u8 *response) 23 | { 24 | const u8 *addr[3]; 25 | size_t len[3]; 26 | 27 | addr[0] = &id; 28 | len[0] = 1; 29 | addr[1] = secret; 30 | len[1] = secret_len; 31 | addr[2] = challenge; 32 | len[2] = challenge_len; 33 | return md5_vector(3, addr, len, response); 34 | } 35 | -------------------------------------------------------------------------------- /wpa_supplicant/dbus/dbus_common_i.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wpa_supplicant D-Bus control interface - internal definitions 3 | * Copyright (c) 2006, Dan Williams and Red Hat, Inc. 4 | * Copyright (c) 2009, Witold Sowa 5 | * Copyright (c) 2009, Jouni Malinen 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * Alternatively, this software may be distributed under the terms of BSD 12 | * license. 13 | * 14 | * See README and COPYING for more details. 15 | */ 16 | 17 | #ifndef DBUS_COMMON_I_H 18 | #define DBUS_COMMON_I_H 19 | 20 | #include 21 | 22 | struct wpas_dbus_priv { 23 | DBusConnection *con; 24 | int should_dispatch; 25 | struct wpa_global *global; 26 | u32 next_objid; 27 | int dbus_new_initialized; 28 | }; 29 | 30 | #endif /* DBUS_COMMON_I_H */ 31 | -------------------------------------------------------------------------------- /src/tls/rsa.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RSA 3 | * Copyright (c) 2006, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef RSA_H 16 | #define RSA_H 17 | 18 | struct crypto_rsa_key; 19 | 20 | struct crypto_rsa_key * 21 | crypto_rsa_import_public_key(const u8 *buf, size_t len); 22 | struct crypto_rsa_key * 23 | crypto_rsa_import_private_key(const u8 *buf, size_t len); 24 | size_t crypto_rsa_get_modulus_len(struct crypto_rsa_key *key); 25 | int crypto_rsa_exptmod(const u8 *in, size_t inlen, u8 *out, size_t *outlen, 26 | struct crypto_rsa_key *key, int use_private); 27 | void crypto_rsa_free(struct crypto_rsa_key *key); 28 | 29 | #endif /* RSA_H */ 30 | -------------------------------------------------------------------------------- /src/ap/wmm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / WMM (Wi-Fi Multimedia) 3 | * Copyright 2002-2003, Instant802 Networks, Inc. 4 | * Copyright 2005-2006, Devicescape Software, Inc. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License version 2 as 8 | * published by the Free Software Foundation. 9 | * 10 | * Alternatively, this software may be distributed under the terms of BSD 11 | * license. 12 | * 13 | * See README and COPYING for more details. 14 | */ 15 | 16 | #ifndef WME_H 17 | #define WME_H 18 | 19 | struct ieee80211_mgmt; 20 | struct wmm_tspec_element; 21 | 22 | u8 * hostapd_eid_wmm(struct hostapd_data *hapd, u8 *eid); 23 | int hostapd_eid_wmm_valid(struct hostapd_data *hapd, const u8 *eid, 24 | size_t len); 25 | void hostapd_wmm_action(struct hostapd_data *hapd, 26 | const struct ieee80211_mgmt *mgmt, size_t len); 27 | int wmm_process_tspec(struct wmm_tspec_element *tspec); 28 | 29 | #endif /* WME_H */ 30 | -------------------------------------------------------------------------------- /src/crypto/dh_groups.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Diffie-Hellman groups 3 | * Copyright (c) 2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef DH_GROUPS_H 16 | #define DH_GROUPS_H 17 | 18 | struct dh_group { 19 | int id; 20 | const u8 *generator; 21 | size_t generator_len; 22 | const u8 *prime; 23 | size_t prime_len; 24 | }; 25 | 26 | const struct dh_group * dh_groups_get(int id); 27 | struct wpabuf * dh_init(const struct dh_group *dh, struct wpabuf **priv); 28 | struct wpabuf * dh_derive_shared(const struct wpabuf *peer_public, 29 | const struct wpabuf *own_private, 30 | const struct dh_group *dh); 31 | 32 | #endif /* DH_GROUPS_H */ 33 | -------------------------------------------------------------------------------- /src/crypto/sha256.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA256 hash implementation and interface functions 3 | * Copyright (c) 2003-2006, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef SHA256_H 16 | #define SHA256_H 17 | 18 | #define SHA256_MAC_LEN 32 19 | 20 | void hmac_sha256_vector(const u8 *key, size_t key_len, size_t num_elem, 21 | const u8 *addr[], const size_t *len, u8 *mac); 22 | void hmac_sha256(const u8 *key, size_t key_len, const u8 *data, 23 | size_t data_len, u8 *mac); 24 | void sha256_prf(const u8 *key, size_t key_len, const char *label, 25 | const u8 *data, size_t data_len, u8 *buf, size_t buf_len); 26 | 27 | #endif /* SHA256_H */ 28 | -------------------------------------------------------------------------------- /src/eap_common/eap_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP common peer/server definitions 3 | * Copyright (c) 2004-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef EAP_COMMON_H 16 | #define EAP_COMMON_H 17 | 18 | #include "wpabuf.h" 19 | 20 | const u8 * eap_hdr_validate(int vendor, EapType eap_type, 21 | const struct wpabuf *msg, size_t *plen); 22 | struct wpabuf * eap_msg_alloc(int vendor, EapType type, size_t payload_len, 23 | u8 code, u8 identifier); 24 | void eap_update_len(struct wpabuf *msg); 25 | u8 eap_get_id(const struct wpabuf *msg); 26 | EapType eap_get_type(const struct wpabuf *msg); 27 | 28 | #endif /* EAP_COMMON_H */ 29 | -------------------------------------------------------------------------------- /src/tls/pkcs1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PKCS #1 (RSA Encryption) 3 | * Copyright (c) 2006-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef PKCS1_H 16 | #define PKCS1_H 17 | 18 | int pkcs1_encrypt(int block_type, struct crypto_rsa_key *key, 19 | int use_private, const u8 *in, size_t inlen, 20 | u8 *out, size_t *outlen); 21 | int pkcs1_v15_private_key_decrypt(struct crypto_rsa_key *key, 22 | const u8 *in, size_t inlen, 23 | u8 *out, size_t *outlen); 24 | int pkcs1_decrypt_public_key(struct crypto_rsa_key *key, 25 | const u8 *crypt, size_t crypt_len, 26 | u8 *plain, size_t *plain_len); 27 | 28 | #endif /* PKCS1_H */ 29 | -------------------------------------------------------------------------------- /wpa_supplicant/blacklist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wpa_supplicant - Temporary BSSID blacklist 3 | * Copyright (c) 2003-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef BLACKLIST_H 16 | #define BLACKLIST_H 17 | 18 | struct wpa_blacklist { 19 | struct wpa_blacklist *next; 20 | u8 bssid[ETH_ALEN]; 21 | int count; 22 | }; 23 | 24 | struct wpa_blacklist * wpa_blacklist_get(struct wpa_supplicant *wpa_s, 25 | const u8 *bssid); 26 | int wpa_blacklist_add(struct wpa_supplicant *wpa_s, const u8 *bssid); 27 | int wpa_blacklist_del(struct wpa_supplicant *wpa_s, const u8 *bssid); 28 | void wpa_blacklist_clear(struct wpa_supplicant *wpa_s); 29 | 30 | #endif /* BLACKLIST_H */ 31 | -------------------------------------------------------------------------------- /hostapd/ctrl_iface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / UNIX domain socket -based control interface 3 | * Copyright (c) 2004, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef CTRL_IFACE_H 16 | #define CTRL_IFACE_H 17 | 18 | #ifndef CONFIG_NO_CTRL_IFACE 19 | int hostapd_ctrl_iface_init(struct hostapd_data *hapd); 20 | void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd); 21 | #else /* CONFIG_NO_CTRL_IFACE */ 22 | static inline int hostapd_ctrl_iface_init(struct hostapd_data *hapd) 23 | { 24 | return 0; 25 | } 26 | 27 | static inline void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd) 28 | { 29 | } 30 | #endif /* CONFIG_NO_CTRL_IFACE */ 31 | 32 | #endif /* CTRL_IFACE_H */ 33 | -------------------------------------------------------------------------------- /src/eap_common/eap_wsc_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP-WSC definitions for Wi-Fi Protected Setup 3 | * Copyright (c) 2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef EAP_WSC_COMMON_H 16 | #define EAP_WSC_COMMON_H 17 | 18 | #define EAP_VENDOR_TYPE_WSC 1 19 | 20 | #define WSC_FLAGS_MF 0x01 21 | #define WSC_FLAGS_LF 0x02 22 | 23 | #define WSC_ID_REGISTRAR "WFA-SimpleConfig-Registrar-1-0" 24 | #define WSC_ID_REGISTRAR_LEN 30 25 | #define WSC_ID_ENROLLEE "WFA-SimpleConfig-Enrollee-1-0" 26 | #define WSC_ID_ENROLLEE_LEN 29 27 | 28 | #define WSC_FRAGMENT_SIZE 1400 29 | 30 | 31 | struct wpabuf * eap_wsc_build_frag_ack(u8 id, u8 code); 32 | 33 | #endif /* EAP_WSC_COMMON_H */ 34 | -------------------------------------------------------------------------------- /src/utils/ip_addr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IP address processing 3 | * Copyright (c) 2003-2006, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef IP_ADDR_H 16 | #define IP_ADDR_H 17 | 18 | struct hostapd_ip_addr { 19 | int af; /* AF_INET / AF_INET6 */ 20 | union { 21 | struct in_addr v4; 22 | #ifdef CONFIG_IPV6 23 | struct in6_addr v6; 24 | #endif /* CONFIG_IPV6 */ 25 | u8 max_len[16]; 26 | } u; 27 | }; 28 | 29 | const char * hostapd_ip_txt(const struct hostapd_ip_addr *addr, char *buf, 30 | size_t buflen); 31 | int hostapd_ip_diff(struct hostapd_ip_addr *a, struct hostapd_ip_addr *b); 32 | int hostapd_parse_ip_addr(const char *txt, struct hostapd_ip_addr *addr); 33 | 34 | #endif /* IP_ADDR_H */ 35 | -------------------------------------------------------------------------------- /src/ap/ieee802_11_auth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / IEEE 802.11 authentication (ACL) 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef IEEE802_11_AUTH_H 16 | #define IEEE802_11_AUTH_H 17 | 18 | enum { 19 | HOSTAPD_ACL_REJECT = 0, 20 | HOSTAPD_ACL_ACCEPT = 1, 21 | HOSTAPD_ACL_PENDING = 2, 22 | HOSTAPD_ACL_ACCEPT_TIMEOUT = 3 23 | }; 24 | 25 | int hostapd_allowed_address(struct hostapd_data *hapd, const u8 *addr, 26 | const u8 *msg, size_t len, u32 *session_timeout, 27 | u32 *acct_interim_interval, int *vlan_id); 28 | int hostapd_acl_init(struct hostapd_data *hapd); 29 | void hostapd_acl_deinit(struct hostapd_data *hapd); 30 | 31 | #endif /* IEEE802_11_AUTH_H */ 32 | -------------------------------------------------------------------------------- /src/crypto/des_i.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DES and 3DES-EDE ciphers 3 | * Copyright (c) 2006-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef DES_I_H 16 | #define DES_I_H 17 | 18 | struct des3_key_s { 19 | u32 ek[3][32]; 20 | u32 dk[3][32]; 21 | }; 22 | 23 | void des_key_setup(const u8 *key, u32 *ek, u32 *dk); 24 | void des_block_encrypt(const u8 *plain, const u32 *ek, u8 *crypt); 25 | void des_block_decrypt(const u8 *crypt, const u32 *dk, u8 *plain); 26 | 27 | void des3_key_setup(const u8 *key, struct des3_key_s *dkey); 28 | void des3_encrypt(const u8 *plain, const struct des3_key_s *key, u8 *crypt); 29 | void des3_decrypt(const u8 *crypt, const struct des3_key_s *key, u8 *plain); 30 | 31 | #endif /* DES_I_H */ 32 | -------------------------------------------------------------------------------- /src/crypto/dh_group5.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Diffie-Hellman group 5 operations 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "dh_groups.h" 19 | #include "dh_group5.h" 20 | 21 | 22 | void * dh5_init(struct wpabuf **priv, struct wpabuf **publ) 23 | { 24 | *publ = dh_init(dh_groups_get(5), priv); 25 | if (*publ == 0) 26 | return NULL; 27 | return (void *) 1; 28 | } 29 | 30 | 31 | struct wpabuf * dh5_derive_shared(void *ctx, const struct wpabuf *peer_public, 32 | const struct wpabuf *own_private) 33 | { 34 | return dh_derive_shared(peer_public, own_private, dh_groups_get(5)); 35 | } 36 | 37 | 38 | void dh5_free(void *ctx) 39 | { 40 | } 41 | -------------------------------------------------------------------------------- /src/crypto/aes-encblock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AES encrypt_block 3 | * 4 | * Copyright (c) 2003-2007, Jouni Malinen 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License version 2 as 8 | * published by the Free Software Foundation. 9 | * 10 | * Alternatively, this software may be distributed under the terms of BSD 11 | * license. 12 | * 13 | * See README and COPYING for more details. 14 | */ 15 | 16 | #include "includes.h" 17 | 18 | #include "common.h" 19 | #include "aes.h" 20 | #include "aes_wrap.h" 21 | 22 | /** 23 | * aes_128_encrypt_block - Perform one AES 128-bit block operation 24 | * @key: Key for AES 25 | * @in: Input data (16 bytes) 26 | * @out: Output of the AES block operation (16 bytes) 27 | * Returns: 0 on success, -1 on failure 28 | */ 29 | int aes_128_encrypt_block(const u8 *key, const u8 *in, u8 *out) 30 | { 31 | void *ctx; 32 | ctx = aes_encrypt_init(key, 16); 33 | if (ctx == NULL) 34 | return -1; 35 | aes_encrypt(ctx, in, out); 36 | aes_encrypt_deinit(ctx); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /src/drivers/netlink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Netlink helper functions for driver wrappers 3 | * Copyright (c) 2002-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef NETLINK_H 16 | #define NETLINK_H 17 | 18 | struct netlink_data; 19 | struct ifinfomsg; 20 | 21 | struct netlink_config { 22 | void *ctx; 23 | void (*newlink_cb)(void *ctx, struct ifinfomsg *ifi, u8 *buf, 24 | size_t len); 25 | void (*dellink_cb)(void *ctx, struct ifinfomsg *ifi, u8 *buf, 26 | size_t len); 27 | }; 28 | 29 | struct netlink_data * netlink_init(struct netlink_config *cfg); 30 | void netlink_deinit(struct netlink_data *netlink); 31 | int netlink_send_oper_ifla(struct netlink_data *netlink, int ifindex, 32 | int linkmode, int operstate); 33 | 34 | #endif /* NETLINK_H */ 35 | -------------------------------------------------------------------------------- /src/drivers/linux_ioctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Linux ioctl helper functions for driver wrappers 3 | * Copyright (c) 2002-2010, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef LINUX_IOCTL_H 16 | #define LINUX_IOCTL_H 17 | 18 | int linux_set_iface_flags(int sock, const char *ifname, int dev_up); 19 | int linux_get_ifhwaddr(int sock, const char *ifname, u8 *addr); 20 | int linux_set_ifhwaddr(int sock, const char *ifname, const u8 *addr); 21 | int linux_br_add(int sock, const char *brname); 22 | int linux_br_del(int sock, const char *brname); 23 | int linux_br_add_if(int sock, const char *brname, const char *ifname); 24 | int linux_br_del_if(int sock, const char *brname, const char *ifname); 25 | int linux_br_get(char *brname, const char *ifname); 26 | 27 | #endif /* LINUX_IOCTL_H */ 28 | -------------------------------------------------------------------------------- /src/crypto/Makefile: -------------------------------------------------------------------------------- 1 | all: libcrypto.a 2 | 3 | clean: 4 | rm -f *~ *.o *.d libcrypto.a 5 | 6 | install: 7 | @echo Nothing to be made. 8 | 9 | 10 | include ../lib.rules 11 | 12 | CFLAGS += -DCONFIG_TLS_INTERNAL_CLIENT 13 | CFLAGS += -DCONFIG_TLS_INTERNAL_SERVER 14 | #CFLAGS += -DALL_DH_GROUPS 15 | 16 | LIB_OBJS= \ 17 | aes-cbc.o \ 18 | aes-ctr.o \ 19 | aes-eax.o \ 20 | aes-encblock.o \ 21 | aes-internal.o \ 22 | aes-internal-dec.o \ 23 | aes-internal-enc.o \ 24 | aes-omac1.o \ 25 | aes-unwrap.o \ 26 | aes-wrap.o \ 27 | des-internal.o \ 28 | dh_group5.o \ 29 | dh_groups.o \ 30 | md4-internal.o \ 31 | md5.o \ 32 | md5-internal.o \ 33 | md5-non-fips.o \ 34 | milenage.o \ 35 | ms_funcs.o \ 36 | rc4.o \ 37 | sha1.o \ 38 | sha1-internal.o \ 39 | sha1-pbkdf2.o \ 40 | sha1-tlsprf.o \ 41 | sha1-tprf.o \ 42 | sha256.o \ 43 | sha256-internal.o 44 | 45 | LIB_OBJS += crypto_internal.o 46 | LIB_OBJS += crypto_internal-cipher.o 47 | LIB_OBJS += crypto_internal-modexp.o 48 | LIB_OBJS += crypto_internal-rsa.o 49 | LIB_OBJS += tls_internal.o 50 | LIB_OBJS += fips_prf_internal.o 51 | 52 | 53 | libcrypto.a: $(LIB_OBJS) 54 | $(AR) crT $@ $? 55 | 56 | -include $(OBJS:%.o=%.d) 57 | -------------------------------------------------------------------------------- /src/ap/beacon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / IEEE 802.11 Management: Beacon and Probe Request/Response 3 | * Copyright (c) 2002-2004, Instant802 Networks, Inc. 4 | * Copyright (c) 2005-2006, Devicescape Software, Inc. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License version 2 as 8 | * published by the Free Software Foundation. 9 | * 10 | * Alternatively, this software may be distributed under the terms of BSD 11 | * license. 12 | * 13 | * See README and COPYING for more details. 14 | */ 15 | 16 | #ifndef BEACON_H 17 | #define BEACON_H 18 | 19 | struct ieee80211_mgmt; 20 | 21 | void handle_probe_req(struct hostapd_data *hapd, 22 | const struct ieee80211_mgmt *mgmt, size_t len); 23 | #ifdef NEED_AP_MLME 24 | void ieee802_11_set_beacon(struct hostapd_data *hapd); 25 | void ieee802_11_set_beacons(struct hostapd_iface *iface); 26 | #else /* NEED_AP_MLME */ 27 | static inline void ieee802_11_set_beacon(struct hostapd_data *hapd) 28 | { 29 | } 30 | 31 | static inline void ieee802_11_set_beacons(struct hostapd_iface *iface) 32 | { 33 | } 34 | #endif /* NEED_AP_MLME */ 35 | 36 | #endif /* BEACON_H */ 37 | -------------------------------------------------------------------------------- /src/eap_common/eap_wsc_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP-WSC common routines for Wi-Fi Protected Setup 3 | * Copyright (c) 2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "eap_defs.h" 19 | #include "eap_common.h" 20 | #include "wps/wps.h" 21 | #include "eap_wsc_common.h" 22 | 23 | struct wpabuf * eap_wsc_build_frag_ack(u8 id, u8 code) 24 | { 25 | struct wpabuf *msg; 26 | 27 | msg = eap_msg_alloc(EAP_VENDOR_WFA, EAP_VENDOR_TYPE_WSC, 2, code, id); 28 | if (msg == NULL) { 29 | wpa_printf(MSG_ERROR, "EAP-WSC: Failed to allocate memory for " 30 | "FRAG_ACK"); 31 | return NULL; 32 | } 33 | 34 | wpa_printf(MSG_DEBUG, "EAP-WSC: Send WSC/FRAG_ACK"); 35 | wpabuf_put_u8(msg, WSC_FRAG_ACK); /* Op-Code */ 36 | wpabuf_put_u8(msg, 0); /* Flags */ 37 | 38 | return msg; 39 | } 40 | -------------------------------------------------------------------------------- /src/crypto/random.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Random number generator 3 | * Copyright (c) 2010-2011, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef RANDOM_H 16 | #define RANDOM_H 17 | 18 | #ifdef CONFIG_NO_RANDOM_POOL 19 | #define random_init() do { } while (0) 20 | #define random_deinit() do { } while (0) 21 | #define random_add_randomness(b, l) do { } while (0) 22 | #define random_get_bytes(b, l) os_get_random((b), (l)) 23 | #define random_pool_ready() 1 24 | #define random_mark_pool_ready() do { } while (0) 25 | #else /* CONFIG_NO_RANDOM_POOL */ 26 | void random_init(void); 27 | void random_deinit(void); 28 | void random_add_randomness(const void *buf, size_t len); 29 | int random_get_bytes(void *buf, size_t len); 30 | int random_pool_ready(void); 31 | void random_mark_pool_ready(void); 32 | #endif /* CONFIG_NO_RANDOM_POOL */ 33 | 34 | #endif /* RANDOM_H */ 35 | -------------------------------------------------------------------------------- /src/eap_peer/mschapv2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MSCHAPV2 (RFC 2759) 3 | * Copyright (c) 2004-2008, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef MSCHAPV2_H 16 | #define MSCHAPV2_H 17 | 18 | #define MSCHAPV2_CHAL_LEN 16 19 | #define MSCHAPV2_NT_RESPONSE_LEN 24 20 | #define MSCHAPV2_AUTH_RESPONSE_LEN 20 21 | #define MSCHAPV2_MASTER_KEY_LEN 16 22 | 23 | const u8 * mschapv2_remove_domain(const u8 *username, size_t *len); 24 | int mschapv2_derive_response(const u8 *username, size_t username_len, 25 | const u8 *password, size_t password_len, 26 | int pwhash, 27 | const u8 *auth_challenge, 28 | const u8 *peer_challenge, 29 | u8 *nt_response, u8 *auth_response, 30 | u8 *master_key); 31 | int mschapv2_verify_auth_response(const u8 *auth_response, 32 | const u8 *buf, size_t buf_len); 33 | 34 | #endif /* MSCHAPV2_H */ 35 | -------------------------------------------------------------------------------- /src/ap/iapp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / IEEE 802.11F-2003 Inter-Access Point Protocol (IAPP) 3 | * Copyright (c) 2002-2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef IAPP_H 16 | #define IAPP_H 17 | 18 | struct iapp_data; 19 | 20 | #ifdef CONFIG_IAPP 21 | 22 | void iapp_new_station(struct iapp_data *iapp, struct sta_info *sta); 23 | struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface); 24 | void iapp_deinit(struct iapp_data *iapp); 25 | 26 | #else /* CONFIG_IAPP */ 27 | 28 | static inline void iapp_new_station(struct iapp_data *iapp, 29 | struct sta_info *sta) 30 | { 31 | } 32 | 33 | static inline struct iapp_data * iapp_init(struct hostapd_data *hapd, 34 | const char *iface) 35 | { 36 | return NULL; 37 | } 38 | 39 | static inline void iapp_deinit(struct iapp_data *iapp) 40 | { 41 | } 42 | 43 | #endif /* CONFIG_IAPP */ 44 | 45 | #endif /* IAPP_H */ 46 | -------------------------------------------------------------------------------- /wpa_supplicant/main_none.c: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant / Example program entrypoint 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "wpa_supplicant_i.h" 19 | 20 | int main(int argc, char *argv[]) 21 | { 22 | struct wpa_interface iface; 23 | int exitcode = 0; 24 | struct wpa_params params; 25 | struct wpa_global *global; 26 | 27 | memset(¶ms, 0, sizeof(params)); 28 | params.wpa_debug_level = MSG_INFO; 29 | 30 | global = wpa_supplicant_init(¶ms); 31 | if (global == NULL) 32 | return -1; 33 | 34 | memset(&iface, 0, sizeof(iface)); 35 | /* TODO: set interface parameters */ 36 | 37 | if (wpa_supplicant_add_iface(global, &iface) == NULL) 38 | exitcode = -1; 39 | 40 | if (exitcode == 0) 41 | exitcode = wpa_supplicant_run(global); 42 | 43 | wpa_supplicant_deinit(global); 44 | 45 | return exitcode; 46 | } 47 | -------------------------------------------------------------------------------- /src/ap/p2p_hostapd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / P2P integration 3 | * Copyright (c) 2009-2010, Atheros Communications 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef P2P_HOSTAPD_H 16 | #define P2P_HOSTAPD_H 17 | 18 | #ifdef CONFIG_P2P 19 | 20 | int hostapd_p2p_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta, 21 | char *buf, size_t buflen); 22 | int hostapd_p2p_set_noa(struct hostapd_data *hapd, u8 count, int start, 23 | int duration); 24 | void hostapd_p2p_non_p2p_sta_connected(struct hostapd_data *hapd); 25 | void hostapd_p2p_non_p2p_sta_disconnected(struct hostapd_data *hapd); 26 | 27 | 28 | #else /* CONFIG_P2P */ 29 | 30 | static inline int hostapd_p2p_get_mib_sta(struct hostapd_data *hapd, 31 | struct sta_info *sta, 32 | char *buf, size_t buflen) 33 | { 34 | return 0; 35 | } 36 | 37 | #endif /* CONFIG_P2P */ 38 | 39 | u8 * hostapd_eid_p2p_manage(struct hostapd_data *hapd, u8 *eid); 40 | 41 | #endif /* P2P_HOSTAPD_H */ 42 | -------------------------------------------------------------------------------- /src/crypto/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MD5 hash implementation and interface functions 3 | * Copyright (c) 2003-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef MD5_H 16 | #define MD5_H 17 | 18 | #define MD5_MAC_LEN 16 19 | 20 | int hmac_md5_vector(const u8 *key, size_t key_len, size_t num_elem, 21 | const u8 *addr[], const size_t *len, u8 *mac); 22 | int hmac_md5(const u8 *key, size_t key_len, const u8 *data, size_t data_len, 23 | u8 *mac); 24 | #ifdef CONFIG_FIPS 25 | int hmac_md5_vector_non_fips_allow(const u8 *key, size_t key_len, 26 | size_t num_elem, const u8 *addr[], 27 | const size_t *len, u8 *mac); 28 | int hmac_md5_non_fips_allow(const u8 *key, size_t key_len, const u8 *data, 29 | size_t data_len, u8 *mac); 30 | #else /* CONFIG_FIPS */ 31 | #define hmac_md5_vector_non_fips_allow hmac_md5_vector 32 | #define hmac_md5_non_fips_allow hmac_md5 33 | #endif /* CONFIG_FIPS */ 34 | 35 | #endif /* MD5_H */ 36 | -------------------------------------------------------------------------------- /wpa_supplicant/main_symbian.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant / Program entrypoint for Symbian 3 | * Copyright (c) 2003-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | extern "C" { 18 | #include "common.h" 19 | #include "wpa_supplicant_i.h" 20 | } 21 | 22 | GLDEF_C TInt E32Main(void) 23 | { 24 | struct wpa_interface iface; 25 | int exitcode = 0; 26 | struct wpa_params params; 27 | struct wpa_global *global; 28 | 29 | memset(¶ms, 0, sizeof(params)); 30 | params.wpa_debug_level = MSG_INFO; 31 | 32 | global = wpa_supplicant_init(¶ms); 33 | if (global == NULL) 34 | return -1; 35 | 36 | memset(&iface, 0, sizeof(iface)); 37 | /* TODO: set interface parameters */ 38 | 39 | if (wpa_supplicant_add_iface(global, &iface) == NULL) 40 | exitcode = -1; 41 | 42 | if (exitcode == 0) 43 | exitcode = wpa_supplicant_run(global); 44 | 45 | wpa_supplicant_deinit(global); 46 | 47 | return exitcode; 48 | } 49 | -------------------------------------------------------------------------------- /hostapd/wired.conf: -------------------------------------------------------------------------------- 1 | ##### hostapd configuration file ############################################## 2 | # Empty lines and lines starting with # are ignored 3 | 4 | # Example configuration file for wired authenticator. See hostapd.conf for 5 | # more details. 6 | 7 | interface=eth0 8 | driver=wired 9 | logger_stdout=-1 10 | logger_stdout_level=1 11 | debug=2 12 | dump_file=/tmp/hostapd.dump 13 | 14 | ieee8021x=1 15 | eap_reauth_period=3600 16 | 17 | use_pae_group_addr=1 18 | 19 | 20 | ##### RADIUS configuration #################################################### 21 | # for IEEE 802.1X with external Authentication Server, IEEE 802.11 22 | # authentication with external ACL for MAC addresses, and accounting 23 | 24 | # The own IP address of the access point (used as NAS-IP-Address) 25 | own_ip_addr=127.0.0.1 26 | 27 | # Optional NAS-Identifier string for RADIUS messages. When used, this should be 28 | # a unique to the NAS within the scope of the RADIUS server. For example, a 29 | # fully qualified domain name can be used here. 30 | nas_identifier=ap.example.com 31 | 32 | # RADIUS authentication server 33 | auth_server_addr=127.0.0.1 34 | auth_server_port=1812 35 | auth_server_shared_secret=radius 36 | 37 | # RADIUS accounting server 38 | acct_server_addr=127.0.0.1 39 | acct_server_port=1813 40 | acct_server_shared_secret=radius 41 | -------------------------------------------------------------------------------- /src/common/eapol_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAPOL definitions shared between hostapd and wpa_supplicant 3 | * Copyright (c) 2002-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef EAPOL_COMMON_H 16 | #define EAPOL_COMMON_H 17 | 18 | /* IEEE Std 802.1X-2004 */ 19 | 20 | #ifdef _MSC_VER 21 | #pragma pack(push, 1) 22 | #endif /* _MSC_VER */ 23 | 24 | struct ieee802_1x_hdr { 25 | u8 version; 26 | u8 type; 27 | be16 length; 28 | /* followed by length octets of data */ 29 | } STRUCT_PACKED; 30 | 31 | #ifdef _MSC_VER 32 | #pragma pack(pop) 33 | #endif /* _MSC_VER */ 34 | 35 | #define EAPOL_VERSION 2 36 | 37 | enum { IEEE802_1X_TYPE_EAP_PACKET = 0, 38 | IEEE802_1X_TYPE_EAPOL_START = 1, 39 | IEEE802_1X_TYPE_EAPOL_LOGOFF = 2, 40 | IEEE802_1X_TYPE_EAPOL_KEY = 3, 41 | IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4 42 | }; 43 | 44 | enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2, 45 | EAPOL_KEY_TYPE_WPA = 254 }; 46 | 47 | #endif /* EAPOL_COMMON_H */ 48 | -------------------------------------------------------------------------------- /wpa_supplicant/dbus/dbus-wpa_supplicant.conf: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/crypto/milenage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UMTS AKA - Milenage algorithm (3GPP TS 35.205, .206, .207, .208) 3 | * Copyright (c) 2006-2007 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef MILENAGE_H 16 | #define MILENAGE_H 17 | 18 | void milenage_generate(const u8 *opc, const u8 *amf, const u8 *k, 19 | const u8 *sqn, const u8 *_rand, u8 *autn, u8 *ik, 20 | u8 *ck, u8 *res, size_t *res_len); 21 | int milenage_auts(const u8 *opc, const u8 *k, const u8 *_rand, const u8 *auts, 22 | u8 *sqn); 23 | int gsm_milenage(const u8 *opc, const u8 *k, const u8 *_rand, u8 *sres, 24 | u8 *kc); 25 | int milenage_check(const u8 *opc, const u8 *k, const u8 *sqn, const u8 *_rand, 26 | const u8 *autn, u8 *ik, u8 *ck, u8 *res, size_t *res_len, 27 | u8 *auts); 28 | int milenage_f1(const u8 *opc, const u8 *k, const u8 *_rand, 29 | const u8 *sqn, const u8 *amf, u8 *mac_a, u8 *mac_s); 30 | int milenage_f2345(const u8 *opc, const u8 *k, const u8 *_rand, 31 | u8 *res, u8 *ck, u8 *ik, u8 *ak, u8 *akstar); 32 | 33 | #endif /* MILENAGE_H */ 34 | -------------------------------------------------------------------------------- /hostapd/nt_password_hash.c: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd - Plaintext password to NtPasswordHash 3 | * Copyright (c) 2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "crypto/ms_funcs.h" 19 | 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | unsigned char password_hash[16]; 24 | size_t i; 25 | char *password, buf[64], *pos; 26 | 27 | if (argc > 1) 28 | password = argv[1]; 29 | else { 30 | if (fgets(buf, sizeof(buf), stdin) == NULL) { 31 | printf("Failed to read password\n"); 32 | return 1; 33 | } 34 | buf[sizeof(buf) - 1] = '\0'; 35 | pos = buf; 36 | while (*pos != '\0') { 37 | if (*pos == '\r' || *pos == '\n') { 38 | *pos = '\0'; 39 | break; 40 | } 41 | pos++; 42 | } 43 | password = buf; 44 | } 45 | 46 | if (nt_password_hash((u8 *) password, strlen(password), password_hash)) 47 | return -1; 48 | for (i = 0; i < sizeof(password_hash); i++) 49 | printf("%02x", password_hash[i]); 50 | printf("\n"); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /wpa_supplicant/win_example.reg: -------------------------------------------------------------------------------- 1 | REGEDIT4 2 | 3 | [HKEY_LOCAL_MACHINE\SOFTWARE\wpa_supplicant] 4 | "debug_level"=dword:00000000 5 | "debug_show_keys"=dword:00000001 6 | "debug_timestamp"=dword:00000000 7 | "debug_use_file"=dword:00000000 8 | 9 | [HKEY_LOCAL_MACHINE\SOFTWARE\wpa_supplicant\configs] 10 | 11 | [HKEY_LOCAL_MACHINE\SOFTWARE\wpa_supplicant\configs\test] 12 | "ap_scan"=dword:00000002 13 | "update_config"=dword:00000001 14 | "uuid"="12345678-9abc-def0-1234-56789abcdef0" 15 | "device_name"="Wireless Client" 16 | "manufacturer"="Company" 17 | "model_name"="cmodel" 18 | "serial_number"="12345" 19 | "device_type"="1-0050F204-1" 20 | "os_version"="01020300" 21 | 22 | [HKEY_LOCAL_MACHINE\SOFTWARE\wpa_supplicant\configs\test\blobs] 23 | "testblob"=hex:01,02,03,04,05 24 | 25 | [HKEY_LOCAL_MACHINE\SOFTWARE\wpa_supplicant\configs\test\networks] 26 | 27 | [HKEY_LOCAL_MACHINE\SOFTWARE\wpa_supplicant\configs\test\networks\0000] 28 | "ssid"="\"example network\"" 29 | "key_mgmt"="WPA-PSK" 30 | "psk"="\"secret password\"" 31 | "pairwise"="CCMP" 32 | "group"="CCMP" 33 | "proto"="WPA" 34 | 35 | [HKEY_LOCAL_MACHINE\SOFTWARE\wpa_supplicant\interfaces] 36 | 37 | [HKEY_LOCAL_MACHINE\SOFTWARE\wpa_supplicant\interfaces\0000] 38 | "adapter"="{A7627643-C310-49E5-BD89-7E77709C04AB}" 39 | "config"="test" 40 | "ctrl_interface"="" 41 | "skip_on_error"=dword:00000000 42 | 43 | -------------------------------------------------------------------------------- /src/ap/ap_mlme.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / IEEE 802.11 MLME 3 | * Copyright 2003, Jouni Malinen 4 | * Copyright 2003-2004, Instant802 Networks, Inc. 5 | * Copyright 2005-2006, Devicescape Software, Inc. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * Alternatively, this software may be distributed under the terms of BSD 12 | * license. 13 | * 14 | * See README and COPYING for more details. 15 | */ 16 | 17 | #ifndef MLME_H 18 | #define MLME_H 19 | 20 | void mlme_authenticate_indication(struct hostapd_data *hapd, 21 | struct sta_info *sta); 22 | 23 | void mlme_deauthenticate_indication(struct hostapd_data *hapd, 24 | struct sta_info *sta, u16 reason_code); 25 | 26 | void mlme_associate_indication(struct hostapd_data *hapd, 27 | struct sta_info *sta); 28 | 29 | void mlme_reassociate_indication(struct hostapd_data *hapd, 30 | struct sta_info *sta); 31 | 32 | void mlme_disassociate_indication(struct hostapd_data *hapd, 33 | struct sta_info *sta, u16 reason_code); 34 | 35 | void mlme_michaelmicfailure_indication(struct hostapd_data *hapd, 36 | const u8 *addr); 37 | 38 | void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta); 39 | 40 | #endif /* MLME_H */ 41 | -------------------------------------------------------------------------------- /src/crypto/sha1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA1 hash implementation and interface functions 3 | * Copyright (c) 2003-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef SHA1_H 16 | #define SHA1_H 17 | 18 | #define SHA1_MAC_LEN 20 19 | 20 | int hmac_sha1_vector(const u8 *key, size_t key_len, size_t num_elem, 21 | const u8 *addr[], const size_t *len, u8 *mac); 22 | int hmac_sha1(const u8 *key, size_t key_len, const u8 *data, size_t data_len, 23 | u8 *mac); 24 | int sha1_prf(const u8 *key, size_t key_len, const char *label, 25 | const u8 *data, size_t data_len, u8 *buf, size_t buf_len); 26 | int sha1_t_prf(const u8 *key, size_t key_len, const char *label, 27 | const u8 *seed, size_t seed_len, u8 *buf, size_t buf_len); 28 | int __must_check tls_prf(const u8 *secret, size_t secret_len, 29 | const char *label, const u8 *seed, size_t seed_len, 30 | u8 *out, size_t outlen); 31 | int pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len, 32 | int iterations, u8 *buf, size_t buflen); 33 | #endif /* SHA1_H */ 34 | -------------------------------------------------------------------------------- /src/eap_peer/tncc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP-TNC - TNCC (IF-IMC and IF-TNCCS) 3 | * Copyright (c) 2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef TNCC_H 16 | #define TNCC_H 17 | 18 | struct tncc_data; 19 | 20 | struct tncc_data * tncc_init(void); 21 | void tncc_deinit(struct tncc_data *tncc); 22 | void tncc_init_connection(struct tncc_data *tncc); 23 | size_t tncc_total_send_len(struct tncc_data *tncc); 24 | u8 * tncc_copy_send_buf(struct tncc_data *tncc, u8 *pos); 25 | char * tncc_if_tnccs_start(struct tncc_data *tncc); 26 | char * tncc_if_tnccs_end(void); 27 | 28 | enum tncc_process_res { 29 | TNCCS_PROCESS_ERROR = -1, 30 | TNCCS_PROCESS_OK_NO_RECOMMENDATION = 0, 31 | TNCCS_RECOMMENDATION_ERROR, 32 | TNCCS_RECOMMENDATION_ALLOW, 33 | TNCCS_RECOMMENDATION_NONE, 34 | TNCCS_RECOMMENDATION_ISOLATE 35 | }; 36 | 37 | enum tncc_process_res tncc_process_if_tnccs(struct tncc_data *tncc, 38 | const u8 *msg, size_t len); 39 | 40 | struct wpabuf * tncc_process_soh_request(int ver, const u8 *data, size_t len); 41 | 42 | #endif /* TNCC_H */ 43 | -------------------------------------------------------------------------------- /src/utils/radiotap_iter.h: -------------------------------------------------------------------------------- 1 | #ifndef __RADIOTAP_ITER_H 2 | #define __RADIOTAP_ITER_H 3 | 4 | #include "radiotap.h" 5 | 6 | /* Radiotap header iteration 7 | * implemented in radiotap.c 8 | */ 9 | /** 10 | * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args 11 | * @rtheader: pointer to the radiotap header we are walking through 12 | * @max_length: length of radiotap header in cpu byte ordering 13 | * @this_arg_index: IEEE80211_RADIOTAP_... index of current arg 14 | * @this_arg: pointer to current radiotap arg 15 | * @arg_index: internal next argument index 16 | * @arg: internal next argument pointer 17 | * @next_bitmap: internal pointer to next present u32 18 | * @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present 19 | */ 20 | 21 | struct ieee80211_radiotap_iterator { 22 | struct ieee80211_radiotap_header *rtheader; 23 | int max_length; 24 | int this_arg_index; 25 | unsigned char *this_arg; 26 | 27 | int arg_index; 28 | unsigned char *arg; 29 | uint32_t *next_bitmap; 30 | uint32_t bitmap_shifter; 31 | }; 32 | 33 | extern int ieee80211_radiotap_iterator_init( 34 | struct ieee80211_radiotap_iterator *iterator, 35 | struct ieee80211_radiotap_header *radiotap_header, 36 | int max_length); 37 | 38 | extern int ieee80211_radiotap_iterator_next( 39 | struct ieee80211_radiotap_iterator *iterator); 40 | 41 | #endif /* __RADIOTAP_ITER_H */ 42 | -------------------------------------------------------------------------------- /src/eap_common/eap_ikev2_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP-IKEv2 definitions 3 | * Copyright (c) 2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef EAP_IKEV2_COMMON_H 16 | #define EAP_IKEV2_COMMON_H 17 | 18 | #ifdef CCNS_PL 19 | /* incorrect bit order */ 20 | #define IKEV2_FLAGS_LENGTH_INCLUDED 0x01 21 | #define IKEV2_FLAGS_MORE_FRAGMENTS 0x02 22 | #define IKEV2_FLAGS_ICV_INCLUDED 0x04 23 | #else /* CCNS_PL */ 24 | #define IKEV2_FLAGS_LENGTH_INCLUDED 0x80 25 | #define IKEV2_FLAGS_MORE_FRAGMENTS 0x40 26 | #define IKEV2_FLAGS_ICV_INCLUDED 0x20 27 | #endif /* CCNS_PL */ 28 | 29 | #define IKEV2_FRAGMENT_SIZE 1400 30 | 31 | struct ikev2_keys; 32 | 33 | int eap_ikev2_derive_keymat(int prf, struct ikev2_keys *keys, 34 | const u8 *i_nonce, size_t i_nonce_len, 35 | const u8 *r_nonce, size_t r_nonce_len, 36 | u8 *keymat); 37 | struct wpabuf * eap_ikev2_build_frag_ack(u8 id, u8 code); 38 | int eap_ikev2_validate_icv(int integ_alg, struct ikev2_keys *keys, 39 | int initiator, const struct wpabuf *msg, 40 | const u8 *pos, const u8 *end); 41 | 42 | #endif /* EAP_IKEV2_COMMON_H */ 43 | -------------------------------------------------------------------------------- /src/ap/accounting.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / RADIUS Accounting 3 | * Copyright (c) 2002-2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef ACCOUNTING_H 16 | #define ACCOUNTING_H 17 | 18 | void accounting_sta_interim(struct hostapd_data *hapd, struct sta_info *sta); 19 | #ifdef CONFIG_NO_ACCOUNTING 20 | static inline void accounting_sta_start(struct hostapd_data *hapd, 21 | struct sta_info *sta) 22 | { 23 | } 24 | 25 | static inline void accounting_sta_stop(struct hostapd_data *hapd, 26 | struct sta_info *sta) 27 | { 28 | } 29 | 30 | static inline int accounting_init(struct hostapd_data *hapd) 31 | { 32 | return 0; 33 | } 34 | 35 | static inline void accounting_deinit(struct hostapd_data *hapd) 36 | { 37 | } 38 | #else /* CONFIG_NO_ACCOUNTING */ 39 | void accounting_sta_start(struct hostapd_data *hapd, struct sta_info *sta); 40 | void accounting_sta_stop(struct hostapd_data *hapd, struct sta_info *sta); 41 | int accounting_init(struct hostapd_data *hapd); 42 | void accounting_deinit(struct hostapd_data *hapd); 43 | #endif /* CONFIG_NO_ACCOUNTING */ 44 | 45 | #endif /* ACCOUNTING_H */ 46 | -------------------------------------------------------------------------------- /src/crypto/rc4.c: -------------------------------------------------------------------------------- 1 | /* 2 | * RC4 stream cipher 3 | * Copyright (c) 2002-2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "crypto.h" 19 | 20 | #define S_SWAP(a,b) do { u8 t = S[a]; S[a] = S[b]; S[b] = t; } while(0) 21 | 22 | int rc4_skip(const u8 *key, size_t keylen, size_t skip, 23 | u8 *data, size_t data_len) 24 | { 25 | u32 i, j, k; 26 | u8 S[256], *pos; 27 | size_t kpos; 28 | 29 | /* Setup RC4 state */ 30 | for (i = 0; i < 256; i++) 31 | S[i] = i; 32 | j = 0; 33 | kpos = 0; 34 | for (i = 0; i < 256; i++) { 35 | j = (j + S[i] + key[kpos]) & 0xff; 36 | kpos++; 37 | if (kpos >= keylen) 38 | kpos = 0; 39 | S_SWAP(i, j); 40 | } 41 | 42 | /* Skip the start of the stream */ 43 | i = j = 0; 44 | for (k = 0; k < skip; k++) { 45 | i = (i + 1) & 0xff; 46 | j = (j + S[i]) & 0xff; 47 | S_SWAP(i, j); 48 | } 49 | 50 | /* Apply RC4 to data */ 51 | pos = data; 52 | for (k = 0; k < data_len; k++) { 53 | i = (i + 1) & 0xff; 54 | j = (j + S[i]) & 0xff; 55 | S_SWAP(i, j); 56 | *pos++ ^= S[(S[i] + S[j]) & 0xff]; 57 | } 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /wpa_supplicant/ibss_rsn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wpa_supplicant - IBSS RSN 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef IBSS_RSN_H 16 | #define IBSS_RSN_H 17 | 18 | struct ibss_rsn; 19 | 20 | struct ibss_rsn_peer { 21 | struct ibss_rsn_peer *next; 22 | struct ibss_rsn *ibss_rsn; 23 | 24 | u8 addr[ETH_ALEN]; 25 | 26 | struct wpa_sm *supp; 27 | enum wpa_states supp_state; 28 | u8 supp_ie[80]; 29 | size_t supp_ie_len; 30 | 31 | struct wpa_state_machine *auth; 32 | }; 33 | 34 | struct ibss_rsn { 35 | struct wpa_supplicant *wpa_s; 36 | struct wpa_authenticator *auth_group; 37 | struct ibss_rsn_peer *peers; 38 | u8 psk[PMK_LEN]; 39 | }; 40 | 41 | 42 | struct ibss_rsn * ibss_rsn_init(struct wpa_supplicant *wpa_s); 43 | void ibss_rsn_deinit(struct ibss_rsn *ibss_rsn); 44 | int ibss_rsn_start(struct ibss_rsn *ibss_rsn, const u8 *addr); 45 | void ibss_rsn_stop(struct ibss_rsn *ibss_rsn, const u8 *peermac); 46 | int ibss_rsn_rx_eapol(struct ibss_rsn *ibss_rsn, const u8 *src_addr, 47 | const u8 *buf, size_t len); 48 | void ibss_rsn_set_psk(struct ibss_rsn *ibss_rsn, const u8 *psk); 49 | 50 | #endif /* IBSS_RSN_H */ 51 | -------------------------------------------------------------------------------- /src/tls/bignum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Big number math 3 | * Copyright (c) 2006, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef BIGNUM_H 16 | #define BIGNUM_H 17 | 18 | struct bignum; 19 | 20 | struct bignum * bignum_init(void); 21 | void bignum_deinit(struct bignum *n); 22 | size_t bignum_get_unsigned_bin_len(struct bignum *n); 23 | int bignum_get_unsigned_bin(const struct bignum *n, u8 *buf, size_t *len); 24 | int bignum_set_unsigned_bin(struct bignum *n, const u8 *buf, size_t len); 25 | int bignum_cmp(const struct bignum *a, const struct bignum *b); 26 | int bignum_cmp_d(const struct bignum *a, unsigned long b); 27 | int bignum_add(const struct bignum *a, const struct bignum *b, 28 | struct bignum *c); 29 | int bignum_sub(const struct bignum *a, const struct bignum *b, 30 | struct bignum *c); 31 | int bignum_mul(const struct bignum *a, const struct bignum *b, 32 | struct bignum *c); 33 | int bignum_mulmod(const struct bignum *a, const struct bignum *b, 34 | const struct bignum *c, struct bignum *d); 35 | int bignum_exptmod(const struct bignum *a, const struct bignum *b, 36 | const struct bignum *c, struct bignum *d); 37 | 38 | #endif /* BIGNUM_H */ 39 | -------------------------------------------------------------------------------- /src/wps/wps_upnp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UPnP WPS Device 3 | * Copyright (c) 2000-2003 Intel Corporation 4 | * Copyright (c) 2006-2007 Sony Corporation 5 | * Copyright (c) 2008-2009 Atheros Communications 6 | * Copyright (c) 2009, Jouni Malinen 7 | * 8 | * See wps_upnp.c for more details on licensing and code history. 9 | */ 10 | 11 | #ifndef WPS_UPNP_H 12 | #define WPS_UPNP_H 13 | 14 | struct upnp_wps_device_sm; 15 | struct wps_context; 16 | struct wps_data; 17 | 18 | struct upnp_wps_peer { 19 | struct wps_data *wps; 20 | }; 21 | 22 | enum upnp_wps_wlanevent_type { 23 | UPNP_WPS_WLANEVENT_TYPE_PROBE = 1, 24 | UPNP_WPS_WLANEVENT_TYPE_EAP = 2 25 | }; 26 | 27 | struct upnp_wps_device_ctx { 28 | int (*rx_req_put_wlan_response)( 29 | void *priv, enum upnp_wps_wlanevent_type ev_type, 30 | const u8 *mac_addr, const struct wpabuf *msg, 31 | enum wps_msg_type msg_type); 32 | 33 | char *ap_pin; 34 | }; 35 | 36 | struct upnp_wps_device_sm * 37 | upnp_wps_device_init(struct upnp_wps_device_ctx *ctx, struct wps_context *wps, 38 | void *priv, char *net_if); 39 | void upnp_wps_device_deinit(struct upnp_wps_device_sm *sm, void *priv); 40 | 41 | int upnp_wps_device_send_wlan_event(struct upnp_wps_device_sm *sm, 42 | const u8 from_mac_addr[ETH_ALEN], 43 | enum upnp_wps_wlanevent_type ev_type, 44 | const struct wpabuf *msg); 45 | int upnp_wps_subscribers(struct upnp_wps_device_sm *sm); 46 | int upnp_wps_set_ap_pin(struct upnp_wps_device_sm *sm, const char *ap_pin); 47 | 48 | #endif /* WPS_UPNP_H */ 49 | -------------------------------------------------------------------------------- /src/wps/http_server.h: -------------------------------------------------------------------------------- 1 | /* 2 | * http_server - HTTP server 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef HTTP_SERVER_H 16 | #define HTTP_SERVER_H 17 | 18 | struct http_server; 19 | struct http_request; 20 | 21 | void http_request_deinit(struct http_request *req); 22 | void http_request_send(struct http_request *req, struct wpabuf *resp); 23 | void http_request_send_and_deinit(struct http_request *req, 24 | struct wpabuf *resp); 25 | enum httpread_hdr_type http_request_get_type(struct http_request *req); 26 | char * http_request_get_uri(struct http_request *req); 27 | char * http_request_get_hdr(struct http_request *req); 28 | char * http_request_get_data(struct http_request *req); 29 | char * http_request_get_hdr_line(struct http_request *req, const char *tag); 30 | struct sockaddr_in * http_request_get_cli_addr(struct http_request *req); 31 | 32 | struct http_server * http_server_init(struct in_addr *addr, int port, 33 | void (*cb)(void *ctx, 34 | struct http_request *req), 35 | void *cb_ctx); 36 | void http_server_deinit(struct http_server *srv); 37 | int http_server_get_port(struct http_server *srv); 38 | 39 | #endif /* HTTP_SERVER_H */ 40 | -------------------------------------------------------------------------------- /src/drivers/MobileApple80211.h: -------------------------------------------------------------------------------- 1 | #ifndef MOBILEAPPLE80211_H 2 | #define MOBILEAPPLE80211_H 3 | 4 | /* 5 | * MobileApple80211 interface for iPhone/iPod touch 6 | * These functions are available from Aeropuerto. 7 | */ 8 | 9 | struct Apple80211; 10 | typedef struct Apple80211 *Apple80211Ref; 11 | 12 | int Apple80211Open(Apple80211Ref *ctx); 13 | int Apple80211Close(Apple80211Ref ctx); 14 | int Apple80211GetIfListCopy(Apple80211Ref handle, CFArrayRef *list); 15 | int Apple80211BindToInterface(Apple80211Ref handle, 16 | CFStringRef interface); 17 | int Apple80211GetInterfaceNameCopy(Apple80211Ref handle, 18 | CFStringRef *name); 19 | int Apple80211GetInfoCopy(Apple80211Ref handle, 20 | CFDictionaryRef *info); 21 | int Apple80211GetPower(Apple80211Ref handle, char *pwr); 22 | int Apple80211SetPower(Apple80211Ref handle, char pwr); 23 | 24 | /* parameters can be NULL; returns scan results in CFArrayRef *list; 25 | * caller will need to free with CFRelease() */ 26 | int Apple80211Scan(Apple80211Ref handle, CFArrayRef *list, 27 | CFDictionaryRef parameters); 28 | 29 | int Apple80211Associate(Apple80211Ref handle, CFDictionaryRef bss, 30 | CFStringRef password); 31 | int Apple80211AssociateAndCopyInfo(Apple80211Ref handle, CFDictionaryRef bss, 32 | CFStringRef password, 33 | CFDictionaryRef *info); 34 | 35 | enum { 36 | APPLE80211_VALUE_SSID = 1, 37 | APPLE80211_VALUE_BSSID = 9 38 | }; 39 | 40 | int Apple80211CopyValue(Apple80211Ref handle, int field, CFDictionaryRef arg2, 41 | void *value); 42 | 43 | #endif /* MOBILEAPPLE80211_H */ 44 | -------------------------------------------------------------------------------- /src/wps/http_client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * http_client - HTTP client 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef HTTP_CLIENT_H 16 | #define HTTP_CLIENT_H 17 | 18 | struct http_client; 19 | 20 | enum http_client_event { 21 | HTTP_CLIENT_FAILED, 22 | HTTP_CLIENT_TIMEOUT, 23 | HTTP_CLIENT_OK, 24 | HTTP_CLIENT_INVALID_REPLY, 25 | }; 26 | 27 | char * http_client_url_parse(const char *url, struct sockaddr_in *dst, 28 | char **path); 29 | struct http_client * http_client_addr(struct sockaddr_in *dst, 30 | struct wpabuf *req, size_t max_response, 31 | void (*cb)(void *ctx, 32 | struct http_client *c, 33 | enum http_client_event event), 34 | void *cb_ctx); 35 | struct http_client * http_client_url(const char *url, 36 | struct wpabuf *req, size_t max_response, 37 | void (*cb)(void *ctx, 38 | struct http_client *c, 39 | enum http_client_event event), 40 | void *cb_ctx); 41 | void http_client_free(struct http_client *c); 42 | struct wpabuf * http_client_get_body(struct http_client *c); 43 | char * http_client_get_hdr_line(struct http_client *c, const char *tag); 44 | char * http_link_update(char *url, const char *base); 45 | 46 | #endif /* HTTP_CLIENT_H */ 47 | -------------------------------------------------------------------------------- /src/tls/tlsv1_cred.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TLSv1 credentials 3 | * Copyright (c) 2006-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef TLSV1_CRED_H 16 | #define TLSV1_CRED_H 17 | 18 | struct tlsv1_credentials { 19 | struct x509_certificate *trusted_certs; 20 | struct x509_certificate *cert; 21 | struct crypto_private_key *key; 22 | 23 | /* Diffie-Hellman parameters */ 24 | u8 *dh_p; /* prime */ 25 | size_t dh_p_len; 26 | u8 *dh_g; /* generator */ 27 | size_t dh_g_len; 28 | }; 29 | 30 | 31 | struct tlsv1_credentials * tlsv1_cred_alloc(void); 32 | void tlsv1_cred_free(struct tlsv1_credentials *cred); 33 | int tlsv1_set_ca_cert(struct tlsv1_credentials *cred, const char *cert, 34 | const u8 *cert_blob, size_t cert_blob_len, 35 | const char *path); 36 | int tlsv1_set_cert(struct tlsv1_credentials *cred, const char *cert, 37 | const u8 *cert_blob, size_t cert_blob_len); 38 | int tlsv1_set_private_key(struct tlsv1_credentials *cred, 39 | const char *private_key, 40 | const char *private_key_passwd, 41 | const u8 *private_key_blob, 42 | size_t private_key_blob_len); 43 | int tlsv1_set_dhparams(struct tlsv1_credentials *cred, const char *dh_file, 44 | const u8 *dh_blob, size_t dh_blob_len); 45 | 46 | #endif /* TLSV1_CRED_H */ 47 | -------------------------------------------------------------------------------- /src/ap/wpa_auth_ie.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd - WPA/RSN IE and KDE definitions 3 | * Copyright (c) 2004-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef WPA_AUTH_IE_H 16 | #define WPA_AUTH_IE_H 17 | 18 | struct wpa_eapol_ie_parse { 19 | const u8 *wpa_ie; 20 | size_t wpa_ie_len; 21 | const u8 *rsn_ie; 22 | size_t rsn_ie_len; 23 | const u8 *pmkid; 24 | const u8 *gtk; 25 | size_t gtk_len; 26 | const u8 *mac_addr; 27 | size_t mac_addr_len; 28 | #ifdef CONFIG_PEERKEY 29 | const u8 *smk; 30 | size_t smk_len; 31 | const u8 *nonce; 32 | size_t nonce_len; 33 | const u8 *lifetime; 34 | size_t lifetime_len; 35 | const u8 *error; 36 | size_t error_len; 37 | #endif /* CONFIG_PEERKEY */ 38 | #ifdef CONFIG_IEEE80211W 39 | const u8 *igtk; 40 | size_t igtk_len; 41 | #endif /* CONFIG_IEEE80211W */ 42 | #ifdef CONFIG_IEEE80211R 43 | const u8 *mdie; 44 | size_t mdie_len; 45 | const u8 *ftie; 46 | size_t ftie_len; 47 | #endif /* CONFIG_IEEE80211R */ 48 | }; 49 | 50 | int wpa_parse_kde_ies(const u8 *buf, size_t len, 51 | struct wpa_eapol_ie_parse *ie); 52 | u8 * wpa_add_kde(u8 *pos, u32 kde, const u8 *data, size_t data_len, 53 | const u8 *data2, size_t data2_len); 54 | int wpa_auth_gen_wpa_ie(struct wpa_authenticator *wpa_auth); 55 | 56 | #endif /* WPA_AUTH_IE_H */ 57 | -------------------------------------------------------------------------------- /src/eap_server/tncs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP-TNC - TNCS (IF-IMV, IF-TNCCS, and IF-TNCCS-SOH) 3 | * Copyright (c) 2007-2008, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef TNCS_H 16 | #define TNCS_H 17 | 18 | struct tncs_data; 19 | 20 | struct tncs_data * tncs_init(void); 21 | void tncs_deinit(struct tncs_data *tncs); 22 | void tncs_init_connection(struct tncs_data *tncs); 23 | size_t tncs_total_send_len(struct tncs_data *tncs); 24 | u8 * tncs_copy_send_buf(struct tncs_data *tncs, u8 *pos); 25 | char * tncs_if_tnccs_start(struct tncs_data *tncs); 26 | char * tncs_if_tnccs_end(void); 27 | 28 | enum tncs_process_res { 29 | TNCCS_PROCESS_ERROR = -1, 30 | TNCCS_PROCESS_OK_NO_RECOMMENDATION = 0, 31 | TNCCS_RECOMMENDATION_ERROR, 32 | TNCCS_RECOMMENDATION_ALLOW, 33 | TNCCS_RECOMMENDATION_NONE, 34 | TNCCS_RECOMMENDATION_ISOLATE, 35 | TNCCS_RECOMMENDATION_NO_ACCESS, 36 | TNCCS_RECOMMENDATION_NO_RECOMMENDATION 37 | }; 38 | 39 | enum tncs_process_res tncs_process_if_tnccs(struct tncs_data *tncs, 40 | const u8 *msg, size_t len); 41 | 42 | int tncs_global_init(void); 43 | void tncs_global_deinit(void); 44 | 45 | struct wpabuf * tncs_build_soh_request(void); 46 | struct wpabuf * tncs_process_soh(const u8 *soh_tlv, size_t soh_tlv_len, 47 | int *failure); 48 | 49 | #endif /* TNCS_H */ 50 | -------------------------------------------------------------------------------- /src/rsn_supp/wpa_ie.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wpa_supplicant - WPA/RSN IE and KDE definitions 3 | * Copyright (c) 2004-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef WPA_IE_H 16 | #define WPA_IE_H 17 | 18 | struct wpa_sm; 19 | 20 | struct wpa_eapol_ie_parse { 21 | const u8 *wpa_ie; 22 | size_t wpa_ie_len; 23 | const u8 *rsn_ie; 24 | size_t rsn_ie_len; 25 | const u8 *pmkid; 26 | const u8 *gtk; 27 | size_t gtk_len; 28 | const u8 *mac_addr; 29 | size_t mac_addr_len; 30 | #ifdef CONFIG_PEERKEY 31 | const u8 *smk; 32 | size_t smk_len; 33 | const u8 *nonce; 34 | size_t nonce_len; 35 | const u8 *lifetime; 36 | size_t lifetime_len; 37 | const u8 *error; 38 | size_t error_len; 39 | #endif /* CONFIG_PEERKEY */ 40 | #ifdef CONFIG_IEEE80211W 41 | const u8 *igtk; 42 | size_t igtk_len; 43 | #endif /* CONFIG_IEEE80211W */ 44 | const u8 *mdie; 45 | size_t mdie_len; 46 | const u8 *ftie; 47 | size_t ftie_len; 48 | const u8 *reassoc_deadline; 49 | const u8 *key_lifetime; 50 | const u8 *lnkid; 51 | size_t lnkid_len; 52 | const u8 *ext_capab; 53 | size_t ext_capab_len; 54 | }; 55 | 56 | int wpa_supplicant_parse_ies(const u8 *buf, size_t len, 57 | struct wpa_eapol_ie_parse *ie); 58 | int wpa_gen_wpa_ie(struct wpa_sm *sm, u8 *wpa_ie, size_t wpa_ie_len); 59 | 60 | #endif /* WPA_IE_H */ 61 | -------------------------------------------------------------------------------- /src/crypto/aes-ctr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AES-128 CTR 3 | * 4 | * Copyright (c) 2003-2007, Jouni Malinen 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License version 2 as 8 | * published by the Free Software Foundation. 9 | * 10 | * Alternatively, this software may be distributed under the terms of BSD 11 | * license. 12 | * 13 | * See README and COPYING for more details. 14 | */ 15 | 16 | #include "includes.h" 17 | 18 | #include "common.h" 19 | #include "aes.h" 20 | #include "aes_wrap.h" 21 | 22 | /** 23 | * aes_128_ctr_encrypt - AES-128 CTR mode encryption 24 | * @key: Key for encryption (16 bytes) 25 | * @nonce: Nonce for counter mode (16 bytes) 26 | * @data: Data to encrypt in-place 27 | * @data_len: Length of data in bytes 28 | * Returns: 0 on success, -1 on failure 29 | */ 30 | int aes_128_ctr_encrypt(const u8 *key, const u8 *nonce, 31 | u8 *data, size_t data_len) 32 | { 33 | void *ctx; 34 | size_t j, len, left = data_len; 35 | int i; 36 | u8 *pos = data; 37 | u8 counter[AES_BLOCK_SIZE], buf[AES_BLOCK_SIZE]; 38 | 39 | ctx = aes_encrypt_init(key, 16); 40 | if (ctx == NULL) 41 | return -1; 42 | os_memcpy(counter, nonce, AES_BLOCK_SIZE); 43 | 44 | while (left > 0) { 45 | aes_encrypt(ctx, counter, buf); 46 | 47 | len = (left < AES_BLOCK_SIZE) ? left : AES_BLOCK_SIZE; 48 | for (j = 0; j < len; j++) 49 | pos[j] ^= buf[j]; 50 | pos += len; 51 | left -= len; 52 | 53 | for (i = AES_BLOCK_SIZE - 1; i >= 0; i--) { 54 | counter[i]++; 55 | if (counter[i]) 56 | break; 57 | } 58 | } 59 | aes_encrypt_deinit(ctx); 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /wpa_supplicant/config_none.c: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant / Configuration backend: empty starting point 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | * 14 | * This file implements dummy example of a configuration backend. None of the 15 | * functions are actually implemented so this can be used as a simple 16 | * compilation test or a starting point for a new configuration backend. 17 | */ 18 | 19 | #include "includes.h" 20 | 21 | #include "common.h" 22 | #include "config.h" 23 | #include "base64.h" 24 | 25 | 26 | struct wpa_config * wpa_config_read(const char *name) 27 | { 28 | struct wpa_config *config; 29 | 30 | config = wpa_config_alloc_empty(NULL, NULL); 31 | if (config == NULL) 32 | return NULL; 33 | /* TODO: fill in configuration data */ 34 | return config; 35 | } 36 | 37 | 38 | int wpa_config_write(const char *name, struct wpa_config *config) 39 | { 40 | struct wpa_ssid *ssid; 41 | struct wpa_config_blob *blob; 42 | 43 | wpa_printf(MSG_DEBUG, "Writing configuration file '%s'", name); 44 | 45 | /* TODO: write global config parameters */ 46 | 47 | 48 | for (ssid = config->ssid; ssid; ssid = ssid->next) { 49 | /* TODO: write networks */ 50 | } 51 | 52 | for (blob = config->blobs; blob; blob = blob->next) { 53 | /* TODO: write blobs */ 54 | } 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /wpa_supplicant/scan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant - Scanning 3 | * Copyright (c) 2003-2010, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef SCAN_H 16 | #define SCAN_H 17 | 18 | int wpa_supplicant_enabled_networks(struct wpa_config *conf); 19 | void wpa_supplicant_req_scan(struct wpa_supplicant *wpa_s, int sec, int usec); 20 | void wpa_supplicant_cancel_scan(struct wpa_supplicant *wpa_s); 21 | void wpa_supplicant_notify_scanning(struct wpa_supplicant *wpa_s, 22 | int scanning); 23 | struct wpa_driver_scan_params; 24 | int wpa_supplicant_trigger_scan(struct wpa_supplicant *wpa_s, 25 | struct wpa_driver_scan_params *params); 26 | struct wpa_scan_results * 27 | wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s, 28 | struct scan_info *info, int new_scan); 29 | int wpa_supplicant_update_scan_results(struct wpa_supplicant *wpa_s); 30 | const u8 * wpa_scan_get_ie(const struct wpa_scan_res *res, u8 ie); 31 | const u8 * wpa_scan_get_vendor_ie(const struct wpa_scan_res *res, 32 | u32 vendor_type); 33 | struct wpabuf * wpa_scan_get_vendor_ie_multi(const struct wpa_scan_res *res, 34 | u32 vendor_type); 35 | struct wpabuf * wpa_scan_get_vendor_ie_multi_beacon( 36 | const struct wpa_scan_res *res, u32 vendor_type); 37 | void wpa_scan_results_free(struct wpa_scan_results *res); 38 | 39 | #endif /* SCAN_H */ 40 | -------------------------------------------------------------------------------- /src/crypto/crypto_internal-modexp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Crypto wrapper for internal crypto implementation - modexp 3 | * Copyright (c) 2006-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "tls/bignum.h" 19 | #include "crypto.h" 20 | 21 | 22 | int crypto_mod_exp(const u8 *base, size_t base_len, 23 | const u8 *power, size_t power_len, 24 | const u8 *modulus, size_t modulus_len, 25 | u8 *result, size_t *result_len) 26 | { 27 | struct bignum *bn_base, *bn_exp, *bn_modulus, *bn_result; 28 | int ret = -1; 29 | 30 | bn_base = bignum_init(); 31 | bn_exp = bignum_init(); 32 | bn_modulus = bignum_init(); 33 | bn_result = bignum_init(); 34 | 35 | if (bn_base == NULL || bn_exp == NULL || bn_modulus == NULL || 36 | bn_result == NULL) 37 | goto error; 38 | 39 | if (bignum_set_unsigned_bin(bn_base, base, base_len) < 0 || 40 | bignum_set_unsigned_bin(bn_exp, power, power_len) < 0 || 41 | bignum_set_unsigned_bin(bn_modulus, modulus, modulus_len) < 0) 42 | goto error; 43 | 44 | if (bignum_exptmod(bn_base, bn_exp, bn_modulus, bn_result) < 0) 45 | goto error; 46 | 47 | ret = bignum_get_unsigned_bin(bn_result, result, result_len); 48 | 49 | error: 50 | bignum_deinit(bn_base); 51 | bignum_deinit(bn_exp); 52 | bignum_deinit(bn_modulus); 53 | bignum_deinit(bn_result); 54 | return ret; 55 | } 56 | -------------------------------------------------------------------------------- /src/ap/preauth_auth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd - Authenticator for IEEE 802.11i RSN pre-authentication 3 | * Copyright (c) 2004-2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef PREAUTH_H 16 | #define PREAUTH_H 17 | 18 | #ifdef CONFIG_RSN_PREAUTH 19 | 20 | int rsn_preauth_iface_init(struct hostapd_data *hapd); 21 | void rsn_preauth_iface_deinit(struct hostapd_data *hapd); 22 | void rsn_preauth_finished(struct hostapd_data *hapd, struct sta_info *sta, 23 | int success); 24 | void rsn_preauth_send(struct hostapd_data *hapd, struct sta_info *sta, 25 | u8 *buf, size_t len); 26 | void rsn_preauth_free_station(struct hostapd_data *hapd, struct sta_info *sta); 27 | 28 | #else /* CONFIG_RSN_PREAUTH */ 29 | 30 | static inline int rsn_preauth_iface_init(struct hostapd_data *hapd) 31 | { 32 | return 0; 33 | } 34 | 35 | static inline void rsn_preauth_iface_deinit(struct hostapd_data *hapd) 36 | { 37 | } 38 | 39 | static inline void rsn_preauth_finished(struct hostapd_data *hapd, 40 | struct sta_info *sta, 41 | int success) 42 | { 43 | } 44 | 45 | static inline void rsn_preauth_send(struct hostapd_data *hapd, 46 | struct sta_info *sta, 47 | u8 *buf, size_t len) 48 | { 49 | } 50 | 51 | static inline void rsn_preauth_free_station(struct hostapd_data *hapd, 52 | struct sta_info *sta) 53 | { 54 | } 55 | 56 | #endif /* CONFIG_RSN_PREAUTH */ 57 | 58 | #endif /* PREAUTH_H */ 59 | -------------------------------------------------------------------------------- /hostapd/hostapd.8: -------------------------------------------------------------------------------- 1 | .TH HOSTAPD 8 "April 7, 2005" hostapd hostapd 2 | .SH NAME 3 | hostapd \- IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator 4 | .SH SYNOPSIS 5 | .B hostapd 6 | [\-hdBKtv] [\-P ] 7 | .SH DESCRIPTION 8 | This manual page documents briefly the 9 | .B hostapd 10 | daemon. 11 | .PP 12 | .B hostapd 13 | is a user space daemon for access point and authentication servers. 14 | It implements IEEE 802.11 access point management, IEEE 802.1X/WPA/WPA2/EAP Authenticators and RADIUS authentication server. 15 | The current version supports Linux (Host AP, madwifi, mac80211-based drivers) and FreeBSD (net80211). 16 | 17 | .B hostapd 18 | is designed to be a "daemon" program that runs in the background and acts as the backend component controlling authentication. 19 | .B hostapd 20 | supports separate frontend programs and an example text-based frontend, 21 | .BR hostapd_cli , 22 | is included with 23 | .BR hostapd . 24 | .SH OPTIONS 25 | A summary of options is included below. 26 | For a complete description, run 27 | .BR hostapd 28 | from the command line. 29 | .TP 30 | .B \-h 31 | Show usage. 32 | .TP 33 | .B \-d 34 | Show more debug messages. 35 | .TP 36 | .B \-dd 37 | Show even more debug messages. 38 | .TP 39 | .B \-B 40 | Run daemon in the background. 41 | .TP 42 | .B \-P 43 | Path to PID file. 44 | .TP 45 | .B \-K 46 | Include key data in debug messages. 47 | .TP 48 | .B \-t 49 | Include timestamps in some debug messages. 50 | .TP 51 | .B \-v 52 | Show hostapd version. 53 | .SH SEE ALSO 54 | .BR hostapd_cli (1). 55 | .SH AUTHOR 56 | hostapd was written by Jouni Malinen . 57 | .PP 58 | This manual page was written by Faidon Liambotis , 59 | for the Debian project (but may be used by others). 60 | -------------------------------------------------------------------------------- /src/ap/vlan_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / VLAN initialization 3 | * Copyright 2003, Instant802 Networks, Inc. 4 | * Copyright 2005, Devicescape Software, Inc. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License version 2 as 8 | * published by the Free Software Foundation. 9 | * 10 | * Alternatively, this software may be distributed under the terms of BSD 11 | * license. 12 | * 13 | * See README and COPYING for more details. 14 | */ 15 | 16 | #ifndef VLAN_INIT_H 17 | #define VLAN_INIT_H 18 | 19 | #ifndef CONFIG_NO_VLAN 20 | int vlan_init(struct hostapd_data *hapd); 21 | void vlan_deinit(struct hostapd_data *hapd); 22 | struct hostapd_vlan * vlan_add_dynamic(struct hostapd_data *hapd, 23 | struct hostapd_vlan *vlan, 24 | int vlan_id); 25 | int vlan_remove_dynamic(struct hostapd_data *hapd, int vlan_id); 26 | int vlan_setup_encryption_dyn(struct hostapd_data *hapd, 27 | struct hostapd_ssid *mssid, 28 | const char *dyn_vlan); 29 | #else /* CONFIG_NO_VLAN */ 30 | static inline int vlan_init(struct hostapd_data *hapd) 31 | { 32 | return 0; 33 | } 34 | 35 | static inline void vlan_deinit(struct hostapd_data *hapd) 36 | { 37 | } 38 | 39 | static inline struct hostapd_vlan * vlan_add_dynamic(struct hostapd_data *hapd, 40 | struct hostapd_vlan *vlan, 41 | int vlan_id) 42 | { 43 | return NULL; 44 | } 45 | 46 | static inline int vlan_remove_dynamic(struct hostapd_data *hapd, int vlan_id) 47 | { 48 | return -1; 49 | } 50 | 51 | static inline int vlan_setup_encryption_dyn(struct hostapd_data *hapd, 52 | struct hostapd_ssid *mssid, 53 | const char *dyn_vlan) 54 | { 55 | return -1; 56 | } 57 | #endif /* CONFIG_NO_VLAN */ 58 | 59 | #endif /* VLAN_INIT_H */ 60 | -------------------------------------------------------------------------------- /src/utils/includes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wpa_supplicant/hostapd - Default include files 3 | * Copyright (c) 2005-2006, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | * 14 | * This header file is included into all C files so that commonly used header 15 | * files can be selected with OS specific ifdef blocks in one place instead of 16 | * having to have OS/C library specific selection in many files. 17 | */ 18 | 19 | #ifndef INCLUDES_H 20 | #define INCLUDES_H 21 | 22 | /* Include possible build time configuration before including anything else */ 23 | #include "build_config.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #ifndef _WIN32_WCE 30 | #ifndef CONFIG_TI_COMPILER 31 | #include 32 | #include 33 | #endif /* CONFIG_TI_COMPILER */ 34 | #include 35 | #endif /* _WIN32_WCE */ 36 | #include 37 | #include 38 | 39 | #ifndef CONFIG_TI_COMPILER 40 | #ifndef _MSC_VER 41 | #include 42 | #endif /* _MSC_VER */ 43 | #endif /* CONFIG_TI_COMPILER */ 44 | 45 | #ifndef CONFIG_NATIVE_WINDOWS 46 | #ifndef CONFIG_TI_COMPILER 47 | #include 48 | #include 49 | #include 50 | #ifndef __vxworks 51 | #ifndef __SYMBIAN32__ 52 | #include 53 | #endif /* __SYMBIAN32__ */ 54 | #include 55 | #endif /* __vxworks */ 56 | #endif /* CONFIG_TI_COMPILER */ 57 | #endif /* CONFIG_NATIVE_WINDOWS */ 58 | 59 | #endif /* INCLUDES_H */ 60 | -------------------------------------------------------------------------------- /src/utils/uuid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Universally Unique IDentifier (UUID) 3 | * Copyright (c) 2008, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "uuid.h" 19 | 20 | int uuid_str2bin(const char *str, u8 *bin) 21 | { 22 | const char *pos; 23 | u8 *opos; 24 | 25 | pos = str; 26 | opos = bin; 27 | 28 | if (hexstr2bin(pos, opos, 4)) 29 | return -1; 30 | pos += 8; 31 | opos += 4; 32 | 33 | if (*pos++ != '-' || hexstr2bin(pos, opos, 2)) 34 | return -1; 35 | pos += 4; 36 | opos += 2; 37 | 38 | if (*pos++ != '-' || hexstr2bin(pos, opos, 2)) 39 | return -1; 40 | pos += 4; 41 | opos += 2; 42 | 43 | if (*pos++ != '-' || hexstr2bin(pos, opos, 2)) 44 | return -1; 45 | pos += 4; 46 | opos += 2; 47 | 48 | if (*pos++ != '-' || hexstr2bin(pos, opos, 6)) 49 | return -1; 50 | 51 | return 0; 52 | } 53 | 54 | 55 | int uuid_bin2str(const u8 *bin, char *str, size_t max_len) 56 | { 57 | int len; 58 | len = os_snprintf(str, max_len, "%02x%02x%02x%02x-%02x%02x-%02x%02x-" 59 | "%02x%02x-%02x%02x%02x%02x%02x%02x", 60 | bin[0], bin[1], bin[2], bin[3], 61 | bin[4], bin[5], bin[6], bin[7], 62 | bin[8], bin[9], bin[10], bin[11], 63 | bin[12], bin[13], bin[14], bin[15]); 64 | if (len < 0 || (size_t) len >= max_len) 65 | return -1; 66 | return 0; 67 | } 68 | 69 | 70 | int is_nil_uuid(const u8 *uuid) 71 | { 72 | int i; 73 | for (i = 0; i < UUID_LEN; i++) 74 | if (uuid[i]) 75 | return 0; 76 | return 1; 77 | } 78 | -------------------------------------------------------------------------------- /hostapd/logwatch/hostapd: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | # 3 | # Logwatch script for hostapd 4 | # 5 | # Copyright 2005 Henrik Brix Andersen 6 | # Distributed under the terms of the GNU General Public License v2 7 | # Alternatively, this file may be distributed under the terms of the BSD License 8 | 9 | use strict; 10 | 11 | my $debug = $ENV{'LOGWATCH_DEBUG'} || 0; 12 | my $detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0; 13 | my $debugcounter = 1; 14 | 15 | my %hostapd; 16 | my @unmatched; 17 | 18 | if ($debug >= 5) { 19 | print STDERR "\n\nDEBUG: Inside HOSTAPD Filter\n\n"; 20 | } 21 | 22 | while (defined(my $line = )) { 23 | if ($debug >= 5) { 24 | print STDERR "DEBUG($debugcounter): $line"; 25 | $debugcounter++; 26 | } 27 | chomp($line); 28 | 29 | if (my ($iface,$mac,$layer,$details) = ($line =~ /(.*?): STA (.*?) (.*?): (.*?)$/i)) { 30 | unless ($detail == 10) { 31 | # collapse association events 32 | $details =~ s/^(associated) .*$/$1/i; 33 | } 34 | $hostapd{$iface}->{$mac}->{$layer}->{$details}++; 35 | } else { 36 | push @unmatched, "$line\n"; 37 | } 38 | } 39 | 40 | if (keys %hostapd) { 41 | foreach my $iface (sort keys %hostapd) { 42 | print "Interface $iface:\n"; 43 | foreach my $mac (sort keys %{$hostapd{$iface}}) { 44 | print " Client MAC Address $mac:\n"; 45 | foreach my $layer (sort keys %{$hostapd{$iface}->{$mac}}) { 46 | print " $layer:\n"; 47 | foreach my $details (sort keys %{$hostapd{$iface}->{$mac}->{$layer}}) { 48 | print " $details"; 49 | my $count = $hostapd{$iface}->{$mac}->{$layer}->{$details}; 50 | if ($count > 1) { 51 | print ": " . $count . " Times"; 52 | } 53 | print "\n"; 54 | } 55 | } 56 | } 57 | } 58 | } 59 | 60 | if ($#unmatched >= 0) { 61 | print "\n**Unmatched Entries**\n"; 62 | print @unmatched; 63 | } 64 | 65 | exit(0); 66 | -------------------------------------------------------------------------------- /src/eap_peer/ikev2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IKEv2 responder (RFC 4306) for EAP-IKEV2 3 | * Copyright (c) 2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef IKEV2_H 16 | #define IKEV2_H 17 | 18 | #include "eap_common/ikev2_common.h" 19 | 20 | struct ikev2_proposal_data { 21 | u8 proposal_num; 22 | int integ; 23 | int prf; 24 | int encr; 25 | int dh; 26 | }; 27 | 28 | 29 | struct ikev2_responder_data { 30 | enum { SA_INIT, SA_AUTH, CHILD_SA, NOTIFY, IKEV2_DONE, IKEV2_FAILED } 31 | state; 32 | u8 i_spi[IKEV2_SPI_LEN]; 33 | u8 r_spi[IKEV2_SPI_LEN]; 34 | u8 i_nonce[IKEV2_NONCE_MAX_LEN]; 35 | size_t i_nonce_len; 36 | u8 r_nonce[IKEV2_NONCE_MAX_LEN]; 37 | size_t r_nonce_len; 38 | struct wpabuf *i_dh_public; 39 | struct wpabuf *r_dh_private; 40 | struct ikev2_proposal_data proposal; 41 | const struct dh_group *dh; 42 | struct ikev2_keys keys; 43 | u8 *IDi; 44 | size_t IDi_len; 45 | u8 IDi_type; 46 | u8 *IDr; 47 | size_t IDr_len; 48 | struct wpabuf *r_sign_msg; 49 | struct wpabuf *i_sign_msg; 50 | u8 *shared_secret; 51 | size_t shared_secret_len; 52 | enum { PEER_AUTH_CERT, PEER_AUTH_SECRET } peer_auth; 53 | u8 *key_pad; 54 | size_t key_pad_len; 55 | u16 error_type; 56 | enum { LAST_MSG_SA_INIT, LAST_MSG_SA_AUTH } last_msg; 57 | }; 58 | 59 | 60 | void ikev2_responder_deinit(struct ikev2_responder_data *data); 61 | int ikev2_responder_process(struct ikev2_responder_data *data, 62 | const struct wpabuf *buf); 63 | struct wpabuf * ikev2_responder_build(struct ikev2_responder_data *data); 64 | 65 | #endif /* IKEV2_H */ 66 | -------------------------------------------------------------------------------- /wpa_supplicant/dbus/Makefile: -------------------------------------------------------------------------------- 1 | all: libwpadbus.a 2 | 3 | clean: 4 | rm -f *~ *.o *.d 5 | rm -f libwpadbus.a 6 | 7 | install: 8 | @echo Nothing to be made. 9 | 10 | ifndef CC 11 | CC=gcc 12 | endif 13 | 14 | ifndef CFLAGS 15 | CFLAGS = -MMD -O2 -Wall -g 16 | endif 17 | 18 | CFLAGS += -I../../src -I../../src/utils 19 | 20 | 21 | Q=@ 22 | E=echo 23 | ifeq ($(V), 1) 24 | Q= 25 | E=true 26 | endif 27 | 28 | %.o: %.c 29 | $(Q)$(CC) -c -o $@ $(CFLAGS) $< 30 | @$(E) " CC " $< 31 | 32 | 33 | ifdef CONFIG_WPS 34 | CFLAGS += -DCONFIG_WPS 35 | endif 36 | 37 | CFLAGS += -DCONFIG_CTRL_IFACE_DBUS_NEW 38 | CFLAGS += -DCONFIG_CTRL_IFACE_DBUS 39 | 40 | ifndef DBUS_LIBS 41 | DBUS_LIBS := $(shell pkg-config --libs dbus-1) 42 | endif 43 | ifndef DBUS_INCLUDE 44 | DBUS_INCLUDE := $(shell pkg-config --cflags dbus-1) 45 | endif 46 | ifdef CONFIG_CTRL_IFACE_DBUS_INTRO 47 | CFLAGS += -DCONFIG_CTRL_IFACE_DBUS_INTRO 48 | DBUS_INCLUDE += $(shell xml2-config --cflags) 49 | DBUS_LIBS += $(shell xml2-config --libs) 50 | endif 51 | 52 | dbus_version=$(subst ., ,$(shell pkg-config --modversion dbus-1)) 53 | DBUS_VERSION_MAJOR=$(word 1,$(dbus_version)) 54 | DBUS_VERSION_MINOR=$(word 2,$(dbus_version)) 55 | ifeq ($(DBUS_VERSION_MAJOR),) 56 | DBUS_VERSION_MAJOR=0 57 | endif 58 | ifeq ($(DBUS_VERSION_MINOR),) 59 | DBUS_VERSION_MINOR=0 60 | endif 61 | DBUS_INCLUDE += -DDBUS_VERSION_MAJOR=$(DBUS_VERSION_MAJOR) 62 | DBUS_INCLUDE += -DDBUS_VERSION_MINOR=$(DBUS_VERSION_MINOR) 63 | 64 | CFLAGS += $(DBUS_INCLUDE) 65 | 66 | LIB_OBJS= \ 67 | dbus_common.o \ 68 | dbus_old.o \ 69 | dbus_old_handlers.o \ 70 | dbus_new.o \ 71 | dbus_new_handlers.o \ 72 | dbus_new_helpers.o \ 73 | dbus_new_introspect.o \ 74 | dbus_dict_helpers.o 75 | 76 | ifdef CONFIG_WPS 77 | LIB_OBJS += dbus_old_handlers_wps.o 78 | LIB_OBJS += dbus_new_handlers_wps.o 79 | endif 80 | 81 | libwpadbus.a: $(LIB_OBJS) 82 | $(AR) crT $@ $? 83 | 84 | -include $(OBJS:%.o=%.d) 85 | -------------------------------------------------------------------------------- /src/eap_peer/eap_fast_pac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP peer method: EAP-FAST PAC file processing 3 | * Copyright (c) 2004-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef EAP_FAST_PAC_H 16 | #define EAP_FAST_PAC_H 17 | 18 | #include "eap_common/eap_fast_common.h" 19 | 20 | struct eap_fast_pac { 21 | struct eap_fast_pac *next; 22 | 23 | u8 pac_key[EAP_FAST_PAC_KEY_LEN]; 24 | u8 *pac_opaque; 25 | size_t pac_opaque_len; 26 | u8 *pac_info; 27 | size_t pac_info_len; 28 | u8 *a_id; 29 | size_t a_id_len; 30 | u8 *i_id; 31 | size_t i_id_len; 32 | u8 *a_id_info; 33 | size_t a_id_info_len; 34 | u16 pac_type; 35 | }; 36 | 37 | 38 | void eap_fast_free_pac(struct eap_fast_pac *pac); 39 | struct eap_fast_pac * eap_fast_get_pac(struct eap_fast_pac *pac_root, 40 | const u8 *a_id, size_t a_id_len, 41 | u16 pac_type); 42 | int eap_fast_add_pac(struct eap_fast_pac **pac_root, 43 | struct eap_fast_pac **pac_current, 44 | struct eap_fast_pac *entry); 45 | int eap_fast_load_pac(struct eap_sm *sm, struct eap_fast_pac **pac_root, 46 | const char *pac_file); 47 | int eap_fast_save_pac(struct eap_sm *sm, struct eap_fast_pac *pac_root, 48 | const char *pac_file); 49 | size_t eap_fast_pac_list_truncate(struct eap_fast_pac *pac_root, 50 | size_t max_len); 51 | int eap_fast_load_pac_bin(struct eap_sm *sm, struct eap_fast_pac **pac_root, 52 | const char *pac_file); 53 | int eap_fast_save_pac_bin(struct eap_sm *sm, struct eap_fast_pac *pac_root, 54 | const char *pac_file); 55 | 56 | #endif /* EAP_FAST_PAC_H */ 57 | -------------------------------------------------------------------------------- /wpa_supplicant/wpa_passphrase.c: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant - ASCII passphrase to WPA PSK tool 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "crypto/sha1.h" 19 | 20 | 21 | int main(int argc, char *argv[]) 22 | { 23 | unsigned char psk[32]; 24 | int i; 25 | char *ssid, *passphrase, buf[64], *pos; 26 | 27 | if (argc < 2) { 28 | printf("usage: wpa_passphrase [passphrase]\n" 29 | "\nIf passphrase is left out, it will be read from " 30 | "stdin\n"); 31 | return 1; 32 | } 33 | 34 | ssid = argv[1]; 35 | 36 | if (argc > 2) { 37 | passphrase = argv[2]; 38 | } else { 39 | printf("# reading passphrase from stdin\n"); 40 | if (fgets(buf, sizeof(buf), stdin) == NULL) { 41 | printf("Failed to read passphrase\n"); 42 | return 1; 43 | } 44 | buf[sizeof(buf) - 1] = '\0'; 45 | pos = buf; 46 | while (*pos != '\0') { 47 | if (*pos == '\r' || *pos == '\n') { 48 | *pos = '\0'; 49 | break; 50 | } 51 | pos++; 52 | } 53 | passphrase = buf; 54 | } 55 | 56 | if (os_strlen(passphrase) < 8 || os_strlen(passphrase) > 63) { 57 | printf("Passphrase must be 8..63 characters\n"); 58 | return 1; 59 | } 60 | 61 | pbkdf2_sha1(passphrase, ssid, os_strlen(ssid), 4096, psk, 32); 62 | 63 | printf("network={\n"); 64 | printf("\tssid=\"%s\"\n", ssid); 65 | printf("\t#psk=\"%s\"\n", passphrase); 66 | printf("\tpsk="); 67 | for (i = 0; i < 32; i++) 68 | printf("%02x", psk[i]); 69 | printf("\n"); 70 | printf("}\n"); 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /src/common/privsep_commands.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant - privilege separation commands 3 | * Copyright (c) 2007-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef PRIVSEP_COMMANDS_H 16 | #define PRIVSEP_COMMANDS_H 17 | 18 | enum privsep_cmd { 19 | PRIVSEP_CMD_REGISTER, 20 | PRIVSEP_CMD_UNREGISTER, 21 | PRIVSEP_CMD_SCAN, 22 | PRIVSEP_CMD_GET_SCAN_RESULTS, 23 | PRIVSEP_CMD_ASSOCIATE, 24 | PRIVSEP_CMD_GET_BSSID, 25 | PRIVSEP_CMD_GET_SSID, 26 | PRIVSEP_CMD_SET_KEY, 27 | PRIVSEP_CMD_GET_CAPA, 28 | PRIVSEP_CMD_L2_REGISTER, 29 | PRIVSEP_CMD_L2_UNREGISTER, 30 | PRIVSEP_CMD_L2_NOTIFY_AUTH_START, 31 | PRIVSEP_CMD_L2_SEND, 32 | PRIVSEP_CMD_SET_COUNTRY, 33 | }; 34 | 35 | struct privsep_cmd_associate 36 | { 37 | u8 bssid[ETH_ALEN]; 38 | u8 ssid[32]; 39 | size_t ssid_len; 40 | int freq; 41 | int pairwise_suite; 42 | int group_suite; 43 | int key_mgmt_suite; 44 | int auth_alg; 45 | int mode; 46 | size_t wpa_ie_len; 47 | /* followed by wpa_ie_len bytes of wpa_ie */ 48 | }; 49 | 50 | struct privsep_cmd_set_key 51 | { 52 | int alg; 53 | u8 addr[ETH_ALEN]; 54 | int key_idx; 55 | int set_tx; 56 | u8 seq[8]; 57 | size_t seq_len; 58 | u8 key[32]; 59 | size_t key_len; 60 | }; 61 | 62 | enum privsep_event { 63 | PRIVSEP_EVENT_SCAN_RESULTS, 64 | PRIVSEP_EVENT_ASSOC, 65 | PRIVSEP_EVENT_DISASSOC, 66 | PRIVSEP_EVENT_ASSOCINFO, 67 | PRIVSEP_EVENT_MICHAEL_MIC_FAILURE, 68 | PRIVSEP_EVENT_INTERFACE_STATUS, 69 | PRIVSEP_EVENT_PMKID_CANDIDATE, 70 | PRIVSEP_EVENT_STKSTART, 71 | PRIVSEP_EVENT_FT_RESPONSE, 72 | PRIVSEP_EVENT_RX_EAPOL, 73 | }; 74 | 75 | #endif /* PRIVSEP_COMMANDS_H */ 76 | -------------------------------------------------------------------------------- /src/crypto/fips_prf_internal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FIPS 186-2 PRF for internal crypto implementation 3 | * Copyright (c) 2006-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "sha1.h" 19 | #include "sha1_i.h" 20 | #include "crypto.h" 21 | 22 | 23 | int fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x, size_t xlen) 24 | { 25 | u8 xkey[64]; 26 | u32 t[5], _t[5]; 27 | int i, j, m, k; 28 | u8 *xpos = x; 29 | u32 carry; 30 | 31 | if (seed_len > sizeof(xkey)) 32 | seed_len = sizeof(xkey); 33 | 34 | /* FIPS 186-2 + change notice 1 */ 35 | 36 | os_memcpy(xkey, seed, seed_len); 37 | os_memset(xkey + seed_len, 0, 64 - seed_len); 38 | t[0] = 0x67452301; 39 | t[1] = 0xEFCDAB89; 40 | t[2] = 0x98BADCFE; 41 | t[3] = 0x10325476; 42 | t[4] = 0xC3D2E1F0; 43 | 44 | m = xlen / 40; 45 | for (j = 0; j < m; j++) { 46 | /* XSEED_j = 0 */ 47 | for (i = 0; i < 2; i++) { 48 | /* XVAL = (XKEY + XSEED_j) mod 2^b */ 49 | 50 | /* w_i = G(t, XVAL) */ 51 | os_memcpy(_t, t, 20); 52 | SHA1Transform(_t, xkey); 53 | _t[0] = host_to_be32(_t[0]); 54 | _t[1] = host_to_be32(_t[1]); 55 | _t[2] = host_to_be32(_t[2]); 56 | _t[3] = host_to_be32(_t[3]); 57 | _t[4] = host_to_be32(_t[4]); 58 | os_memcpy(xpos, _t, 20); 59 | 60 | /* XKEY = (1 + XKEY + w_i) mod 2^b */ 61 | carry = 1; 62 | for (k = 19; k >= 0; k--) { 63 | carry += xkey[k] + xpos[k]; 64 | xkey[k] = carry & 0xff; 65 | carry >>= 8; 66 | } 67 | 68 | xpos += SHA1_MAC_LEN; 69 | } 70 | /* x_j = w_0|w_1 */ 71 | } 72 | 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /src/eap_server/ikev2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IKEv2 initiator (RFC 4306) for EAP-IKEV2 3 | * Copyright (c) 2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef IKEV2_H 16 | #define IKEV2_H 17 | 18 | #include "eap_common/ikev2_common.h" 19 | 20 | struct ikev2_proposal_data { 21 | u8 proposal_num; 22 | int integ; 23 | int prf; 24 | int encr; 25 | int dh; 26 | }; 27 | 28 | 29 | struct ikev2_initiator_data { 30 | enum { SA_INIT, SA_AUTH, CHILD_SA, IKEV2_DONE } state; 31 | u8 i_spi[IKEV2_SPI_LEN]; 32 | u8 r_spi[IKEV2_SPI_LEN]; 33 | u8 i_nonce[IKEV2_NONCE_MAX_LEN]; 34 | size_t i_nonce_len; 35 | u8 r_nonce[IKEV2_NONCE_MAX_LEN]; 36 | size_t r_nonce_len; 37 | struct wpabuf *r_dh_public; 38 | struct wpabuf *i_dh_private; 39 | struct ikev2_proposal_data proposal; 40 | const struct dh_group *dh; 41 | struct ikev2_keys keys; 42 | u8 *IDi; 43 | size_t IDi_len; 44 | u8 *IDr; 45 | size_t IDr_len; 46 | u8 IDr_type; 47 | struct wpabuf *r_sign_msg; 48 | struct wpabuf *i_sign_msg; 49 | u8 *shared_secret; 50 | size_t shared_secret_len; 51 | enum { PEER_AUTH_CERT, PEER_AUTH_SECRET } peer_auth; 52 | u8 *key_pad; 53 | size_t key_pad_len; 54 | 55 | const u8 * (*get_shared_secret)(void *ctx, const u8 *IDr, 56 | size_t IDr_len, size_t *secret_len); 57 | void *cb_ctx; 58 | int unknown_user; 59 | }; 60 | 61 | 62 | void ikev2_initiator_deinit(struct ikev2_initiator_data *data); 63 | int ikev2_initiator_process(struct ikev2_initiator_data *data, 64 | const struct wpabuf *buf); 65 | struct wpabuf * ikev2_initiator_build(struct ikev2_initiator_data *data); 66 | 67 | #endif /* IKEV2_H */ 68 | -------------------------------------------------------------------------------- /src/crypto/aes_wrap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AES-based functions 3 | * 4 | * - AES Key Wrap Algorithm (128-bit KEK) (RFC3394) 5 | * - One-Key CBC MAC (OMAC1) hash with AES-128 6 | * - AES-128 CTR mode encryption 7 | * - AES-128 EAX mode encryption/decryption 8 | * - AES-128 CBC 9 | * 10 | * Copyright (c) 2003-2007, Jouni Malinen 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License version 2 as 14 | * published by the Free Software Foundation. 15 | * 16 | * Alternatively, this software may be distributed under the terms of BSD 17 | * license. 18 | * 19 | * See README and COPYING for more details. 20 | */ 21 | 22 | #ifndef AES_WRAP_H 23 | #define AES_WRAP_H 24 | 25 | int __must_check aes_wrap(const u8 *kek, int n, const u8 *plain, u8 *cipher); 26 | int __must_check aes_unwrap(const u8 *kek, int n, const u8 *cipher, u8 *plain); 27 | int __must_check omac1_aes_128_vector(const u8 *key, size_t num_elem, 28 | const u8 *addr[], const size_t *len, 29 | u8 *mac); 30 | int __must_check omac1_aes_128(const u8 *key, const u8 *data, size_t data_len, 31 | u8 *mac); 32 | int __must_check aes_128_encrypt_block(const u8 *key, const u8 *in, u8 *out); 33 | int __must_check aes_128_ctr_encrypt(const u8 *key, const u8 *nonce, 34 | u8 *data, size_t data_len); 35 | int __must_check aes_128_eax_encrypt(const u8 *key, 36 | const u8 *nonce, size_t nonce_len, 37 | const u8 *hdr, size_t hdr_len, 38 | u8 *data, size_t data_len, u8 *tag); 39 | int __must_check aes_128_eax_decrypt(const u8 *key, 40 | const u8 *nonce, size_t nonce_len, 41 | const u8 *hdr, size_t hdr_len, 42 | u8 *data, size_t data_len, const u8 *tag); 43 | int __must_check aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data, 44 | size_t data_len); 45 | int __must_check aes_128_cbc_decrypt(const u8 *key, const u8 *iv, u8 *data, 46 | size_t data_len); 47 | 48 | #endif /* AES_WRAP_H */ 49 | -------------------------------------------------------------------------------- /scripts/init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ### BEGIN INIT INFO 4 | # Provides: hostapd 5 | # Required-Start: $remote_fs 6 | # Required-Stop: $remote_fs 7 | # Should-Start: $network 8 | # Should-Stop: 9 | # Default-Start: 2 3 4 5 10 | # Default-Stop: 0 1 6 11 | # Short-Description: Advanced IEEE 802.11 management daemon 12 | # Description: Userspace IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP 13 | # Authenticator 14 | ### END INIT INFO 15 | 16 | PATH=/sbin:/bin:/usr/sbin:/usr/bin 17 | DAEMON_SBIN=/usr/local/bin/hostapd 18 | DAEMON_CONF=/etc/hostapd/hostapd.conf 19 | NAME=hostapd 20 | DESC="advanced IEEE 802.11 management" 21 | PIDFILE=/var/run/hostapd.pid 22 | 23 | [ -x "$DAEMON_SBIN" ] || exit 0 24 | [ -n "$DAEMON_CONF" ] || exit 0 25 | 26 | DAEMON_OPTS="-B -P $PIDFILE $DAEMON_OPTS $DAEMON_CONF" 27 | 28 | . /lib/lsb/init-functions 29 | 30 | case "$1" in 31 | start) 32 | log_daemon_msg "Starting $DESC" "$NAME" 33 | start-stop-daemon --start --oknodo --quiet --exec "$DAEMON_SBIN" \ 34 | --pidfile "$PIDFILE" -- $DAEMON_OPTS >/dev/null 35 | log_end_msg "$?" 36 | ;; 37 | stop) 38 | log_daemon_msg "Stopping $DESC" "$NAME" 39 | start-stop-daemon --stop --oknodo --quiet --exec "$DAEMON_SBIN" \ 40 | --pidfile "$PIDFILE" 41 | log_end_msg "$?" 42 | ;; 43 | reload) 44 | log_daemon_msg "Reloading $DESC" "$NAME" 45 | start-stop-daemon --stop --signal HUP --exec "$DAEMON_SBIN" \ 46 | --pidfile "$PIDFILE" 47 | log_end_msg "$?" 48 | ;; 49 | restart|force-reload) 50 | $0 stop 51 | sleep 8 52 | $0 start 53 | ;; 54 | status) 55 | status_of_proc "$DAEMON_SBIN" "$NAME" 56 | exit $? 57 | ;; 58 | *) 59 | N=/etc/init.d/$NAME 60 | echo "Usage: $N {start|stop|restart|force-reload|reload|status}" >&2 61 | exit 1 62 | ;; 63 | esac 64 | 65 | exit 0 66 | 67 | -------------------------------------------------------------------------------- /src/drivers/driver_ndis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant - Windows/NDIS driver interface 3 | * Copyright (c) 2004-2006, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef DRIVER_NDIS_H 16 | #define DRIVER_NDIS_H 17 | 18 | #ifdef CONFIG_NDIS_EVENTS_INTEGRATED 19 | struct ndis_events_data; 20 | struct ndis_events_data * ndis_events_init(HANDLE *read_pipe, HANDLE *event, 21 | const char *ifname, 22 | const char *desc); 23 | void ndis_events_deinit(struct ndis_events_data *events); 24 | #endif /* CONFIG_NDIS_EVENTS_INTEGRATED */ 25 | 26 | struct ndis_pmkid_entry { 27 | struct ndis_pmkid_entry *next; 28 | u8 bssid[ETH_ALEN]; 29 | u8 pmkid[16]; 30 | }; 31 | 32 | struct wpa_driver_ndis_data { 33 | void *ctx; 34 | char ifname[100]; /* GUID: {7EE3EFE5-C165-472F-986D-F6FBEDFE8C8D} */ 35 | #ifdef _WIN32_WCE 36 | TCHAR *adapter_name; 37 | HANDLE event_queue; /* NDISUIO notifier MsgQueue */ 38 | HANDLE connected_event; /* WpaSupplicantConnected event */ 39 | #endif /* _WIN32_WCE */ 40 | u8 own_addr[ETH_ALEN]; 41 | #ifdef CONFIG_USE_NDISUIO 42 | HANDLE ndisuio; 43 | #else /* CONFIG_USE_NDISUIO */ 44 | LPADAPTER adapter; 45 | #endif /* CONFIG_USE_NDISUIO */ 46 | u8 bssid[ETH_ALEN]; 47 | 48 | int has_capability; 49 | int no_of_pmkid; 50 | int radio_enabled; 51 | struct wpa_driver_capa capa; 52 | struct ndis_pmkid_entry *pmkid; 53 | char *adapter_desc; 54 | int wired; 55 | int native80211; 56 | int mode; 57 | int wzc_disabled; 58 | int oid_bssid_set; 59 | #ifdef CONFIG_NDIS_EVENTS_INTEGRATED 60 | HANDLE events_pipe, event_avail; 61 | struct ndis_events_data *events; 62 | #endif /* CONFIG_NDIS_EVENTS_INTEGRATED */ 63 | }; 64 | 65 | #endif /* DRIVER_NDIS_H */ 66 | -------------------------------------------------------------------------------- /src/utils/ip_addr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * IP address processing 3 | * Copyright (c) 2003-2006, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "ip_addr.h" 19 | 20 | const char * hostapd_ip_txt(const struct hostapd_ip_addr *addr, char *buf, 21 | size_t buflen) 22 | { 23 | if (buflen == 0 || addr == NULL) 24 | return NULL; 25 | 26 | if (addr->af == AF_INET) { 27 | os_strlcpy(buf, inet_ntoa(addr->u.v4), buflen); 28 | } else { 29 | buf[0] = '\0'; 30 | } 31 | #ifdef CONFIG_IPV6 32 | if (addr->af == AF_INET6) { 33 | if (inet_ntop(AF_INET6, &addr->u.v6, buf, buflen) == NULL) 34 | buf[0] = '\0'; 35 | } 36 | #endif /* CONFIG_IPV6 */ 37 | 38 | return buf; 39 | } 40 | 41 | 42 | int hostapd_ip_diff(struct hostapd_ip_addr *a, struct hostapd_ip_addr *b) 43 | { 44 | if (a == NULL && b == NULL) 45 | return 0; 46 | if (a == NULL || b == NULL) 47 | return 1; 48 | 49 | switch (a->af) { 50 | case AF_INET: 51 | if (a->u.v4.s_addr != b->u.v4.s_addr) 52 | return 1; 53 | break; 54 | #ifdef CONFIG_IPV6 55 | case AF_INET6: 56 | if (os_memcmp(&a->u.v6, &b->u.v6, sizeof(a->u.v6)) != 0) 57 | return 1; 58 | break; 59 | #endif /* CONFIG_IPV6 */ 60 | } 61 | 62 | return 0; 63 | } 64 | 65 | 66 | int hostapd_parse_ip_addr(const char *txt, struct hostapd_ip_addr *addr) 67 | { 68 | #ifndef CONFIG_NATIVE_WINDOWS 69 | if (inet_aton(txt, &addr->u.v4)) { 70 | addr->af = AF_INET; 71 | return 0; 72 | } 73 | 74 | #ifdef CONFIG_IPV6 75 | if (inet_pton(AF_INET6, txt, &addr->u.v6) > 0) { 76 | addr->af = AF_INET6; 77 | return 0; 78 | } 79 | #endif /* CONFIG_IPV6 */ 80 | #endif /* CONFIG_NATIVE_WINDOWS */ 81 | 82 | return -1; 83 | } 84 | -------------------------------------------------------------------------------- /src/crypto/aes-wrap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AES Key Wrap Algorithm (128-bit KEK) (RFC3394) 3 | * 4 | * Copyright (c) 2003-2007, Jouni Malinen 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License version 2 as 8 | * published by the Free Software Foundation. 9 | * 10 | * Alternatively, this software may be distributed under the terms of BSD 11 | * license. 12 | * 13 | * See README and COPYING for more details. 14 | */ 15 | 16 | #include "includes.h" 17 | 18 | #include "common.h" 19 | #include "aes.h" 20 | #include "aes_wrap.h" 21 | 22 | /** 23 | * aes_wrap - Wrap keys with AES Key Wrap Algorithm (128-bit KEK) (RFC3394) 24 | * @kek: 16-octet Key encryption key (KEK) 25 | * @n: Length of the plaintext key in 64-bit units; e.g., 2 = 128-bit = 16 26 | * bytes 27 | * @plain: Plaintext key to be wrapped, n * 64 bits 28 | * @cipher: Wrapped key, (n + 1) * 64 bits 29 | * Returns: 0 on success, -1 on failure 30 | */ 31 | int aes_wrap(const u8 *kek, int n, const u8 *plain, u8 *cipher) 32 | { 33 | u8 *a, *r, b[16]; 34 | int i, j; 35 | void *ctx; 36 | 37 | a = cipher; 38 | r = cipher + 8; 39 | 40 | /* 1) Initialize variables. */ 41 | os_memset(a, 0xa6, 8); 42 | os_memcpy(r, plain, 8 * n); 43 | 44 | ctx = aes_encrypt_init(kek, 16); 45 | if (ctx == NULL) 46 | return -1; 47 | 48 | /* 2) Calculate intermediate values. 49 | * For j = 0 to 5 50 | * For i=1 to n 51 | * B = AES(K, A | R[i]) 52 | * A = MSB(64, B) ^ t where t = (n*j)+i 53 | * R[i] = LSB(64, B) 54 | */ 55 | for (j = 0; j <= 5; j++) { 56 | r = cipher + 8; 57 | for (i = 1; i <= n; i++) { 58 | os_memcpy(b, a, 8); 59 | os_memcpy(b + 8, r, 8); 60 | aes_encrypt(ctx, b, b); 61 | os_memcpy(a, b, 8); 62 | a[7] ^= n * j + i; 63 | os_memcpy(r, b + 8, 8); 64 | r += 8; 65 | } 66 | } 67 | aes_encrypt_deinit(ctx); 68 | 69 | /* 3) Output the results. 70 | * 71 | * These are already in @cipher due to the location of temporary 72 | * variables. 73 | */ 74 | 75 | return 0; 76 | } 77 | -------------------------------------------------------------------------------- /src/wps/wps_dev_attr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Wi-Fi Protected Setup - device attributes 3 | * Copyright (c) 2008, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef WPS_DEV_ATTR_H 16 | #define WPS_DEV_ATTR_H 17 | 18 | struct wps_parse_attr; 19 | 20 | int wps_build_manufacturer(struct wps_device_data *dev, struct wpabuf *msg); 21 | int wps_build_model_name(struct wps_device_data *dev, struct wpabuf *msg); 22 | int wps_build_model_number(struct wps_device_data *dev, struct wpabuf *msg); 23 | int wps_build_dev_name(struct wps_device_data *dev, struct wpabuf *msg); 24 | int wps_build_device_attrs(struct wps_device_data *dev, struct wpabuf *msg); 25 | int wps_build_os_version(struct wps_device_data *dev, struct wpabuf *msg); 26 | int wps_build_rf_bands(struct wps_device_data *dev, struct wpabuf *msg); 27 | int wps_build_primary_dev_type(struct wps_device_data *dev, 28 | struct wpabuf *msg); 29 | int wps_build_secondary_dev_type(struct wps_device_data *dev, 30 | struct wpabuf *msg); 31 | int wps_build_dev_name(struct wps_device_data *dev, struct wpabuf *msg); 32 | int wps_process_device_attrs(struct wps_device_data *dev, 33 | struct wps_parse_attr *attr); 34 | int wps_process_os_version(struct wps_device_data *dev, const u8 *ver); 35 | int wps_process_rf_bands(struct wps_device_data *dev, const u8 *bands); 36 | void wps_device_data_dup(struct wps_device_data *dst, 37 | const struct wps_device_data *src); 38 | void wps_device_data_free(struct wps_device_data *dev); 39 | int wps_build_vendor_ext(struct wps_device_data *dev, struct wpabuf *msg); 40 | int wps_build_req_dev_type(struct wps_device_data *dev, struct wpabuf *msg, 41 | unsigned int num_req_dev_types, 42 | const u8 *req_dev_types); 43 | 44 | #endif /* WPS_DEV_ATTR_H */ 45 | -------------------------------------------------------------------------------- /src/eap_server/eap_methods.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP server method registration 3 | * Copyright (c) 2004-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef EAP_SERVER_METHODS_H 16 | #define EAP_SERVER_METHODS_H 17 | 18 | #include "eap_common/eap_defs.h" 19 | 20 | const struct eap_method * eap_server_get_eap_method(int vendor, 21 | EapType method); 22 | struct eap_method * eap_server_method_alloc(int version, int vendor, 23 | EapType method, const char *name); 24 | void eap_server_method_free(struct eap_method *method); 25 | int eap_server_method_register(struct eap_method *method); 26 | 27 | EapType eap_server_get_type(const char *name, int *vendor); 28 | void eap_server_unregister_methods(void); 29 | const char * eap_server_get_name(int vendor, EapType type); 30 | 31 | /* EAP server method registration calls for statically linked in methods */ 32 | int eap_server_identity_register(void); 33 | int eap_server_md5_register(void); 34 | int eap_server_tls_register(void); 35 | int eap_server_mschapv2_register(void); 36 | int eap_server_peap_register(void); 37 | int eap_server_tlv_register(void); 38 | int eap_server_gtc_register(void); 39 | int eap_server_ttls_register(void); 40 | int eap_server_sim_register(void); 41 | int eap_server_aka_register(void); 42 | int eap_server_aka_prime_register(void); 43 | int eap_server_pax_register(void); 44 | int eap_server_psk_register(void); 45 | int eap_server_sake_register(void); 46 | int eap_server_gpsk_register(void); 47 | int eap_server_vendor_test_register(void); 48 | int eap_server_fast_register(void); 49 | int eap_server_wsc_register(void); 50 | int eap_server_ikev2_register(void); 51 | int eap_server_tnc_register(void); 52 | int eap_server_pwd_register(void); 53 | 54 | #endif /* EAP_SERVER_METHODS_H */ 55 | -------------------------------------------------------------------------------- /src/eap_common/eap_psk_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP server/peer: EAP-PSK shared routines 3 | * Copyright (c) 2004-2006, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "crypto/aes_wrap.h" 19 | #include "eap_defs.h" 20 | #include "eap_psk_common.h" 21 | 22 | #define aes_block_size 16 23 | 24 | 25 | int eap_psk_key_setup(const u8 *psk, u8 *ak, u8 *kdk) 26 | { 27 | os_memset(ak, 0, aes_block_size); 28 | if (aes_128_encrypt_block(psk, ak, ak)) 29 | return -1; 30 | os_memcpy(kdk, ak, aes_block_size); 31 | ak[aes_block_size - 1] ^= 0x01; 32 | kdk[aes_block_size - 1] ^= 0x02; 33 | if (aes_128_encrypt_block(psk, ak, ak) || 34 | aes_128_encrypt_block(psk, kdk, kdk)) 35 | return -1; 36 | return 0; 37 | } 38 | 39 | 40 | int eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek, u8 *msk, 41 | u8 *emsk) 42 | { 43 | u8 hash[aes_block_size]; 44 | u8 counter = 1; 45 | int i; 46 | 47 | if (aes_128_encrypt_block(kdk, rand_p, hash)) 48 | return -1; 49 | 50 | hash[aes_block_size - 1] ^= counter; 51 | if (aes_128_encrypt_block(kdk, hash, tek)) 52 | return -1; 53 | hash[aes_block_size - 1] ^= counter; 54 | counter++; 55 | 56 | for (i = 0; i < EAP_MSK_LEN / aes_block_size; i++) { 57 | hash[aes_block_size - 1] ^= counter; 58 | if (aes_128_encrypt_block(kdk, hash, &msk[i * aes_block_size])) 59 | return -1; 60 | hash[aes_block_size - 1] ^= counter; 61 | counter++; 62 | } 63 | 64 | for (i = 0; i < EAP_EMSK_LEN / aes_block_size; i++) { 65 | hash[aes_block_size - 1] ^= counter; 66 | if (aes_128_encrypt_block(kdk, hash, 67 | &emsk[i * aes_block_size])) 68 | return -1; 69 | hash[aes_block_size - 1] ^= counter; 70 | counter++; 71 | } 72 | 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /src/ap/hw_features.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / Hardware feature query and different modes 3 | * Copyright 2002-2003, Instant802 Networks, Inc. 4 | * Copyright 2005-2006, Devicescape Software, Inc. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License version 2 as 8 | * published by the Free Software Foundation. 9 | * 10 | * Alternatively, this software may be distributed under the terms of BSD 11 | * license. 12 | * 13 | * See README and COPYING for more details. 14 | */ 15 | 16 | #ifndef HW_FEATURES_H 17 | #define HW_FEATURES_H 18 | 19 | #ifdef NEED_AP_MLME 20 | void hostapd_free_hw_features(struct hostapd_hw_modes *hw_features, 21 | size_t num_hw_features); 22 | int hostapd_get_hw_features(struct hostapd_iface *iface); 23 | int hostapd_select_hw_mode(struct hostapd_iface *iface); 24 | const char * hostapd_hw_mode_txt(int mode); 25 | int hostapd_hw_get_freq(struct hostapd_data *hapd, int chan); 26 | int hostapd_hw_get_channel(struct hostapd_data *hapd, int freq); 27 | int hostapd_check_ht_capab(struct hostapd_iface *iface); 28 | int hostapd_prepare_rates(struct hostapd_data *hapd, 29 | struct hostapd_hw_modes *mode); 30 | #else /* NEED_AP_MLME */ 31 | static inline void 32 | hostapd_free_hw_features(struct hostapd_hw_modes *hw_features, 33 | size_t num_hw_features) 34 | { 35 | } 36 | 37 | static inline int hostapd_get_hw_features(struct hostapd_iface *iface) 38 | { 39 | return -1; 40 | } 41 | 42 | static inline int hostapd_select_hw_mode(struct hostapd_iface *iface) 43 | { 44 | return -1; 45 | } 46 | 47 | static inline const char * hostapd_hw_mode_txt(int mode) 48 | { 49 | return NULL; 50 | } 51 | 52 | static inline int hostapd_hw_get_freq(struct hostapd_data *hapd, int chan) 53 | { 54 | return -1; 55 | } 56 | 57 | static inline int hostapd_check_ht_capab(struct hostapd_iface *iface) 58 | { 59 | return 0; 60 | } 61 | 62 | static inline int hostapd_prepare_rates(struct hostapd_data *hapd, 63 | struct hostapd_hw_modes *mode) 64 | { 65 | return 0; 66 | } 67 | 68 | #endif /* NEED_AP_MLME */ 69 | 70 | #endif /* HW_FEATURES_H */ 71 | -------------------------------------------------------------------------------- /src/eap_common/eap_ttls.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP server/peer: EAP-TTLS (RFC 5281) 3 | * Copyright (c) 2004-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef EAP_TTLS_H 16 | #define EAP_TTLS_H 17 | 18 | struct ttls_avp { 19 | be32 avp_code; 20 | be32 avp_length; /* 8-bit flags, 24-bit length; 21 | * length includes AVP header */ 22 | /* optional 32-bit Vendor-ID */ 23 | /* Data */ 24 | }; 25 | 26 | struct ttls_avp_vendor { 27 | be32 avp_code; 28 | be32 avp_length; /* 8-bit flags, 24-bit length; 29 | * length includes AVP header */ 30 | be32 vendor_id; 31 | /* Data */ 32 | }; 33 | 34 | #define AVP_FLAGS_VENDOR 0x80 35 | #define AVP_FLAGS_MANDATORY 0x40 36 | 37 | #define AVP_PAD(start, pos) \ 38 | do { \ 39 | int __pad; \ 40 | __pad = (4 - (((pos) - (start)) & 3)) & 3; \ 41 | os_memset((pos), 0, __pad); \ 42 | pos += __pad; \ 43 | } while (0) 44 | 45 | 46 | /* RFC 2865 */ 47 | #define RADIUS_ATTR_USER_NAME 1 48 | #define RADIUS_ATTR_USER_PASSWORD 2 49 | #define RADIUS_ATTR_CHAP_PASSWORD 3 50 | #define RADIUS_ATTR_REPLY_MESSAGE 18 51 | #define RADIUS_ATTR_CHAP_CHALLENGE 60 52 | #define RADIUS_ATTR_EAP_MESSAGE 79 53 | 54 | /* RFC 2548 */ 55 | #define RADIUS_VENDOR_ID_MICROSOFT 311 56 | #define RADIUS_ATTR_MS_CHAP_RESPONSE 1 57 | #define RADIUS_ATTR_MS_CHAP_ERROR 2 58 | #define RADIUS_ATTR_MS_CHAP_NT_ENC_PW 6 59 | #define RADIUS_ATTR_MS_CHAP_CHALLENGE 11 60 | #define RADIUS_ATTR_MS_CHAP2_RESPONSE 25 61 | #define RADIUS_ATTR_MS_CHAP2_SUCCESS 26 62 | #define RADIUS_ATTR_MS_CHAP2_CPW 27 63 | 64 | #define EAP_TTLS_MSCHAPV2_CHALLENGE_LEN 16 65 | #define EAP_TTLS_MSCHAPV2_RESPONSE_LEN 50 66 | #define EAP_TTLS_MSCHAP_CHALLENGE_LEN 8 67 | #define EAP_TTLS_MSCHAP_RESPONSE_LEN 50 68 | #define EAP_TTLS_CHAP_CHALLENGE_LEN 16 69 | #define EAP_TTLS_CHAP_PASSWORD_LEN 16 70 | 71 | #endif /* EAP_TTLS_H */ 72 | -------------------------------------------------------------------------------- /hostapd/bsd_hostapd.conf: -------------------------------------------------------------------------------- 1 | ##### hostapd configuration file ############################################## 2 | 3 | interface=rtw0 4 | ctrl_interface=/var/run/hostapd 5 | ssid=freebsd_ap_test 6 | channel=6 7 | wpa=2 8 | wpa_passphrase=87654321 9 | 10 | 11 | 12 | ##### Wi-Fi Protected Setup (WPS) ############################################# 13 | 14 | eap_server=1 15 | 16 | # WPS state 17 | # 0 = WPS disabled (default) 18 | # 1 = WPS enabled, not configured 19 | # 2 = WPS enabled, configured 20 | wps_state=2 21 | 22 | uuid=12345678-9abc-def0-1234-56789abcdef0 23 | 24 | # Device Name 25 | # User-friendly description of device; up to 32 octets encoded in UTF-8 26 | device_name=RTL8192CU 27 | 28 | # Manufacturer 29 | # The manufacturer of the device (up to 64 ASCII characters) 30 | manufacturer=Realtek 31 | 32 | # Model Name 33 | # Model of the device (up to 32 ASCII characters) 34 | model_name=RTW_SOFTAP 35 | 36 | # Model Number 37 | # Additional device description (up to 32 ASCII characters) 38 | model_number=WLAN_CU 39 | 40 | # Serial Number 41 | # Serial number of the device (up to 32 characters) 42 | serial_number=12345 43 | 44 | # Primary Device Type 45 | # Used format: -- 46 | # categ = Category as an integer value 47 | # OUI = OUI and type octet as a 4-octet hex-encoded value; 0050F204 for 48 | # default WPS OUI 49 | # subcateg = OUI-specific Sub Category as an integer value 50 | # Examples: 51 | # 1-0050F204-1 (Computer / PC) 52 | # 1-0050F204-2 (Computer / Server) 53 | # 5-0050F204-1 (Storage / NAS) 54 | # 6-0050F204-1 (Network Infrastructure / AP) 55 | device_type=6-0050F204-1 56 | 57 | # OS Version 58 | # 4-octet operating system version number (hex string) 59 | os_version=01020300 60 | 61 | # Config Methods 62 | # List of the supported configuration methods 63 | config_methods=label display push_button keypad 64 | 65 | 66 | ##### default configuration ####################################### 67 | 68 | driver=bsd 69 | beacon_int=100 70 | hw_mode=g 71 | ieee80211n=1 72 | wme_enabled=1 73 | ht_capab=[SHORT-GI-20][SHORT-GI-40] 74 | wpa_key_mgmt=WPA-PSK 75 | wpa_pairwise=CCMP 76 | max_num_sta=8 77 | wpa_group_rekey=86400 78 | 79 | -------------------------------------------------------------------------------- /src/crypto/fips_prf_openssl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FIPS 186-2 PRF for libcrypto 3 | * Copyright (c) 2004-2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | #include 17 | 18 | #include "common.h" 19 | #include "crypto.h" 20 | 21 | 22 | static void sha1_transform(u8 *state, const u8 data[64]) 23 | { 24 | SHA_CTX context; 25 | os_memset(&context, 0, sizeof(context)); 26 | os_memcpy(&context.h0, state, 5 * 4); 27 | SHA1_Transform(&context, data); 28 | os_memcpy(state, &context.h0, 5 * 4); 29 | } 30 | 31 | 32 | int fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x, size_t xlen) 33 | { 34 | u8 xkey[64]; 35 | u32 t[5], _t[5]; 36 | int i, j, m, k; 37 | u8 *xpos = x; 38 | u32 carry; 39 | 40 | if (seed_len > sizeof(xkey)) 41 | seed_len = sizeof(xkey); 42 | 43 | /* FIPS 186-2 + change notice 1 */ 44 | 45 | os_memcpy(xkey, seed, seed_len); 46 | os_memset(xkey + seed_len, 0, 64 - seed_len); 47 | t[0] = 0x67452301; 48 | t[1] = 0xEFCDAB89; 49 | t[2] = 0x98BADCFE; 50 | t[3] = 0x10325476; 51 | t[4] = 0xC3D2E1F0; 52 | 53 | m = xlen / 40; 54 | for (j = 0; j < m; j++) { 55 | /* XSEED_j = 0 */ 56 | for (i = 0; i < 2; i++) { 57 | /* XVAL = (XKEY + XSEED_j) mod 2^b */ 58 | 59 | /* w_i = G(t, XVAL) */ 60 | os_memcpy(_t, t, 20); 61 | sha1_transform((u8 *) _t, xkey); 62 | _t[0] = host_to_be32(_t[0]); 63 | _t[1] = host_to_be32(_t[1]); 64 | _t[2] = host_to_be32(_t[2]); 65 | _t[3] = host_to_be32(_t[3]); 66 | _t[4] = host_to_be32(_t[4]); 67 | os_memcpy(xpos, _t, 20); 68 | 69 | /* XKEY = (1 + XKEY + w_i) mod 2^b */ 70 | carry = 1; 71 | for (k = 19; k >= 0; k--) { 72 | carry += xkey[k] + xpos[k]; 73 | xkey[k] = carry & 0xff; 74 | carry >>= 8; 75 | } 76 | 77 | xpos += 20; 78 | } 79 | /* x_j = w_0|w_1 */ 80 | } 81 | 82 | return 0; 83 | } 84 | -------------------------------------------------------------------------------- /src/ap/pmksa_cache_auth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd - PMKSA cache for IEEE 802.11i RSN 3 | * Copyright (c) 2004-2008, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef PMKSA_CACHE_H 16 | #define PMKSA_CACHE_H 17 | 18 | #include "radius/radius.h" 19 | 20 | /** 21 | * struct rsn_pmksa_cache_entry - PMKSA cache entry 22 | */ 23 | struct rsn_pmksa_cache_entry { 24 | struct rsn_pmksa_cache_entry *next, *hnext; 25 | u8 pmkid[PMKID_LEN]; 26 | u8 pmk[PMK_LEN]; 27 | size_t pmk_len; 28 | os_time_t expiration; 29 | int akmp; /* WPA_KEY_MGMT_* */ 30 | u8 spa[ETH_ALEN]; 31 | 32 | u8 *identity; 33 | size_t identity_len; 34 | struct radius_class_data radius_class; 35 | u8 eap_type_authsrv; 36 | int vlan_id; 37 | int opportunistic; 38 | }; 39 | 40 | struct rsn_pmksa_cache; 41 | 42 | struct rsn_pmksa_cache * 43 | pmksa_cache_auth_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry, 44 | void *ctx), void *ctx); 45 | void pmksa_cache_auth_deinit(struct rsn_pmksa_cache *pmksa); 46 | struct rsn_pmksa_cache_entry * 47 | pmksa_cache_auth_get(struct rsn_pmksa_cache *pmksa, 48 | const u8 *spa, const u8 *pmkid); 49 | struct rsn_pmksa_cache_entry * pmksa_cache_get_okc( 50 | struct rsn_pmksa_cache *pmksa, const u8 *spa, const u8 *aa, 51 | const u8 *pmkid); 52 | struct rsn_pmksa_cache_entry * 53 | pmksa_cache_auth_add(struct rsn_pmksa_cache *pmksa, 54 | const u8 *pmk, size_t pmk_len, 55 | const u8 *aa, const u8 *spa, int session_timeout, 56 | struct eapol_state_machine *eapol, int akmp); 57 | struct rsn_pmksa_cache_entry * 58 | pmksa_cache_add_okc(struct rsn_pmksa_cache *pmksa, 59 | const struct rsn_pmksa_cache_entry *old_entry, 60 | const u8 *aa, const u8 *pmkid); 61 | void pmksa_cache_to_eapol_data(struct rsn_pmksa_cache_entry *entry, 62 | struct eapol_state_machine *eapol); 63 | 64 | #endif /* PMKSA_CACHE_H */ 65 | -------------------------------------------------------------------------------- /hostapd/hostapd_cli.1: -------------------------------------------------------------------------------- 1 | .TH HOSTAPD_CLI 1 "April 7, 2005" hostapd_cli "hostapd command-line interface" 2 | .SH NAME 3 | hostapd_cli \- hostapd command-line interface 4 | .SH SYNOPSIS 5 | .B hostapd_cli 6 | [\-p] [\-i] [\-a] [\-hvB] [command..] 7 | .SH DESCRIPTION 8 | This manual page documents briefly the 9 | .B hostapd_cli 10 | utility. 11 | .PP 12 | .B hostapd_cli 13 | is a command-line interface for the 14 | .B hostapd 15 | daemon. 16 | 17 | .B hostapd 18 | is a user space daemon for access point and authentication servers. 19 | It implements IEEE 802.11 access point management, IEEE 802.1X/WPA/WPA2/EAP Authenticators and RADIUS authentication server. 20 | For more information about 21 | .B hostapd 22 | refer to the 23 | .BR hostapd (8) 24 | man page. 25 | .SH OPTIONS 26 | A summary of options is included below. 27 | For a complete description, run 28 | .BR hostapd_cli 29 | from the command line. 30 | .TP 31 | .B \-p 32 | Path to find control sockets. 33 | 34 | Default: /var/run/hostapd 35 | .TP 36 | .B \-i 37 | Interface to listen on. 38 | 39 | Default: first interface found in socket path. 40 | .TP 41 | .B \-a 42 | Run in daemon mode executing the action file based on events from hostapd. 43 | .TP 44 | .B \-B 45 | Run a daemon in the background. 46 | .TP 47 | .B \-h 48 | Show usage. 49 | .TP 50 | .B \-v 51 | Show hostapd_cli version. 52 | .SH COMMANDS 53 | A summary of commands is included below. 54 | For a complete description, run 55 | .BR hostapd_cli 56 | from the command line. 57 | .TP 58 | .B mib 59 | Get MIB variables (dot1x, dot11, radius). 60 | .TP 61 | .B sta 62 | Get MIB variables for one station. 63 | .TP 64 | .B all_sta 65 | Get MIB variables for all stations. 66 | .TP 67 | .B help 68 | Get usage help. 69 | .TP 70 | .B interface [ifname] 71 | Show interfaces/select interface. 72 | .TP 73 | .B level 74 | Change debug level. 75 | .TP 76 | .B license 77 | Show full 78 | .B hostapd_cli 79 | license. 80 | .TP 81 | .B quit 82 | Exit hostapd_cli. 83 | .SH SEE ALSO 84 | .BR hostapd (8). 85 | .SH AUTHOR 86 | hostapd_cli was written by Jouni Malinen . 87 | .PP 88 | This manual page was written by Faidon Liambotis , 89 | for the Debian project (but may be used by others). 90 | -------------------------------------------------------------------------------- /src/crypto/aes-unwrap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AES key unwrap (128-bit KEK, RFC3394) 3 | * 4 | * Copyright (c) 2003-2007, Jouni Malinen 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License version 2 as 8 | * published by the Free Software Foundation. 9 | * 10 | * Alternatively, this software may be distributed under the terms of BSD 11 | * license. 12 | * 13 | * See README and COPYING for more details. 14 | */ 15 | 16 | #include "includes.h" 17 | 18 | #include "common.h" 19 | #include "aes.h" 20 | #include "aes_wrap.h" 21 | 22 | /** 23 | * aes_unwrap - Unwrap key with AES Key Wrap Algorithm (128-bit KEK) (RFC3394) 24 | * @kek: Key encryption key (KEK) 25 | * @n: Length of the plaintext key in 64-bit units; e.g., 2 = 128-bit = 16 26 | * bytes 27 | * @cipher: Wrapped key to be unwrapped, (n + 1) * 64 bits 28 | * @plain: Plaintext key, n * 64 bits 29 | * Returns: 0 on success, -1 on failure (e.g., integrity verification failed) 30 | */ 31 | int aes_unwrap(const u8 *kek, int n, const u8 *cipher, u8 *plain) 32 | { 33 | u8 a[8], *r, b[16]; 34 | int i, j; 35 | void *ctx; 36 | 37 | /* 1) Initialize variables. */ 38 | os_memcpy(a, cipher, 8); 39 | r = plain; 40 | os_memcpy(r, cipher + 8, 8 * n); 41 | 42 | ctx = aes_decrypt_init(kek, 16); 43 | if (ctx == NULL) 44 | return -1; 45 | 46 | /* 2) Compute intermediate values. 47 | * For j = 5 to 0 48 | * For i = n to 1 49 | * B = AES-1(K, (A ^ t) | R[i]) where t = n*j+i 50 | * A = MSB(64, B) 51 | * R[i] = LSB(64, B) 52 | */ 53 | for (j = 5; j >= 0; j--) { 54 | r = plain + (n - 1) * 8; 55 | for (i = n; i >= 1; i--) { 56 | os_memcpy(b, a, 8); 57 | b[7] ^= n * j + i; 58 | 59 | os_memcpy(b + 8, r, 8); 60 | aes_decrypt(ctx, b, b); 61 | os_memcpy(a, b, 8); 62 | os_memcpy(r, b + 8, 8); 63 | r -= 8; 64 | } 65 | } 66 | aes_decrypt_deinit(ctx); 67 | 68 | /* 3) Output results. 69 | * 70 | * These are already in @plain due to the location of temporary 71 | * variables. Just verify that the IV matches with the expected value. 72 | */ 73 | for (i = 0; i < 8; i++) { 74 | if (a[i] != 0xa6) 75 | return -1; 76 | } 77 | 78 | return 0; 79 | } 80 | -------------------------------------------------------------------------------- /src/eap_common/eap_gpsk_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP server/peer: EAP-GPSK shared routines 3 | * Copyright (c) 2006-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef EAP_GPSK_COMMON_H 16 | #define EAP_GPSK_COMMON_H 17 | 18 | #define EAP_GPSK_OPCODE_GPSK_1 1 19 | #define EAP_GPSK_OPCODE_GPSK_2 2 20 | #define EAP_GPSK_OPCODE_GPSK_3 3 21 | #define EAP_GPSK_OPCODE_GPSK_4 4 22 | #define EAP_GPSK_OPCODE_FAIL 5 23 | #define EAP_GPSK_OPCODE_PROTECTED_FAIL 6 24 | 25 | /* Failure-Code in GPSK-Fail and GPSK-Protected-Fail */ 26 | #define EAP_GPSK_FAIL_PSK_NOT_FOUND 0x00000001 27 | #define EAP_GPSK_FAIL_AUTHENTICATION_FAILURE 0x00000002 28 | #define EAP_GPSK_FAIL_AUTHORIZATION_FAILURE 0x00000003 29 | 30 | #define EAP_GPSK_RAND_LEN 32 31 | #define EAP_GPSK_MAX_SK_LEN 32 32 | #define EAP_GPSK_MAX_PK_LEN 32 33 | #define EAP_GPSK_MAX_MIC_LEN 32 34 | 35 | #define EAP_GPSK_VENDOR_IETF 0x00000000 36 | #define EAP_GPSK_CIPHER_RESERVED 0x000000 37 | #define EAP_GPSK_CIPHER_AES 0x000001 38 | #define EAP_GPSK_CIPHER_SHA256 0x000002 39 | 40 | 41 | #ifdef _MSC_VER 42 | #pragma pack(push, 1) 43 | #endif /* _MSC_VER */ 44 | 45 | struct eap_gpsk_csuite { 46 | u8 vendor[4]; 47 | u8 specifier[2]; 48 | } STRUCT_PACKED; 49 | 50 | #ifdef _MSC_VER 51 | #pragma pack(pop) 52 | #endif /* _MSC_VER */ 53 | 54 | int eap_gpsk_supported_ciphersuite(int vendor, int specifier); 55 | int eap_gpsk_derive_keys(const u8 *psk, size_t psk_len, int vendor, 56 | int specifier, 57 | const u8 *rand_client, const u8 *rand_server, 58 | const u8 *id_client, size_t id_client_len, 59 | const u8 *id_server, size_t id_server_len, 60 | u8 *msk, u8 *emsk, u8 *sk, size_t *sk_len, 61 | u8 *pk, size_t *pk_len); 62 | size_t eap_gpsk_mic_len(int vendor, int specifier); 63 | int eap_gpsk_compute_mic(const u8 *sk, size_t sk_len, int vendor, 64 | int specifier, const u8 *data, size_t len, u8 *mic); 65 | 66 | #endif /* EAP_GPSK_COMMON_H */ 67 | -------------------------------------------------------------------------------- /src/tls/tlsv1_server.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TLSv1 server (RFC 2246) 3 | * Copyright (c) 2006-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef TLSV1_SERVER_H 16 | #define TLSV1_SERVER_H 17 | 18 | #include "tlsv1_cred.h" 19 | 20 | struct tlsv1_server; 21 | 22 | int tlsv1_server_global_init(void); 23 | void tlsv1_server_global_deinit(void); 24 | struct tlsv1_server * tlsv1_server_init(struct tlsv1_credentials *cred); 25 | void tlsv1_server_deinit(struct tlsv1_server *conn); 26 | int tlsv1_server_established(struct tlsv1_server *conn); 27 | int tlsv1_server_prf(struct tlsv1_server *conn, const char *label, 28 | int server_random_first, u8 *out, size_t out_len); 29 | u8 * tlsv1_server_handshake(struct tlsv1_server *conn, 30 | const u8 *in_data, size_t in_len, size_t *out_len); 31 | int tlsv1_server_encrypt(struct tlsv1_server *conn, 32 | const u8 *in_data, size_t in_len, 33 | u8 *out_data, size_t out_len); 34 | int tlsv1_server_decrypt(struct tlsv1_server *conn, 35 | const u8 *in_data, size_t in_len, 36 | u8 *out_data, size_t out_len); 37 | int tlsv1_server_get_cipher(struct tlsv1_server *conn, char *buf, 38 | size_t buflen); 39 | int tlsv1_server_shutdown(struct tlsv1_server *conn); 40 | int tlsv1_server_resumed(struct tlsv1_server *conn); 41 | int tlsv1_server_get_keys(struct tlsv1_server *conn, struct tls_keys *keys); 42 | int tlsv1_server_get_keyblock_size(struct tlsv1_server *conn); 43 | int tlsv1_server_set_cipher_list(struct tlsv1_server *conn, u8 *ciphers); 44 | int tlsv1_server_set_verify(struct tlsv1_server *conn, int verify_peer); 45 | 46 | typedef int (*tlsv1_server_session_ticket_cb) 47 | (void *ctx, const u8 *ticket, size_t len, const u8 *client_random, 48 | const u8 *server_random, u8 *master_secret); 49 | 50 | void tlsv1_server_set_session_ticket_cb(struct tlsv1_server *conn, 51 | tlsv1_server_session_ticket_cb cb, 52 | void *ctx); 53 | 54 | #endif /* TLSV1_SERVER_H */ 55 | -------------------------------------------------------------------------------- /src/utils/pcsc_funcs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant / PC/SC smartcard interface for USIM, GSM SIM 3 | * Copyright (c) 2004-2006, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef PCSC_FUNCS_H 16 | #define PCSC_FUNCS_H 17 | 18 | /* GSM files 19 | * File type in first octet: 20 | * 3F = Master File 21 | * 7F = Dedicated File 22 | * 2F = Elementary File under the Master File 23 | * 6F = Elementary File under a Dedicated File 24 | */ 25 | #define SCARD_FILE_MF 0x3F00 26 | #define SCARD_FILE_GSM_DF 0x7F20 27 | #define SCARD_FILE_UMTS_DF 0x7F50 28 | #define SCARD_FILE_GSM_EF_IMSI 0x6F07 29 | #define SCARD_FILE_EF_DIR 0x2F00 30 | #define SCARD_FILE_EF_ICCID 0x2FE2 31 | #define SCARD_FILE_EF_CK 0x6FE1 32 | #define SCARD_FILE_EF_IK 0x6FE2 33 | 34 | #define SCARD_CHV1_OFFSET 13 35 | #define SCARD_CHV1_FLAG 0x80 36 | 37 | typedef enum { 38 | SCARD_GSM_SIM_ONLY, 39 | SCARD_USIM_ONLY, 40 | SCARD_TRY_BOTH 41 | } scard_sim_type; 42 | 43 | 44 | #ifdef PCSC_FUNCS 45 | struct scard_data * scard_init(scard_sim_type sim_type); 46 | void scard_deinit(struct scard_data *scard); 47 | 48 | int scard_set_pin(struct scard_data *scard, const char *pin); 49 | int scard_get_imsi(struct scard_data *scard, char *imsi, size_t *len); 50 | int scard_gsm_auth(struct scard_data *scard, const unsigned char *_rand, 51 | unsigned char *sres, unsigned char *kc); 52 | int scard_umts_auth(struct scard_data *scard, const unsigned char *_rand, 53 | const unsigned char *autn, 54 | unsigned char *res, size_t *res_len, 55 | unsigned char *ik, unsigned char *ck, unsigned char *auts); 56 | 57 | #else /* PCSC_FUNCS */ 58 | 59 | #define scard_init(s) NULL 60 | #define scard_deinit(s) do { } while (0) 61 | #define scard_set_pin(s, p) -1 62 | #define scard_get_imsi(s, i, l) -1 63 | #define scard_gsm_auth(s, r, s2, k) -1 64 | #define scard_umts_auth(s, r, a, r2, rl, i, c, a2) -1 65 | 66 | #endif /* PCSC_FUNCS */ 67 | 68 | #endif /* PCSC_FUNCS_H */ 69 | -------------------------------------------------------------------------------- /src/utils/edit_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Minimal command line editing 3 | * Copyright (c) 2010, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "eloop.h" 19 | #include "edit.h" 20 | 21 | 22 | #define CMD_BUF_LEN 256 23 | static char cmdbuf[CMD_BUF_LEN]; 24 | static int cmdbuf_pos = 0; 25 | 26 | static void *edit_cb_ctx; 27 | static void (*edit_cmd_cb)(void *ctx, char *cmd); 28 | static void (*edit_eof_cb)(void *ctx); 29 | 30 | 31 | static void edit_read_char(int sock, void *eloop_ctx, void *sock_ctx) 32 | { 33 | int c; 34 | unsigned char buf[1]; 35 | int res; 36 | 37 | res = read(sock, buf, 1); 38 | if (res < 0) 39 | perror("read"); 40 | if (res <= 0) { 41 | edit_eof_cb(edit_cb_ctx); 42 | return; 43 | } 44 | c = buf[0]; 45 | 46 | if (c == '\r' || c == '\n') { 47 | cmdbuf[cmdbuf_pos] = '\0'; 48 | cmdbuf_pos = 0; 49 | edit_cmd_cb(edit_cb_ctx, cmdbuf); 50 | printf("> "); 51 | fflush(stdout); 52 | return; 53 | } 54 | 55 | if (c >= 32 && c <= 255) { 56 | if (cmdbuf_pos < (int) sizeof(cmdbuf) - 1) { 57 | cmdbuf[cmdbuf_pos++] = c; 58 | } 59 | } 60 | } 61 | 62 | 63 | int edit_init(void (*cmd_cb)(void *ctx, char *cmd), 64 | void (*eof_cb)(void *ctx), 65 | char ** (*completion_cb)(void *ctx, const char *cmd, int pos), 66 | void *ctx, const char *history_file) 67 | { 68 | edit_cb_ctx = ctx; 69 | edit_cmd_cb = cmd_cb; 70 | edit_eof_cb = eof_cb; 71 | eloop_register_read_sock(STDIN_FILENO, edit_read_char, NULL, NULL); 72 | 73 | printf("> "); 74 | fflush(stdout); 75 | 76 | return 0; 77 | } 78 | 79 | 80 | void edit_deinit(const char *history_file, 81 | int (*filter_cb)(void *ctx, const char *cmd)) 82 | { 83 | eloop_unregister_read_sock(STDIN_FILENO); 84 | } 85 | 86 | 87 | void edit_clear_line(void) 88 | { 89 | } 90 | 91 | 92 | void edit_redraw(void) 93 | { 94 | cmdbuf[cmdbuf_pos] = '\0'; 95 | printf("\r> %s", cmdbuf); 96 | } 97 | -------------------------------------------------------------------------------- /src/crypto/sha1-tprf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA1 T-PRF for EAP-FAST 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "sha1.h" 19 | #include "crypto.h" 20 | 21 | /** 22 | * sha1_t_prf - EAP-FAST Pseudo-Random Function (T-PRF) 23 | * @key: Key for PRF 24 | * @key_len: Length of the key in bytes 25 | * @label: A unique label for each purpose of the PRF 26 | * @seed: Seed value to bind into the key 27 | * @seed_len: Length of the seed 28 | * @buf: Buffer for the generated pseudo-random key 29 | * @buf_len: Number of bytes of key to generate 30 | * Returns: 0 on success, -1 of failure 31 | * 32 | * This function is used to derive new, cryptographically separate keys from a 33 | * given key for EAP-FAST. T-PRF is defined in RFC 4851, Section 5.5. 34 | */ 35 | int sha1_t_prf(const u8 *key, size_t key_len, const char *label, 36 | const u8 *seed, size_t seed_len, u8 *buf, size_t buf_len) 37 | { 38 | unsigned char counter = 0; 39 | size_t pos, plen; 40 | u8 hash[SHA1_MAC_LEN]; 41 | size_t label_len = os_strlen(label); 42 | u8 output_len[2]; 43 | const unsigned char *addr[5]; 44 | size_t len[5]; 45 | 46 | addr[0] = hash; 47 | len[0] = 0; 48 | addr[1] = (unsigned char *) label; 49 | len[1] = label_len + 1; 50 | addr[2] = seed; 51 | len[2] = seed_len; 52 | addr[3] = output_len; 53 | len[3] = 2; 54 | addr[4] = &counter; 55 | len[4] = 1; 56 | 57 | output_len[0] = (buf_len >> 8) & 0xff; 58 | output_len[1] = buf_len & 0xff; 59 | pos = 0; 60 | while (pos < buf_len) { 61 | counter++; 62 | plen = buf_len - pos; 63 | if (hmac_sha1_vector(key, key_len, 5, addr, len, hash)) 64 | return -1; 65 | if (plen >= SHA1_MAC_LEN) { 66 | os_memcpy(&buf[pos], hash, SHA1_MAC_LEN); 67 | pos += SHA1_MAC_LEN; 68 | } else { 69 | os_memcpy(&buf[pos], hash, plen); 70 | break; 71 | } 72 | len[0] = SHA1_MAC_LEN; 73 | } 74 | 75 | return 0; 76 | } 77 | -------------------------------------------------------------------------------- /src/eap_common/eap_psk_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP server/peer: EAP-PSK shared routines 3 | * Copyright (c) 2004-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef EAP_PSK_COMMON_H 16 | #define EAP_PSK_COMMON_H 17 | 18 | 19 | #define EAP_PSK_RAND_LEN 16 20 | #define EAP_PSK_MAC_LEN 16 21 | #define EAP_PSK_TEK_LEN 16 22 | #define EAP_PSK_PSK_LEN 16 23 | #define EAP_PSK_AK_LEN 16 24 | #define EAP_PSK_KDK_LEN 16 25 | 26 | #define EAP_PSK_R_FLAG_CONT 1 27 | #define EAP_PSK_R_FLAG_DONE_SUCCESS 2 28 | #define EAP_PSK_R_FLAG_DONE_FAILURE 3 29 | #define EAP_PSK_E_FLAG 0x20 30 | 31 | #define EAP_PSK_FLAGS_GET_T(flags) (((flags) & 0xc0) >> 6) 32 | #define EAP_PSK_FLAGS_SET_T(t) ((u8) (t) << 6) 33 | 34 | #ifdef _MSC_VER 35 | #pragma pack(push, 1) 36 | #endif /* _MSC_VER */ 37 | 38 | /* EAP-PSK First Message (AS -> Supplicant) */ 39 | struct eap_psk_hdr_1 { 40 | u8 flags; 41 | u8 rand_s[EAP_PSK_RAND_LEN]; 42 | /* Followed by variable length ID_S */ 43 | } STRUCT_PACKED; 44 | 45 | /* EAP-PSK Second Message (Supplicant -> AS) */ 46 | struct eap_psk_hdr_2 { 47 | u8 flags; 48 | u8 rand_s[EAP_PSK_RAND_LEN]; 49 | u8 rand_p[EAP_PSK_RAND_LEN]; 50 | u8 mac_p[EAP_PSK_MAC_LEN]; 51 | /* Followed by variable length ID_P */ 52 | } STRUCT_PACKED; 53 | 54 | /* EAP-PSK Third Message (AS -> Supplicant) */ 55 | struct eap_psk_hdr_3 { 56 | u8 flags; 57 | u8 rand_s[EAP_PSK_RAND_LEN]; 58 | u8 mac_s[EAP_PSK_MAC_LEN]; 59 | /* Followed by variable length PCHANNEL */ 60 | } STRUCT_PACKED; 61 | 62 | /* EAP-PSK Fourth Message (Supplicant -> AS) */ 63 | struct eap_psk_hdr_4 { 64 | u8 flags; 65 | u8 rand_s[EAP_PSK_RAND_LEN]; 66 | /* Followed by variable length PCHANNEL */ 67 | } STRUCT_PACKED; 68 | 69 | #ifdef _MSC_VER 70 | #pragma pack(pop) 71 | #endif /* _MSC_VER */ 72 | 73 | 74 | int __must_check eap_psk_key_setup(const u8 *psk, u8 *ak, u8 *kdk); 75 | int __must_check eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek, 76 | u8 *msk, u8 *emsk); 77 | 78 | #endif /* EAP_PSK_COMMON_H */ 79 | -------------------------------------------------------------------------------- /src/common/ieee802_11_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IEEE 802.11 Common routines 3 | * Copyright (c) 2002-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef IEEE802_11_COMMON_H 16 | #define IEEE802_11_COMMON_H 17 | 18 | /* Parsed Information Elements */ 19 | struct ieee802_11_elems { 20 | const u8 *ssid; 21 | const u8 *supp_rates; 22 | const u8 *fh_params; 23 | const u8 *ds_params; 24 | const u8 *cf_params; 25 | const u8 *tim; 26 | const u8 *ibss_params; 27 | const u8 *challenge; 28 | const u8 *erp_info; 29 | const u8 *ext_supp_rates; 30 | const u8 *wpa_ie; 31 | const u8 *rsn_ie; 32 | const u8 *wmm; /* WMM Information or Parameter Element */ 33 | const u8 *wmm_tspec; 34 | const u8 *wps_ie; 35 | const u8 *power_cap; 36 | const u8 *supp_channels; 37 | const u8 *mdie; 38 | const u8 *ftie; 39 | const u8 *timeout_int; 40 | const u8 *ht_capabilities; 41 | const u8 *ht_operation; 42 | const u8 *vendor_ht_cap; 43 | const u8 *p2p; 44 | const u8 *link_id; 45 | 46 | u8 ssid_len; 47 | u8 supp_rates_len; 48 | u8 fh_params_len; 49 | u8 ds_params_len; 50 | u8 cf_params_len; 51 | u8 tim_len; 52 | u8 ibss_params_len; 53 | u8 challenge_len; 54 | u8 erp_info_len; 55 | u8 ext_supp_rates_len; 56 | u8 wpa_ie_len; 57 | u8 rsn_ie_len; 58 | u8 wmm_len; /* 7 = WMM Information; 24 = WMM Parameter */ 59 | u8 wmm_tspec_len; 60 | u8 wps_ie_len; 61 | u8 power_cap_len; 62 | u8 supp_channels_len; 63 | u8 mdie_len; 64 | u8 ftie_len; 65 | u8 timeout_int_len; 66 | u8 ht_capabilities_len; 67 | u8 ht_operation_len; 68 | u8 vendor_ht_cap_len; 69 | u8 p2p_len; 70 | }; 71 | 72 | typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes; 73 | 74 | ParseRes ieee802_11_parse_elems(const u8 *start, size_t len, 75 | struct ieee802_11_elems *elems, 76 | int show_errors); 77 | int ieee802_11_ie_count(const u8 *ies, size_t ies_len); 78 | struct wpabuf * ieee802_11_vendor_ie_concat(const u8 *ies, size_t ies_len, 79 | u32 oui_type); 80 | 81 | #endif /* IEEE802_11_COMMON_H */ 82 | -------------------------------------------------------------------------------- /wpa_supplicant/main_winmain.c: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant / WinMain() function for Windows-based applications 3 | * Copyright (c) 2006, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "wpa_supplicant_i.h" 19 | 20 | #ifdef _WIN32_WCE 21 | #define CMDLINE LPWSTR 22 | #else /* _WIN32_WCE */ 23 | #define CMDLINE LPSTR 24 | #endif /* _WIN32_WCE */ 25 | 26 | 27 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 28 | CMDLINE lpCmdLine, int nShowCmd) 29 | { 30 | int i; 31 | struct wpa_interface *ifaces, *iface; 32 | int iface_count, exitcode = -1; 33 | struct wpa_params params; 34 | struct wpa_global *global; 35 | 36 | if (os_program_init()) 37 | return -1; 38 | 39 | os_memset(¶ms, 0, sizeof(params)); 40 | params.wpa_debug_level = MSG_MSGDUMP; 41 | params.wpa_debug_file_path = "\\Temp\\wpa_supplicant-log.txt"; 42 | params.wpa_debug_show_keys = 1; 43 | 44 | iface = ifaces = os_zalloc(sizeof(struct wpa_interface)); 45 | if (ifaces == NULL) 46 | return -1; 47 | iface_count = 1; 48 | 49 | iface->confname = "default"; 50 | iface->driver = "ndis"; 51 | iface->ifname = ""; 52 | 53 | exitcode = 0; 54 | global = wpa_supplicant_init(¶ms); 55 | if (global == NULL) { 56 | printf("Failed to initialize wpa_supplicant\n"); 57 | exitcode = -1; 58 | } 59 | 60 | for (i = 0; exitcode == 0 && i < iface_count; i++) { 61 | if ((ifaces[i].confname == NULL && 62 | ifaces[i].ctrl_interface == NULL) || 63 | ifaces[i].ifname == NULL) { 64 | if (iface_count == 1 && (params.ctrl_interface || 65 | params.dbus_ctrl_interface)) 66 | break; 67 | exitcode = -1; 68 | break; 69 | } 70 | if (wpa_supplicant_add_iface(global, &ifaces[i]) == NULL) 71 | exitcode = -1; 72 | } 73 | 74 | if (exitcode == 0) 75 | exitcode = wpa_supplicant_run(global); 76 | 77 | wpa_supplicant_deinit(global); 78 | 79 | os_free(ifaces); 80 | 81 | os_program_deinit(); 82 | 83 | return exitcode; 84 | } 85 | -------------------------------------------------------------------------------- /src/eap_common/eap_peap_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP-PEAP common routines 3 | * Copyright (c) 2008, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "crypto/sha1.h" 19 | #include "eap_peap_common.h" 20 | 21 | void peap_prfplus(int version, const u8 *key, size_t key_len, 22 | const char *label, const u8 *seed, size_t seed_len, 23 | u8 *buf, size_t buf_len) 24 | { 25 | unsigned char counter = 0; 26 | size_t pos, plen; 27 | u8 hash[SHA1_MAC_LEN]; 28 | size_t label_len = os_strlen(label); 29 | u8 extra[2]; 30 | const unsigned char *addr[5]; 31 | size_t len[5]; 32 | 33 | addr[0] = hash; 34 | len[0] = 0; 35 | addr[1] = (unsigned char *) label; 36 | len[1] = label_len; 37 | addr[2] = seed; 38 | len[2] = seed_len; 39 | 40 | if (version == 0) { 41 | /* 42 | * PRF+(K, S, LEN) = T1 | T2 | ... | Tn 43 | * T1 = HMAC-SHA1(K, S | 0x01 | 0x00 | 0x00) 44 | * T2 = HMAC-SHA1(K, T1 | S | 0x02 | 0x00 | 0x00) 45 | * ... 46 | * Tn = HMAC-SHA1(K, Tn-1 | S | n | 0x00 | 0x00) 47 | */ 48 | 49 | extra[0] = 0; 50 | extra[1] = 0; 51 | 52 | addr[3] = &counter; 53 | len[3] = 1; 54 | addr[4] = extra; 55 | len[4] = 2; 56 | } else { 57 | /* 58 | * PRF (K,S,LEN) = T1 | T2 | T3 | T4 | ... where: 59 | * T1 = HMAC-SHA1(K, S | LEN | 0x01) 60 | * T2 = HMAC-SHA1 (K, T1 | S | LEN | 0x02) 61 | * T3 = HMAC-SHA1 (K, T2 | S | LEN | 0x03) 62 | * T4 = HMAC-SHA1 (K, T3 | S | LEN | 0x04) 63 | * ... 64 | */ 65 | 66 | extra[0] = buf_len & 0xff; 67 | 68 | addr[3] = extra; 69 | len[3] = 1; 70 | addr[4] = &counter; 71 | len[4] = 1; 72 | } 73 | 74 | pos = 0; 75 | while (pos < buf_len) { 76 | counter++; 77 | plen = buf_len - pos; 78 | hmac_sha1_vector(key, key_len, 5, addr, len, hash); 79 | if (plen >= SHA1_MAC_LEN) { 80 | os_memcpy(&buf[pos], hash, SHA1_MAC_LEN); 81 | pos += SHA1_MAC_LEN; 82 | } else { 83 | os_memcpy(&buf[pos], hash, plen); 84 | break; 85 | } 86 | len[0] = SHA1_MAC_LEN; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/utils/trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Backtrace debugging 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef TRACE_H 16 | #define TRACE_H 17 | 18 | #define WPA_TRACE_LEN 16 19 | 20 | #ifdef WPA_TRACE 21 | #include 22 | 23 | #include "list.h" 24 | 25 | #define WPA_TRACE_INFO void *btrace[WPA_TRACE_LEN]; int btrace_num; 26 | 27 | struct wpa_trace_ref { 28 | struct dl_list list; 29 | const void *addr; 30 | WPA_TRACE_INFO 31 | }; 32 | #define WPA_TRACE_REF(name) struct wpa_trace_ref wpa_trace_ref_##name 33 | 34 | #define wpa_trace_dump(title, ptr) \ 35 | wpa_trace_dump_func((title), (ptr)->btrace, (ptr)->btrace_num) 36 | void wpa_trace_dump_func(const char *title, void **btrace, int btrace_num); 37 | #define wpa_trace_record(ptr) \ 38 | (ptr)->btrace_num = backtrace((ptr)->btrace, WPA_TRACE_LEN) 39 | void wpa_trace_show(const char *title); 40 | #define wpa_trace_add_ref(ptr, name, addr) \ 41 | wpa_trace_add_ref_func(&(ptr)->wpa_trace_ref_##name, (addr)) 42 | void wpa_trace_add_ref_func(struct wpa_trace_ref *ref, const void *addr); 43 | #define wpa_trace_remove_ref(ptr, name, addr) \ 44 | do { \ 45 | if ((addr)) \ 46 | dl_list_del(&(ptr)->wpa_trace_ref_##name.list); \ 47 | } while (0) 48 | void wpa_trace_check_ref(const void *addr); 49 | 50 | #else /* WPA_TRACE */ 51 | 52 | #define WPA_TRACE_INFO 53 | #define WPA_TRACE_REF(n) 54 | #define wpa_trace_dump(title, ptr) do { } while (0) 55 | #define wpa_trace_record(ptr) do { } while (0) 56 | #define wpa_trace_show(title) do { } while (0) 57 | #define wpa_trace_add_ref(ptr, name, addr) do { } while (0) 58 | #define wpa_trace_remove_ref(ptr, name, addr) do { } while (0) 59 | #define wpa_trace_check_ref(addr) do { } while (0) 60 | 61 | #endif /* WPA_TRACE */ 62 | 63 | 64 | #ifdef WPA_TRACE_BFD 65 | 66 | void wpa_trace_dump_funcname(const char *title, void *pc); 67 | 68 | #else /* WPA_TRACE_BFD */ 69 | 70 | #define wpa_trace_dump_funcname(title, pc) do { } while (0) 71 | 72 | #endif /* WPA_TRACE_BFD */ 73 | 74 | #endif /* TRACE_H */ 75 | -------------------------------------------------------------------------------- /wpa_supplicant/bgscan.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant - background scan and roaming interface 3 | * Copyright (c) 2009-2010, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef BGSCAN_H 16 | #define BGSCAN_H 17 | 18 | struct wpa_supplicant; 19 | struct wpa_ssid; 20 | 21 | struct bgscan_ops { 22 | const char *name; 23 | 24 | void * (*init)(struct wpa_supplicant *wpa_s, const char *params, 25 | const struct wpa_ssid *ssid); 26 | void (*deinit)(void *priv); 27 | 28 | int (*notify_scan)(void *priv, struct wpa_scan_results *scan_res); 29 | void (*notify_beacon_loss)(void *priv); 30 | void (*notify_signal_change)(void *priv, int above, 31 | int current_signal, 32 | int current_noise, 33 | int current_txrate); 34 | }; 35 | 36 | #ifdef CONFIG_BGSCAN 37 | 38 | int bgscan_init(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); 39 | void bgscan_deinit(struct wpa_supplicant *wpa_s); 40 | int bgscan_notify_scan(struct wpa_supplicant *wpa_s, 41 | struct wpa_scan_results *scan_res); 42 | void bgscan_notify_beacon_loss(struct wpa_supplicant *wpa_s); 43 | void bgscan_notify_signal_change(struct wpa_supplicant *wpa_s, int above, 44 | int current_signal, int current_noise, 45 | int current_txrate); 46 | 47 | #else /* CONFIG_BGSCAN */ 48 | 49 | static inline int bgscan_init(struct wpa_supplicant *wpa_s, 50 | struct wpa_ssid *ssid) 51 | { 52 | return 0; 53 | } 54 | 55 | static inline void bgscan_deinit(struct wpa_supplicant *wpa_s) 56 | { 57 | } 58 | 59 | static inline int bgscan_notify_scan(struct wpa_supplicant *wpa_s, 60 | struct wpa_scan_results *scan_res) 61 | { 62 | return 0; 63 | } 64 | 65 | static inline void bgscan_notify_beacon_loss(struct wpa_supplicant *wpa_s) 66 | { 67 | } 68 | 69 | static inline void bgscan_notify_signal_change(struct wpa_supplicant *wpa_s, 70 | int above, int current_signal, 71 | int current_noise, 72 | int current_txrate) 73 | { 74 | } 75 | 76 | #endif /* CONFIG_BGSCAN */ 77 | 78 | #endif /* BGSCAN_H */ 79 | -------------------------------------------------------------------------------- /src/tls/tlsv1_server_i.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TLSv1 server - internal structures 3 | * Copyright (c) 2006-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef TLSV1_SERVER_I_H 16 | #define TLSV1_SERVER_I_H 17 | 18 | struct tlsv1_server { 19 | enum { 20 | CLIENT_HELLO, SERVER_HELLO, SERVER_CERTIFICATE, 21 | SERVER_KEY_EXCHANGE, SERVER_CERTIFICATE_REQUEST, 22 | SERVER_HELLO_DONE, CLIENT_CERTIFICATE, CLIENT_KEY_EXCHANGE, 23 | CERTIFICATE_VERIFY, CHANGE_CIPHER_SPEC, CLIENT_FINISHED, 24 | SERVER_CHANGE_CIPHER_SPEC, SERVER_FINISHED, 25 | ESTABLISHED, FAILED 26 | } state; 27 | 28 | struct tlsv1_record_layer rl; 29 | 30 | u8 session_id[TLS_SESSION_ID_MAX_LEN]; 31 | size_t session_id_len; 32 | u8 client_random[TLS_RANDOM_LEN]; 33 | u8 server_random[TLS_RANDOM_LEN]; 34 | u8 master_secret[TLS_MASTER_SECRET_LEN]; 35 | 36 | u8 alert_level; 37 | u8 alert_description; 38 | 39 | struct crypto_public_key *client_rsa_key; 40 | 41 | struct tls_verify_hash verify; 42 | 43 | #define MAX_CIPHER_COUNT 30 44 | u16 cipher_suites[MAX_CIPHER_COUNT]; 45 | size_t num_cipher_suites; 46 | 47 | u16 cipher_suite; 48 | 49 | struct tlsv1_credentials *cred; 50 | 51 | int verify_peer; 52 | u16 client_version; 53 | 54 | u8 *session_ticket; 55 | size_t session_ticket_len; 56 | 57 | tlsv1_server_session_ticket_cb session_ticket_cb; 58 | void *session_ticket_cb_ctx; 59 | 60 | int use_session_ticket; 61 | 62 | u8 *dh_secret; 63 | size_t dh_secret_len; 64 | }; 65 | 66 | 67 | void tlsv1_server_alert(struct tlsv1_server *conn, u8 level, u8 description); 68 | int tlsv1_server_derive_keys(struct tlsv1_server *conn, 69 | const u8 *pre_master_secret, 70 | size_t pre_master_secret_len); 71 | u8 * tlsv1_server_handshake_write(struct tlsv1_server *conn, size_t *out_len); 72 | u8 * tlsv1_server_send_alert(struct tlsv1_server *conn, u8 level, 73 | u8 description, size_t *out_len); 74 | int tlsv1_server_process_handshake(struct tlsv1_server *conn, u8 ct, 75 | const u8 *buf, size_t *len); 76 | 77 | #endif /* TLSV1_SERVER_I_H */ 78 | -------------------------------------------------------------------------------- /src/tls/tlsv1_record.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TLSv1 Record Protocol 3 | * Copyright (c) 2006-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef TLSV1_RECORD_H 16 | #define TLSV1_RECORD_H 17 | 18 | #include "crypto/crypto.h" 19 | 20 | #define TLS_MAX_WRITE_MAC_SECRET_LEN 20 21 | #define TLS_MAX_WRITE_KEY_LEN 32 22 | #define TLS_MAX_IV_LEN 16 23 | #define TLS_MAX_KEY_BLOCK_LEN (2 * (TLS_MAX_WRITE_MAC_SECRET_LEN + \ 24 | TLS_MAX_WRITE_KEY_LEN + TLS_MAX_IV_LEN)) 25 | 26 | #define TLS_SEQ_NUM_LEN 8 27 | #define TLS_RECORD_HEADER_LEN 5 28 | 29 | /* ContentType */ 30 | enum { 31 | TLS_CONTENT_TYPE_CHANGE_CIPHER_SPEC = 20, 32 | TLS_CONTENT_TYPE_ALERT = 21, 33 | TLS_CONTENT_TYPE_HANDSHAKE = 22, 34 | TLS_CONTENT_TYPE_APPLICATION_DATA = 23 35 | }; 36 | 37 | struct tlsv1_record_layer { 38 | u8 write_mac_secret[TLS_MAX_WRITE_MAC_SECRET_LEN]; 39 | u8 read_mac_secret[TLS_MAX_WRITE_MAC_SECRET_LEN]; 40 | u8 write_key[TLS_MAX_WRITE_KEY_LEN]; 41 | u8 read_key[TLS_MAX_WRITE_KEY_LEN]; 42 | u8 write_iv[TLS_MAX_IV_LEN]; 43 | u8 read_iv[TLS_MAX_IV_LEN]; 44 | 45 | size_t hash_size; 46 | size_t key_material_len; 47 | size_t iv_size; /* also block_size */ 48 | 49 | enum crypto_hash_alg hash_alg; 50 | enum crypto_cipher_alg cipher_alg; 51 | 52 | u8 write_seq_num[TLS_SEQ_NUM_LEN]; 53 | u8 read_seq_num[TLS_SEQ_NUM_LEN]; 54 | 55 | u16 cipher_suite; 56 | u16 write_cipher_suite; 57 | u16 read_cipher_suite; 58 | 59 | struct crypto_cipher *write_cbc; 60 | struct crypto_cipher *read_cbc; 61 | }; 62 | 63 | 64 | int tlsv1_record_set_cipher_suite(struct tlsv1_record_layer *rl, 65 | u16 cipher_suite); 66 | int tlsv1_record_change_write_cipher(struct tlsv1_record_layer *rl); 67 | int tlsv1_record_change_read_cipher(struct tlsv1_record_layer *rl); 68 | int tlsv1_record_send(struct tlsv1_record_layer *rl, u8 content_type, u8 *buf, 69 | size_t buf_size, size_t payload_len, size_t *out_len); 70 | int tlsv1_record_receive(struct tlsv1_record_layer *rl, 71 | const u8 *in_data, size_t in_len, 72 | u8 *out_data, size_t *out_len, u8 *alert); 73 | 74 | #endif /* TLSV1_RECORD_H */ 75 | -------------------------------------------------------------------------------- /src/tls/tlsv1_client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TLSv1 client (RFC 2246) 3 | * Copyright (c) 2006-2007, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef TLSV1_CLIENT_H 16 | #define TLSV1_CLIENT_H 17 | 18 | #include "tlsv1_cred.h" 19 | 20 | struct tlsv1_client; 21 | 22 | int tlsv1_client_global_init(void); 23 | void tlsv1_client_global_deinit(void); 24 | struct tlsv1_client * tlsv1_client_init(void); 25 | void tlsv1_client_deinit(struct tlsv1_client *conn); 26 | int tlsv1_client_established(struct tlsv1_client *conn); 27 | int tlsv1_client_prf(struct tlsv1_client *conn, const char *label, 28 | int server_random_first, u8 *out, size_t out_len); 29 | u8 * tlsv1_client_handshake(struct tlsv1_client *conn, 30 | const u8 *in_data, size_t in_len, 31 | size_t *out_len, u8 **appl_data, 32 | size_t *appl_data_len); 33 | int tlsv1_client_encrypt(struct tlsv1_client *conn, 34 | const u8 *in_data, size_t in_len, 35 | u8 *out_data, size_t out_len); 36 | int tlsv1_client_decrypt(struct tlsv1_client *conn, 37 | const u8 *in_data, size_t in_len, 38 | u8 *out_data, size_t out_len); 39 | int tlsv1_client_get_cipher(struct tlsv1_client *conn, char *buf, 40 | size_t buflen); 41 | int tlsv1_client_shutdown(struct tlsv1_client *conn); 42 | int tlsv1_client_resumed(struct tlsv1_client *conn); 43 | int tlsv1_client_hello_ext(struct tlsv1_client *conn, int ext_type, 44 | const u8 *data, size_t data_len); 45 | int tlsv1_client_get_keys(struct tlsv1_client *conn, struct tls_keys *keys); 46 | int tlsv1_client_get_keyblock_size(struct tlsv1_client *conn); 47 | int tlsv1_client_set_cipher_list(struct tlsv1_client *conn, u8 *ciphers); 48 | int tlsv1_client_set_cred(struct tlsv1_client *conn, 49 | struct tlsv1_credentials *cred); 50 | 51 | typedef int (*tlsv1_client_session_ticket_cb) 52 | (void *ctx, const u8 *ticket, size_t len, const u8 *client_random, 53 | const u8 *server_random, u8 *master_secret); 54 | 55 | void tlsv1_client_set_session_ticket_cb(struct tlsv1_client *conn, 56 | tlsv1_client_session_ticket_cb cb, 57 | void *ctx); 58 | 59 | #endif /* TLSV1_CLIENT_H */ 60 | -------------------------------------------------------------------------------- /src/ap/utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AP mode helper functions 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "common/ieee802_11_defs.h" 19 | #include "sta_info.h" 20 | #include "hostapd.h" 21 | 22 | 23 | int hostapd_register_probereq_cb(struct hostapd_data *hapd, 24 | int (*cb)(void *ctx, const u8 *sa, 25 | const u8 *ie, size_t ie_len), 26 | void *ctx) 27 | { 28 | struct hostapd_probereq_cb *n; 29 | 30 | n = os_realloc(hapd->probereq_cb, (hapd->num_probereq_cb + 1) * 31 | sizeof(struct hostapd_probereq_cb)); 32 | if (n == NULL) 33 | return -1; 34 | 35 | hapd->probereq_cb = n; 36 | n = &hapd->probereq_cb[hapd->num_probereq_cb]; 37 | hapd->num_probereq_cb++; 38 | 39 | n->cb = cb; 40 | n->ctx = ctx; 41 | 42 | return 0; 43 | } 44 | 45 | 46 | struct prune_data { 47 | struct hostapd_data *hapd; 48 | const u8 *addr; 49 | }; 50 | 51 | static int prune_associations(struct hostapd_iface *iface, void *ctx) 52 | { 53 | struct prune_data *data = ctx; 54 | struct sta_info *osta; 55 | struct hostapd_data *ohapd; 56 | size_t j; 57 | 58 | for (j = 0; j < iface->num_bss; j++) { 59 | ohapd = iface->bss[j]; 60 | if (ohapd == data->hapd) 61 | continue; 62 | osta = ap_get_sta(ohapd, data->addr); 63 | if (!osta) 64 | continue; 65 | 66 | ap_sta_disassociate(ohapd, osta, WLAN_REASON_UNSPECIFIED); 67 | } 68 | 69 | return 0; 70 | } 71 | 72 | /** 73 | * hostapd_prune_associations - Remove extraneous associations 74 | * @hapd: Pointer to BSS data for the most recent association 75 | * @addr: Associated STA address 76 | * 77 | * This function looks through all radios and BSS's for previous 78 | * (stale) associations of STA. If any are found they are removed. 79 | */ 80 | void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr) 81 | { 82 | struct prune_data data; 83 | data.hapd = hapd; 84 | data.addr = addr; 85 | if (hapd->iface->for_each_interface) 86 | hapd->iface->for_each_interface(hapd->iface->interfaces, 87 | prune_associations, &data); 88 | } 89 | -------------------------------------------------------------------------------- /src/ap/wps_hostapd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / WPS integration 3 | * Copyright (c) 2008-2010, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef WPS_HOSTAPD_H 16 | #define WPS_HOSTAPD_H 17 | 18 | #ifdef CONFIG_WPS 19 | 20 | int hostapd_init_wps(struct hostapd_data *hapd, 21 | struct hostapd_bss_config *conf); 22 | void hostapd_deinit_wps(struct hostapd_data *hapd); 23 | void hostapd_update_wps(struct hostapd_data *hapd); 24 | int hostapd_wps_add_pin(struct hostapd_data *hapd, const u8 *addr, 25 | const char *uuid, const char *pin, int timeout); 26 | int hostapd_wps_button_pushed(struct hostapd_data *hapd, 27 | const u8 *p2p_dev_addr); 28 | int hostapd_wps_start_oob(struct hostapd_data *hapd, char *device_type, 29 | char *path, char *method, char *name); 30 | int hostapd_wps_get_mib_sta(struct hostapd_data *hapd, const u8 *addr, 31 | char *buf, size_t buflen); 32 | void hostapd_wps_ap_pin_disable(struct hostapd_data *hapd); 33 | const char * hostapd_wps_ap_pin_random(struct hostapd_data *hapd, int timeout); 34 | const char * hostapd_wps_ap_pin_get(struct hostapd_data *hapd); 35 | int hostapd_wps_ap_pin_set(struct hostapd_data *hapd, const char *pin, 36 | int timeout); 37 | void hostapd_wps_update_ie(struct hostapd_data *hapd); 38 | int hostapd_wps_config_ap(struct hostapd_data *hapd, const char *ssid, 39 | const char *auth, const char *encr, const char *key); 40 | 41 | #else /* CONFIG_WPS */ 42 | 43 | static inline int hostapd_init_wps(struct hostapd_data *hapd, 44 | struct hostapd_bss_config *conf) 45 | { 46 | return 0; 47 | } 48 | 49 | static inline void hostapd_deinit_wps(struct hostapd_data *hapd) 50 | { 51 | } 52 | 53 | static inline void hostapd_update_wps(struct hostapd_data *hapd) 54 | { 55 | } 56 | 57 | static inline int hostapd_wps_get_mib_sta(struct hostapd_data *hapd, 58 | const u8 *addr, 59 | char *buf, size_t buflen) 60 | { 61 | return 0; 62 | } 63 | 64 | static inline int hostapd_wps_button_pushed(struct hostapd_data *hapd, 65 | const u8 *p2p_dev_addr) 66 | { 67 | return 0; 68 | } 69 | 70 | #endif /* CONFIG_WPS */ 71 | 72 | #endif /* WPS_HOSTAPD_H */ 73 | -------------------------------------------------------------------------------- /src/crypto/aes-cbc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AES-128 CBC 3 | * 4 | * Copyright (c) 2003-2007, Jouni Malinen 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License version 2 as 8 | * published by the Free Software Foundation. 9 | * 10 | * Alternatively, this software may be distributed under the terms of BSD 11 | * license. 12 | * 13 | * See README and COPYING for more details. 14 | */ 15 | 16 | #include "includes.h" 17 | 18 | #include "common.h" 19 | #include "aes.h" 20 | #include "aes_wrap.h" 21 | 22 | /** 23 | * aes_128_cbc_encrypt - AES-128 CBC encryption 24 | * @key: Encryption key 25 | * @iv: Encryption IV for CBC mode (16 bytes) 26 | * @data: Data to encrypt in-place 27 | * @data_len: Length of data in bytes (must be divisible by 16) 28 | * Returns: 0 on success, -1 on failure 29 | */ 30 | int aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len) 31 | { 32 | void *ctx; 33 | u8 cbc[AES_BLOCK_SIZE]; 34 | u8 *pos = data; 35 | int i, j, blocks; 36 | 37 | ctx = aes_encrypt_init(key, 16); 38 | if (ctx == NULL) 39 | return -1; 40 | os_memcpy(cbc, iv, AES_BLOCK_SIZE); 41 | 42 | blocks = data_len / AES_BLOCK_SIZE; 43 | for (i = 0; i < blocks; i++) { 44 | for (j = 0; j < AES_BLOCK_SIZE; j++) 45 | cbc[j] ^= pos[j]; 46 | aes_encrypt(ctx, cbc, cbc); 47 | os_memcpy(pos, cbc, AES_BLOCK_SIZE); 48 | pos += AES_BLOCK_SIZE; 49 | } 50 | aes_encrypt_deinit(ctx); 51 | return 0; 52 | } 53 | 54 | 55 | /** 56 | * aes_128_cbc_decrypt - AES-128 CBC decryption 57 | * @key: Decryption key 58 | * @iv: Decryption IV for CBC mode (16 bytes) 59 | * @data: Data to decrypt in-place 60 | * @data_len: Length of data in bytes (must be divisible by 16) 61 | * Returns: 0 on success, -1 on failure 62 | */ 63 | int aes_128_cbc_decrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len) 64 | { 65 | void *ctx; 66 | u8 cbc[AES_BLOCK_SIZE], tmp[AES_BLOCK_SIZE]; 67 | u8 *pos = data; 68 | int i, j, blocks; 69 | 70 | ctx = aes_decrypt_init(key, 16); 71 | if (ctx == NULL) 72 | return -1; 73 | os_memcpy(cbc, iv, AES_BLOCK_SIZE); 74 | 75 | blocks = data_len / AES_BLOCK_SIZE; 76 | for (i = 0; i < blocks; i++) { 77 | os_memcpy(tmp, pos, AES_BLOCK_SIZE); 78 | aes_decrypt(ctx, pos, pos); 79 | for (j = 0; j < AES_BLOCK_SIZE; j++) 80 | pos[j] ^= cbc[j]; 81 | os_memcpy(cbc, tmp, AES_BLOCK_SIZE); 82 | pos += AES_BLOCK_SIZE; 83 | } 84 | aes_decrypt_deinit(ctx); 85 | return 0; 86 | } 87 | -------------------------------------------------------------------------------- /wpa_supplicant/ap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant - Basic AP mode support routines 3 | * Copyright (c) 2003-2009, Jouni Malinen 4 | * Copyright (c) 2009, Atheros Communications 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License version 2 as 8 | * published by the Free Software Foundation. 9 | * 10 | * Alternatively, this software may be distributed under the terms of BSD 11 | * license. 12 | * 13 | * See README and COPYING for more details. 14 | */ 15 | 16 | #ifndef AP_H 17 | #define AP_H 18 | 19 | int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s, 20 | struct wpa_ssid *ssid); 21 | void wpa_supplicant_ap_deinit(struct wpa_supplicant *wpa_s); 22 | void wpa_supplicant_ap_rx_eapol(struct wpa_supplicant *wpa_s, 23 | const u8 *src_addr, const u8 *buf, size_t len); 24 | int wpa_supplicant_ap_wps_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid, 25 | const u8 *p2p_dev_addr); 26 | int wpa_supplicant_ap_wps_pin(struct wpa_supplicant *wpa_s, const u8 *bssid, 27 | const char *pin, char *buf, size_t buflen); 28 | int wpa_supplicant_ap_wps_cancel(struct wpa_supplicant *wpa_s); 29 | void wpas_wps_ap_pin_disable(struct wpa_supplicant *wpa_s); 30 | const char * wpas_wps_ap_pin_random(struct wpa_supplicant *wpa_s, int timeout); 31 | const char * wpas_wps_ap_pin_get(struct wpa_supplicant *wpa_s); 32 | int wpas_wps_ap_pin_set(struct wpa_supplicant *wpa_s, const char *pin, 33 | int timeout); 34 | int ap_ctrl_iface_sta_first(struct wpa_supplicant *wpa_s, 35 | char *buf, size_t buflen); 36 | int ap_ctrl_iface_sta(struct wpa_supplicant *wpa_s, const char *txtaddr, 37 | char *buf, size_t buflen); 38 | int ap_ctrl_iface_sta_next(struct wpa_supplicant *wpa_s, const char *txtaddr, 39 | char *buf, size_t buflen); 40 | int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf, 41 | size_t buflen, int verbose); 42 | void ap_tx_status(void *ctx, const u8 *addr, 43 | const u8 *buf, size_t len, int ack); 44 | void ap_rx_from_unknown_sta(void *ctx, const u8 *frame, size_t len); 45 | void ap_mgmt_rx(void *ctx, struct rx_mgmt *rx_mgmt); 46 | void ap_mgmt_tx_cb(void *ctx, const u8 *buf, size_t len, u16 stype, int ok); 47 | int wpa_supplicant_ap_update_beacon(struct wpa_supplicant *wpa_s); 48 | int wpa_supplicant_ap_mac_addr_filter(struct wpa_supplicant *wpa_s, 49 | const u8 *addr); 50 | void wpa_supplicant_ap_pwd_auth_fail(struct wpa_supplicant *wpa_s); 51 | 52 | #endif /* AP_H */ 53 | -------------------------------------------------------------------------------- /src/rsn_supp/preauth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wpa_supplicant - WPA2/RSN pre-authentication functions 3 | * Copyright (c) 2003-2009, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef PREAUTH_H 16 | #define PREAUTH_H 17 | 18 | struct wpa_scan_results; 19 | 20 | #if defined(IEEE8021X_EAPOL) && !defined(CONFIG_NO_WPA2) 21 | 22 | void pmksa_candidate_free(struct wpa_sm *sm); 23 | int rsn_preauth_init(struct wpa_sm *sm, const u8 *dst, 24 | struct eap_peer_config *eap_conf); 25 | void rsn_preauth_deinit(struct wpa_sm *sm); 26 | int rsn_preauth_scan_results(struct wpa_sm *sm); 27 | void rsn_preauth_scan_result(struct wpa_sm *sm, const u8 *bssid, 28 | const u8 *ssid, const u8 *rsn); 29 | void pmksa_candidate_add(struct wpa_sm *sm, const u8 *bssid, 30 | int prio, int preauth); 31 | void rsn_preauth_candidate_process(struct wpa_sm *sm); 32 | int rsn_preauth_get_status(struct wpa_sm *sm, char *buf, size_t buflen, 33 | int verbose); 34 | int rsn_preauth_in_progress(struct wpa_sm *sm); 35 | 36 | #else /* IEEE8021X_EAPOL and !CONFIG_NO_WPA2 */ 37 | 38 | static inline void pmksa_candidate_free(struct wpa_sm *sm) 39 | { 40 | } 41 | 42 | static inline void rsn_preauth_candidate_process(struct wpa_sm *sm) 43 | { 44 | } 45 | 46 | static inline int rsn_preauth_init(struct wpa_sm *sm, const u8 *dst, 47 | struct eap_peer_config *eap_conf) 48 | { 49 | return -1; 50 | } 51 | 52 | static inline void rsn_preauth_deinit(struct wpa_sm *sm) 53 | { 54 | } 55 | 56 | static inline int rsn_preauth_scan_results(struct wpa_sm *sm) 57 | { 58 | return -1; 59 | } 60 | 61 | static inline void rsn_preauth_scan_result(struct wpa_sm *sm, const u8 *bssid, 62 | const u8 *ssid, const u8 *rsn) 63 | { 64 | } 65 | 66 | static inline void pmksa_candidate_add(struct wpa_sm *sm, 67 | const u8 *bssid, 68 | int prio, int preauth) 69 | { 70 | } 71 | 72 | static inline int rsn_preauth_get_status(struct wpa_sm *sm, char *buf, 73 | size_t buflen, int verbose) 74 | { 75 | return 0; 76 | } 77 | 78 | static inline int rsn_preauth_in_progress(struct wpa_sm *sm) 79 | { 80 | return 0; 81 | } 82 | 83 | #endif /* IEEE8021X_EAPOL and !CONFIG_NO_WPA2 */ 84 | 85 | #endif /* PREAUTH_H */ 86 | -------------------------------------------------------------------------------- /src/drivers/driver_none.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Driver interface for RADIUS server or WPS ER only (no driver) 3 | * Copyright (c) 2008, Atheros Communications 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #include "includes.h" 16 | 17 | #include "common.h" 18 | #include "driver.h" 19 | 20 | 21 | struct none_driver_data { 22 | struct hostapd_data *hapd; 23 | void *ctx; 24 | }; 25 | 26 | 27 | static void * none_driver_hapd_init(struct hostapd_data *hapd, 28 | struct wpa_init_params *params) 29 | { 30 | struct none_driver_data *drv; 31 | 32 | drv = os_zalloc(sizeof(struct none_driver_data)); 33 | if (drv == NULL) { 34 | wpa_printf(MSG_ERROR, "Could not allocate memory for none " 35 | "driver data"); 36 | return NULL; 37 | } 38 | drv->hapd = hapd; 39 | 40 | return drv; 41 | } 42 | 43 | 44 | static void none_driver_hapd_deinit(void *priv) 45 | { 46 | struct none_driver_data *drv = priv; 47 | 48 | os_free(drv); 49 | } 50 | 51 | 52 | static int none_driver_send_ether(void *priv, const u8 *dst, const u8 *src, 53 | u16 proto, const u8 *data, size_t data_len) 54 | { 55 | return 0; 56 | } 57 | 58 | 59 | static void * none_driver_init(void *ctx, const char *ifname) 60 | { 61 | struct none_driver_data *drv; 62 | 63 | drv = os_zalloc(sizeof(struct none_driver_data)); 64 | if (drv == NULL) { 65 | wpa_printf(MSG_ERROR, "Could not allocate memory for none " 66 | "driver data"); 67 | return NULL; 68 | } 69 | drv->ctx = ctx; 70 | 71 | return drv; 72 | } 73 | 74 | 75 | static void none_driver_deinit(void *priv) 76 | { 77 | struct none_driver_data *drv = priv; 78 | 79 | os_free(drv); 80 | } 81 | 82 | 83 | static int none_driver_send_eapol(void *priv, const u8 *dest, u16 proto, 84 | const u8 *data, size_t data_len) 85 | { 86 | return -1; 87 | } 88 | 89 | 90 | const struct wpa_driver_ops wpa_driver_none_ops = { 91 | .name = "none", 92 | .desc = "no driver (RADIUS server/WPS ER)", 93 | .hapd_init = none_driver_hapd_init, 94 | .hapd_deinit = none_driver_hapd_deinit, 95 | .send_ether = none_driver_send_ether, 96 | .init = none_driver_init, 97 | .deinit = none_driver_deinit, 98 | .send_eapol = none_driver_send_eapol, 99 | }; 100 | --------------------------------------------------------------------------------