├── hostapd-2.0.tar.gz ├── hostapd-2.0 ├── .gitignore ├── src │ ├── ap │ │ ├── Makefile │ │ ├── hs20.h │ │ ├── authsrv.h │ │ ├── vlan_util.h │ │ ├── wnm_ap.h │ │ ├── wpa_auth_glue.h │ │ ├── tkip_countermeasures.h │ │ ├── hs20.c │ │ ├── ctrl_iface_ap.h │ │ ├── ieee802_11_auth.h │ │ ├── wmm.h │ │ ├── iapp.h │ │ ├── beacon.h │ │ ├── p2p_hostapd.h │ │ ├── ap_mlme.h │ │ ├── accounting.h │ │ ├── wpa_auth_ie.h │ │ ├── preauth_auth.h │ │ ├── vlan_init.h │ │ ├── pmksa_cache_auth.h │ │ ├── hw_features.h │ │ ├── utils.c │ │ ├── ap_list.h │ │ ├── gas_serv.h │ │ └── ieee802_1x.h │ ├── common │ │ ├── Makefile │ │ ├── version.h │ │ ├── gas.h │ │ ├── privsep_commands.h │ │ └── eapol_common.h │ ├── wps │ │ ├── Makefile │ │ ├── http.h │ │ ├── upnp_xml.h │ │ ├── http_server.h │ │ ├── http_client.h │ │ ├── wps_upnp.h │ │ └── wps_dev_attr.h │ ├── eap_common │ │ ├── Makefile │ │ ├── chap.h │ │ ├── eap_peap_common.h │ │ ├── chap.c │ │ ├── eap_wsc_common.h │ │ ├── eap_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_pwd_common.h │ │ └── eap_pax_common.h │ ├── eap_server │ │ ├── Makefile │ │ ├── tncs.h │ │ ├── ikev2.h │ │ └── eap_methods.h │ ├── eapol_auth │ │ └── Makefile │ ├── eapol_supp │ │ └── Makefile │ ├── l2_packet │ │ └── Makefile │ ├── rsn_supp │ │ ├── Makefile │ │ ├── wpa_ie.h │ │ ├── preauth.h │ │ └── peerkey.h │ ├── drivers │ │ ├── Makefile │ │ ├── rfkill.h │ │ ├── netlink.h │ │ ├── linux_ioctl.h │ │ ├── linux_wext.h │ │ ├── driver_ndis.h │ │ ├── driver_common.c │ │ ├── driver_none.c │ │ └── android_drv.h │ ├── p2p │ │ └── Makefile │ ├── eap_peer │ │ ├── Makefile │ │ ├── mschapv2.h │ │ ├── tncc.h │ │ ├── ikev2.h │ │ ├── eap_fast_pac.h │ │ └── eap_otp.c │ ├── lib.rules │ ├── radius │ │ ├── Makefile │ │ └── radius_das.h │ ├── Makefile │ ├── crypto │ │ ├── fips_prf_nss.c │ │ ├── fips_prf_cryptoapi.c │ │ ├── fips_prf_gnutls.c │ │ ├── crypto_none.c │ │ ├── md5.h │ │ ├── md5_i.h │ │ ├── dh_group5.h │ │ ├── aes.h │ │ ├── sha1_i.h │ │ ├── sha256_i.h │ │ ├── dh_groups.h │ │ ├── des_i.h │ │ ├── aes-encblock.c │ │ ├── sha256.h │ │ ├── dh_group5.c │ │ ├── random.h │ │ ├── milenage.h │ │ ├── sha1.h │ │ ├── rc4.c │ │ ├── Makefile │ │ ├── aes-ctr.c │ │ ├── crypto_internal-modexp.c │ │ ├── fips_prf_internal.c │ │ ├── aes-wrap.c │ │ ├── sha1-prf.c │ │ ├── sha256-prf.c │ │ ├── fips_prf_openssl.c │ │ ├── aes-unwrap.c │ │ ├── sha1-tprf.c │ │ ├── sha256-tlsprf.c │ │ ├── aes-cbc.c │ │ ├── ms_funcs.h │ │ └── sha1-pbkdf2.c │ ├── tls │ │ ├── pkcs5.h │ │ ├── pkcs8.h │ │ ├── rsa.h │ │ ├── Makefile │ │ ├── pkcs1.h │ │ ├── bignum.h │ │ ├── tlsv1_cred.h │ │ ├── tlsv1_server.h │ │ ├── tlsv1_server_i.h │ │ ├── tlsv1_record.h │ │ ├── tlsv1_client.h │ │ ├── asn1.h │ │ └── tlsv1_client_i.h │ └── utils │ │ ├── uuid.h │ │ ├── base64.h │ │ ├── ext_password_i.h │ │ ├── edit.h │ │ ├── Makefile │ │ ├── ip_addr.h │ │ ├── ext_password.h │ │ ├── includes.h │ │ ├── uuid.c │ │ ├── pcsc_funcs.h │ │ ├── ip_addr.c │ │ ├── radiotap_iter.h │ │ ├── trace.h │ │ ├── edit_simple.c │ │ ├── ext_password_test.c │ │ ├── build_config.h │ │ └── list.h ├── hostapd │ ├── hostapd.deny │ ├── hostapd.radius_clients │ ├── hostapd.accept │ ├── hostapd.vlan │ ├── logwatch │ │ ├── hostapd.conf │ │ ├── README │ │ └── hostapd │ ├── eap_register.h │ ├── dump_state.h │ ├── hostapd.sim_db │ ├── hostapd.wpa_psk │ ├── hostapd.eap_user_sqlite │ ├── config_file.h │ ├── hlr_auc_gw.milenage_db │ ├── nt_password_hash.c │ ├── ctrl_iface.h │ ├── wired.conf │ ├── hostapd.8 │ └── hostapd_cli.1 ├── COPYING └── README ├── README.md └── .gitignore /hostapd-2.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mengning/chameleon/HEAD/hostapd-2.0.tar.gz -------------------------------------------------------------------------------- /hostapd-2.0/.gitignore: -------------------------------------------------------------------------------- 1 | .tags 2 | .tags_sorted_by_file 3 | hostapd 4 | hostapd_cli 5 | *.hostapd 6 | *.d 7 | *.o 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # chameleon 2 | 实现一种WiFi路由器伪装技术,代号变色龙chameleon,以便使变色龙附近的手机(STA,station)能自动关联认证,以使WiFi技术拥有更好的使用体验和更大的覆盖范围。 3 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | #define VERSION_STR "2.0" VERSION_STR_POSTFIX 9 | 10 | #endif /* VERSION_H */ 11 | -------------------------------------------------------------------------------- /hostapd-2.0/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-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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-2.0/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-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | -------------------------------------------------------------------------------- /hostapd-2.0/hostapd/eap_register.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP method registration 3 | * Copyright (c) 2004-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EAP_REGISTER_H 10 | #define EAP_REGISTER_H 11 | 12 | int eap_server_register_methods(void); 13 | 14 | #endif /* EAP_REGISTER_H */ 15 | -------------------------------------------------------------------------------- /hostapd-2.0/hostapd/dump_state.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / State dump 3 | * Copyright (c) 2002-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef DUMP_STATE_H 10 | #define DUMP_STATE_H 11 | 12 | int handle_dump_state_iface(struct hostapd_iface *iface, void *ctx); 13 | 14 | #endif /* DUMP_STATE_H */ 15 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/hs20.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Hotspot 2.0 AP ANQP processing 3 | * Copyright (c) 2011-2012, Qualcomm Atheros, Inc. 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef HS20_H 10 | #define HS20_H 11 | 12 | struct hostapd_data; 13 | 14 | u8 * hostapd_eid_hs20_indication(struct hostapd_data *hapd, u8 *eid); 15 | 16 | #endif /* HS20_H */ 17 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/authsrv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Authentication server setup 3 | * Copyright (c) 2002-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef AUTHSRV_H 10 | #define AUTHSRV_H 11 | 12 | int authsrv_init(struct hostapd_data *hapd); 13 | void authsrv_deinit(struct hostapd_data *hapd); 14 | 15 | #endif /* AUTHSRV_H */ 16 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/vlan_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / VLAN netlink api 3 | * Copyright (c) 2012, Michael Braun 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef VLAN_UTIL_H 10 | #define VLAN_UTIL_H 11 | 12 | int vlan_add(const char *if_name, int vid, const char *vlan_if_name); 13 | int vlan_rem(const char *if_name); 14 | 15 | #endif /* VLAN_UTIL_H */ 16 | -------------------------------------------------------------------------------- /hostapd-2.0/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-2.0/src/crypto/fips_prf_nss.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FIPS 186-2 PRF for NSS 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | #include 11 | 12 | #include "common.h" 13 | #include "crypto.h" 14 | 15 | 16 | int fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x, size_t xlen) 17 | { 18 | return -1; 19 | } 20 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/wnm_ap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IEEE 802.11v WNM related functions and structures 3 | * Copyright (c) 2011-2012, Qualcomm Atheros, Inc. 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef WNM_AP_H 10 | #define WNM_AP_H 11 | 12 | struct rx_action; 13 | 14 | int ieee802_11_rx_wnm_action_ap(struct hostapd_data *hapd, 15 | struct rx_action *action); 16 | 17 | #endif /* WNM_AP_H */ 18 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_common/chap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CHAP-MD5 (RFC 1994) 3 | * Copyright (c) 2007-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef CHAP_H 10 | #define CHAP_H 11 | 12 | #define CHAP_MD5_LEN 16 13 | 14 | int chap_md5(u8 id, const u8 *secret, size_t secret_len, const u8 *challenge, 15 | size_t challenge_len, u8 *response); 16 | 17 | #endif /* CHAP_H */ 18 | -------------------------------------------------------------------------------- /hostapd-2.0/src/tls/pkcs5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PKCS #5 (Password-based Encryption) 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef PKCS5_H 10 | #define PKCS5_H 11 | 12 | u8 * pkcs5_decrypt(const u8 *enc_alg, size_t enc_alg_len, 13 | const u8 *enc_data, size_t enc_data_len, 14 | const char *passwd, size_t *data_len); 15 | 16 | #endif /* PKCS5_H */ 17 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/uuid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Universally Unique IDentifier (UUID) 3 | * Copyright (c) 2008, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef UUID_H 10 | #define UUID_H 11 | 12 | #define UUID_LEN 16 13 | 14 | int uuid_str2bin(const char *str, u8 *bin); 15 | int uuid_bin2str(const u8 *bin, char *str, size_t max_len); 16 | int is_nil_uuid(const u8 *uuid); 17 | 18 | #endif /* UUID_H */ 19 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/fips_prf_cryptoapi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FIPS 186-2 PRF for Microsoft CryptoAPI 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "crypto.h" 13 | 14 | 15 | int fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x, size_t xlen) 16 | { 17 | /* FIX: how to do this with CryptoAPI? */ 18 | return -1; 19 | } 20 | -------------------------------------------------------------------------------- /hostapd-2.0/src/tls/pkcs8.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PKCS #8 (Private-key information syntax) 3 | * Copyright (c) 2006-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef PKCS8_H 10 | #define PKCS8_H 11 | 12 | struct crypto_private_key * pkcs8_key_import(const u8 *buf, size_t len); 13 | struct crypto_private_key * 14 | pkcs8_enc_key_import(const u8 *buf, size_t len, const char *passwd); 15 | 16 | #endif /* PKCS8_H */ 17 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_common/eap_peap_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP-PEAP common routines 3 | * Copyright (c) 2008-2011, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EAP_PEAP_COMMON_H 10 | #define EAP_PEAP_COMMON_H 11 | 12 | int peap_prfplus(int version, const u8 *key, size_t key_len, 13 | const char *label, const u8 *seed, size_t seed_len, 14 | u8 *buf, size_t buf_len); 15 | 16 | #endif /* EAP_PEAP_COMMON_H */ 17 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/wpa_auth_glue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / WPA authenticator glue code 3 | * Copyright (c) 2002-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef WPA_AUTH_GLUE_H 10 | #define WPA_AUTH_GLUE_H 11 | 12 | int hostapd_setup_wpa(struct hostapd_data *hapd); 13 | void hostapd_reconfig_wpa(struct hostapd_data *hapd); 14 | void hostapd_deinit_wpa(struct hostapd_data *hapd); 15 | 16 | #endif /* WPA_AUTH_GLUE_H */ 17 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/fips_prf_gnutls.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FIPS 186-2 PRF for libgcrypt 3 | * Copyright (c) 2004-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | #include 11 | 12 | #include "common.h" 13 | #include "crypto.h" 14 | 15 | 16 | int fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x, size_t xlen) 17 | { 18 | /* FIX: how to do this with libgcrypt? */ 19 | return -1; 20 | } 21 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/tkip_countermeasures.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / TKIP countermeasures 3 | * Copyright (c) 2002-2012, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef TKIP_COUNTERMEASURES_H 10 | #define TKIP_COUNTERMEASURES_H 11 | 12 | int michael_mic_failure(struct hostapd_data *hapd, const u8 *addr, int local); 13 | void ieee80211_tkip_countermeasures_deinit(struct hostapd_data *hapd); 14 | 15 | #endif /* TKIP_COUNTERMEASURES_H */ 16 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Base64 encoding/decoding (RFC1341) 3 | * Copyright (c) 2005, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef BASE64_H 10 | #define BASE64_H 11 | 12 | unsigned char * base64_encode(const unsigned char *src, size_t len, 13 | size_t *out_len); 14 | unsigned char * base64_decode(const unsigned char *src, size_t len, 15 | size_t *out_len); 16 | 17 | #endif /* BASE64_H */ 18 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/crypto_none.c: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant / Empty template functions for crypto wrapper 3 | * Copyright (c) 2005, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "crypto.h" 13 | 14 | 15 | int md4_vector(size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac) 16 | { 17 | return 0; 18 | } 19 | 20 | 21 | void des_encrypt(const u8 *clear, const u8 *key, u8 *cypher) 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /hostapd-2.0/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-2.0/src/crypto/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MD5 hash implementation and interface functions 3 | * Copyright (c) 2003-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef MD5_H 10 | #define MD5_H 11 | 12 | #define MD5_MAC_LEN 16 13 | 14 | int hmac_md5_vector(const u8 *key, size_t key_len, size_t num_elem, 15 | const u8 *addr[], const size_t *len, u8 *mac); 16 | int hmac_md5(const u8 *key, size_t key_len, const u8 *data, size_t data_len, 17 | u8 *mac); 18 | 19 | #endif /* MD5_H */ 20 | -------------------------------------------------------------------------------- /hostapd-2.0/hostapd/hostapd.eap_user_sqlite: -------------------------------------------------------------------------------- 1 | CREATE TABLE users( 2 | identity TEXT PRIMARY KEY, 3 | methods TEXT, 4 | password TEXT, 5 | phase2 INTEGER 6 | ); 7 | 8 | CREATE TABLE wildcards( 9 | identity TEXT PRIMARY KEY, 10 | methods TEXT 11 | ); 12 | 13 | INSERT INTO users(identity,methods,password,phase2) VALUES ('user','TTLS-MSCHAPV2','password',1); 14 | INSERT INTO users(identity,methods,password,phase2) VALUES ('DOMAIN\mschapv2 user','TTLS-MSCHAPV2','password',1); 15 | 16 | INSERT INTO wildcards(identity,methods) VALUES ('','TTLS,TLS'); 17 | INSERT INTO wildcards(identity,methods) VALUES ('0','AKA'); 18 | -------------------------------------------------------------------------------- /hostapd-2.0/hostapd/config_file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / Configuration file parser 3 | * Copyright (c) 2003-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef CONFIG_FILE_H 10 | #define CONFIG_FILE_H 11 | 12 | struct hostapd_config * hostapd_config_read(const char *fname); 13 | int hostapd_set_iface(struct hostapd_config *conf, 14 | struct hostapd_bss_config *bss, char *field, 15 | char *value); 16 | void hostapd_set_security_params(struct hostapd_bss_config *bss); 17 | 18 | #endif /* CONFIG_FILE_H */ 19 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/md5_i.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MD5 internal definitions 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef MD5_I_H 10 | #define MD5_I_H 11 | 12 | struct MD5Context { 13 | u32 buf[4]; 14 | u32 bits[2]; 15 | u8 in[64]; 16 | }; 17 | 18 | void MD5Init(struct MD5Context *context); 19 | void MD5Update(struct MD5Context *context, unsigned char const *buf, 20 | unsigned len); 21 | void MD5Final(unsigned char digest[16], struct MD5Context *context); 22 | 23 | #endif /* MD5_I_H */ 24 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/dh_group5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Diffie-Hellman group 5 operations 3 | * Copyright (c) 2009, 2012, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef DH_GROUP5_H 10 | #define DH_GROUP5_H 11 | 12 | void * dh5_init(struct wpabuf **priv, struct wpabuf **publ); 13 | void * dh5_init_fixed(const struct wpabuf *priv, const struct wpabuf *publ); 14 | struct wpabuf * dh5_derive_shared(void *ctx, const struct wpabuf *peer_public, 15 | const struct wpabuf *own_private); 16 | void dh5_free(void *ctx); 17 | 18 | #endif /* DH_GROUP5_H */ 19 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/aes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AES functions 3 | * Copyright (c) 2003-2006, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef AES_H 10 | #define AES_H 11 | 12 | #define AES_BLOCK_SIZE 16 13 | 14 | void * aes_encrypt_init(const u8 *key, size_t len); 15 | void aes_encrypt(void *ctx, const u8 *plain, u8 *crypt); 16 | void aes_encrypt_deinit(void *ctx); 17 | void * aes_decrypt_init(const u8 *key, size_t len); 18 | void aes_decrypt(void *ctx, const u8 *crypt, u8 *plain); 19 | void aes_decrypt_deinit(void *ctx); 20 | 21 | #endif /* AES_H */ 22 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/ext_password_i.h: -------------------------------------------------------------------------------- 1 | /* 2 | * External password backend - internal definitions 3 | * Copyright (c) 2012, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EXT_PASSWORD_I_H 10 | #define EXT_PASSWORD_I_H 11 | 12 | #include "ext_password.h" 13 | 14 | struct ext_password_backend { 15 | const char *name; 16 | void * (*init)(const char *params); 17 | void (*deinit)(void *ctx); 18 | struct wpabuf * (*get)(void *ctx, const char *name); 19 | }; 20 | 21 | struct wpabuf * ext_password_alloc(size_t len); 22 | 23 | #endif /* EXT_PASSWORD_I_H */ 24 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/sha1_i.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA1 internal definitions 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef SHA1_I_H 10 | #define SHA1_I_H 11 | 12 | struct SHA1Context { 13 | u32 state[5]; 14 | u32 count[2]; 15 | unsigned char buffer[64]; 16 | }; 17 | 18 | void SHA1Init(struct SHA1Context *context); 19 | void SHA1Update(struct SHA1Context *context, const void *data, u32 len); 20 | void SHA1Final(unsigned char digest[20], struct SHA1Context *context); 21 | void SHA1Transform(u32 state[5], const unsigned char buffer[64]); 22 | 23 | #endif /* SHA1_I_H */ 24 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/sha256_i.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA-256 internal definitions 3 | * Copyright (c) 2003-2011, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef SHA256_I_H 10 | #define SHA256_I_H 11 | 12 | #define SHA256_BLOCK_SIZE 64 13 | 14 | struct sha256_state { 15 | u64 length; 16 | u32 state[8], curlen; 17 | u8 buf[SHA256_BLOCK_SIZE]; 18 | }; 19 | 20 | void sha256_init(struct sha256_state *md); 21 | int sha256_process(struct sha256_state *md, const unsigned char *in, 22 | unsigned long inlen); 23 | int sha256_done(struct sha256_state *md, unsigned char *out); 24 | 25 | #endif /* SHA256_I_H */ 26 | -------------------------------------------------------------------------------- /hostapd-2.0/src/drivers/rfkill.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Linux rfkill helper functions for driver wrappers 3 | * Copyright (c) 2010, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef RFKILL_H 10 | #define RFKILL_H 11 | 12 | struct rfkill_data; 13 | 14 | struct rfkill_config { 15 | void *ctx; 16 | char ifname[IFNAMSIZ]; 17 | void (*blocked_cb)(void *ctx); 18 | void (*unblocked_cb)(void *ctx); 19 | }; 20 | 21 | struct rfkill_data * rfkill_init(struct rfkill_config *cfg); 22 | void rfkill_deinit(struct rfkill_data *rfkill); 23 | int rfkill_is_blocked(struct rfkill_data *rfkill); 24 | 25 | #endif /* RFKILL_H */ 26 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/edit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Command line editing and history 3 | * Copyright (c) 2010, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EDIT_H 10 | #define EDIT_H 11 | 12 | int edit_init(void (*cmd_cb)(void *ctx, char *cmd), 13 | void (*eof_cb)(void *ctx), 14 | char ** (*completion_cb)(void *ctx, const char *cmd, int pos), 15 | void *ctx, const char *history_file, const char *ps); 16 | void edit_deinit(const char *history_file, 17 | int (*filter_cb)(void *ctx, const char *cmd)); 18 | void edit_clear_line(void); 19 | void edit_redraw(void); 20 | 21 | #endif /* EDIT_H */ 22 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_common/chap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CHAP-MD5 (RFC 1994) 3 | * Copyright (c) 2007-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "crypto/crypto.h" 13 | #include "chap.h" 14 | 15 | int chap_md5(u8 id, const u8 *secret, size_t secret_len, const u8 *challenge, 16 | size_t challenge_len, u8 *response) 17 | { 18 | const u8 *addr[3]; 19 | size_t len[3]; 20 | 21 | addr[0] = &id; 22 | len[0] = 1; 23 | addr[1] = secret; 24 | len[1] = secret_len; 25 | addr[2] = challenge; 26 | len[2] = challenge_len; 27 | return md5_vector(3, addr, len, response); 28 | } 29 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/dh_groups.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Diffie-Hellman groups 3 | * Copyright (c) 2007, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef DH_GROUPS_H 10 | #define DH_GROUPS_H 11 | 12 | struct dh_group { 13 | int id; 14 | const u8 *generator; 15 | size_t generator_len; 16 | const u8 *prime; 17 | size_t prime_len; 18 | }; 19 | 20 | const struct dh_group * dh_groups_get(int id); 21 | struct wpabuf * dh_init(const struct dh_group *dh, struct wpabuf **priv); 22 | struct wpabuf * dh_derive_shared(const struct wpabuf *peer_public, 23 | const struct wpabuf *own_private, 24 | const struct dh_group *dh); 25 | 26 | #endif /* DH_GROUPS_H */ 27 | -------------------------------------------------------------------------------- /hostapd-2.0/src/tls/rsa.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RSA 3 | * Copyright (c) 2006, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef RSA_H 10 | #define RSA_H 11 | 12 | struct crypto_rsa_key; 13 | 14 | struct crypto_rsa_key * 15 | crypto_rsa_import_public_key(const u8 *buf, size_t len); 16 | struct crypto_rsa_key * 17 | crypto_rsa_import_private_key(const u8 *buf, size_t len); 18 | size_t crypto_rsa_get_modulus_len(struct crypto_rsa_key *key); 19 | int crypto_rsa_exptmod(const u8 *in, size_t inlen, u8 *out, size_t *outlen, 20 | struct crypto_rsa_key *key, int use_private); 21 | void crypto_rsa_free(struct crypto_rsa_key *key); 22 | 23 | #endif /* RSA_H */ 24 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | CFLAGS += -DCONFIG_TLSV11 15 | CFLAGS += -DCONFIG_TLSV12 16 | 17 | LIB_OBJS= \ 18 | asn1.o \ 19 | bignum.o \ 20 | pkcs1.o \ 21 | pkcs5.o \ 22 | pkcs8.o \ 23 | rsa.o \ 24 | tlsv1_client.o \ 25 | tlsv1_client_read.o \ 26 | tlsv1_client_write.o \ 27 | tlsv1_common.o \ 28 | tlsv1_cred.o \ 29 | tlsv1_record.o \ 30 | tlsv1_server.o \ 31 | tlsv1_server_read.o \ 32 | tlsv1_server_write.o \ 33 | x509v3.o 34 | 35 | 36 | libtls.a: $(LIB_OBJS) 37 | $(AR) crT $@ $? 38 | 39 | -include $(OBJS:%.o=%.d) 40 | -------------------------------------------------------------------------------- /hostapd-2.0/src/tls/pkcs1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PKCS #1 (RSA Encryption) 3 | * Copyright (c) 2006-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef PKCS1_H 10 | #define PKCS1_H 11 | 12 | int pkcs1_encrypt(int block_type, struct crypto_rsa_key *key, 13 | int use_private, const u8 *in, size_t inlen, 14 | u8 *out, size_t *outlen); 15 | int pkcs1_v15_private_key_decrypt(struct crypto_rsa_key *key, 16 | const u8 *in, size_t inlen, 17 | u8 *out, size_t *outlen); 18 | int pkcs1_decrypt_public_key(struct crypto_rsa_key *key, 19 | const u8 *crypt, size_t crypt_len, 20 | u8 *plain, size_t *plain_len); 21 | 22 | #endif /* PKCS1_H */ 23 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EAP_WSC_COMMON_H 10 | #define EAP_WSC_COMMON_H 11 | 12 | #define EAP_VENDOR_TYPE_WSC 1 13 | 14 | #define WSC_FLAGS_MF 0x01 15 | #define WSC_FLAGS_LF 0x02 16 | 17 | #define WSC_ID_REGISTRAR "WFA-SimpleConfig-Registrar-1-0" 18 | #define WSC_ID_REGISTRAR_LEN 30 19 | #define WSC_ID_ENROLLEE "WFA-SimpleConfig-Enrollee-1-0" 20 | #define WSC_ID_ENROLLEE_LEN 29 21 | 22 | #define WSC_FRAGMENT_SIZE 1400 23 | 24 | 25 | struct wpabuf * eap_wsc_build_frag_ack(u8 id, u8 code); 26 | 27 | #endif /* EAP_WSC_COMMON_H */ 28 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/ip_addr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IP address processing 3 | * Copyright (c) 2003-2006, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef IP_ADDR_H 10 | #define IP_ADDR_H 11 | 12 | struct hostapd_ip_addr { 13 | int af; /* AF_INET / AF_INET6 */ 14 | union { 15 | struct in_addr v4; 16 | #ifdef CONFIG_IPV6 17 | struct in6_addr v6; 18 | #endif /* CONFIG_IPV6 */ 19 | u8 max_len[16]; 20 | } u; 21 | }; 22 | 23 | const char * hostapd_ip_txt(const struct hostapd_ip_addr *addr, char *buf, 24 | size_t buflen); 25 | int hostapd_ip_diff(struct hostapd_ip_addr *a, struct hostapd_ip_addr *b); 26 | int hostapd_parse_ip_addr(const char *txt, struct hostapd_ip_addr *addr); 27 | 28 | #endif /* IP_ADDR_H */ 29 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/des_i.h: -------------------------------------------------------------------------------- 1 | /* 2 | * DES and 3DES-EDE ciphers 3 | * Copyright (c) 2006-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef DES_I_H 10 | #define DES_I_H 11 | 12 | struct des3_key_s { 13 | u32 ek[3][32]; 14 | u32 dk[3][32]; 15 | }; 16 | 17 | void des_key_setup(const u8 *key, u32 *ek, u32 *dk); 18 | void des_block_encrypt(const u8 *plain, const u32 *ek, u8 *crypt); 19 | void des_block_decrypt(const u8 *crypt, const u32 *dk, u8 *plain); 20 | 21 | void des3_key_setup(const u8 *key, struct des3_key_s *dkey); 22 | void des3_encrypt(const u8 *plain, const struct des3_key_s *key, u8 *crypt); 23 | void des3_decrypt(const u8 *crypt, const struct des3_key_s *key, u8 *plain); 24 | 25 | #endif /* DES_I_H */ 26 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_common/eap_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP common peer/server definitions 3 | * Copyright (c) 2004-2012, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EAP_COMMON_H 10 | #define EAP_COMMON_H 11 | 12 | #include "wpabuf.h" 13 | 14 | int eap_hdr_len_valid(const struct wpabuf *msg, size_t min_payload); 15 | const u8 * eap_hdr_validate(int vendor, EapType eap_type, 16 | const struct wpabuf *msg, size_t *plen); 17 | struct wpabuf * eap_msg_alloc(int vendor, EapType type, size_t payload_len, 18 | u8 code, u8 identifier); 19 | void eap_update_len(struct wpabuf *msg); 20 | u8 eap_get_id(const struct wpabuf *msg); 21 | EapType eap_get_type(const struct wpabuf *msg); 22 | 23 | #endif /* EAP_COMMON_H */ 24 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/aes-encblock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AES encrypt_block 3 | * 4 | * Copyright (c) 2003-2007, Jouni Malinen 5 | * 6 | * This software may be distributed under the terms of the BSD license. 7 | * See README for more details. 8 | */ 9 | 10 | #include "includes.h" 11 | 12 | #include "common.h" 13 | #include "aes.h" 14 | #include "aes_wrap.h" 15 | 16 | /** 17 | * aes_128_encrypt_block - Perform one AES 128-bit block operation 18 | * @key: Key for AES 19 | * @in: Input data (16 bytes) 20 | * @out: Output of the AES block operation (16 bytes) 21 | * Returns: 0 on success, -1 on failure 22 | */ 23 | int aes_128_encrypt_block(const u8 *key, const u8 *in, u8 *out) 24 | { 25 | void *ctx; 26 | ctx = aes_encrypt_init(key, 16); 27 | if (ctx == NULL) 28 | return -1; 29 | aes_encrypt(ctx, in, out); 30 | aes_encrypt_deinit(ctx); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/hs20.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Hotspot 2.0 AP ANQP processing 3 | * Copyright (c) 2009, Atheros Communications, Inc. 4 | * Copyright (c) 2011-2012, Qualcomm Atheros, Inc. 5 | * 6 | * This software may be distributed under the terms of the BSD license. 7 | * See README for more details. 8 | */ 9 | 10 | #include "includes.h" 11 | 12 | #include "common.h" 13 | #include "common/ieee802_11_defs.h" 14 | #include "hostapd.h" 15 | #include "ap_config.h" 16 | #include "hs20.h" 17 | 18 | 19 | u8 * hostapd_eid_hs20_indication(struct hostapd_data *hapd, u8 *eid) 20 | { 21 | if (!hapd->conf->hs20) 22 | return eid; 23 | *eid++ = WLAN_EID_VENDOR_SPECIFIC; 24 | *eid++ = 5; 25 | WPA_PUT_BE24(eid, OUI_WFA); 26 | eid += 3; 27 | *eid++ = HS20_INDICATION_OUI_TYPE; 28 | /* Hotspot Configuration: DGAF Enabled */ 29 | *eid++ = hapd->conf->disable_dgaf ? 0x01 : 0x00; 30 | return eid; 31 | } 32 | -------------------------------------------------------------------------------- /hostapd-2.0/src/drivers/netlink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Netlink helper functions for driver wrappers 3 | * Copyright (c) 2002-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef NETLINK_H 10 | #define NETLINK_H 11 | 12 | struct netlink_data; 13 | struct ifinfomsg; 14 | 15 | struct netlink_config { 16 | void *ctx; 17 | void (*newlink_cb)(void *ctx, struct ifinfomsg *ifi, u8 *buf, 18 | size_t len); 19 | void (*dellink_cb)(void *ctx, struct ifinfomsg *ifi, u8 *buf, 20 | size_t len); 21 | }; 22 | 23 | struct netlink_data * netlink_init(struct netlink_config *cfg); 24 | void netlink_deinit(struct netlink_data *netlink); 25 | int netlink_send_oper_ifla(struct netlink_data *netlink, int ifindex, 26 | int linkmode, int operstate); 27 | 28 | #endif /* NETLINK_H */ 29 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/ctrl_iface_ap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Control interface for shared AP commands 3 | * Copyright (c) 2004-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef CTRL_IFACE_AP_H 10 | #define CTRL_IFACE_AP_H 11 | 12 | int hostapd_ctrl_iface_sta_first(struct hostapd_data *hapd, 13 | char *buf, size_t buflen); 14 | int hostapd_ctrl_iface_sta(struct hostapd_data *hapd, const char *txtaddr, 15 | char *buf, size_t buflen); 16 | int hostapd_ctrl_iface_sta_next(struct hostapd_data *hapd, const char *txtaddr, 17 | char *buf, size_t buflen); 18 | int hostapd_ctrl_iface_deauthenticate(struct hostapd_data *hapd, 19 | const char *txtaddr); 20 | int hostapd_ctrl_iface_disassociate(struct hostapd_data *hapd, 21 | const char *txtaddr); 22 | 23 | #endif /* CTRL_IFACE_AP_H */ 24 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | int xml_next_tag(const char *in, const char **out, 20 | const char **out_tagname, const char **end); 21 | char * xml_get_first_item(const char *doc, const char *item); 22 | struct wpabuf * xml_get_base64_item(const char *data, const char *name, 23 | enum http_reply_code *ret); 24 | 25 | #endif /* UPNP_XML_H */ 26 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/sha256.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA256 hash implementation and interface functions 3 | * Copyright (c) 2003-2011, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef SHA256_H 10 | #define SHA256_H 11 | 12 | #define SHA256_MAC_LEN 32 13 | 14 | int hmac_sha256_vector(const u8 *key, size_t key_len, size_t num_elem, 15 | const u8 *addr[], const size_t *len, u8 *mac); 16 | int hmac_sha256(const u8 *key, size_t key_len, const u8 *data, 17 | size_t data_len, u8 *mac); 18 | void sha256_prf(const u8 *key, size_t key_len, const char *label, 19 | const u8 *data, size_t data_len, u8 *buf, size_t buf_len); 20 | void tls_prf_sha256(const u8 *secret, size_t secret_len, 21 | const char *label, const u8 *seed, size_t seed_len, 22 | u8 *out, size_t outlen); 23 | 24 | #endif /* SHA256_H */ 25 | -------------------------------------------------------------------------------- /hostapd-2.0/src/drivers/linux_ioctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Linux ioctl helper functions for driver wrappers 3 | * Copyright (c) 2002-2010, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef LINUX_IOCTL_H 10 | #define LINUX_IOCTL_H 11 | 12 | int linux_set_iface_flags(int sock, const char *ifname, int dev_up); 13 | int linux_iface_up(int sock, const char *ifname); 14 | int linux_get_ifhwaddr(int sock, const char *ifname, u8 *addr); 15 | int linux_set_ifhwaddr(int sock, const char *ifname, const u8 *addr); 16 | int linux_br_add(int sock, const char *brname); 17 | int linux_br_del(int sock, const char *brname); 18 | int linux_br_add_if(int sock, const char *brname, const char *ifname); 19 | int linux_br_del_if(int sock, const char *brname, const char *ifname); 20 | int linux_br_get(char *brname, const char *ifname); 21 | 22 | #endif /* LINUX_IOCTL_H */ 23 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "eap_defs.h" 13 | #include "eap_common.h" 14 | #include "wps/wps.h" 15 | #include "eap_wsc_common.h" 16 | 17 | struct wpabuf * eap_wsc_build_frag_ack(u8 id, u8 code) 18 | { 19 | struct wpabuf *msg; 20 | 21 | msg = eap_msg_alloc(EAP_VENDOR_WFA, EAP_VENDOR_TYPE_WSC, 2, code, id); 22 | if (msg == NULL) { 23 | wpa_printf(MSG_ERROR, "EAP-WSC: Failed to allocate memory for " 24 | "FRAG_ACK"); 25 | return NULL; 26 | } 27 | 28 | wpa_printf(MSG_DEBUG, "EAP-WSC: Send WSC/FRAG_ACK"); 29 | wpabuf_put_u8(msg, WSC_FRAG_ACK); /* Op-Code */ 30 | wpabuf_put_u8(msg, 0); /* Flags */ 31 | 32 | return msg; 33 | } 34 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_peer/mschapv2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MSCHAPV2 (RFC 2759) 3 | * Copyright (c) 2004-2008, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef MSCHAPV2_H 10 | #define MSCHAPV2_H 11 | 12 | #define MSCHAPV2_CHAL_LEN 16 13 | #define MSCHAPV2_NT_RESPONSE_LEN 24 14 | #define MSCHAPV2_AUTH_RESPONSE_LEN 20 15 | #define MSCHAPV2_MASTER_KEY_LEN 16 16 | 17 | const u8 * mschapv2_remove_domain(const u8 *username, size_t *len); 18 | int mschapv2_derive_response(const u8 *username, size_t username_len, 19 | const u8 *password, size_t password_len, 20 | int pwhash, 21 | const u8 *auth_challenge, 22 | const u8 *peer_challenge, 23 | u8 *nt_response, u8 *auth_response, 24 | u8 *master_key); 25 | int mschapv2_verify_auth_response(const u8 *auth_response, 26 | const u8 *buf, size_t buf_len); 27 | 28 | #endif /* MSCHAPV2_H */ 29 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/dh_group5.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Diffie-Hellman group 5 operations 3 | * Copyright (c) 2009, 2012, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "dh_groups.h" 13 | #include "dh_group5.h" 14 | 15 | 16 | void * dh5_init(struct wpabuf **priv, struct wpabuf **publ) 17 | { 18 | *publ = dh_init(dh_groups_get(5), priv); 19 | if (*publ == NULL) 20 | return NULL; 21 | return (void *) 1; 22 | } 23 | 24 | 25 | void * dh5_init_fixed(const struct wpabuf *priv, const struct wpabuf *publ) 26 | { 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 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/random.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Random number generator 3 | * Copyright (c) 2010-2011, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef RANDOM_H 10 | #define RANDOM_H 11 | 12 | #ifdef CONFIG_NO_RANDOM_POOL 13 | #define random_init(e) do { } while (0) 14 | #define random_deinit() do { } while (0) 15 | #define random_add_randomness(b, l) do { } while (0) 16 | #define random_get_bytes(b, l) os_get_random((b), (l)) 17 | #define random_pool_ready() 1 18 | #define random_mark_pool_ready() do { } while (0) 19 | #else /* CONFIG_NO_RANDOM_POOL */ 20 | void random_init(const char *entropy_file); 21 | void random_deinit(void); 22 | void random_add_randomness(const void *buf, size_t len); 23 | int random_get_bytes(void *buf, size_t len); 24 | int random_pool_ready(void); 25 | void random_mark_pool_ready(void); 26 | #endif /* CONFIG_NO_RANDOM_POOL */ 27 | 28 | #endif /* RANDOM_H */ 29 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/ieee802_11_auth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / IEEE 802.11 authentication (ACL) 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef IEEE802_11_AUTH_H 10 | #define IEEE802_11_AUTH_H 11 | 12 | enum { 13 | HOSTAPD_ACL_REJECT = 0, 14 | HOSTAPD_ACL_ACCEPT = 1, 15 | HOSTAPD_ACL_PENDING = 2, 16 | HOSTAPD_ACL_ACCEPT_TIMEOUT = 3 17 | }; 18 | 19 | int hostapd_allowed_address(struct hostapd_data *hapd, const u8 *addr, 20 | const u8 *msg, size_t len, u32 *session_timeout, 21 | u32 *acct_interim_interval, int *vlan_id, 22 | struct hostapd_sta_wpa_psk_short **psk, 23 | char **identity, char **radius_cui); 24 | int hostapd_acl_init(struct hostapd_data *hapd); 25 | void hostapd_acl_deinit(struct hostapd_data *hapd); 26 | void hostapd_free_psk_list(struct hostapd_sta_wpa_psk_short *psk); 27 | 28 | #endif /* IEEE802_11_AUTH_H */ 29 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef IAPP_H 10 | #define IAPP_H 11 | 12 | struct iapp_data; 13 | 14 | #ifdef CONFIG_IAPP 15 | 16 | void iapp_new_station(struct iapp_data *iapp, struct sta_info *sta); 17 | struct iapp_data * iapp_init(struct hostapd_data *hapd, const char *iface); 18 | void iapp_deinit(struct iapp_data *iapp); 19 | 20 | #else /* CONFIG_IAPP */ 21 | 22 | static inline void iapp_new_station(struct iapp_data *iapp, 23 | struct sta_info *sta) 24 | { 25 | } 26 | 27 | static inline struct iapp_data * iapp_init(struct hostapd_data *hapd, 28 | const char *iface) 29 | { 30 | return NULL; 31 | } 32 | 33 | static inline void iapp_deinit(struct iapp_data *iapp) 34 | { 35 | } 36 | 37 | #endif /* CONFIG_IAPP */ 38 | 39 | #endif /* IAPP_H */ 40 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/ext_password.h: -------------------------------------------------------------------------------- 1 | /* 2 | * External password backend 3 | * Copyright (c) 2012, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EXT_PASSWORD_H 10 | #define EXT_PASSWORD_H 11 | 12 | struct ext_password_data; 13 | 14 | #ifdef CONFIG_EXT_PASSWORD 15 | 16 | struct ext_password_data * ext_password_init(const char *backend, 17 | const char *params); 18 | void ext_password_deinit(struct ext_password_data *data); 19 | 20 | struct wpabuf * ext_password_get(struct ext_password_data *data, 21 | const char *name); 22 | void ext_password_free(struct wpabuf *pw); 23 | 24 | #else /* CONFIG_EXT_PASSWORD */ 25 | 26 | #define ext_password_init(b, p) ((void *) 1) 27 | #define ext_password_deinit(d) do { } while (0) 28 | #define ext_password_get(d, n) (NULL) 29 | #define ext_password_free(p) do { } while (0) 30 | 31 | #endif /* CONFIG_EXT_PASSWORD */ 32 | 33 | #endif /* EXT_PASSWORD_H */ 34 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | int ssi_signal); 24 | void ieee802_11_set_beacon(struct hostapd_data *hapd); 25 | void ieee802_11_set_beacons(struct hostapd_iface *iface); 26 | void ieee802_11_update_beacons(struct hostapd_iface *iface); 27 | 28 | #endif /* BEACON_H */ 29 | -------------------------------------------------------------------------------- /hostapd-2.0/COPYING: -------------------------------------------------------------------------------- 1 | wpa_supplicant and hostapd 2 | -------------------------- 3 | 4 | Copyright (c) 2002-2012, Jouni Malinen and contributors 5 | All Rights Reserved. 6 | 7 | 8 | See the README file for the current license terms. 9 | 10 | This software was previously distributed under BSD/GPL v2 dual license 11 | terms that allowed either of those license alternatives to be 12 | selected. As of February 11, 2012, the project has chosen to use only 13 | the BSD license option for future distribution. As such, the GPL v2 14 | license option is no longer used. It should be noted that the BSD 15 | license option (the one with advertisement clause removed) is compatible 16 | with GPL and as such, does not prevent use of this software in projects 17 | that use GPL. 18 | 19 | Some of the files may still include pointers to GPL version 2 license 20 | terms. However, such copyright and license notifications are maintained 21 | only for attribution purposes and any distribution of this software 22 | after February 11, 2012 is no longer under the GPL v2 option. 23 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/p2p_hostapd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / P2P integration 3 | * Copyright (c) 2009-2010, Atheros Communications 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef P2P_HOSTAPD_H 10 | #define P2P_HOSTAPD_H 11 | 12 | #ifdef CONFIG_P2P 13 | 14 | int hostapd_p2p_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta, 15 | char *buf, size_t buflen); 16 | int hostapd_p2p_set_noa(struct hostapd_data *hapd, u8 count, int start, 17 | int duration); 18 | void hostapd_p2p_non_p2p_sta_connected(struct hostapd_data *hapd); 19 | void hostapd_p2p_non_p2p_sta_disconnected(struct hostapd_data *hapd); 20 | 21 | 22 | #else /* CONFIG_P2P */ 23 | 24 | static inline int hostapd_p2p_get_mib_sta(struct hostapd_data *hapd, 25 | struct sta_info *sta, 26 | char *buf, size_t buflen) 27 | { 28 | return 0; 29 | } 30 | 31 | #endif /* CONFIG_P2P */ 32 | 33 | u8 * hostapd_eid_p2p_manage(struct hostapd_data *hapd, u8 *eid); 34 | 35 | #endif /* P2P_HOSTAPD_H */ 36 | -------------------------------------------------------------------------------- /hostapd-2.0/src/drivers/linux_wext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Driver interaction with generic Linux Wireless Extensions 3 | * Copyright (c) 2003-2011, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef LINUX_WEXT_H 10 | #define LINUX_WEXT_H 11 | 12 | #ifndef ANDROID 13 | 14 | /* 15 | * Avoid including other kernel header to avoid conflicts with C library 16 | * headers. 17 | */ 18 | #define _LINUX_TYPES_H 19 | #define _LINUX_SOCKET_H 20 | #define _LINUX_IF_H 21 | 22 | #include 23 | #include 24 | typedef __uint32_t __u32; 25 | typedef __int32_t __s32; 26 | typedef __uint16_t __u16; 27 | typedef __int16_t __s16; 28 | typedef __uint8_t __u8; 29 | #ifndef __user 30 | #define __user 31 | #endif /* __user */ 32 | 33 | #endif /* ANDROID */ 34 | 35 | #include 36 | 37 | #ifndef IW_ENCODE_ALG_PMK 38 | #define IW_ENCODE_ALG_PMK 4 39 | #endif 40 | 41 | #ifndef IW_ENC_CAPA_4WAY_HANDSHAKE 42 | #define IW_ENC_CAPA_4WAY_HANDSHAKE 0x00000010 43 | #endif 44 | 45 | #endif /* LINUX_WEXT_H */ 46 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef MILENAGE_H 10 | #define MILENAGE_H 11 | 12 | void milenage_generate(const u8 *opc, const u8 *amf, const u8 *k, 13 | const u8 *sqn, const u8 *_rand, u8 *autn, u8 *ik, 14 | u8 *ck, u8 *res, size_t *res_len); 15 | int milenage_auts(const u8 *opc, const u8 *k, const u8 *_rand, const u8 *auts, 16 | u8 *sqn); 17 | int gsm_milenage(const u8 *opc, const u8 *k, const u8 *_rand, u8 *sres, 18 | u8 *kc); 19 | int milenage_check(const u8 *opc, const u8 *k, const u8 *sqn, const u8 *_rand, 20 | const u8 *autn, u8 *ik, u8 *ck, u8 *res, size_t *res_len, 21 | u8 *auts); 22 | int milenage_f1(const u8 *opc, const u8 *k, const u8 *_rand, 23 | const u8 *sqn, const u8 *amf, u8 *mac_a, u8 *mac_s); 24 | int milenage_f2345(const u8 *opc, const u8 *k, const u8 *_rand, 25 | u8 *res, u8 *ck, u8 *ik, u8 *ak, u8 *akstar); 26 | 27 | #endif /* MILENAGE_H */ 28 | -------------------------------------------------------------------------------- /hostapd-2.0/hostapd/nt_password_hash.c: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd - Plaintext password to NtPasswordHash 3 | * Copyright (c) 2005, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "crypto/ms_funcs.h" 13 | 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | unsigned char password_hash[16]; 18 | size_t i; 19 | char *password, buf[64], *pos; 20 | 21 | if (argc > 1) 22 | password = argv[1]; 23 | else { 24 | if (fgets(buf, sizeof(buf), stdin) == NULL) { 25 | printf("Failed to read password\n"); 26 | return 1; 27 | } 28 | buf[sizeof(buf) - 1] = '\0'; 29 | pos = buf; 30 | while (*pos != '\0') { 31 | if (*pos == '\r' || *pos == '\n') { 32 | *pos = '\0'; 33 | break; 34 | } 35 | pos++; 36 | } 37 | password = buf; 38 | } 39 | 40 | if (nt_password_hash((u8 *) password, strlen(password), password_hash)) 41 | return -1; 42 | for (i = 0; i < sizeof(password_hash); i++) 43 | printf("%02x", password_hash[i]); 44 | printf("\n"); 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 8 | * See README for more details. 9 | */ 10 | 11 | #ifndef MLME_H 12 | #define MLME_H 13 | 14 | void mlme_authenticate_indication(struct hostapd_data *hapd, 15 | struct sta_info *sta); 16 | 17 | void mlme_deauthenticate_indication(struct hostapd_data *hapd, 18 | struct sta_info *sta, u16 reason_code); 19 | 20 | void mlme_associate_indication(struct hostapd_data *hapd, 21 | struct sta_info *sta); 22 | 23 | void mlme_reassociate_indication(struct hostapd_data *hapd, 24 | struct sta_info *sta); 25 | 26 | void mlme_disassociate_indication(struct hostapd_data *hapd, 27 | struct sta_info *sta, u16 reason_code); 28 | 29 | void mlme_michaelmicfailure_indication(struct hostapd_data *hapd, 30 | const u8 *addr); 31 | 32 | void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta); 33 | 34 | #endif /* MLME_H */ 35 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_peer/tncc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP-TNC - TNCC (IF-IMC and IF-TNCCS) 3 | * Copyright (c) 2007, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef TNCC_H 10 | #define TNCC_H 11 | 12 | struct tncc_data; 13 | 14 | struct tncc_data * tncc_init(void); 15 | void tncc_deinit(struct tncc_data *tncc); 16 | void tncc_init_connection(struct tncc_data *tncc); 17 | size_t tncc_total_send_len(struct tncc_data *tncc); 18 | u8 * tncc_copy_send_buf(struct tncc_data *tncc, u8 *pos); 19 | char * tncc_if_tnccs_start(struct tncc_data *tncc); 20 | char * tncc_if_tnccs_end(void); 21 | 22 | enum tncc_process_res { 23 | TNCCS_PROCESS_ERROR = -1, 24 | TNCCS_PROCESS_OK_NO_RECOMMENDATION = 0, 25 | TNCCS_RECOMMENDATION_ERROR, 26 | TNCCS_RECOMMENDATION_ALLOW, 27 | TNCCS_RECOMMENDATION_NONE, 28 | TNCCS_RECOMMENDATION_ISOLATE 29 | }; 30 | 31 | enum tncc_process_res tncc_process_if_tnccs(struct tncc_data *tncc, 32 | const u8 *msg, size_t len); 33 | 34 | struct wpabuf * tncc_process_soh_request(int ver, const u8 *data, size_t len); 35 | 36 | #endif /* TNCC_H */ 37 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/sha1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA1 hash implementation and interface functions 3 | * Copyright (c) 2003-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef SHA1_H 10 | #define SHA1_H 11 | 12 | #define SHA1_MAC_LEN 20 13 | 14 | int hmac_sha1_vector(const u8 *key, size_t key_len, size_t num_elem, 15 | const u8 *addr[], const size_t *len, u8 *mac); 16 | int hmac_sha1(const u8 *key, size_t key_len, const u8 *data, size_t data_len, 17 | u8 *mac); 18 | int sha1_prf(const u8 *key, size_t key_len, const char *label, 19 | const u8 *data, size_t data_len, u8 *buf, size_t buf_len); 20 | int sha1_t_prf(const u8 *key, size_t key_len, const char *label, 21 | const u8 *seed, size_t seed_len, u8 *buf, size_t buf_len); 22 | int __must_check tls_prf_sha1_md5(const u8 *secret, size_t secret_len, 23 | const char *label, const u8 *seed, 24 | size_t seed_len, u8 *out, size_t outlen); 25 | int pbkdf2_sha1(const char *passphrase, const u8 *ssid, size_t ssid_len, 26 | int iterations, u8 *buf, size_t buflen); 27 | #endif /* SHA1_H */ 28 | -------------------------------------------------------------------------------- /hostapd-2.0/hostapd/ctrl_iface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / UNIX domain socket -based control interface 3 | * Copyright (c) 2004, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef CTRL_IFACE_H 10 | #define CTRL_IFACE_H 11 | 12 | #ifndef CONFIG_NO_CTRL_IFACE 13 | int hostapd_ctrl_iface_init(struct hostapd_data *hapd); 14 | void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd); 15 | int hostapd_global_ctrl_iface_init(struct hapd_interfaces *interface); 16 | void hostapd_global_ctrl_iface_deinit(struct hapd_interfaces *interface); 17 | #else /* CONFIG_NO_CTRL_IFACE */ 18 | static inline int hostapd_ctrl_iface_init(struct hostapd_data *hapd) 19 | { 20 | return 0; 21 | } 22 | 23 | static inline void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd) 24 | { 25 | } 26 | 27 | static inline int 28 | hostapd_global_ctrl_iface_init(struct hapd_interfaces *interface) 29 | { 30 | return 0; 31 | } 32 | 33 | static inline void 34 | hostapd_global_ctrl_iface_deinit(struct hapd_interfaces *interface) 35 | { 36 | } 37 | #endif /* CONFIG_NO_CTRL_IFACE */ 38 | 39 | #endif /* CTRL_IFACE_H */ 40 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_common/eap_ikev2_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP-IKEv2 definitions 3 | * Copyright (c) 2007, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EAP_IKEV2_COMMON_H 10 | #define EAP_IKEV2_COMMON_H 11 | 12 | #ifdef CCNS_PL 13 | /* incorrect bit order */ 14 | #define IKEV2_FLAGS_LENGTH_INCLUDED 0x01 15 | #define IKEV2_FLAGS_MORE_FRAGMENTS 0x02 16 | #define IKEV2_FLAGS_ICV_INCLUDED 0x04 17 | #else /* CCNS_PL */ 18 | #define IKEV2_FLAGS_LENGTH_INCLUDED 0x80 19 | #define IKEV2_FLAGS_MORE_FRAGMENTS 0x40 20 | #define IKEV2_FLAGS_ICV_INCLUDED 0x20 21 | #endif /* CCNS_PL */ 22 | 23 | #define IKEV2_FRAGMENT_SIZE 1400 24 | 25 | struct ikev2_keys; 26 | 27 | int eap_ikev2_derive_keymat(int prf, struct ikev2_keys *keys, 28 | const u8 *i_nonce, size_t i_nonce_len, 29 | const u8 *r_nonce, size_t r_nonce_len, 30 | u8 *keymat); 31 | struct wpabuf * eap_ikev2_build_frag_ack(u8 id, u8 code); 32 | int eap_ikev2_validate_icv(int integ_alg, struct ikev2_keys *keys, 33 | int initiator, const struct wpabuf *msg, 34 | const u8 *pos, const u8 *end); 35 | 36 | #endif /* EAP_IKEV2_COMMON_H */ 37 | -------------------------------------------------------------------------------- /hostapd-2.0/src/radius/radius_das.h: -------------------------------------------------------------------------------- 1 | /* 2 | * RADIUS Dynamic Authorization Server (DAS) 3 | * Copyright (c) 2012, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef RADIUS_DAS_H 10 | #define RADIUS_DAS_H 11 | 12 | struct radius_das_data; 13 | 14 | enum radius_das_res { 15 | RADIUS_DAS_SUCCESS, 16 | RADIUS_DAS_NAS_MISMATCH, 17 | RADIUS_DAS_SESSION_NOT_FOUND 18 | }; 19 | 20 | struct radius_das_attrs { 21 | const u8 *sta_addr; 22 | const u8 *user_name; 23 | size_t user_name_len; 24 | const u8 *acct_session_id; 25 | size_t acct_session_id_len; 26 | const u8 *cui; 27 | size_t cui_len; 28 | }; 29 | 30 | struct radius_das_conf { 31 | int port; 32 | const u8 *shared_secret; 33 | size_t shared_secret_len; 34 | const struct hostapd_ip_addr *client_addr; 35 | unsigned int time_window; 36 | int require_event_timestamp; 37 | void *ctx; 38 | enum radius_das_res (*disconnect)(void *ctx, 39 | struct radius_das_attrs *attr); 40 | }; 41 | 42 | struct radius_das_data * 43 | radius_das_init(struct radius_das_conf *conf); 44 | 45 | void radius_das_deinit(struct radius_das_data *data); 46 | 47 | #endif /* RADIUS_DAS_H */ 48 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/rc4.c: -------------------------------------------------------------------------------- 1 | /* 2 | * RC4 stream cipher 3 | * Copyright (c) 2002-2005, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "crypto.h" 13 | 14 | #define S_SWAP(a,b) do { u8 t = S[a]; S[a] = S[b]; S[b] = t; } while(0) 15 | 16 | int rc4_skip(const u8 *key, size_t keylen, size_t skip, 17 | u8 *data, size_t data_len) 18 | { 19 | u32 i, j, k; 20 | u8 S[256], *pos; 21 | size_t kpos; 22 | 23 | /* Setup RC4 state */ 24 | for (i = 0; i < 256; i++) 25 | S[i] = i; 26 | j = 0; 27 | kpos = 0; 28 | for (i = 0; i < 256; i++) { 29 | j = (j + S[i] + key[kpos]) & 0xff; 30 | kpos++; 31 | if (kpos >= keylen) 32 | kpos = 0; 33 | S_SWAP(i, j); 34 | } 35 | 36 | /* Skip the start of the stream */ 37 | i = j = 0; 38 | for (k = 0; k < skip; k++) { 39 | i = (i + 1) & 0xff; 40 | j = (j + S[i]) & 0xff; 41 | S_SWAP(i, j); 42 | } 43 | 44 | /* Apply RC4 to data */ 45 | pos = data; 46 | for (k = 0; k < data_len; k++) { 47 | i = (i + 1) & 0xff; 48 | j = (j + S[i]) & 0xff; 49 | S_SWAP(i, j); 50 | *pos++ ^= S[(S[i] + S[j]) & 0xff]; 51 | } 52 | 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /hostapd-2.0/src/tls/bignum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Big number math 3 | * Copyright (c) 2006, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef BIGNUM_H 10 | #define BIGNUM_H 11 | 12 | struct bignum; 13 | 14 | struct bignum * bignum_init(void); 15 | void bignum_deinit(struct bignum *n); 16 | size_t bignum_get_unsigned_bin_len(struct bignum *n); 17 | int bignum_get_unsigned_bin(const struct bignum *n, u8 *buf, size_t *len); 18 | int bignum_set_unsigned_bin(struct bignum *n, const u8 *buf, size_t len); 19 | int bignum_cmp(const struct bignum *a, const struct bignum *b); 20 | int bignum_cmp_d(const struct bignum *a, unsigned long b); 21 | int bignum_add(const struct bignum *a, const struct bignum *b, 22 | struct bignum *c); 23 | int bignum_sub(const struct bignum *a, const struct bignum *b, 24 | struct bignum *c); 25 | int bignum_mul(const struct bignum *a, const struct bignum *b, 26 | struct bignum *c); 27 | int bignum_mulmod(const struct bignum *a, const struct bignum *b, 28 | const struct bignum *c, struct bignum *d); 29 | int bignum_exptmod(const struct bignum *a, const struct bignum *b, 30 | const struct bignum *c, struct bignum *d); 31 | 32 | #endif /* BIGNUM_H */ 33 | -------------------------------------------------------------------------------- /hostapd-2.0/src/wps/http_server.h: -------------------------------------------------------------------------------- 1 | /* 2 | * http_server - HTTP server 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef HTTP_SERVER_H 10 | #define HTTP_SERVER_H 11 | 12 | struct http_server; 13 | struct http_request; 14 | 15 | void http_request_deinit(struct http_request *req); 16 | void http_request_send(struct http_request *req, struct wpabuf *resp); 17 | void http_request_send_and_deinit(struct http_request *req, 18 | struct wpabuf *resp); 19 | enum httpread_hdr_type http_request_get_type(struct http_request *req); 20 | char * http_request_get_uri(struct http_request *req); 21 | char * http_request_get_hdr(struct http_request *req); 22 | char * http_request_get_data(struct http_request *req); 23 | char * http_request_get_hdr_line(struct http_request *req, const char *tag); 24 | struct sockaddr_in * http_request_get_cli_addr(struct http_request *req); 25 | 26 | struct http_server * http_server_init(struct in_addr *addr, int port, 27 | void (*cb)(void *ctx, 28 | struct http_request *req), 29 | void *cb_ctx); 30 | void http_server_deinit(struct http_server *srv); 31 | int http_server_get_port(struct http_server *srv); 32 | 33 | #endif /* HTTP_SERVER_H */ 34 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | CFLAGS += -DCONFIG_SHA256 16 | 17 | LIB_OBJS= \ 18 | aes-cbc.o \ 19 | aes-ccm.o \ 20 | aes-ctr.o \ 21 | aes-eax.o \ 22 | aes-encblock.o \ 23 | aes-gcm.o \ 24 | aes-internal.o \ 25 | aes-internal-dec.o \ 26 | aes-internal-enc.o \ 27 | aes-omac1.o \ 28 | aes-unwrap.o \ 29 | aes-wrap.o \ 30 | des-internal.o \ 31 | dh_group5.o \ 32 | dh_groups.o \ 33 | md4-internal.o \ 34 | md5.o \ 35 | md5-internal.o \ 36 | milenage.o \ 37 | ms_funcs.o \ 38 | rc4.o \ 39 | sha1.o \ 40 | sha1-internal.o \ 41 | sha1-pbkdf2.o \ 42 | sha1-prf.o \ 43 | sha1-tlsprf.o \ 44 | sha1-tprf.o \ 45 | sha256.o \ 46 | sha256-prf.o \ 47 | sha256-tlsprf.o \ 48 | sha256-internal.o 49 | 50 | LIB_OBJS += crypto_internal.o 51 | LIB_OBJS += crypto_internal-cipher.o 52 | LIB_OBJS += crypto_internal-modexp.o 53 | LIB_OBJS += crypto_internal-rsa.o 54 | LIB_OBJS += tls_internal.o 55 | LIB_OBJS += fips_prf_internal.o 56 | LIB_OBJS += random.o 57 | 58 | 59 | libcrypto.a: $(LIB_OBJS) 60 | $(AR) crT $@ $? 61 | 62 | -include $(OBJS:%.o=%.d) 63 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/accounting.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / RADIUS Accounting 3 | * Copyright (c) 2002-2005, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef ACCOUNTING_H 10 | #define ACCOUNTING_H 11 | 12 | #ifdef CONFIG_NO_ACCOUNTING 13 | static inline void accounting_sta_get_id(struct hostapd_data *hapd, 14 | struct sta_info *sta) 15 | { 16 | } 17 | 18 | static inline void accounting_sta_start(struct hostapd_data *hapd, 19 | struct sta_info *sta) 20 | { 21 | } 22 | 23 | static inline void accounting_sta_stop(struct hostapd_data *hapd, 24 | struct sta_info *sta) 25 | { 26 | } 27 | 28 | static inline int accounting_init(struct hostapd_data *hapd) 29 | { 30 | return 0; 31 | } 32 | 33 | static inline void accounting_deinit(struct hostapd_data *hapd) 34 | { 35 | } 36 | #else /* CONFIG_NO_ACCOUNTING */ 37 | void accounting_sta_get_id(struct hostapd_data *hapd, struct sta_info *sta); 38 | void accounting_sta_start(struct hostapd_data *hapd, struct sta_info *sta); 39 | void accounting_sta_stop(struct hostapd_data *hapd, struct sta_info *sta); 40 | int accounting_init(struct hostapd_data *hapd); 41 | void accounting_deinit(struct hostapd_data *hapd); 42 | #endif /* CONFIG_NO_ACCOUNTING */ 43 | 44 | #endif /* ACCOUNTING_H */ 45 | -------------------------------------------------------------------------------- /hostapd-2.0/src/wps/http_client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * http_client - HTTP client 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef HTTP_CLIENT_H 10 | #define HTTP_CLIENT_H 11 | 12 | struct http_client; 13 | 14 | enum http_client_event { 15 | HTTP_CLIENT_FAILED, 16 | HTTP_CLIENT_TIMEOUT, 17 | HTTP_CLIENT_OK, 18 | HTTP_CLIENT_INVALID_REPLY, 19 | }; 20 | 21 | char * http_client_url_parse(const char *url, struct sockaddr_in *dst, 22 | char **path); 23 | struct http_client * http_client_addr(struct sockaddr_in *dst, 24 | struct wpabuf *req, size_t max_response, 25 | void (*cb)(void *ctx, 26 | struct http_client *c, 27 | enum http_client_event event), 28 | void *cb_ctx); 29 | struct http_client * http_client_url(const char *url, 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 | void http_client_free(struct http_client *c); 36 | struct wpabuf * http_client_get_body(struct http_client *c); 37 | char * http_client_get_hdr_line(struct http_client *c, const char *tag); 38 | char * http_link_update(char *url, const char *base); 39 | 40 | #endif /* HTTP_CLIENT_H */ 41 | -------------------------------------------------------------------------------- /hostapd-2.0/src/tls/tlsv1_cred.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TLSv1 credentials 3 | * Copyright (c) 2006-2007, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef TLSV1_CRED_H 10 | #define TLSV1_CRED_H 11 | 12 | struct tlsv1_credentials { 13 | struct x509_certificate *trusted_certs; 14 | struct x509_certificate *cert; 15 | struct crypto_private_key *key; 16 | 17 | /* Diffie-Hellman parameters */ 18 | u8 *dh_p; /* prime */ 19 | size_t dh_p_len; 20 | u8 *dh_g; /* generator */ 21 | size_t dh_g_len; 22 | }; 23 | 24 | 25 | struct tlsv1_credentials * tlsv1_cred_alloc(void); 26 | void tlsv1_cred_free(struct tlsv1_credentials *cred); 27 | int tlsv1_set_ca_cert(struct tlsv1_credentials *cred, const char *cert, 28 | const u8 *cert_blob, size_t cert_blob_len, 29 | const char *path); 30 | int tlsv1_set_cert(struct tlsv1_credentials *cred, const char *cert, 31 | const u8 *cert_blob, size_t cert_blob_len); 32 | int tlsv1_set_private_key(struct tlsv1_credentials *cred, 33 | const char *private_key, 34 | const char *private_key_passwd, 35 | const u8 *private_key_blob, 36 | size_t private_key_blob_len); 37 | int tlsv1_set_dhparams(struct tlsv1_credentials *cred, const char *dh_file, 38 | const u8 *dh_blob, size_t dh_blob_len); 39 | 40 | #endif /* TLSV1_CRED_H */ 41 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef WPA_AUTH_IE_H 10 | #define WPA_AUTH_IE_H 11 | 12 | struct wpa_eapol_ie_parse { 13 | const u8 *wpa_ie; 14 | size_t wpa_ie_len; 15 | const u8 *rsn_ie; 16 | size_t rsn_ie_len; 17 | const u8 *pmkid; 18 | const u8 *gtk; 19 | size_t gtk_len; 20 | const u8 *mac_addr; 21 | size_t mac_addr_len; 22 | #ifdef CONFIG_PEERKEY 23 | const u8 *smk; 24 | size_t smk_len; 25 | const u8 *nonce; 26 | size_t nonce_len; 27 | const u8 *lifetime; 28 | size_t lifetime_len; 29 | const u8 *error; 30 | size_t error_len; 31 | #endif /* CONFIG_PEERKEY */ 32 | #ifdef CONFIG_IEEE80211W 33 | const u8 *igtk; 34 | size_t igtk_len; 35 | #endif /* CONFIG_IEEE80211W */ 36 | #ifdef CONFIG_IEEE80211R 37 | const u8 *mdie; 38 | size_t mdie_len; 39 | const u8 *ftie; 40 | size_t ftie_len; 41 | #endif /* CONFIG_IEEE80211R */ 42 | }; 43 | 44 | int wpa_parse_kde_ies(const u8 *buf, size_t len, 45 | struct wpa_eapol_ie_parse *ie); 46 | u8 * wpa_add_kde(u8 *pos, u32 kde, const u8 *data, size_t data_len, 47 | const u8 *data2, size_t data2_len); 48 | int wpa_auth_gen_wpa_ie(struct wpa_authenticator *wpa_auth); 49 | 50 | #endif /* WPA_AUTH_IE_H */ 51 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef TNCS_H 10 | #define TNCS_H 11 | 12 | struct tncs_data; 13 | 14 | struct tncs_data * tncs_init(void); 15 | void tncs_deinit(struct tncs_data *tncs); 16 | void tncs_init_connection(struct tncs_data *tncs); 17 | size_t tncs_total_send_len(struct tncs_data *tncs); 18 | u8 * tncs_copy_send_buf(struct tncs_data *tncs, u8 *pos); 19 | char * tncs_if_tnccs_start(struct tncs_data *tncs); 20 | char * tncs_if_tnccs_end(void); 21 | 22 | enum tncs_process_res { 23 | TNCCS_PROCESS_ERROR = -1, 24 | TNCCS_PROCESS_OK_NO_RECOMMENDATION = 0, 25 | TNCCS_RECOMMENDATION_ERROR, 26 | TNCCS_RECOMMENDATION_ALLOW, 27 | TNCCS_RECOMMENDATION_NONE, 28 | TNCCS_RECOMMENDATION_ISOLATE, 29 | TNCCS_RECOMMENDATION_NO_ACCESS, 30 | TNCCS_RECOMMENDATION_NO_RECOMMENDATION 31 | }; 32 | 33 | enum tncs_process_res tncs_process_if_tnccs(struct tncs_data *tncs, 34 | const u8 *msg, size_t len); 35 | 36 | int tncs_global_init(void); 37 | void tncs_global_deinit(void); 38 | 39 | struct wpabuf * tncs_build_soh_request(void); 40 | struct wpabuf * tncs_process_soh(const u8 *soh_tlv, size_t soh_tlv_len, 41 | int *failure); 42 | 43 | #endif /* TNCS_H */ 44 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/aes-ctr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AES-128 CTR 3 | * 4 | * Copyright (c) 2003-2007, Jouni Malinen 5 | * 6 | * This software may be distributed under the terms of the BSD license. 7 | * See README for more details. 8 | */ 9 | 10 | #include "includes.h" 11 | 12 | #include "common.h" 13 | #include "aes.h" 14 | #include "aes_wrap.h" 15 | 16 | /** 17 | * aes_128_ctr_encrypt - AES-128 CTR mode encryption 18 | * @key: Key for encryption (16 bytes) 19 | * @nonce: Nonce for counter mode (16 bytes) 20 | * @data: Data to encrypt in-place 21 | * @data_len: Length of data in bytes 22 | * Returns: 0 on success, -1 on failure 23 | */ 24 | int aes_128_ctr_encrypt(const u8 *key, const u8 *nonce, 25 | u8 *data, size_t data_len) 26 | { 27 | void *ctx; 28 | size_t j, len, left = data_len; 29 | int i; 30 | u8 *pos = data; 31 | u8 counter[AES_BLOCK_SIZE], buf[AES_BLOCK_SIZE]; 32 | 33 | ctx = aes_encrypt_init(key, 16); 34 | if (ctx == NULL) 35 | return -1; 36 | os_memcpy(counter, nonce, AES_BLOCK_SIZE); 37 | 38 | while (left > 0) { 39 | aes_encrypt(ctx, counter, buf); 40 | 41 | len = (left < AES_BLOCK_SIZE) ? left : AES_BLOCK_SIZE; 42 | for (j = 0; j < len; j++) 43 | pos[j] ^= buf[j]; 44 | pos += len; 45 | left -= len; 46 | 47 | for (i = AES_BLOCK_SIZE - 1; i >= 0; i--) { 48 | counter[i]++; 49 | if (counter[i]) 50 | break; 51 | } 52 | } 53 | aes_encrypt_deinit(ctx); 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "tls/bignum.h" 13 | #include "crypto.h" 14 | 15 | 16 | int crypto_mod_exp(const u8 *base, size_t base_len, 17 | const u8 *power, size_t power_len, 18 | const u8 *modulus, size_t modulus_len, 19 | u8 *result, size_t *result_len) 20 | { 21 | struct bignum *bn_base, *bn_exp, *bn_modulus, *bn_result; 22 | int ret = -1; 23 | 24 | bn_base = bignum_init(); 25 | bn_exp = bignum_init(); 26 | bn_modulus = bignum_init(); 27 | bn_result = bignum_init(); 28 | 29 | if (bn_base == NULL || bn_exp == NULL || bn_modulus == NULL || 30 | bn_result == NULL) 31 | goto error; 32 | 33 | if (bignum_set_unsigned_bin(bn_base, base, base_len) < 0 || 34 | bignum_set_unsigned_bin(bn_exp, power, power_len) < 0 || 35 | bignum_set_unsigned_bin(bn_modulus, modulus, modulus_len) < 0) 36 | goto error; 37 | 38 | if (bignum_exptmod(bn_base, bn_exp, bn_modulus, bn_result) < 0) 39 | goto error; 40 | 41 | ret = bignum_get_unsigned_bin(bn_result, result, result_len); 42 | 43 | error: 44 | bignum_deinit(bn_base); 45 | bignum_deinit(bn_exp); 46 | bignum_deinit(bn_modulus); 47 | bignum_deinit(bn_result); 48 | return ret; 49 | } 50 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/includes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wpa_supplicant/hostapd - Default include files 3 | * Copyright (c) 2005-2006, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | * 8 | * This header file is included into all C files so that commonly used header 9 | * files can be selected with OS specific ifdef blocks in one place instead of 10 | * having to have OS/C library specific selection in many files. 11 | */ 12 | 13 | #ifndef INCLUDES_H 14 | #define INCLUDES_H 15 | 16 | /* Include possible build time configuration before including anything else */ 17 | #include "build_config.h" 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #ifndef _WIN32_WCE 24 | #ifndef CONFIG_TI_COMPILER 25 | #include 26 | #include 27 | #endif /* CONFIG_TI_COMPILER */ 28 | #include 29 | #endif /* _WIN32_WCE */ 30 | #include 31 | 32 | #ifndef CONFIG_TI_COMPILER 33 | #ifndef _MSC_VER 34 | #include 35 | #endif /* _MSC_VER */ 36 | #endif /* CONFIG_TI_COMPILER */ 37 | 38 | #ifndef CONFIG_NATIVE_WINDOWS 39 | #ifndef CONFIG_TI_COMPILER 40 | #include 41 | #include 42 | #include 43 | #ifndef __vxworks 44 | #include 45 | #include 46 | #endif /* __vxworks */ 47 | #endif /* CONFIG_TI_COMPILER */ 48 | #endif /* CONFIG_NATIVE_WINDOWS */ 49 | 50 | #endif /* INCLUDES_H */ 51 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef PREAUTH_H 10 | #define PREAUTH_H 11 | 12 | #ifdef CONFIG_RSN_PREAUTH 13 | 14 | int rsn_preauth_iface_init(struct hostapd_data *hapd); 15 | void rsn_preauth_iface_deinit(struct hostapd_data *hapd); 16 | void rsn_preauth_finished(struct hostapd_data *hapd, struct sta_info *sta, 17 | int success); 18 | void rsn_preauth_send(struct hostapd_data *hapd, struct sta_info *sta, 19 | u8 *buf, size_t len); 20 | void rsn_preauth_free_station(struct hostapd_data *hapd, struct sta_info *sta); 21 | 22 | #else /* CONFIG_RSN_PREAUTH */ 23 | 24 | static inline int rsn_preauth_iface_init(struct hostapd_data *hapd) 25 | { 26 | return 0; 27 | } 28 | 29 | static inline void rsn_preauth_iface_deinit(struct hostapd_data *hapd) 30 | { 31 | } 32 | 33 | static inline void rsn_preauth_finished(struct hostapd_data *hapd, 34 | struct sta_info *sta, 35 | int success) 36 | { 37 | } 38 | 39 | static inline void rsn_preauth_send(struct hostapd_data *hapd, 40 | struct sta_info *sta, 41 | u8 *buf, size_t len) 42 | { 43 | } 44 | 45 | static inline void rsn_preauth_free_station(struct hostapd_data *hapd, 46 | struct sta_info *sta) 47 | { 48 | } 49 | 50 | #endif /* CONFIG_RSN_PREAUTH */ 51 | 52 | #endif /* PREAUTH_H */ 53 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef WPA_IE_H 10 | #define WPA_IE_H 11 | 12 | struct wpa_sm; 13 | 14 | struct wpa_eapol_ie_parse { 15 | const u8 *wpa_ie; 16 | size_t wpa_ie_len; 17 | const u8 *rsn_ie; 18 | size_t rsn_ie_len; 19 | const u8 *pmkid; 20 | const u8 *gtk; 21 | size_t gtk_len; 22 | const u8 *mac_addr; 23 | size_t mac_addr_len; 24 | #ifdef CONFIG_PEERKEY 25 | const u8 *smk; 26 | size_t smk_len; 27 | const u8 *nonce; 28 | size_t nonce_len; 29 | const u8 *lifetime; 30 | size_t lifetime_len; 31 | const u8 *error; 32 | size_t error_len; 33 | #endif /* CONFIG_PEERKEY */ 34 | #ifdef CONFIG_IEEE80211W 35 | const u8 *igtk; 36 | size_t igtk_len; 37 | #endif /* CONFIG_IEEE80211W */ 38 | const u8 *mdie; 39 | size_t mdie_len; 40 | const u8 *ftie; 41 | size_t ftie_len; 42 | const u8 *reassoc_deadline; 43 | const u8 *key_lifetime; 44 | const u8 *lnkid; 45 | size_t lnkid_len; 46 | const u8 *ext_capab; 47 | size_t ext_capab_len; 48 | const u8 *supp_rates; 49 | size_t supp_rates_len; 50 | const u8 *ext_supp_rates; 51 | size_t ext_supp_rates_len; 52 | }; 53 | 54 | int wpa_supplicant_parse_ies(const u8 *buf, size_t len, 55 | struct wpa_eapol_ie_parse *ie); 56 | int wpa_gen_wpa_ie(struct wpa_sm *sm, u8 *wpa_ie, size_t wpa_ie_len); 57 | 58 | #endif /* WPA_IE_H */ 59 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/src/common/gas.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generic advertisement service (GAS) (IEEE 802.11u) 3 | * Copyright (c) 2009, Atheros Communications 4 | * Copyright (c) 2011-2012, Qualcomm Atheros 5 | * 6 | * This software may be distributed under the terms of the BSD license. 7 | * See README for more details. 8 | */ 9 | 10 | #ifndef GAS_H 11 | #define GAS_H 12 | 13 | struct wpabuf * gas_build_initial_req(u8 dialog_token, size_t size); 14 | struct wpabuf * gas_build_comeback_req(u8 dialog_token); 15 | struct wpabuf * gas_build_initial_resp(u8 dialog_token, u16 status_code, 16 | u16 comeback_delay, size_t size); 17 | struct wpabuf * gas_anqp_build_initial_req(u8 dialog_token, size_t size); 18 | struct wpabuf * gas_anqp_build_initial_resp(u8 dialog_token, u16 status_code, 19 | u16 comeback_delay, size_t size); 20 | struct wpabuf * gas_anqp_build_initial_resp_buf(u8 dialog_token, 21 | u16 status_code, 22 | u16 comeback_delay, 23 | struct wpabuf *payload); 24 | struct wpabuf * gas_anqp_build_comeback_resp(u8 dialog_token, u16 status_code, 25 | u8 frag_id, u8 more, 26 | u16 comeback_delay, size_t size); 27 | struct wpabuf * gas_anqp_build_comeback_resp_buf(u8 dialog_token, 28 | u16 status_code, 29 | u8 frag_id, u8 more, 30 | u16 comeback_delay, 31 | struct wpabuf *payload); 32 | void gas_anqp_set_len(struct wpabuf *buf); 33 | 34 | u8 * gas_anqp_add_element(struct wpabuf *buf, u16 info_id); 35 | void gas_anqp_set_element_len(struct wpabuf *buf, u8 *len_pos); 36 | 37 | #endif /* GAS_H */ 38 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/uuid.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Universally Unique IDentifier (UUID) 3 | * Copyright (c) 2008, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "uuid.h" 13 | 14 | int uuid_str2bin(const char *str, u8 *bin) 15 | { 16 | const char *pos; 17 | u8 *opos; 18 | 19 | pos = str; 20 | opos = bin; 21 | 22 | if (hexstr2bin(pos, opos, 4)) 23 | return -1; 24 | pos += 8; 25 | opos += 4; 26 | 27 | if (*pos++ != '-' || hexstr2bin(pos, opos, 2)) 28 | return -1; 29 | pos += 4; 30 | opos += 2; 31 | 32 | if (*pos++ != '-' || hexstr2bin(pos, opos, 2)) 33 | return -1; 34 | pos += 4; 35 | opos += 2; 36 | 37 | if (*pos++ != '-' || hexstr2bin(pos, opos, 2)) 38 | return -1; 39 | pos += 4; 40 | opos += 2; 41 | 42 | if (*pos++ != '-' || hexstr2bin(pos, opos, 6)) 43 | return -1; 44 | 45 | return 0; 46 | } 47 | 48 | 49 | int uuid_bin2str(const u8 *bin, char *str, size_t max_len) 50 | { 51 | int len; 52 | len = os_snprintf(str, max_len, "%02x%02x%02x%02x-%02x%02x-%02x%02x-" 53 | "%02x%02x-%02x%02x%02x%02x%02x%02x", 54 | bin[0], bin[1], bin[2], bin[3], 55 | bin[4], bin[5], bin[6], bin[7], 56 | bin[8], bin[9], bin[10], bin[11], 57 | bin[12], bin[13], bin[14], bin[15]); 58 | if (len < 0 || (size_t) len >= max_len) 59 | return -1; 60 | return 0; 61 | } 62 | 63 | 64 | int is_nil_uuid(const u8 *uuid) 65 | { 66 | int i; 67 | for (i = 0; i < UUID_LEN; i++) 68 | if (uuid[i]) 69 | return 0; 70 | return 1; 71 | } 72 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_peer/ikev2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IKEv2 responder (RFC 4306) for EAP-IKEV2 3 | * Copyright (c) 2007, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef IKEV2_H 10 | #define IKEV2_H 11 | 12 | #include "eap_common/ikev2_common.h" 13 | 14 | struct ikev2_proposal_data { 15 | u8 proposal_num; 16 | int integ; 17 | int prf; 18 | int encr; 19 | int dh; 20 | }; 21 | 22 | 23 | struct ikev2_responder_data { 24 | enum { SA_INIT, SA_AUTH, CHILD_SA, NOTIFY, IKEV2_DONE, IKEV2_FAILED } 25 | state; 26 | u8 i_spi[IKEV2_SPI_LEN]; 27 | u8 r_spi[IKEV2_SPI_LEN]; 28 | u8 i_nonce[IKEV2_NONCE_MAX_LEN]; 29 | size_t i_nonce_len; 30 | u8 r_nonce[IKEV2_NONCE_MAX_LEN]; 31 | size_t r_nonce_len; 32 | struct wpabuf *i_dh_public; 33 | struct wpabuf *r_dh_private; 34 | struct ikev2_proposal_data proposal; 35 | const struct dh_group *dh; 36 | struct ikev2_keys keys; 37 | u8 *IDi; 38 | size_t IDi_len; 39 | u8 IDi_type; 40 | u8 *IDr; 41 | size_t IDr_len; 42 | struct wpabuf *r_sign_msg; 43 | struct wpabuf *i_sign_msg; 44 | u8 *shared_secret; 45 | size_t shared_secret_len; 46 | enum { PEER_AUTH_CERT, PEER_AUTH_SECRET } peer_auth; 47 | u8 *key_pad; 48 | size_t key_pad_len; 49 | u16 error_type; 50 | enum { LAST_MSG_SA_INIT, LAST_MSG_SA_AUTH } last_msg; 51 | }; 52 | 53 | 54 | void ikev2_responder_deinit(struct ikev2_responder_data *data); 55 | int ikev2_responder_process(struct ikev2_responder_data *data, 56 | const struct wpabuf *buf); 57 | struct wpabuf * ikev2_responder_build(struct ikev2_responder_data *data); 58 | 59 | #endif /* IKEV2_H */ 60 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EAP_FAST_PAC_H 10 | #define EAP_FAST_PAC_H 11 | 12 | #include "eap_common/eap_fast_common.h" 13 | 14 | struct eap_fast_pac { 15 | struct eap_fast_pac *next; 16 | 17 | u8 pac_key[EAP_FAST_PAC_KEY_LEN]; 18 | u8 *pac_opaque; 19 | size_t pac_opaque_len; 20 | u8 *pac_info; 21 | size_t pac_info_len; 22 | u8 *a_id; 23 | size_t a_id_len; 24 | u8 *i_id; 25 | size_t i_id_len; 26 | u8 *a_id_info; 27 | size_t a_id_info_len; 28 | u16 pac_type; 29 | }; 30 | 31 | 32 | void eap_fast_free_pac(struct eap_fast_pac *pac); 33 | struct eap_fast_pac * eap_fast_get_pac(struct eap_fast_pac *pac_root, 34 | const u8 *a_id, size_t a_id_len, 35 | u16 pac_type); 36 | int eap_fast_add_pac(struct eap_fast_pac **pac_root, 37 | struct eap_fast_pac **pac_current, 38 | struct eap_fast_pac *entry); 39 | int eap_fast_load_pac(struct eap_sm *sm, struct eap_fast_pac **pac_root, 40 | const char *pac_file); 41 | int eap_fast_save_pac(struct eap_sm *sm, struct eap_fast_pac *pac_root, 42 | const char *pac_file); 43 | size_t eap_fast_pac_list_truncate(struct eap_fast_pac *pac_root, 44 | size_t max_len); 45 | int eap_fast_load_pac_bin(struct eap_sm *sm, struct eap_fast_pac **pac_root, 46 | const char *pac_file); 47 | int eap_fast_save_pac_bin(struct eap_sm *sm, struct eap_fast_pac *pac_root, 48 | const char *pac_file); 49 | 50 | #endif /* EAP_FAST_PAC_H */ 51 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_server/ikev2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IKEv2 initiator (RFC 4306) for EAP-IKEV2 3 | * Copyright (c) 2007, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef IKEV2_H 10 | #define IKEV2_H 11 | 12 | #include "eap_common/ikev2_common.h" 13 | 14 | struct ikev2_proposal_data { 15 | u8 proposal_num; 16 | int integ; 17 | int prf; 18 | int encr; 19 | int dh; 20 | }; 21 | 22 | 23 | struct ikev2_initiator_data { 24 | enum { SA_INIT, SA_AUTH, CHILD_SA, IKEV2_DONE } state; 25 | u8 i_spi[IKEV2_SPI_LEN]; 26 | u8 r_spi[IKEV2_SPI_LEN]; 27 | u8 i_nonce[IKEV2_NONCE_MAX_LEN]; 28 | size_t i_nonce_len; 29 | u8 r_nonce[IKEV2_NONCE_MAX_LEN]; 30 | size_t r_nonce_len; 31 | struct wpabuf *r_dh_public; 32 | struct wpabuf *i_dh_private; 33 | struct ikev2_proposal_data proposal; 34 | const struct dh_group *dh; 35 | struct ikev2_keys keys; 36 | u8 *IDi; 37 | size_t IDi_len; 38 | u8 *IDr; 39 | size_t IDr_len; 40 | u8 IDr_type; 41 | struct wpabuf *r_sign_msg; 42 | struct wpabuf *i_sign_msg; 43 | u8 *shared_secret; 44 | size_t shared_secret_len; 45 | enum { PEER_AUTH_CERT, PEER_AUTH_SECRET } peer_auth; 46 | u8 *key_pad; 47 | size_t key_pad_len; 48 | 49 | const u8 * (*get_shared_secret)(void *ctx, const u8 *IDr, 50 | size_t IDr_len, size_t *secret_len); 51 | void *cb_ctx; 52 | int unknown_user; 53 | }; 54 | 55 | 56 | void ikev2_initiator_deinit(struct ikev2_initiator_data *data); 57 | int ikev2_initiator_process(struct ikev2_initiator_data *data, 58 | const struct wpabuf *buf); 59 | struct wpabuf * ikev2_initiator_build(struct ikev2_initiator_data *data); 60 | 61 | #endif /* IKEV2_H */ 62 | -------------------------------------------------------------------------------- /hostapd-2.0/src/common/privsep_commands.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant - privilege separation commands 3 | * Copyright (c) 2007-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef PRIVSEP_COMMANDS_H 10 | #define PRIVSEP_COMMANDS_H 11 | 12 | enum privsep_cmd { 13 | PRIVSEP_CMD_REGISTER, 14 | PRIVSEP_CMD_UNREGISTER, 15 | PRIVSEP_CMD_SCAN, 16 | PRIVSEP_CMD_GET_SCAN_RESULTS, 17 | PRIVSEP_CMD_ASSOCIATE, 18 | PRIVSEP_CMD_GET_BSSID, 19 | PRIVSEP_CMD_GET_SSID, 20 | PRIVSEP_CMD_SET_KEY, 21 | PRIVSEP_CMD_GET_CAPA, 22 | PRIVSEP_CMD_L2_REGISTER, 23 | PRIVSEP_CMD_L2_UNREGISTER, 24 | PRIVSEP_CMD_L2_NOTIFY_AUTH_START, 25 | PRIVSEP_CMD_L2_SEND, 26 | PRIVSEP_CMD_SET_COUNTRY, 27 | }; 28 | 29 | struct privsep_cmd_associate 30 | { 31 | u8 bssid[ETH_ALEN]; 32 | u8 ssid[32]; 33 | size_t ssid_len; 34 | int freq; 35 | int pairwise_suite; 36 | int group_suite; 37 | int key_mgmt_suite; 38 | int auth_alg; 39 | int mode; 40 | size_t wpa_ie_len; 41 | /* followed by wpa_ie_len bytes of wpa_ie */ 42 | }; 43 | 44 | struct privsep_cmd_set_key 45 | { 46 | int alg; 47 | u8 addr[ETH_ALEN]; 48 | int key_idx; 49 | int set_tx; 50 | u8 seq[8]; 51 | size_t seq_len; 52 | u8 key[32]; 53 | size_t key_len; 54 | }; 55 | 56 | enum privsep_event { 57 | PRIVSEP_EVENT_SCAN_RESULTS, 58 | PRIVSEP_EVENT_ASSOC, 59 | PRIVSEP_EVENT_DISASSOC, 60 | PRIVSEP_EVENT_ASSOCINFO, 61 | PRIVSEP_EVENT_MICHAEL_MIC_FAILURE, 62 | PRIVSEP_EVENT_INTERFACE_STATUS, 63 | PRIVSEP_EVENT_PMKID_CANDIDATE, 64 | PRIVSEP_EVENT_STKSTART, 65 | PRIVSEP_EVENT_FT_RESPONSE, 66 | PRIVSEP_EVENT_RX_EAPOL, 67 | }; 68 | 69 | #endif /* PRIVSEP_COMMANDS_H */ 70 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "sha1.h" 13 | #include "sha1_i.h" 14 | #include "crypto.h" 15 | 16 | 17 | int fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x, size_t xlen) 18 | { 19 | u8 xkey[64]; 20 | u32 t[5], _t[5]; 21 | int i, j, m, k; 22 | u8 *xpos = x; 23 | u32 carry; 24 | 25 | if (seed_len < sizeof(xkey)) 26 | os_memset(xkey + seed_len, 0, sizeof(xkey) - seed_len); 27 | else 28 | seed_len = sizeof(xkey); 29 | 30 | /* FIPS 186-2 + change notice 1 */ 31 | 32 | os_memcpy(xkey, seed, seed_len); 33 | t[0] = 0x67452301; 34 | t[1] = 0xEFCDAB89; 35 | t[2] = 0x98BADCFE; 36 | t[3] = 0x10325476; 37 | t[4] = 0xC3D2E1F0; 38 | 39 | m = xlen / 40; 40 | for (j = 0; j < m; j++) { 41 | /* XSEED_j = 0 */ 42 | for (i = 0; i < 2; i++) { 43 | /* XVAL = (XKEY + XSEED_j) mod 2^b */ 44 | 45 | /* w_i = G(t, XVAL) */ 46 | os_memcpy(_t, t, 20); 47 | SHA1Transform(_t, xkey); 48 | _t[0] = host_to_be32(_t[0]); 49 | _t[1] = host_to_be32(_t[1]); 50 | _t[2] = host_to_be32(_t[2]); 51 | _t[3] = host_to_be32(_t[3]); 52 | _t[4] = host_to_be32(_t[4]); 53 | os_memcpy(xpos, _t, 20); 54 | 55 | /* XKEY = (1 + XKEY + w_i) mod 2^b */ 56 | carry = 1; 57 | for (k = 19; k >= 0; k--) { 58 | carry += xkey[k] + xpos[k]; 59 | xkey[k] = carry & 0xff; 60 | carry >>= 8; 61 | } 62 | 63 | xpos += SHA1_MAC_LEN; 64 | } 65 | /* x_j = w_0|w_1 */ 66 | } 67 | 68 | return 0; 69 | } 70 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/pcsc_funcs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant / PC/SC smartcard interface for USIM, GSM SIM 3 | * Copyright (c) 2004-2006, 2012, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef PCSC_FUNCS_H 10 | #define PCSC_FUNCS_H 11 | 12 | typedef enum { 13 | SCARD_GSM_SIM_ONLY, 14 | SCARD_USIM_ONLY, 15 | SCARD_TRY_BOTH 16 | } scard_sim_type; 17 | 18 | 19 | #ifdef PCSC_FUNCS 20 | struct scard_data * scard_init(scard_sim_type sim_type, const char *reader); 21 | void scard_deinit(struct scard_data *scard); 22 | 23 | int scard_set_pin(struct scard_data *scard, const char *pin); 24 | int scard_get_imsi(struct scard_data *scard, char *imsi, size_t *len); 25 | int scard_get_mnc_len(struct scard_data *scard); 26 | int scard_gsm_auth(struct scard_data *scard, const unsigned char *_rand, 27 | unsigned char *sres, unsigned char *kc); 28 | int scard_umts_auth(struct scard_data *scard, const unsigned char *_rand, 29 | const unsigned char *autn, 30 | unsigned char *res, size_t *res_len, 31 | unsigned char *ik, unsigned char *ck, unsigned char *auts); 32 | int scard_get_pin_retry_counter(struct scard_data *scard); 33 | int scard_supports_umts(struct scard_data *scard); 34 | 35 | #else /* PCSC_FUNCS */ 36 | 37 | #define scard_init(s, r) NULL 38 | #define scard_deinit(s) do { } while (0) 39 | #define scard_set_pin(s, p) -1 40 | #define scard_get_imsi(s, i, l) -1 41 | #define scard_get_mnc_len(s) -1 42 | #define scard_gsm_auth(s, r, s2, k) -1 43 | #define scard_umts_auth(s, r, a, r2, rl, i, c, a2) -1 44 | #define scard_get_pin_retry_counter(s) -1 45 | #define scard_supports_umts(s) 0 46 | 47 | #endif /* PCSC_FUNCS */ 48 | 49 | #endif /* PCSC_FUNCS_H */ 50 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/src/drivers/driver_ndis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant - Windows/NDIS driver interface 3 | * Copyright (c) 2004-2006, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef DRIVER_NDIS_H 10 | #define DRIVER_NDIS_H 11 | 12 | #ifdef CONFIG_NDIS_EVENTS_INTEGRATED 13 | struct ndis_events_data; 14 | struct ndis_events_data * ndis_events_init(HANDLE *read_pipe, HANDLE *event, 15 | const char *ifname, 16 | const char *desc); 17 | void ndis_events_deinit(struct ndis_events_data *events); 18 | #endif /* CONFIG_NDIS_EVENTS_INTEGRATED */ 19 | 20 | struct ndis_pmkid_entry { 21 | struct ndis_pmkid_entry *next; 22 | u8 bssid[ETH_ALEN]; 23 | u8 pmkid[16]; 24 | }; 25 | 26 | struct wpa_driver_ndis_data { 27 | void *ctx; 28 | char ifname[100]; /* GUID: {7EE3EFE5-C165-472F-986D-F6FBEDFE8C8D} */ 29 | #ifdef _WIN32_WCE 30 | TCHAR *adapter_name; 31 | HANDLE event_queue; /* NDISUIO notifier MsgQueue */ 32 | HANDLE connected_event; /* WpaSupplicantConnected event */ 33 | #endif /* _WIN32_WCE */ 34 | u8 own_addr[ETH_ALEN]; 35 | #ifdef CONFIG_USE_NDISUIO 36 | HANDLE ndisuio; 37 | #else /* CONFIG_USE_NDISUIO */ 38 | LPADAPTER adapter; 39 | #endif /* CONFIG_USE_NDISUIO */ 40 | u8 bssid[ETH_ALEN]; 41 | 42 | int has_capability; 43 | int no_of_pmkid; 44 | int radio_enabled; 45 | struct wpa_driver_capa capa; 46 | struct ndis_pmkid_entry *pmkid; 47 | char *adapter_desc; 48 | int wired; 49 | int native80211; 50 | int mode; 51 | int wzc_disabled; 52 | int oid_bssid_set; 53 | #ifdef CONFIG_NDIS_EVENTS_INTEGRATED 54 | HANDLE events_pipe, event_avail; 55 | struct ndis_events_data *events; 56 | #endif /* CONFIG_NDIS_EVENTS_INTEGRATED */ 57 | }; 58 | 59 | #endif /* DRIVER_NDIS_H */ 60 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/ip_addr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * IP address processing 3 | * Copyright (c) 2003-2006, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "ip_addr.h" 13 | 14 | const char * hostapd_ip_txt(const struct hostapd_ip_addr *addr, char *buf, 15 | size_t buflen) 16 | { 17 | if (buflen == 0 || addr == NULL) 18 | return NULL; 19 | 20 | if (addr->af == AF_INET) { 21 | os_strlcpy(buf, inet_ntoa(addr->u.v4), buflen); 22 | } else { 23 | buf[0] = '\0'; 24 | } 25 | #ifdef CONFIG_IPV6 26 | if (addr->af == AF_INET6) { 27 | if (inet_ntop(AF_INET6, &addr->u.v6, buf, buflen) == NULL) 28 | buf[0] = '\0'; 29 | } 30 | #endif /* CONFIG_IPV6 */ 31 | 32 | return buf; 33 | } 34 | 35 | 36 | int hostapd_ip_diff(struct hostapd_ip_addr *a, struct hostapd_ip_addr *b) 37 | { 38 | if (a == NULL && b == NULL) 39 | return 0; 40 | if (a == NULL || b == NULL) 41 | return 1; 42 | 43 | switch (a->af) { 44 | case AF_INET: 45 | if (a->u.v4.s_addr != b->u.v4.s_addr) 46 | return 1; 47 | break; 48 | #ifdef CONFIG_IPV6 49 | case AF_INET6: 50 | if (os_memcmp(&a->u.v6, &b->u.v6, sizeof(a->u.v6)) != 0) 51 | return 1; 52 | break; 53 | #endif /* CONFIG_IPV6 */ 54 | } 55 | 56 | return 0; 57 | } 58 | 59 | 60 | int hostapd_parse_ip_addr(const char *txt, struct hostapd_ip_addr *addr) 61 | { 62 | #ifndef CONFIG_NATIVE_WINDOWS 63 | if (inet_aton(txt, &addr->u.v4)) { 64 | addr->af = AF_INET; 65 | return 0; 66 | } 67 | 68 | #ifdef CONFIG_IPV6 69 | if (inet_pton(AF_INET6, txt, &addr->u.v6) > 0) { 70 | addr->af = AF_INET6; 71 | return 0; 72 | } 73 | #endif /* CONFIG_IPV6 */ 74 | #endif /* CONFIG_NATIVE_WINDOWS */ 75 | 76 | return -1; 77 | } 78 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 7 | * See README for more details. 8 | */ 9 | 10 | #include "includes.h" 11 | 12 | #include "common.h" 13 | #include "aes.h" 14 | #include "aes_wrap.h" 15 | 16 | /** 17 | * aes_wrap - Wrap keys with AES Key Wrap Algorithm (128-bit KEK) (RFC3394) 18 | * @kek: 16-octet Key encryption key (KEK) 19 | * @n: Length of the plaintext key in 64-bit units; e.g., 2 = 128-bit = 16 20 | * bytes 21 | * @plain: Plaintext key to be wrapped, n * 64 bits 22 | * @cipher: Wrapped key, (n + 1) * 64 bits 23 | * Returns: 0 on success, -1 on failure 24 | */ 25 | int aes_wrap(const u8 *kek, int n, const u8 *plain, u8 *cipher) 26 | { 27 | u8 *a, *r, b[16]; 28 | int i, j; 29 | void *ctx; 30 | 31 | a = cipher; 32 | r = cipher + 8; 33 | 34 | /* 1) Initialize variables. */ 35 | os_memset(a, 0xa6, 8); 36 | os_memcpy(r, plain, 8 * n); 37 | 38 | ctx = aes_encrypt_init(kek, 16); 39 | if (ctx == NULL) 40 | return -1; 41 | 42 | /* 2) Calculate intermediate values. 43 | * For j = 0 to 5 44 | * For i=1 to n 45 | * B = AES(K, A | R[i]) 46 | * A = MSB(64, B) ^ t where t = (n*j)+i 47 | * R[i] = LSB(64, B) 48 | */ 49 | for (j = 0; j <= 5; j++) { 50 | r = cipher + 8; 51 | for (i = 1; i <= n; i++) { 52 | os_memcpy(b, a, 8); 53 | os_memcpy(b + 8, r, 8); 54 | aes_encrypt(ctx, b, b); 55 | os_memcpy(a, b, 8); 56 | a[7] ^= n * j + i; 57 | os_memcpy(r, b + 8, 8); 58 | r += 8; 59 | } 60 | } 61 | aes_encrypt_deinit(ctx); 62 | 63 | /* 3) Output the results. 64 | * 65 | * These are already in @cipher due to the location of temporary 66 | * variables. 67 | */ 68 | 69 | return 0; 70 | } 71 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "crypto/aes_wrap.h" 13 | #include "eap_defs.h" 14 | #include "eap_psk_common.h" 15 | 16 | #define aes_block_size 16 17 | 18 | 19 | int eap_psk_key_setup(const u8 *psk, u8 *ak, u8 *kdk) 20 | { 21 | os_memset(ak, 0, aes_block_size); 22 | if (aes_128_encrypt_block(psk, ak, ak)) 23 | return -1; 24 | os_memcpy(kdk, ak, aes_block_size); 25 | ak[aes_block_size - 1] ^= 0x01; 26 | kdk[aes_block_size - 1] ^= 0x02; 27 | if (aes_128_encrypt_block(psk, ak, ak) || 28 | aes_128_encrypt_block(psk, kdk, kdk)) 29 | return -1; 30 | return 0; 31 | } 32 | 33 | 34 | int eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek, u8 *msk, 35 | u8 *emsk) 36 | { 37 | u8 hash[aes_block_size]; 38 | u8 counter = 1; 39 | int i; 40 | 41 | if (aes_128_encrypt_block(kdk, rand_p, hash)) 42 | return -1; 43 | 44 | hash[aes_block_size - 1] ^= counter; 45 | if (aes_128_encrypt_block(kdk, hash, tek)) 46 | return -1; 47 | hash[aes_block_size - 1] ^= counter; 48 | counter++; 49 | 50 | for (i = 0; i < EAP_MSK_LEN / aes_block_size; i++) { 51 | hash[aes_block_size - 1] ^= counter; 52 | if (aes_128_encrypt_block(kdk, hash, &msk[i * aes_block_size])) 53 | return -1; 54 | hash[aes_block_size - 1] ^= counter; 55 | counter++; 56 | } 57 | 58 | for (i = 0; i < EAP_EMSK_LEN / aes_block_size; i++) { 59 | hash[aes_block_size - 1] ^= counter; 60 | if (aes_128_encrypt_block(kdk, hash, 61 | &emsk[i * aes_block_size])) 62 | return -1; 63 | hash[aes_block_size - 1] ^= counter; 64 | counter++; 65 | } 66 | 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/sha1-prf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA1-based PRF 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "sha1.h" 13 | #include "crypto.h" 14 | 15 | 16 | /** 17 | * sha1_prf - SHA1-based Pseudo-Random Function (PRF) (IEEE 802.11i, 8.5.1.1) 18 | * @key: Key for PRF 19 | * @key_len: Length of the key in bytes 20 | * @label: A unique label for each purpose of the PRF 21 | * @data: Extra data to bind into the key 22 | * @data_len: Length of the data 23 | * @buf: Buffer for the generated pseudo-random key 24 | * @buf_len: Number of bytes of key to generate 25 | * Returns: 0 on success, -1 of failure 26 | * 27 | * This function is used to derive new, cryptographically separate keys from a 28 | * given key (e.g., PMK in IEEE 802.11i). 29 | */ 30 | int sha1_prf(const u8 *key, size_t key_len, const char *label, 31 | const u8 *data, size_t data_len, u8 *buf, size_t buf_len) 32 | { 33 | u8 counter = 0; 34 | size_t pos, plen; 35 | u8 hash[SHA1_MAC_LEN]; 36 | size_t label_len = os_strlen(label) + 1; 37 | const unsigned char *addr[3]; 38 | size_t len[3]; 39 | 40 | addr[0] = (u8 *) label; 41 | len[0] = label_len; 42 | addr[1] = data; 43 | len[1] = data_len; 44 | addr[2] = &counter; 45 | len[2] = 1; 46 | 47 | pos = 0; 48 | while (pos < buf_len) { 49 | plen = buf_len - pos; 50 | if (plen >= SHA1_MAC_LEN) { 51 | if (hmac_sha1_vector(key, key_len, 3, addr, len, 52 | &buf[pos])) 53 | return -1; 54 | pos += SHA1_MAC_LEN; 55 | } else { 56 | if (hmac_sha1_vector(key, key_len, 3, addr, len, 57 | hash)) 58 | return -1; 59 | os_memcpy(&buf[pos], hash, plen); 60 | break; 61 | } 62 | counter++; 63 | } 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/radiotap_iter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Radiotap parser 3 | * 4 | * Copyright 2007 Andy Green 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 __RADIOTAP_ITER_H 17 | #define __RADIOTAP_ITER_H 18 | 19 | #include "radiotap.h" 20 | 21 | /* Radiotap header iteration 22 | * implemented in radiotap.c 23 | */ 24 | /** 25 | * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args 26 | * @rtheader: pointer to the radiotap header we are walking through 27 | * @max_length: length of radiotap header in cpu byte ordering 28 | * @this_arg_index: IEEE80211_RADIOTAP_... index of current arg 29 | * @this_arg: pointer to current radiotap arg 30 | * @arg_index: internal next argument index 31 | * @arg: internal next argument pointer 32 | * @next_bitmap: internal pointer to next present u32 33 | * @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present 34 | */ 35 | 36 | struct ieee80211_radiotap_iterator { 37 | struct ieee80211_radiotap_header *rtheader; 38 | int max_length; 39 | int this_arg_index; 40 | unsigned char *this_arg; 41 | 42 | int arg_index; 43 | unsigned char *arg; 44 | uint32_t *next_bitmap; 45 | uint32_t bitmap_shifter; 46 | }; 47 | 48 | extern int ieee80211_radiotap_iterator_init( 49 | struct ieee80211_radiotap_iterator *iterator, 50 | struct ieee80211_radiotap_header *radiotap_header, 51 | int max_length); 52 | 53 | extern int ieee80211_radiotap_iterator_next( 54 | struct ieee80211_radiotap_iterator *iterator); 55 | 56 | #endif /* __RADIOTAP_ITER_H */ 57 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/sha256-prf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA256-based PRF (IEEE 802.11r) 3 | * Copyright (c) 2003-2007, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "sha256.h" 13 | #include "crypto.h" 14 | 15 | 16 | /** 17 | * sha256_prf - SHA256-based Pseudo-Random Function (IEEE 802.11r, 8.5.1.5.2) 18 | * @key: Key for PRF 19 | * @key_len: Length of the key in bytes 20 | * @label: A unique label for each purpose of the PRF 21 | * @data: Extra data to bind into the key 22 | * @data_len: Length of the data 23 | * @buf: Buffer for the generated pseudo-random key 24 | * @buf_len: Number of bytes of key to generate 25 | * 26 | * This function is used to derive new, cryptographically separate keys from a 27 | * given key. 28 | */ 29 | void sha256_prf(const u8 *key, size_t key_len, const char *label, 30 | const u8 *data, size_t data_len, u8 *buf, size_t buf_len) 31 | { 32 | u16 counter = 1; 33 | size_t pos, plen; 34 | u8 hash[SHA256_MAC_LEN]; 35 | const u8 *addr[4]; 36 | size_t len[4]; 37 | u8 counter_le[2], length_le[2]; 38 | 39 | addr[0] = counter_le; 40 | len[0] = 2; 41 | addr[1] = (u8 *) label; 42 | len[1] = os_strlen(label); 43 | addr[2] = data; 44 | len[2] = data_len; 45 | addr[3] = length_le; 46 | len[3] = sizeof(length_le); 47 | 48 | WPA_PUT_LE16(length_le, buf_len * 8); 49 | pos = 0; 50 | while (pos < buf_len) { 51 | plen = buf_len - pos; 52 | WPA_PUT_LE16(counter_le, counter); 53 | if (plen >= SHA256_MAC_LEN) { 54 | hmac_sha256_vector(key, key_len, 4, addr, len, 55 | &buf[pos]); 56 | pos += SHA256_MAC_LEN; 57 | } else { 58 | hmac_sha256_vector(key, key_len, 4, addr, len, hash); 59 | os_memcpy(&buf[pos], hash, plen); 60 | break; 61 | } 62 | counter++; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_server/eap_methods.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP server method registration 3 | * Copyright (c) 2004-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EAP_SERVER_METHODS_H 10 | #define EAP_SERVER_METHODS_H 11 | 12 | #include "eap_common/eap_defs.h" 13 | 14 | const struct eap_method * eap_server_get_eap_method(int vendor, 15 | EapType method); 16 | struct eap_method * eap_server_method_alloc(int version, int vendor, 17 | EapType method, const char *name); 18 | void eap_server_method_free(struct eap_method *method); 19 | int eap_server_method_register(struct eap_method *method); 20 | 21 | EapType eap_server_get_type(const char *name, int *vendor); 22 | void eap_server_unregister_methods(void); 23 | const char * eap_server_get_name(int vendor, EapType type); 24 | 25 | /* EAP server method registration calls for statically linked in methods */ 26 | int eap_server_identity_register(void); 27 | int eap_server_md5_register(void); 28 | int eap_server_tls_register(void); 29 | int eap_server_unauth_tls_register(void); 30 | int eap_server_mschapv2_register(void); 31 | int eap_server_peap_register(void); 32 | int eap_server_tlv_register(void); 33 | int eap_server_gtc_register(void); 34 | int eap_server_ttls_register(void); 35 | int eap_server_sim_register(void); 36 | int eap_server_aka_register(void); 37 | int eap_server_aka_prime_register(void); 38 | int eap_server_pax_register(void); 39 | int eap_server_psk_register(void); 40 | int eap_server_sake_register(void); 41 | int eap_server_gpsk_register(void); 42 | int eap_server_vendor_test_register(void); 43 | int eap_server_fast_register(void); 44 | int eap_server_wsc_register(void); 45 | int eap_server_ikev2_register(void); 46 | int eap_server_tnc_register(void); 47 | int eap_server_pwd_register(void); 48 | 49 | #endif /* EAP_SERVER_METHODS_H */ 50 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EAP_TTLS_H 10 | #define EAP_TTLS_H 11 | 12 | struct ttls_avp { 13 | be32 avp_code; 14 | be32 avp_length; /* 8-bit flags, 24-bit length; 15 | * length includes AVP header */ 16 | /* optional 32-bit Vendor-ID */ 17 | /* Data */ 18 | }; 19 | 20 | struct ttls_avp_vendor { 21 | be32 avp_code; 22 | be32 avp_length; /* 8-bit flags, 24-bit length; 23 | * length includes AVP header */ 24 | be32 vendor_id; 25 | /* Data */ 26 | }; 27 | 28 | #define AVP_FLAGS_VENDOR 0x80 29 | #define AVP_FLAGS_MANDATORY 0x40 30 | 31 | #define AVP_PAD(start, pos) \ 32 | do { \ 33 | int __pad; \ 34 | __pad = (4 - (((pos) - (start)) & 3)) & 3; \ 35 | os_memset((pos), 0, __pad); \ 36 | pos += __pad; \ 37 | } while (0) 38 | 39 | 40 | /* RFC 2865 */ 41 | #define RADIUS_ATTR_USER_NAME 1 42 | #define RADIUS_ATTR_USER_PASSWORD 2 43 | #define RADIUS_ATTR_CHAP_PASSWORD 3 44 | #define RADIUS_ATTR_REPLY_MESSAGE 18 45 | #define RADIUS_ATTR_CHAP_CHALLENGE 60 46 | #define RADIUS_ATTR_EAP_MESSAGE 79 47 | 48 | /* RFC 2548 */ 49 | #define RADIUS_VENDOR_ID_MICROSOFT 311 50 | #define RADIUS_ATTR_MS_CHAP_RESPONSE 1 51 | #define RADIUS_ATTR_MS_CHAP_ERROR 2 52 | #define RADIUS_ATTR_MS_CHAP_NT_ENC_PW 6 53 | #define RADIUS_ATTR_MS_CHAP_CHALLENGE 11 54 | #define RADIUS_ATTR_MS_CHAP2_RESPONSE 25 55 | #define RADIUS_ATTR_MS_CHAP2_SUCCESS 26 56 | #define RADIUS_ATTR_MS_CHAP2_CPW 27 57 | 58 | #define EAP_TTLS_MSCHAPV2_CHALLENGE_LEN 16 59 | #define EAP_TTLS_MSCHAPV2_RESPONSE_LEN 50 60 | #define EAP_TTLS_MSCHAP_CHALLENGE_LEN 8 61 | #define EAP_TTLS_MSCHAP_RESPONSE_LEN 50 62 | #define EAP_TTLS_CHAP_CHALLENGE_LEN 16 63 | #define EAP_TTLS_CHAP_PASSWORD_LEN 16 64 | 65 | #endif /* EAP_TTLS_H */ 66 | -------------------------------------------------------------------------------- /hostapd-2.0/src/wps/wps_dev_attr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Wi-Fi Protected Setup - device attributes 3 | * Copyright (c) 2008, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef WPS_DEV_ATTR_H 10 | #define WPS_DEV_ATTR_H 11 | 12 | struct wps_parse_attr; 13 | 14 | int wps_build_manufacturer(struct wps_device_data *dev, struct wpabuf *msg); 15 | int wps_build_model_name(struct wps_device_data *dev, struct wpabuf *msg); 16 | int wps_build_model_number(struct wps_device_data *dev, struct wpabuf *msg); 17 | int wps_build_dev_name(struct wps_device_data *dev, struct wpabuf *msg); 18 | int wps_build_device_attrs(struct wps_device_data *dev, struct wpabuf *msg); 19 | int wps_build_os_version(struct wps_device_data *dev, struct wpabuf *msg); 20 | int wps_build_vendor_ext_m1(struct wps_device_data *dev, struct wpabuf *msg); 21 | int wps_build_rf_bands(struct wps_device_data *dev, struct wpabuf *msg); 22 | int wps_build_primary_dev_type(struct wps_device_data *dev, 23 | struct wpabuf *msg); 24 | int wps_build_secondary_dev_type(struct wps_device_data *dev, 25 | struct wpabuf *msg); 26 | int wps_build_dev_name(struct wps_device_data *dev, struct wpabuf *msg); 27 | int wps_process_device_attrs(struct wps_device_data *dev, 28 | struct wps_parse_attr *attr); 29 | int wps_process_os_version(struct wps_device_data *dev, const u8 *ver); 30 | int wps_process_rf_bands(struct wps_device_data *dev, const u8 *bands); 31 | void wps_device_data_dup(struct wps_device_data *dst, 32 | const struct wps_device_data *src); 33 | void wps_device_data_free(struct wps_device_data *dev); 34 | int wps_build_vendor_ext(struct wps_device_data *dev, struct wpabuf *msg); 35 | int wps_build_req_dev_type(struct wps_device_data *dev, struct wpabuf *msg, 36 | unsigned int num_req_dev_types, 37 | const u8 *req_dev_types); 38 | 39 | #endif /* WPS_DEV_ATTR_H */ 40 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/fips_prf_openssl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FIPS 186-2 PRF for libcrypto 3 | * Copyright (c) 2004-2005, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | #include 11 | 12 | #include "common.h" 13 | #include "crypto.h" 14 | 15 | 16 | static void sha1_transform(u8 *state, const u8 data[64]) 17 | { 18 | SHA_CTX context; 19 | os_memset(&context, 0, sizeof(context)); 20 | os_memcpy(&context.h0, state, 5 * 4); 21 | SHA1_Transform(&context, data); 22 | os_memcpy(state, &context.h0, 5 * 4); 23 | } 24 | 25 | 26 | int fips186_2_prf(const u8 *seed, size_t seed_len, u8 *x, size_t xlen) 27 | { 28 | u8 xkey[64]; 29 | u32 t[5], _t[5]; 30 | int i, j, m, k; 31 | u8 *xpos = x; 32 | u32 carry; 33 | 34 | if (seed_len < sizeof(xkey)) 35 | os_memset(xkey + seed_len, 0, sizeof(xkey) - seed_len); 36 | else 37 | seed_len = sizeof(xkey); 38 | 39 | /* FIPS 186-2 + change notice 1 */ 40 | 41 | os_memcpy(xkey, seed, seed_len); 42 | t[0] = 0x67452301; 43 | t[1] = 0xEFCDAB89; 44 | t[2] = 0x98BADCFE; 45 | t[3] = 0x10325476; 46 | t[4] = 0xC3D2E1F0; 47 | 48 | m = xlen / 40; 49 | for (j = 0; j < m; j++) { 50 | /* XSEED_j = 0 */ 51 | for (i = 0; i < 2; i++) { 52 | /* XVAL = (XKEY + XSEED_j) mod 2^b */ 53 | 54 | /* w_i = G(t, XVAL) */ 55 | os_memcpy(_t, t, 20); 56 | sha1_transform((u8 *) _t, xkey); 57 | _t[0] = host_to_be32(_t[0]); 58 | _t[1] = host_to_be32(_t[1]); 59 | _t[2] = host_to_be32(_t[2]); 60 | _t[3] = host_to_be32(_t[3]); 61 | _t[4] = host_to_be32(_t[4]); 62 | os_memcpy(xpos, _t, 20); 63 | 64 | /* XKEY = (1 + XKEY + w_i) mod 2^b */ 65 | carry = 1; 66 | for (k = 19; k >= 0; k--) { 67 | carry += xkey[k] + xpos[k]; 68 | xkey[k] = carry & 0xff; 69 | carry >>= 8; 70 | } 71 | 72 | xpos += 20; 73 | } 74 | /* x_j = w_0|w_1 */ 75 | } 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/pmksa_cache_auth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd - PMKSA cache for IEEE 802.11i RSN 3 | * Copyright (c) 2004-2008, 2012, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef PMKSA_CACHE_H 10 | #define PMKSA_CACHE_H 11 | 12 | #include "radius/radius.h" 13 | 14 | /** 15 | * struct rsn_pmksa_cache_entry - PMKSA cache entry 16 | */ 17 | struct rsn_pmksa_cache_entry { 18 | struct rsn_pmksa_cache_entry *next, *hnext; 19 | u8 pmkid[PMKID_LEN]; 20 | u8 pmk[PMK_LEN]; 21 | size_t pmk_len; 22 | os_time_t expiration; 23 | int akmp; /* WPA_KEY_MGMT_* */ 24 | u8 spa[ETH_ALEN]; 25 | 26 | u8 *identity; 27 | size_t identity_len; 28 | struct wpabuf *cui; 29 | struct radius_class_data radius_class; 30 | u8 eap_type_authsrv; 31 | int vlan_id; 32 | int opportunistic; 33 | }; 34 | 35 | struct rsn_pmksa_cache; 36 | 37 | struct rsn_pmksa_cache * 38 | pmksa_cache_auth_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry, 39 | void *ctx), void *ctx); 40 | void pmksa_cache_auth_deinit(struct rsn_pmksa_cache *pmksa); 41 | struct rsn_pmksa_cache_entry * 42 | pmksa_cache_auth_get(struct rsn_pmksa_cache *pmksa, 43 | const u8 *spa, const u8 *pmkid); 44 | struct rsn_pmksa_cache_entry * pmksa_cache_get_okc( 45 | struct rsn_pmksa_cache *pmksa, const u8 *spa, const u8 *aa, 46 | const u8 *pmkid); 47 | struct rsn_pmksa_cache_entry * 48 | pmksa_cache_auth_add(struct rsn_pmksa_cache *pmksa, 49 | const u8 *pmk, size_t pmk_len, 50 | const u8 *aa, const u8 *spa, int session_timeout, 51 | struct eapol_state_machine *eapol, int akmp); 52 | struct rsn_pmksa_cache_entry * 53 | pmksa_cache_add_okc(struct rsn_pmksa_cache *pmksa, 54 | const struct rsn_pmksa_cache_entry *old_entry, 55 | const u8 *aa, const u8 *pmkid); 56 | void pmksa_cache_to_eapol_data(struct rsn_pmksa_cache_entry *entry, 57 | struct eapol_state_machine *eapol); 58 | 59 | #endif /* PMKSA_CACHE_H */ 60 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 7 | * See README for more details. 8 | */ 9 | 10 | #include "includes.h" 11 | 12 | #include "common.h" 13 | #include "aes.h" 14 | #include "aes_wrap.h" 15 | 16 | /** 17 | * aes_unwrap - Unwrap key with AES Key Wrap Algorithm (128-bit KEK) (RFC3394) 18 | * @kek: Key encryption key (KEK) 19 | * @n: Length of the plaintext key in 64-bit units; e.g., 2 = 128-bit = 16 20 | * bytes 21 | * @cipher: Wrapped key to be unwrapped, (n + 1) * 64 bits 22 | * @plain: Plaintext key, n * 64 bits 23 | * Returns: 0 on success, -1 on failure (e.g., integrity verification failed) 24 | */ 25 | int aes_unwrap(const u8 *kek, int n, const u8 *cipher, u8 *plain) 26 | { 27 | u8 a[8], *r, b[16]; 28 | int i, j; 29 | void *ctx; 30 | 31 | /* 1) Initialize variables. */ 32 | os_memcpy(a, cipher, 8); 33 | r = plain; 34 | os_memcpy(r, cipher + 8, 8 * n); 35 | 36 | ctx = aes_decrypt_init(kek, 16); 37 | if (ctx == NULL) 38 | return -1; 39 | 40 | /* 2) Compute intermediate values. 41 | * For j = 5 to 0 42 | * For i = n to 1 43 | * B = AES-1(K, (A ^ t) | R[i]) where t = n*j+i 44 | * A = MSB(64, B) 45 | * R[i] = LSB(64, B) 46 | */ 47 | for (j = 5; j >= 0; j--) { 48 | r = plain + (n - 1) * 8; 49 | for (i = n; i >= 1; i--) { 50 | os_memcpy(b, a, 8); 51 | b[7] ^= n * j + i; 52 | 53 | os_memcpy(b + 8, r, 8); 54 | aes_decrypt(ctx, b, b); 55 | os_memcpy(a, b, 8); 56 | os_memcpy(r, b + 8, 8); 57 | r -= 8; 58 | } 59 | } 60 | aes_decrypt_deinit(ctx); 61 | 62 | /* 3) Output results. 63 | * 64 | * These are already in @plain due to the location of temporary 65 | * variables. Just verify that the IV matches with the expected value. 66 | */ 67 | for (i = 0; i < 8; i++) { 68 | if (a[i] != 0xa6) 69 | return -1; 70 | } 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EAP_GPSK_COMMON_H 10 | #define EAP_GPSK_COMMON_H 11 | 12 | #define EAP_GPSK_OPCODE_GPSK_1 1 13 | #define EAP_GPSK_OPCODE_GPSK_2 2 14 | #define EAP_GPSK_OPCODE_GPSK_3 3 15 | #define EAP_GPSK_OPCODE_GPSK_4 4 16 | #define EAP_GPSK_OPCODE_FAIL 5 17 | #define EAP_GPSK_OPCODE_PROTECTED_FAIL 6 18 | 19 | /* Failure-Code in GPSK-Fail and GPSK-Protected-Fail */ 20 | #define EAP_GPSK_FAIL_PSK_NOT_FOUND 0x00000001 21 | #define EAP_GPSK_FAIL_AUTHENTICATION_FAILURE 0x00000002 22 | #define EAP_GPSK_FAIL_AUTHORIZATION_FAILURE 0x00000003 23 | 24 | #define EAP_GPSK_RAND_LEN 32 25 | #define EAP_GPSK_MAX_SK_LEN 32 26 | #define EAP_GPSK_MAX_PK_LEN 32 27 | #define EAP_GPSK_MAX_MIC_LEN 32 28 | 29 | #define EAP_GPSK_VENDOR_IETF 0x00000000 30 | #define EAP_GPSK_CIPHER_RESERVED 0x000000 31 | #define EAP_GPSK_CIPHER_AES 0x000001 32 | #define EAP_GPSK_CIPHER_SHA256 0x000002 33 | 34 | 35 | #ifdef _MSC_VER 36 | #pragma pack(push, 1) 37 | #endif /* _MSC_VER */ 38 | 39 | struct eap_gpsk_csuite { 40 | u8 vendor[4]; 41 | u8 specifier[2]; 42 | } STRUCT_PACKED; 43 | 44 | #ifdef _MSC_VER 45 | #pragma pack(pop) 46 | #endif /* _MSC_VER */ 47 | 48 | int eap_gpsk_supported_ciphersuite(int vendor, int specifier); 49 | int eap_gpsk_derive_keys(const u8 *psk, size_t psk_len, int vendor, 50 | int specifier, 51 | const u8 *rand_client, const u8 *rand_server, 52 | const u8 *id_client, size_t id_client_len, 53 | const u8 *id_server, size_t id_server_len, 54 | u8 *msk, u8 *emsk, u8 *sk, size_t *sk_len, 55 | u8 *pk, size_t *pk_len); 56 | size_t eap_gpsk_mic_len(int vendor, int specifier); 57 | int eap_gpsk_compute_mic(const u8 *sk, size_t sk_len, int vendor, 58 | int specifier, const u8 *data, size_t len, u8 *mic); 59 | 60 | #endif /* EAP_GPSK_COMMON_H */ 61 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/sha1-tprf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA1 T-PRF for EAP-FAST 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "sha1.h" 13 | #include "crypto.h" 14 | 15 | /** 16 | * sha1_t_prf - EAP-FAST Pseudo-Random Function (T-PRF) 17 | * @key: Key for PRF 18 | * @key_len: Length of the key in bytes 19 | * @label: A unique label for each purpose of the PRF 20 | * @seed: Seed value to bind into the key 21 | * @seed_len: Length of the seed 22 | * @buf: Buffer for the generated pseudo-random key 23 | * @buf_len: Number of bytes of key to generate 24 | * Returns: 0 on success, -1 of failure 25 | * 26 | * This function is used to derive new, cryptographically separate keys from a 27 | * given key for EAP-FAST. T-PRF is defined in RFC 4851, Section 5.5. 28 | */ 29 | int sha1_t_prf(const u8 *key, size_t key_len, const char *label, 30 | const u8 *seed, size_t seed_len, u8 *buf, size_t buf_len) 31 | { 32 | unsigned char counter = 0; 33 | size_t pos, plen; 34 | u8 hash[SHA1_MAC_LEN]; 35 | size_t label_len = os_strlen(label); 36 | u8 output_len[2]; 37 | const unsigned char *addr[5]; 38 | size_t len[5]; 39 | 40 | addr[0] = hash; 41 | len[0] = 0; 42 | addr[1] = (unsigned char *) label; 43 | len[1] = label_len + 1; 44 | addr[2] = seed; 45 | len[2] = seed_len; 46 | addr[3] = output_len; 47 | len[3] = 2; 48 | addr[4] = &counter; 49 | len[4] = 1; 50 | 51 | output_len[0] = (buf_len >> 8) & 0xff; 52 | output_len[1] = buf_len & 0xff; 53 | pos = 0; 54 | while (pos < buf_len) { 55 | counter++; 56 | plen = buf_len - pos; 57 | if (hmac_sha1_vector(key, key_len, 5, addr, len, hash)) 58 | return -1; 59 | if (plen >= SHA1_MAC_LEN) { 60 | os_memcpy(&buf[pos], hash, SHA1_MAC_LEN); 61 | pos += SHA1_MAC_LEN; 62 | } else { 63 | os_memcpy(&buf[pos], hash, plen); 64 | break; 65 | } 66 | len[0] = SHA1_MAC_LEN; 67 | } 68 | 69 | return 0; 70 | } 71 | -------------------------------------------------------------------------------- /hostapd-2.0/src/tls/tlsv1_server.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TLS v1.0/v1.1/v1.2 server (RFC 2246, RFC 4346, RFC 5246) 3 | * Copyright (c) 2006-2011, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef TLSV1_SERVER_H 10 | #define TLSV1_SERVER_H 11 | 12 | #include "tlsv1_cred.h" 13 | 14 | struct tlsv1_server; 15 | 16 | int tlsv1_server_global_init(void); 17 | void tlsv1_server_global_deinit(void); 18 | struct tlsv1_server * tlsv1_server_init(struct tlsv1_credentials *cred); 19 | void tlsv1_server_deinit(struct tlsv1_server *conn); 20 | int tlsv1_server_established(struct tlsv1_server *conn); 21 | int tlsv1_server_prf(struct tlsv1_server *conn, const char *label, 22 | int server_random_first, u8 *out, size_t out_len); 23 | u8 * tlsv1_server_handshake(struct tlsv1_server *conn, 24 | const u8 *in_data, size_t in_len, size_t *out_len); 25 | int tlsv1_server_encrypt(struct tlsv1_server *conn, 26 | const u8 *in_data, size_t in_len, 27 | u8 *out_data, size_t out_len); 28 | int tlsv1_server_decrypt(struct tlsv1_server *conn, 29 | const u8 *in_data, size_t in_len, 30 | u8 *out_data, size_t out_len); 31 | int tlsv1_server_get_cipher(struct tlsv1_server *conn, char *buf, 32 | size_t buflen); 33 | int tlsv1_server_shutdown(struct tlsv1_server *conn); 34 | int tlsv1_server_resumed(struct tlsv1_server *conn); 35 | int tlsv1_server_get_keys(struct tlsv1_server *conn, struct tls_keys *keys); 36 | int tlsv1_server_get_keyblock_size(struct tlsv1_server *conn); 37 | int tlsv1_server_set_cipher_list(struct tlsv1_server *conn, u8 *ciphers); 38 | int tlsv1_server_set_verify(struct tlsv1_server *conn, int verify_peer); 39 | 40 | typedef int (*tlsv1_server_session_ticket_cb) 41 | (void *ctx, const u8 *ticket, size_t len, const u8 *client_random, 42 | const u8 *server_random, u8 *master_secret); 43 | 44 | void tlsv1_server_set_session_ticket_cb(struct tlsv1_server *conn, 45 | tlsv1_server_session_ticket_cb cb, 46 | void *ctx); 47 | 48 | #endif /* TLSV1_SERVER_H */ 49 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/sha256-tlsprf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * TLS PRF P_SHA256 3 | * Copyright (c) 2011, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "sha256.h" 13 | 14 | 15 | /** 16 | * tls_prf_sha256 - Pseudo-Random Function for TLS v1.2 (P_SHA256, RFC 5246) 17 | * @secret: Key for PRF 18 | * @secret_len: Length of the key in bytes 19 | * @label: A unique label for each purpose of the PRF 20 | * @seed: Seed value to bind into the key 21 | * @seed_len: Length of the seed 22 | * @out: Buffer for the generated pseudo-random key 23 | * @outlen: Number of bytes of key to generate 24 | * Returns: 0 on success, -1 on failure. 25 | * 26 | * This function is used to derive new, cryptographically separate keys from a 27 | * given key in TLS. This PRF is defined in RFC 2246, Chapter 5. 28 | */ 29 | void tls_prf_sha256(const u8 *secret, size_t secret_len, const char *label, 30 | const u8 *seed, size_t seed_len, u8 *out, size_t outlen) 31 | { 32 | size_t clen; 33 | u8 A[SHA256_MAC_LEN]; 34 | u8 P[SHA256_MAC_LEN]; 35 | size_t pos; 36 | const unsigned char *addr[3]; 37 | size_t len[3]; 38 | 39 | addr[0] = A; 40 | len[0] = SHA256_MAC_LEN; 41 | addr[1] = (unsigned char *) label; 42 | len[1] = os_strlen(label); 43 | addr[2] = seed; 44 | len[2] = seed_len; 45 | 46 | /* 47 | * RFC 5246, Chapter 5 48 | * A(0) = seed, A(i) = HMAC(secret, A(i-1)) 49 | * P_hash = HMAC(secret, A(1) + seed) + HMAC(secret, A(2) + seed) + .. 50 | * PRF(secret, label, seed) = P_SHA256(secret, label + seed) 51 | */ 52 | 53 | hmac_sha256_vector(secret, secret_len, 2, &addr[1], &len[1], A); 54 | 55 | pos = 0; 56 | while (pos < outlen) { 57 | hmac_sha256_vector(secret, secret_len, 3, addr, len, P); 58 | hmac_sha256(secret, secret_len, A, SHA256_MAC_LEN, A); 59 | 60 | clen = outlen - pos; 61 | if (clen > SHA256_MAC_LEN) 62 | clen = SHA256_MAC_LEN; 63 | os_memcpy(out + pos, P, clen); 64 | pos += clen; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EAP_PSK_COMMON_H 10 | #define EAP_PSK_COMMON_H 11 | 12 | 13 | #define EAP_PSK_RAND_LEN 16 14 | #define EAP_PSK_MAC_LEN 16 15 | #define EAP_PSK_TEK_LEN 16 16 | #define EAP_PSK_PSK_LEN 16 17 | #define EAP_PSK_AK_LEN 16 18 | #define EAP_PSK_KDK_LEN 16 19 | 20 | #define EAP_PSK_R_FLAG_CONT 1 21 | #define EAP_PSK_R_FLAG_DONE_SUCCESS 2 22 | #define EAP_PSK_R_FLAG_DONE_FAILURE 3 23 | #define EAP_PSK_E_FLAG 0x20 24 | 25 | #define EAP_PSK_FLAGS_GET_T(flags) (((flags) & 0xc0) >> 6) 26 | #define EAP_PSK_FLAGS_SET_T(t) ((u8) (t) << 6) 27 | 28 | #ifdef _MSC_VER 29 | #pragma pack(push, 1) 30 | #endif /* _MSC_VER */ 31 | 32 | /* EAP-PSK First Message (AS -> Supplicant) */ 33 | struct eap_psk_hdr_1 { 34 | u8 flags; 35 | u8 rand_s[EAP_PSK_RAND_LEN]; 36 | /* Followed by variable length ID_S */ 37 | } STRUCT_PACKED; 38 | 39 | /* EAP-PSK Second Message (Supplicant -> AS) */ 40 | struct eap_psk_hdr_2 { 41 | u8 flags; 42 | u8 rand_s[EAP_PSK_RAND_LEN]; 43 | u8 rand_p[EAP_PSK_RAND_LEN]; 44 | u8 mac_p[EAP_PSK_MAC_LEN]; 45 | /* Followed by variable length ID_P */ 46 | } STRUCT_PACKED; 47 | 48 | /* EAP-PSK Third Message (AS -> Supplicant) */ 49 | struct eap_psk_hdr_3 { 50 | u8 flags; 51 | u8 rand_s[EAP_PSK_RAND_LEN]; 52 | u8 mac_s[EAP_PSK_MAC_LEN]; 53 | /* Followed by variable length PCHANNEL */ 54 | } STRUCT_PACKED; 55 | 56 | /* EAP-PSK Fourth Message (Supplicant -> AS) */ 57 | struct eap_psk_hdr_4 { 58 | u8 flags; 59 | u8 rand_s[EAP_PSK_RAND_LEN]; 60 | /* Followed by variable length PCHANNEL */ 61 | } STRUCT_PACKED; 62 | 63 | #ifdef _MSC_VER 64 | #pragma pack(pop) 65 | #endif /* _MSC_VER */ 66 | 67 | 68 | int __must_check eap_psk_key_setup(const u8 *psk, u8 *ak, u8 *kdk); 69 | int __must_check eap_psk_derive_keys(const u8 *kdk, const u8 *rand_p, u8 *tek, 70 | u8 *msk, u8 *emsk); 71 | 72 | #endif /* EAP_PSK_COMMON_H */ 73 | -------------------------------------------------------------------------------- /hostapd-2.0/src/drivers/driver_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Common driver-related functions 3 | * Copyright (c) 2003-2011, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | #include "utils/common.h" 11 | #include "driver.h" 12 | 13 | void wpa_scan_results_free(struct wpa_scan_results *res) 14 | { 15 | size_t i; 16 | 17 | if (res == NULL) 18 | return; 19 | 20 | for (i = 0; i < res->num; i++) 21 | os_free(res->res[i]); 22 | os_free(res->res); 23 | os_free(res); 24 | } 25 | 26 | 27 | const char * event_to_string(enum wpa_event_type event) 28 | { 29 | #define E2S(n) case EVENT_ ## n: return #n 30 | switch (event) { 31 | E2S(ASSOC); 32 | E2S(DISASSOC); 33 | E2S(MICHAEL_MIC_FAILURE); 34 | E2S(SCAN_RESULTS); 35 | E2S(ASSOCINFO); 36 | E2S(INTERFACE_STATUS); 37 | E2S(PMKID_CANDIDATE); 38 | E2S(STKSTART); 39 | E2S(TDLS); 40 | E2S(FT_RESPONSE); 41 | E2S(IBSS_RSN_START); 42 | E2S(AUTH); 43 | E2S(DEAUTH); 44 | E2S(ASSOC_REJECT); 45 | E2S(AUTH_TIMED_OUT); 46 | E2S(ASSOC_TIMED_OUT); 47 | E2S(FT_RRB_RX); 48 | E2S(WPS_BUTTON_PUSHED); 49 | E2S(TX_STATUS); 50 | E2S(RX_FROM_UNKNOWN); 51 | E2S(RX_MGMT); 52 | E2S(RX_ACTION); 53 | E2S(REMAIN_ON_CHANNEL); 54 | E2S(CANCEL_REMAIN_ON_CHANNEL); 55 | E2S(MLME_RX); 56 | E2S(RX_PROBE_REQ); 57 | E2S(NEW_STA); 58 | E2S(EAPOL_RX); 59 | E2S(SIGNAL_CHANGE); 60 | E2S(INTERFACE_ENABLED); 61 | E2S(INTERFACE_DISABLED); 62 | E2S(CHANNEL_LIST_CHANGED); 63 | E2S(INTERFACE_UNAVAILABLE); 64 | E2S(BEST_CHANNEL); 65 | E2S(UNPROT_DEAUTH); 66 | E2S(UNPROT_DISASSOC); 67 | E2S(STATION_LOW_ACK); 68 | E2S(P2P_DEV_FOUND); 69 | E2S(P2P_GO_NEG_REQ_RX); 70 | E2S(P2P_GO_NEG_COMPLETED); 71 | E2S(P2P_PROV_DISC_REQUEST); 72 | E2S(P2P_PROV_DISC_RESPONSE); 73 | E2S(P2P_SD_REQUEST); 74 | E2S(P2P_SD_RESPONSE); 75 | E2S(IBSS_PEER_LOST); 76 | E2S(DRIVER_GTK_REKEY); 77 | E2S(SCHED_SCAN_STOPPED); 78 | E2S(DRIVER_CLIENT_POLL_OK); 79 | E2S(EAPOL_TX_STATUS); 80 | E2S(CH_SWITCH); 81 | E2S(WNM); 82 | } 83 | 84 | return "UNKNOWN"; 85 | #undef E2S 86 | } 87 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Backtrace debugging 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef TRACE_H 10 | #define TRACE_H 11 | 12 | #define WPA_TRACE_LEN 16 13 | 14 | #ifdef WPA_TRACE 15 | #include 16 | 17 | #include "list.h" 18 | 19 | #define WPA_TRACE_INFO void *btrace[WPA_TRACE_LEN]; int btrace_num; 20 | 21 | struct wpa_trace_ref { 22 | struct dl_list list; 23 | const void *addr; 24 | WPA_TRACE_INFO 25 | }; 26 | #define WPA_TRACE_REF(name) struct wpa_trace_ref wpa_trace_ref_##name 27 | 28 | #define wpa_trace_dump(title, ptr) \ 29 | wpa_trace_dump_func((title), (ptr)->btrace, (ptr)->btrace_num) 30 | void wpa_trace_dump_func(const char *title, void **btrace, int btrace_num); 31 | #define wpa_trace_record(ptr) \ 32 | (ptr)->btrace_num = backtrace((ptr)->btrace, WPA_TRACE_LEN) 33 | void wpa_trace_show(const char *title); 34 | #define wpa_trace_add_ref(ptr, name, addr) \ 35 | wpa_trace_add_ref_func(&(ptr)->wpa_trace_ref_##name, (addr)) 36 | void wpa_trace_add_ref_func(struct wpa_trace_ref *ref, const void *addr); 37 | #define wpa_trace_remove_ref(ptr, name, addr) \ 38 | do { \ 39 | if ((addr)) \ 40 | dl_list_del(&(ptr)->wpa_trace_ref_##name.list); \ 41 | } while (0) 42 | void wpa_trace_check_ref(const void *addr); 43 | 44 | #else /* WPA_TRACE */ 45 | 46 | #define WPA_TRACE_INFO 47 | #define WPA_TRACE_REF(n) 48 | #define wpa_trace_dump(title, ptr) do { } while (0) 49 | #define wpa_trace_record(ptr) do { } while (0) 50 | #define wpa_trace_show(title) do { } while (0) 51 | #define wpa_trace_add_ref(ptr, name, addr) do { } while (0) 52 | #define wpa_trace_remove_ref(ptr, name, addr) do { } while (0) 53 | #define wpa_trace_check_ref(addr) do { } while (0) 54 | 55 | #endif /* WPA_TRACE */ 56 | 57 | 58 | #ifdef WPA_TRACE_BFD 59 | 60 | void wpa_trace_dump_funcname(const char *title, void *pc); 61 | 62 | #else /* WPA_TRACE_BFD */ 63 | 64 | #define wpa_trace_dump_funcname(title, pc) do { } while (0) 65 | 66 | #endif /* WPA_TRACE_BFD */ 67 | 68 | #endif /* TRACE_H */ 69 | -------------------------------------------------------------------------------- /hostapd-2.0/src/tls/tlsv1_server_i.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TLSv1 server - internal structures 3 | * Copyright (c) 2006-2007, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef TLSV1_SERVER_I_H 10 | #define TLSV1_SERVER_I_H 11 | 12 | struct tlsv1_server { 13 | enum { 14 | CLIENT_HELLO, SERVER_HELLO, SERVER_CERTIFICATE, 15 | SERVER_KEY_EXCHANGE, SERVER_CERTIFICATE_REQUEST, 16 | SERVER_HELLO_DONE, CLIENT_CERTIFICATE, CLIENT_KEY_EXCHANGE, 17 | CERTIFICATE_VERIFY, CHANGE_CIPHER_SPEC, CLIENT_FINISHED, 18 | SERVER_CHANGE_CIPHER_SPEC, SERVER_FINISHED, 19 | ESTABLISHED, FAILED 20 | } state; 21 | 22 | struct tlsv1_record_layer rl; 23 | 24 | u8 session_id[TLS_SESSION_ID_MAX_LEN]; 25 | size_t session_id_len; 26 | u8 client_random[TLS_RANDOM_LEN]; 27 | u8 server_random[TLS_RANDOM_LEN]; 28 | u8 master_secret[TLS_MASTER_SECRET_LEN]; 29 | 30 | u8 alert_level; 31 | u8 alert_description; 32 | 33 | struct crypto_public_key *client_rsa_key; 34 | 35 | struct tls_verify_hash verify; 36 | 37 | #define MAX_CIPHER_COUNT 30 38 | u16 cipher_suites[MAX_CIPHER_COUNT]; 39 | size_t num_cipher_suites; 40 | 41 | u16 cipher_suite; 42 | 43 | struct tlsv1_credentials *cred; 44 | 45 | int verify_peer; 46 | u16 client_version; 47 | 48 | u8 *session_ticket; 49 | size_t session_ticket_len; 50 | 51 | tlsv1_server_session_ticket_cb session_ticket_cb; 52 | void *session_ticket_cb_ctx; 53 | 54 | int use_session_ticket; 55 | 56 | u8 *dh_secret; 57 | size_t dh_secret_len; 58 | }; 59 | 60 | 61 | void tlsv1_server_alert(struct tlsv1_server *conn, u8 level, u8 description); 62 | int tlsv1_server_derive_keys(struct tlsv1_server *conn, 63 | const u8 *pre_master_secret, 64 | size_t pre_master_secret_len); 65 | u8 * tlsv1_server_handshake_write(struct tlsv1_server *conn, size_t *out_len); 66 | u8 * tlsv1_server_send_alert(struct tlsv1_server *conn, u8 level, 67 | u8 description, size_t *out_len); 68 | int tlsv1_server_process_handshake(struct tlsv1_server *conn, u8 ct, 69 | const u8 *buf, size_t *len); 70 | 71 | #endif /* TLSV1_SERVER_I_H */ 72 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/edit_simple.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Minimal command line editing 3 | * Copyright (c) 2010, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "eloop.h" 13 | #include "edit.h" 14 | 15 | 16 | #define CMD_BUF_LEN 256 17 | static char cmdbuf[CMD_BUF_LEN]; 18 | static int cmdbuf_pos = 0; 19 | static const char *ps2 = NULL; 20 | 21 | static void *edit_cb_ctx; 22 | static void (*edit_cmd_cb)(void *ctx, char *cmd); 23 | static void (*edit_eof_cb)(void *ctx); 24 | 25 | 26 | static void edit_read_char(int sock, void *eloop_ctx, void *sock_ctx) 27 | { 28 | int c; 29 | unsigned char buf[1]; 30 | int res; 31 | 32 | res = read(sock, buf, 1); 33 | if (res < 0) 34 | perror("read"); 35 | if (res <= 0) { 36 | edit_eof_cb(edit_cb_ctx); 37 | return; 38 | } 39 | c = buf[0]; 40 | 41 | if (c == '\r' || c == '\n') { 42 | cmdbuf[cmdbuf_pos] = '\0'; 43 | cmdbuf_pos = 0; 44 | edit_cmd_cb(edit_cb_ctx, cmdbuf); 45 | printf("%s> ", ps2 ? ps2 : ""); 46 | fflush(stdout); 47 | return; 48 | } 49 | 50 | if (c >= 32 && c <= 255) { 51 | if (cmdbuf_pos < (int) sizeof(cmdbuf) - 1) { 52 | cmdbuf[cmdbuf_pos++] = c; 53 | } 54 | } 55 | } 56 | 57 | 58 | int edit_init(void (*cmd_cb)(void *ctx, char *cmd), 59 | void (*eof_cb)(void *ctx), 60 | char ** (*completion_cb)(void *ctx, const char *cmd, int pos), 61 | void *ctx, const char *history_file, const char *ps) 62 | { 63 | edit_cb_ctx = ctx; 64 | edit_cmd_cb = cmd_cb; 65 | edit_eof_cb = eof_cb; 66 | eloop_register_read_sock(STDIN_FILENO, edit_read_char, NULL, NULL); 67 | ps2 = ps; 68 | 69 | printf("%s> ", ps2 ? ps2 : ""); 70 | fflush(stdout); 71 | 72 | return 0; 73 | } 74 | 75 | 76 | void edit_deinit(const char *history_file, 77 | int (*filter_cb)(void *ctx, const char *cmd)) 78 | { 79 | eloop_unregister_read_sock(STDIN_FILENO); 80 | } 81 | 82 | 83 | void edit_clear_line(void) 84 | { 85 | } 86 | 87 | 88 | void edit_redraw(void) 89 | { 90 | cmdbuf[cmdbuf_pos] = '\0'; 91 | printf("\r> %s", cmdbuf); 92 | } 93 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/ext_password_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * External password backend 3 | * Copyright (c) 2012, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "ext_password_i.h" 13 | 14 | 15 | struct ext_password_test_data { 16 | char *params; 17 | }; 18 | 19 | 20 | static void * ext_password_test_init(const char *params) 21 | { 22 | struct ext_password_test_data *data; 23 | 24 | data = os_zalloc(sizeof(*data)); 25 | if (data == NULL) 26 | return NULL; 27 | 28 | if (params) 29 | data->params = os_strdup(params); 30 | 31 | return data; 32 | } 33 | 34 | 35 | static void ext_password_test_deinit(void *ctx) 36 | { 37 | struct ext_password_test_data *data = ctx; 38 | 39 | os_free(data->params); 40 | os_free(data); 41 | } 42 | 43 | 44 | static struct wpabuf * ext_password_test_get(void *ctx, const char *name) 45 | { 46 | struct ext_password_test_data *data = ctx; 47 | char *pos, *pos2; 48 | size_t nlen; 49 | 50 | wpa_printf(MSG_DEBUG, "EXT PW TEST: get(%s)", name); 51 | 52 | pos = data->params; 53 | if (pos == NULL) 54 | return NULL; 55 | nlen = os_strlen(name); 56 | 57 | while (pos && *pos) { 58 | if (os_strncmp(pos, name, nlen) == 0 && pos[nlen] == '=') { 59 | struct wpabuf *buf; 60 | pos += nlen + 1; 61 | pos2 = pos; 62 | while (*pos2 != '|' && *pos2 != '\0') 63 | pos2++; 64 | buf = ext_password_alloc(pos2 - pos); 65 | if (buf == NULL) 66 | return NULL; 67 | wpabuf_put_data(buf, pos, pos2 - pos); 68 | wpa_hexdump_ascii_key(MSG_DEBUG, "EXT PW TEST: value", 69 | wpabuf_head(buf), 70 | wpabuf_len(buf)); 71 | return buf; 72 | } 73 | 74 | pos = os_strchr(pos + 1, '|'); 75 | if (pos) 76 | pos++; 77 | } 78 | 79 | wpa_printf(MSG_DEBUG, "EXT PW TEST: get(%s) - not found", name); 80 | 81 | return NULL; 82 | } 83 | 84 | 85 | const struct ext_password_backend ext_password_test = { 86 | .name = "test", 87 | .init = ext_password_test_init, 88 | .deinit = ext_password_test_deinit, 89 | .get = ext_password_test_get, 90 | }; 91 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_common/eap_peap_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP-PEAP common routines 3 | * Copyright (c) 2008-2011, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "crypto/sha1.h" 13 | #include "eap_peap_common.h" 14 | 15 | int peap_prfplus(int version, const u8 *key, size_t key_len, 16 | const char *label, const u8 *seed, size_t seed_len, 17 | u8 *buf, size_t buf_len) 18 | { 19 | unsigned char counter = 0; 20 | size_t pos, plen; 21 | u8 hash[SHA1_MAC_LEN]; 22 | size_t label_len = os_strlen(label); 23 | u8 extra[2]; 24 | const unsigned char *addr[5]; 25 | size_t len[5]; 26 | 27 | addr[0] = hash; 28 | len[0] = 0; 29 | addr[1] = (unsigned char *) label; 30 | len[1] = label_len; 31 | addr[2] = seed; 32 | len[2] = seed_len; 33 | 34 | if (version == 0) { 35 | /* 36 | * PRF+(K, S, LEN) = T1 | T2 | ... | Tn 37 | * T1 = HMAC-SHA1(K, S | 0x01 | 0x00 | 0x00) 38 | * T2 = HMAC-SHA1(K, T1 | S | 0x02 | 0x00 | 0x00) 39 | * ... 40 | * Tn = HMAC-SHA1(K, Tn-1 | S | n | 0x00 | 0x00) 41 | */ 42 | 43 | extra[0] = 0; 44 | extra[1] = 0; 45 | 46 | addr[3] = &counter; 47 | len[3] = 1; 48 | addr[4] = extra; 49 | len[4] = 2; 50 | } else { 51 | /* 52 | * PRF (K,S,LEN) = T1 | T2 | T3 | T4 | ... where: 53 | * T1 = HMAC-SHA1(K, S | LEN | 0x01) 54 | * T2 = HMAC-SHA1 (K, T1 | S | LEN | 0x02) 55 | * T3 = HMAC-SHA1 (K, T2 | S | LEN | 0x03) 56 | * T4 = HMAC-SHA1 (K, T3 | S | LEN | 0x04) 57 | * ... 58 | */ 59 | 60 | extra[0] = buf_len & 0xff; 61 | 62 | addr[3] = extra; 63 | len[3] = 1; 64 | addr[4] = &counter; 65 | len[4] = 1; 66 | } 67 | 68 | pos = 0; 69 | while (pos < buf_len) { 70 | counter++; 71 | plen = buf_len - pos; 72 | if (hmac_sha1_vector(key, key_len, 5, addr, len, hash) < 0) 73 | return -1; 74 | if (plen >= SHA1_MAC_LEN) { 75 | os_memcpy(&buf[pos], hash, SHA1_MAC_LEN); 76 | pos += SHA1_MAC_LEN; 77 | } else { 78 | os_memcpy(&buf[pos], hash, plen); 79 | break; 80 | } 81 | len[0] = SHA1_MAC_LEN; 82 | } 83 | 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | * Copyright (c) 2008-2011, 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 HW_FEATURES_H 18 | #define HW_FEATURES_H 19 | 20 | #ifdef NEED_AP_MLME 21 | void hostapd_free_hw_features(struct hostapd_hw_modes *hw_features, 22 | size_t num_hw_features); 23 | int hostapd_get_hw_features(struct hostapd_iface *iface); 24 | int hostapd_select_hw_mode(struct hostapd_iface *iface); 25 | const char * hostapd_hw_mode_txt(int mode); 26 | int hostapd_hw_get_freq(struct hostapd_data *hapd, int chan); 27 | int hostapd_hw_get_channel(struct hostapd_data *hapd, int freq); 28 | int hostapd_check_ht_capab(struct hostapd_iface *iface); 29 | int hostapd_prepare_rates(struct hostapd_iface *iface, 30 | struct hostapd_hw_modes *mode); 31 | #else /* NEED_AP_MLME */ 32 | static inline void 33 | hostapd_free_hw_features(struct hostapd_hw_modes *hw_features, 34 | size_t num_hw_features) 35 | { 36 | } 37 | 38 | static inline int hostapd_get_hw_features(struct hostapd_iface *iface) 39 | { 40 | return -1; 41 | } 42 | 43 | static inline int hostapd_select_hw_mode(struct hostapd_iface *iface) 44 | { 45 | return -100; 46 | } 47 | 48 | static inline const char * hostapd_hw_mode_txt(int mode) 49 | { 50 | return NULL; 51 | } 52 | 53 | static inline int hostapd_hw_get_freq(struct hostapd_data *hapd, int chan) 54 | { 55 | return -1; 56 | } 57 | 58 | static inline int hostapd_check_ht_capab(struct hostapd_iface *iface) 59 | { 60 | return 0; 61 | } 62 | 63 | static inline int hostapd_prepare_rates(struct hostapd_iface *iface, 64 | struct hostapd_hw_modes *mode) 65 | { 66 | return 0; 67 | } 68 | 69 | #endif /* NEED_AP_MLME */ 70 | 71 | #endif /* HW_FEATURES_H */ 72 | -------------------------------------------------------------------------------- /hostapd-2.0/src/tls/tlsv1_record.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TLSv1 Record Protocol 3 | * Copyright (c) 2006-2011, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef TLSV1_RECORD_H 10 | #define TLSV1_RECORD_H 11 | 12 | #include "crypto/crypto.h" 13 | 14 | #define TLS_MAX_WRITE_MAC_SECRET_LEN 32 15 | #define TLS_MAX_WRITE_KEY_LEN 32 16 | #define TLS_MAX_IV_LEN 16 17 | #define TLS_MAX_KEY_BLOCK_LEN (2 * (TLS_MAX_WRITE_MAC_SECRET_LEN + \ 18 | TLS_MAX_WRITE_KEY_LEN + TLS_MAX_IV_LEN)) 19 | 20 | #define TLS_SEQ_NUM_LEN 8 21 | #define TLS_RECORD_HEADER_LEN 5 22 | 23 | /* ContentType */ 24 | enum { 25 | TLS_CONTENT_TYPE_CHANGE_CIPHER_SPEC = 20, 26 | TLS_CONTENT_TYPE_ALERT = 21, 27 | TLS_CONTENT_TYPE_HANDSHAKE = 22, 28 | TLS_CONTENT_TYPE_APPLICATION_DATA = 23 29 | }; 30 | 31 | struct tlsv1_record_layer { 32 | u16 tls_version; 33 | 34 | u8 write_mac_secret[TLS_MAX_WRITE_MAC_SECRET_LEN]; 35 | u8 read_mac_secret[TLS_MAX_WRITE_MAC_SECRET_LEN]; 36 | u8 write_key[TLS_MAX_WRITE_KEY_LEN]; 37 | u8 read_key[TLS_MAX_WRITE_KEY_LEN]; 38 | u8 write_iv[TLS_MAX_IV_LEN]; 39 | u8 read_iv[TLS_MAX_IV_LEN]; 40 | 41 | size_t hash_size; 42 | size_t key_material_len; 43 | size_t iv_size; /* also block_size */ 44 | 45 | enum crypto_hash_alg hash_alg; 46 | enum crypto_cipher_alg cipher_alg; 47 | 48 | u8 write_seq_num[TLS_SEQ_NUM_LEN]; 49 | u8 read_seq_num[TLS_SEQ_NUM_LEN]; 50 | 51 | u16 cipher_suite; 52 | u16 write_cipher_suite; 53 | u16 read_cipher_suite; 54 | 55 | struct crypto_cipher *write_cbc; 56 | struct crypto_cipher *read_cbc; 57 | }; 58 | 59 | 60 | int tlsv1_record_set_cipher_suite(struct tlsv1_record_layer *rl, 61 | u16 cipher_suite); 62 | int tlsv1_record_change_write_cipher(struct tlsv1_record_layer *rl); 63 | int tlsv1_record_change_read_cipher(struct tlsv1_record_layer *rl); 64 | int tlsv1_record_send(struct tlsv1_record_layer *rl, u8 content_type, u8 *buf, 65 | size_t buf_size, const u8 *payload, size_t payload_len, 66 | size_t *out_len); 67 | int tlsv1_record_receive(struct tlsv1_record_layer *rl, 68 | const u8 *in_data, size_t in_len, 69 | u8 *out_data, size_t *out_len, u8 *alert); 70 | 71 | #endif /* TLSV1_RECORD_H */ 72 | -------------------------------------------------------------------------------- /hostapd-2.0/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 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "driver.h" 13 | 14 | 15 | struct none_driver_data { 16 | struct hostapd_data *hapd; 17 | void *ctx; 18 | }; 19 | 20 | 21 | static void * none_driver_hapd_init(struct hostapd_data *hapd, 22 | struct wpa_init_params *params) 23 | { 24 | struct none_driver_data *drv; 25 | 26 | drv = os_zalloc(sizeof(struct none_driver_data)); 27 | if (drv == NULL) { 28 | wpa_printf(MSG_ERROR, "Could not allocate memory for none " 29 | "driver data"); 30 | return NULL; 31 | } 32 | drv->hapd = hapd; 33 | 34 | return drv; 35 | } 36 | 37 | 38 | static void none_driver_hapd_deinit(void *priv) 39 | { 40 | struct none_driver_data *drv = priv; 41 | 42 | os_free(drv); 43 | } 44 | 45 | 46 | static int none_driver_send_ether(void *priv, const u8 *dst, const u8 *src, 47 | u16 proto, const u8 *data, size_t data_len) 48 | { 49 | return 0; 50 | } 51 | 52 | 53 | static void * none_driver_init(void *ctx, const char *ifname) 54 | { 55 | struct none_driver_data *drv; 56 | 57 | drv = os_zalloc(sizeof(struct none_driver_data)); 58 | if (drv == NULL) { 59 | wpa_printf(MSG_ERROR, "Could not allocate memory for none " 60 | "driver data"); 61 | return NULL; 62 | } 63 | drv->ctx = ctx; 64 | 65 | return drv; 66 | } 67 | 68 | 69 | static void none_driver_deinit(void *priv) 70 | { 71 | struct none_driver_data *drv = priv; 72 | 73 | os_free(drv); 74 | } 75 | 76 | 77 | static int none_driver_send_eapol(void *priv, const u8 *dest, u16 proto, 78 | const u8 *data, size_t data_len) 79 | { 80 | return -1; 81 | } 82 | 83 | 84 | const struct wpa_driver_ops wpa_driver_none_ops = { 85 | .name = "none", 86 | .desc = "no driver (RADIUS server/WPS ER)", 87 | .hapd_init = none_driver_hapd_init, 88 | .hapd_deinit = none_driver_hapd_deinit, 89 | .send_ether = none_driver_send_ether, 90 | .init = none_driver_init, 91 | .deinit = none_driver_deinit, 92 | .send_eapol = none_driver_send_eapol, 93 | }; 94 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/aes-cbc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AES-128 CBC 3 | * 4 | * Copyright (c) 2003-2007, Jouni Malinen 5 | * 6 | * This software may be distributed under the terms of the BSD license. 7 | * See README for more details. 8 | */ 9 | 10 | #include "includes.h" 11 | 12 | #include "common.h" 13 | #include "aes.h" 14 | #include "aes_wrap.h" 15 | 16 | /** 17 | * aes_128_cbc_encrypt - AES-128 CBC encryption 18 | * @key: Encryption key 19 | * @iv: Encryption IV for CBC mode (16 bytes) 20 | * @data: Data to encrypt in-place 21 | * @data_len: Length of data in bytes (must be divisible by 16) 22 | * Returns: 0 on success, -1 on failure 23 | */ 24 | int aes_128_cbc_encrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len) 25 | { 26 | void *ctx; 27 | u8 cbc[AES_BLOCK_SIZE]; 28 | u8 *pos = data; 29 | int i, j, blocks; 30 | 31 | ctx = aes_encrypt_init(key, 16); 32 | if (ctx == NULL) 33 | return -1; 34 | os_memcpy(cbc, iv, AES_BLOCK_SIZE); 35 | 36 | blocks = data_len / AES_BLOCK_SIZE; 37 | for (i = 0; i < blocks; i++) { 38 | for (j = 0; j < AES_BLOCK_SIZE; j++) 39 | cbc[j] ^= pos[j]; 40 | aes_encrypt(ctx, cbc, cbc); 41 | os_memcpy(pos, cbc, AES_BLOCK_SIZE); 42 | pos += AES_BLOCK_SIZE; 43 | } 44 | aes_encrypt_deinit(ctx); 45 | return 0; 46 | } 47 | 48 | 49 | /** 50 | * aes_128_cbc_decrypt - AES-128 CBC decryption 51 | * @key: Decryption key 52 | * @iv: Decryption IV for CBC mode (16 bytes) 53 | * @data: Data to decrypt in-place 54 | * @data_len: Length of data in bytes (must be divisible by 16) 55 | * Returns: 0 on success, -1 on failure 56 | */ 57 | int aes_128_cbc_decrypt(const u8 *key, const u8 *iv, u8 *data, size_t data_len) 58 | { 59 | void *ctx; 60 | u8 cbc[AES_BLOCK_SIZE], tmp[AES_BLOCK_SIZE]; 61 | u8 *pos = data; 62 | int i, j, blocks; 63 | 64 | ctx = aes_decrypt_init(key, 16); 65 | if (ctx == NULL) 66 | return -1; 67 | os_memcpy(cbc, iv, AES_BLOCK_SIZE); 68 | 69 | blocks = data_len / AES_BLOCK_SIZE; 70 | for (i = 0; i < blocks; i++) { 71 | os_memcpy(tmp, pos, AES_BLOCK_SIZE); 72 | aes_decrypt(ctx, pos, pos); 73 | for (j = 0; j < AES_BLOCK_SIZE; j++) 74 | pos[j] ^= cbc[j]; 75 | os_memcpy(cbc, tmp, AES_BLOCK_SIZE); 76 | pos += AES_BLOCK_SIZE; 77 | } 78 | aes_decrypt_deinit(ctx); 79 | return 0; 80 | } 81 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_common/eap_pwd_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP server/peer: EAP-pwd shared definitions 3 | * Copyright (c) 2009, Dan Harkins 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EAP_PWD_COMMON_H 10 | #define EAP_PWD_COMMON_H 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | /* 17 | * definition of a finite cyclic group 18 | * TODO: support one based on a prime field 19 | */ 20 | typedef struct group_definition_ { 21 | u16 group_num; 22 | EC_GROUP *group; 23 | EC_POINT *pwe; 24 | BIGNUM *order; 25 | BIGNUM *prime; 26 | } EAP_PWD_group; 27 | 28 | /* 29 | * EAP-pwd header, included on all payloads 30 | * L(1 bit) | M(1 bit) | exch(6 bits) | total_length(if L is set) 31 | */ 32 | #define EAP_PWD_HDR_SIZE 1 33 | 34 | #define EAP_PWD_OPCODE_ID_EXCH 1 35 | #define EAP_PWD_OPCODE_COMMIT_EXCH 2 36 | #define EAP_PWD_OPCODE_CONFIRM_EXCH 3 37 | #define EAP_PWD_GET_LENGTH_BIT(x) ((x) & 0x80) 38 | #define EAP_PWD_SET_LENGTH_BIT(x) ((x) |= 0x80) 39 | #define EAP_PWD_GET_MORE_BIT(x) ((x) & 0x40) 40 | #define EAP_PWD_SET_MORE_BIT(x) ((x) |= 0x40) 41 | #define EAP_PWD_GET_EXCHANGE(x) ((x) & 0x3f) 42 | #define EAP_PWD_SET_EXCHANGE(x,y) ((x) |= (y)) 43 | 44 | /* EAP-pwd-ID payload */ 45 | struct eap_pwd_id { 46 | be16 group_num; 47 | u8 random_function; 48 | #define EAP_PWD_DEFAULT_RAND_FUNC 1 49 | u8 prf; 50 | #define EAP_PWD_DEFAULT_PRF 1 51 | u8 token[4]; 52 | u8 prep; 53 | #define EAP_PWD_PREP_NONE 0 54 | #define EAP_PWD_PREP_MS 1 55 | u8 identity[0]; /* length inferred from payload */ 56 | } STRUCT_PACKED; 57 | 58 | /* common routines */ 59 | int compute_password_element(EAP_PWD_group *, u16, u8 *, int, u8 *, int, u8 *, 60 | int, u8 *); 61 | int compute_keys(EAP_PWD_group *, BN_CTX *, BIGNUM *, BIGNUM *, BIGNUM *, 62 | u8 *, u8 *, u32 *, u8 *, u8 *); 63 | struct crypto_hash * eap_pwd_h_init(void); 64 | void eap_pwd_h_update(struct crypto_hash *hash, const u8 *data, size_t len); 65 | void eap_pwd_h_final(struct crypto_hash *hash, u8 *digest); 66 | 67 | #endif /* EAP_PWD_COMMON_H */ 68 | -------------------------------------------------------------------------------- /hostapd-2.0/src/rsn_supp/preauth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wpa_supplicant - WPA2/RSN pre-authentication functions 3 | * Copyright (c) 2003-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef PREAUTH_H 10 | #define PREAUTH_H 11 | 12 | struct wpa_scan_results; 13 | 14 | #if defined(IEEE8021X_EAPOL) && !defined(CONFIG_NO_WPA2) 15 | 16 | void pmksa_candidate_free(struct wpa_sm *sm); 17 | int rsn_preauth_init(struct wpa_sm *sm, const u8 *dst, 18 | struct eap_peer_config *eap_conf); 19 | void rsn_preauth_deinit(struct wpa_sm *sm); 20 | int rsn_preauth_scan_results(struct wpa_sm *sm); 21 | void rsn_preauth_scan_result(struct wpa_sm *sm, const u8 *bssid, 22 | const u8 *ssid, const u8 *rsn); 23 | void pmksa_candidate_add(struct wpa_sm *sm, const u8 *bssid, 24 | int prio, int preauth); 25 | void rsn_preauth_candidate_process(struct wpa_sm *sm); 26 | int rsn_preauth_get_status(struct wpa_sm *sm, char *buf, size_t buflen, 27 | int verbose); 28 | int rsn_preauth_in_progress(struct wpa_sm *sm); 29 | 30 | #else /* IEEE8021X_EAPOL and !CONFIG_NO_WPA2 */ 31 | 32 | static inline void pmksa_candidate_free(struct wpa_sm *sm) 33 | { 34 | } 35 | 36 | static inline void rsn_preauth_candidate_process(struct wpa_sm *sm) 37 | { 38 | } 39 | 40 | static inline int rsn_preauth_init(struct wpa_sm *sm, const u8 *dst, 41 | struct eap_peer_config *eap_conf) 42 | { 43 | return -1; 44 | } 45 | 46 | static inline void rsn_preauth_deinit(struct wpa_sm *sm) 47 | { 48 | } 49 | 50 | static inline int rsn_preauth_scan_results(struct wpa_sm *sm) 51 | { 52 | return -1; 53 | } 54 | 55 | static inline void rsn_preauth_scan_result(struct wpa_sm *sm, const u8 *bssid, 56 | const u8 *ssid, const u8 *rsn) 57 | { 58 | } 59 | 60 | static inline void pmksa_candidate_add(struct wpa_sm *sm, 61 | const u8 *bssid, 62 | int prio, int preauth) 63 | { 64 | } 65 | 66 | static inline int rsn_preauth_get_status(struct wpa_sm *sm, char *buf, 67 | size_t buflen, int verbose) 68 | { 69 | return 0; 70 | } 71 | 72 | static inline int rsn_preauth_in_progress(struct wpa_sm *sm) 73 | { 74 | return 0; 75 | } 76 | 77 | #endif /* IEEE8021X_EAPOL and !CONFIG_NO_WPA2 */ 78 | 79 | #endif /* PREAUTH_H */ 80 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AP mode helper functions 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "common/ieee802_11_defs.h" 13 | #include "sta_info.h" 14 | #include "hostapd.h" 15 | 16 | 17 | int hostapd_register_probereq_cb(struct hostapd_data *hapd, 18 | int (*cb)(void *ctx, const u8 *sa, 19 | const u8 *da, const u8 *bssid, 20 | const u8 *ie, size_t ie_len, 21 | int ssi_signal), 22 | void *ctx) 23 | { 24 | struct hostapd_probereq_cb *n; 25 | 26 | n = os_realloc_array(hapd->probereq_cb, hapd->num_probereq_cb + 1, 27 | sizeof(struct hostapd_probereq_cb)); 28 | if (n == NULL) 29 | return -1; 30 | 31 | hapd->probereq_cb = n; 32 | n = &hapd->probereq_cb[hapd->num_probereq_cb]; 33 | hapd->num_probereq_cb++; 34 | 35 | n->cb = cb; 36 | n->ctx = ctx; 37 | 38 | return 0; 39 | } 40 | 41 | 42 | struct prune_data { 43 | struct hostapd_data *hapd; 44 | const u8 *addr; 45 | }; 46 | 47 | static int prune_associations(struct hostapd_iface *iface, void *ctx) 48 | { 49 | struct prune_data *data = ctx; 50 | struct sta_info *osta; 51 | struct hostapd_data *ohapd; 52 | size_t j; 53 | 54 | for (j = 0; j < iface->num_bss; j++) { 55 | ohapd = iface->bss[j]; 56 | if (ohapd == data->hapd) 57 | continue; 58 | osta = ap_get_sta(ohapd, data->addr); 59 | if (!osta) 60 | continue; 61 | 62 | ap_sta_disassociate(ohapd, osta, WLAN_REASON_UNSPECIFIED); 63 | } 64 | 65 | return 0; 66 | } 67 | 68 | /** 69 | * hostapd_prune_associations - Remove extraneous associations 70 | * @hapd: Pointer to BSS data for the most recent association 71 | * @addr: Associated STA address 72 | * 73 | * This function looks through all radios and BSS's for previous 74 | * (stale) associations of STA. If any are found they are removed. 75 | */ 76 | void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr) 77 | { 78 | struct prune_data data; 79 | data.hapd = hapd; 80 | data.addr = addr; 81 | if (hapd->iface->interfaces && 82 | hapd->iface->interfaces->for_each_interface) 83 | hapd->iface->interfaces->for_each_interface( 84 | hapd->iface->interfaces, prune_associations, &data); 85 | } 86 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/build_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wpa_supplicant/hostapd - Build time configuration defines 3 | * Copyright (c) 2005-2006, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | * 8 | * This header file can be used to define configuration defines that were 9 | * originally defined in Makefile. This is mainly meant for IDE use or for 10 | * systems that do not have suitable 'make' tool. In these cases, it may be 11 | * easier to have a single place for defining all the needed C pre-processor 12 | * defines. 13 | */ 14 | 15 | #ifndef BUILD_CONFIG_H 16 | #define BUILD_CONFIG_H 17 | 18 | /* Insert configuration defines, e.g., #define EAP_MD5, here, if needed. */ 19 | 20 | #ifdef CONFIG_WIN32_DEFAULTS 21 | #define CONFIG_NATIVE_WINDOWS 22 | #define CONFIG_ANSI_C_EXTRA 23 | #define CONFIG_WINPCAP 24 | #define IEEE8021X_EAPOL 25 | #define PKCS12_FUNCS 26 | #define PCSC_FUNCS 27 | #define CONFIG_CTRL_IFACE 28 | #define CONFIG_CTRL_IFACE_NAMED_PIPE 29 | #define CONFIG_DRIVER_NDIS 30 | #define CONFIG_NDIS_EVENTS_INTEGRATED 31 | #define CONFIG_DEBUG_FILE 32 | #define EAP_MD5 33 | #define EAP_TLS 34 | #define EAP_MSCHAPv2 35 | #define EAP_PEAP 36 | #define EAP_TTLS 37 | #define EAP_GTC 38 | #define EAP_OTP 39 | #define EAP_LEAP 40 | #define EAP_TNC 41 | #define _CRT_SECURE_NO_DEPRECATE 42 | 43 | #ifdef USE_INTERNAL_CRYPTO 44 | #define CONFIG_TLS_INTERNAL_CLIENT 45 | #define CONFIG_INTERNAL_LIBTOMMATH 46 | #define CONFIG_CRYPTO_INTERNAL 47 | #endif /* USE_INTERNAL_CRYPTO */ 48 | #endif /* CONFIG_WIN32_DEFAULTS */ 49 | 50 | #ifdef CONFIG_XCODE_DEFAULTS 51 | #define CONFIG_DRIVER_OSX 52 | #define CONFIG_BACKEND_FILE 53 | #define IEEE8021X_EAPOL 54 | #define PKCS12_FUNCS 55 | #define CONFIG_CTRL_IFACE 56 | #define CONFIG_CTRL_IFACE_UNIX 57 | #define CONFIG_DEBUG_FILE 58 | #define EAP_MD5 59 | #define EAP_TLS 60 | #define EAP_MSCHAPv2 61 | #define EAP_PEAP 62 | #define EAP_TTLS 63 | #define EAP_GTC 64 | #define EAP_OTP 65 | #define EAP_LEAP 66 | #define EAP_TNC 67 | #define CONFIG_WPS 68 | #define EAP_WSC 69 | 70 | #ifdef USE_INTERNAL_CRYPTO 71 | #define CONFIG_TLS_INTERNAL_CLIENT 72 | #define CONFIG_INTERNAL_LIBTOMMATH 73 | #define CONFIG_CRYPTO_INTERNAL 74 | #endif /* USE_INTERNAL_CRYPTO */ 75 | #endif /* CONFIG_XCODE_DEFAULTS */ 76 | 77 | #endif /* BUILD_CONFIG_H */ 78 | -------------------------------------------------------------------------------- /hostapd-2.0/src/tls/tlsv1_client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TLS v1.0/v1.1/v1.2 client (RFC 2246, RFC 4346, RFC 5246) 3 | * Copyright (c) 2006-2011, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef TLSV1_CLIENT_H 10 | #define TLSV1_CLIENT_H 11 | 12 | #include "tlsv1_cred.h" 13 | 14 | struct tlsv1_client; 15 | 16 | int tlsv1_client_global_init(void); 17 | void tlsv1_client_global_deinit(void); 18 | struct tlsv1_client * tlsv1_client_init(void); 19 | void tlsv1_client_deinit(struct tlsv1_client *conn); 20 | int tlsv1_client_established(struct tlsv1_client *conn); 21 | int tlsv1_client_prf(struct tlsv1_client *conn, const char *label, 22 | int server_random_first, u8 *out, size_t out_len); 23 | u8 * tlsv1_client_handshake(struct tlsv1_client *conn, 24 | const u8 *in_data, size_t in_len, 25 | size_t *out_len, u8 **appl_data, 26 | size_t *appl_data_len, int *need_more_data); 27 | int tlsv1_client_encrypt(struct tlsv1_client *conn, 28 | const u8 *in_data, size_t in_len, 29 | u8 *out_data, size_t out_len); 30 | struct wpabuf * tlsv1_client_decrypt(struct tlsv1_client *conn, 31 | const u8 *in_data, size_t in_len, 32 | int *need_more_data); 33 | int tlsv1_client_get_cipher(struct tlsv1_client *conn, char *buf, 34 | size_t buflen); 35 | int tlsv1_client_shutdown(struct tlsv1_client *conn); 36 | int tlsv1_client_resumed(struct tlsv1_client *conn); 37 | int tlsv1_client_hello_ext(struct tlsv1_client *conn, int ext_type, 38 | const u8 *data, size_t data_len); 39 | int tlsv1_client_get_keys(struct tlsv1_client *conn, struct tls_keys *keys); 40 | int tlsv1_client_get_keyblock_size(struct tlsv1_client *conn); 41 | int tlsv1_client_set_cipher_list(struct tlsv1_client *conn, u8 *ciphers); 42 | int tlsv1_client_set_cred(struct tlsv1_client *conn, 43 | struct tlsv1_credentials *cred); 44 | void tlsv1_client_set_time_checks(struct tlsv1_client *conn, int enabled); 45 | 46 | typedef int (*tlsv1_client_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_client_set_session_ticket_cb(struct tlsv1_client *conn, 51 | tlsv1_client_session_ticket_cb cb, 52 | void *ctx); 53 | 54 | #endif /* TLSV1_CLIENT_H */ 55 | -------------------------------------------------------------------------------- /hostapd-2.0/src/tls/asn1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ASN.1 DER parsing 3 | * Copyright (c) 2006, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef ASN1_H 10 | #define ASN1_H 11 | 12 | #define ASN1_TAG_EOC 0x00 /* not used with DER */ 13 | #define ASN1_TAG_BOOLEAN 0x01 14 | #define ASN1_TAG_INTEGER 0x02 15 | #define ASN1_TAG_BITSTRING 0x03 16 | #define ASN1_TAG_OCTETSTRING 0x04 17 | #define ASN1_TAG_NULL 0x05 18 | #define ASN1_TAG_OID 0x06 19 | #define ASN1_TAG_OBJECT_DESCRIPTOR 0x07 /* not yet parsed */ 20 | #define ASN1_TAG_EXTERNAL 0x08 /* not yet parsed */ 21 | #define ASN1_TAG_REAL 0x09 /* not yet parsed */ 22 | #define ASN1_TAG_ENUMERATED 0x0A /* not yet parsed */ 23 | #define ASN1_TAG_UTF8STRING 0x0C /* not yet parsed */ 24 | #define ANS1_TAG_RELATIVE_OID 0x0D 25 | #define ASN1_TAG_SEQUENCE 0x10 /* shall be constructed */ 26 | #define ASN1_TAG_SET 0x11 27 | #define ASN1_TAG_NUMERICSTRING 0x12 /* not yet parsed */ 28 | #define ASN1_TAG_PRINTABLESTRING 0x13 29 | #define ASN1_TAG_TG1STRING 0x14 /* not yet parsed */ 30 | #define ASN1_TAG_VIDEOTEXSTRING 0x15 /* not yet parsed */ 31 | #define ASN1_TAG_IA5STRING 0x16 32 | #define ASN1_TAG_UTCTIME 0x17 33 | #define ASN1_TAG_GENERALIZEDTIME 0x18 /* not yet parsed */ 34 | #define ASN1_TAG_GRAPHICSTRING 0x19 /* not yet parsed */ 35 | #define ASN1_TAG_VISIBLESTRING 0x1A 36 | #define ASN1_TAG_GENERALSTRING 0x1B /* not yet parsed */ 37 | #define ASN1_TAG_UNIVERSALSTRING 0x1C /* not yet parsed */ 38 | #define ASN1_TAG_BMPSTRING 0x1D /* not yet parsed */ 39 | 40 | #define ASN1_CLASS_UNIVERSAL 0 41 | #define ASN1_CLASS_APPLICATION 1 42 | #define ASN1_CLASS_CONTEXT_SPECIFIC 2 43 | #define ASN1_CLASS_PRIVATE 3 44 | 45 | 46 | struct asn1_hdr { 47 | const u8 *payload; 48 | u8 identifier, class, constructed; 49 | unsigned int tag, length; 50 | }; 51 | 52 | #define ASN1_MAX_OID_LEN 20 53 | struct asn1_oid { 54 | unsigned long oid[ASN1_MAX_OID_LEN]; 55 | size_t len; 56 | }; 57 | 58 | 59 | int asn1_get_next(const u8 *buf, size_t len, struct asn1_hdr *hdr); 60 | int asn1_parse_oid(const u8 *buf, size_t len, struct asn1_oid *oid); 61 | int asn1_get_oid(const u8 *buf, size_t len, struct asn1_oid *oid, 62 | const u8 **next); 63 | void asn1_oid_to_str(struct asn1_oid *oid, char *buf, size_t len); 64 | unsigned long asn1_bit_string_to_long(const u8 *buf, size_t len); 65 | 66 | #endif /* ASN1_H */ 67 | -------------------------------------------------------------------------------- /hostapd-2.0/src/drivers/android_drv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Android driver interface 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License version 2 as 6 | * published by the Free Software Foundation. 7 | * 8 | * Alternatively, this software may be distributed under the terms of BSD 9 | * license. 10 | */ 11 | 12 | #ifndef ANDROID_DRV_H 13 | #define ANDROID_DRV_H 14 | 15 | #define WPA_EVENT_DRIVER_STATE "CTRL-EVENT-DRIVER-STATE " 16 | 17 | #define MAX_SSID_LEN 32 18 | 19 | #define MAX_DRV_CMD_SIZE 248 20 | #define DRV_NUMBER_SEQUENTIAL_ERRORS 4 21 | 22 | #define WEXT_PNOSETUP_HEADER "PNOSETUP " 23 | #define WEXT_PNOSETUP_HEADER_SIZE 9 24 | #define WEXT_PNO_TLV_PREFIX 'S' 25 | #define WEXT_PNO_TLV_VERSION '1' 26 | #define WEXT_PNO_TLV_SUBVERSION '2' 27 | #define WEXT_PNO_TLV_RESERVED '0' 28 | #define WEXT_PNO_VERSION_SIZE 4 29 | #define WEXT_PNO_AMOUNT 16 30 | #define WEXT_PNO_SSID_SECTION 'S' 31 | /* SSID header size is SSID section type above + SSID length */ 32 | #define WEXT_PNO_SSID_HEADER_SIZE 2 33 | #define WEXT_PNO_SCAN_INTERVAL_SECTION 'T' 34 | #define WEXT_PNO_SCAN_INTERVAL_LENGTH 2 35 | #define WEXT_PNO_SCAN_INTERVAL 30 36 | /* Scan interval size is scan interval section type + scan interval length 37 | * above */ 38 | #define WEXT_PNO_SCAN_INTERVAL_SIZE (1 + WEXT_PNO_SCAN_INTERVAL_LENGTH) 39 | #define WEXT_PNO_REPEAT_SECTION 'R' 40 | #define WEXT_PNO_REPEAT_LENGTH 1 41 | #define WEXT_PNO_REPEAT 4 42 | /* Repeat section size is Repeat section type + Repeat value length above */ 43 | #define WEXT_PNO_REPEAT_SIZE (1 + WEXT_PNO_REPEAT_LENGTH) 44 | #define WEXT_PNO_MAX_REPEAT_SECTION 'M' 45 | #define WEXT_PNO_MAX_REPEAT_LENGTH 1 46 | #define WEXT_PNO_MAX_REPEAT 3 47 | /* Max Repeat section size is Max Repeat section type + Max Repeat value length 48 | * above */ 49 | #define WEXT_PNO_MAX_REPEAT_SIZE (1 + WEXT_PNO_MAX_REPEAT_LENGTH) 50 | /* This corresponds to the size of all sections expect SSIDs */ 51 | #define WEXT_PNO_NONSSID_SECTIONS_SIZE \ 52 | (WEXT_PNO_SCAN_INTERVAL_SIZE + WEXT_PNO_REPEAT_SIZE + WEXT_PNO_MAX_REPEAT_SIZE) 53 | /* PNO Max command size is total of header, version, ssid and other sections + 54 | * Null termination */ 55 | #define WEXT_PNO_MAX_COMMAND_SIZE \ 56 | (WEXT_PNOSETUP_HEADER_SIZE + WEXT_PNO_VERSION_SIZE \ 57 | + WEXT_PNO_AMOUNT * (WEXT_PNO_SSID_HEADER_SIZE + MAX_SSID_LEN) \ 58 | + WEXT_PNO_NONSSID_SECTIONS_SIZE + 1) 59 | 60 | #endif /* ANDROID_DRV_H */ 61 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/ap_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / AP table 3 | * Copyright (c) 2002-2003, Jouni Malinen 4 | * Copyright (c) 2003-2004, Instant802 Networks, Inc. 5 | * Copyright (c) 2006, Devicescape Software, Inc. 6 | * 7 | * This software may be distributed under the terms of the BSD license. 8 | * See README for more details. 9 | */ 10 | 11 | #ifndef AP_LIST_H 12 | #define AP_LIST_H 13 | 14 | struct ap_info { 15 | /* Note: next/prev pointers are updated whenever a new beacon is 16 | * received because these are used to find the least recently used 17 | * entries. iter_next/iter_prev are updated only when adding new BSSes 18 | * and when removing old ones. These should be used when iterating 19 | * through the table in a manner that allows beacons to be received 20 | * during the iteration. */ 21 | struct ap_info *next; /* next entry in AP list */ 22 | struct ap_info *prev; /* previous entry in AP list */ 23 | struct ap_info *hnext; /* next entry in hash table list */ 24 | struct ap_info *iter_next; /* next entry in AP iteration list */ 25 | struct ap_info *iter_prev; /* previous entry in AP iteration list */ 26 | u8 addr[6]; 27 | u16 beacon_int; 28 | u16 capability; 29 | u8 supported_rates[WLAN_SUPP_RATES_MAX]; 30 | u8 ssid[33]; 31 | size_t ssid_len; 32 | int wpa; 33 | int erp; /* ERP Info or -1 if ERP info element not present */ 34 | 35 | int channel; 36 | int datarate; /* in 100 kbps */ 37 | 38 | int ht_support; 39 | 40 | unsigned int num_beacons; /* number of beacon frames received */ 41 | os_time_t last_beacon; 42 | 43 | int already_seen; /* whether API call AP-NEW has already fetched 44 | * information about this AP */ 45 | }; 46 | 47 | struct ieee802_11_elems; 48 | struct hostapd_frame_info; 49 | 50 | struct ap_info * ap_get_ap(struct hostapd_iface *iface, const u8 *sta); 51 | int ap_ap_for_each(struct hostapd_iface *iface, 52 | int (*func)(struct ap_info *s, void *data), void *data); 53 | void ap_list_process_beacon(struct hostapd_iface *iface, 54 | const struct ieee80211_mgmt *mgmt, 55 | struct ieee802_11_elems *elems, 56 | struct hostapd_frame_info *fi); 57 | #ifdef NEED_AP_MLME 58 | int ap_list_init(struct hostapd_iface *iface); 59 | void ap_list_deinit(struct hostapd_iface *iface); 60 | #else /* NEED_AP_MLME */ 61 | static inline int ap_list_init(struct hostapd_iface *iface) 62 | { 63 | return 0; 64 | } 65 | 66 | static inline void ap_list_deinit(struct hostapd_iface *iface) 67 | { 68 | } 69 | #endif /* NEED_AP_MLME */ 70 | 71 | #endif /* AP_LIST_H */ 72 | -------------------------------------------------------------------------------- /hostapd-2.0/src/rsn_supp/peerkey.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant - PeerKey for Direct Link Setup (DLS) 3 | * Copyright (c) 2006-2008, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef PEERKEY_H 10 | #define PEERKEY_H 11 | 12 | #define PEERKEY_MAX_IE_LEN 80 13 | struct wpa_peerkey { 14 | struct wpa_peerkey *next; 15 | int initiator; /* whether this end was initator for SMK handshake */ 16 | u8 addr[ETH_ALEN]; /* other end MAC address */ 17 | u8 inonce[WPA_NONCE_LEN]; /* Initiator Nonce */ 18 | u8 pnonce[WPA_NONCE_LEN]; /* Peer Nonce */ 19 | u8 rsnie_i[PEERKEY_MAX_IE_LEN]; /* Initiator RSN IE */ 20 | size_t rsnie_i_len; 21 | u8 rsnie_p[PEERKEY_MAX_IE_LEN]; /* Peer RSN IE */ 22 | size_t rsnie_p_len; 23 | u8 smk[PMK_LEN]; 24 | int smk_complete; 25 | u8 smkid[PMKID_LEN]; 26 | u32 lifetime; 27 | os_time_t expiration; 28 | int cipher; /* Selected cipher (WPA_CIPHER_*) */ 29 | u8 replay_counter[WPA_REPLAY_COUNTER_LEN]; 30 | int replay_counter_set; 31 | int use_sha256; /* whether AKMP indicate SHA256-based derivations */ 32 | 33 | struct wpa_ptk stk, tstk; 34 | int stk_set, tstk_set; 35 | }; 36 | 37 | 38 | #ifdef CONFIG_PEERKEY 39 | 40 | int peerkey_verify_eapol_key_mic(struct wpa_sm *sm, 41 | struct wpa_peerkey *peerkey, 42 | struct wpa_eapol_key *key, u16 ver, 43 | const u8 *buf, size_t len); 44 | void peerkey_rx_eapol_4way(struct wpa_sm *sm, struct wpa_peerkey *peerkey, 45 | struct wpa_eapol_key *key, u16 key_info, u16 ver); 46 | void peerkey_rx_eapol_smk(struct wpa_sm *sm, const u8 *src_addr, 47 | struct wpa_eapol_key *key, size_t extra_len, 48 | u16 key_info, u16 ver); 49 | void peerkey_deinit(struct wpa_sm *sm); 50 | 51 | #else /* CONFIG_PEERKEY */ 52 | 53 | static inline int 54 | peerkey_verify_eapol_key_mic(struct wpa_sm *sm, 55 | struct wpa_peerkey *peerkey, 56 | struct wpa_eapol_key *key, u16 ver, 57 | const u8 *buf, size_t len) 58 | { 59 | return -1; 60 | } 61 | 62 | static inline void 63 | peerkey_rx_eapol_4way(struct wpa_sm *sm, struct wpa_peerkey *peerkey, 64 | struct wpa_eapol_key *key, u16 key_info, u16 ver) 65 | { 66 | } 67 | 68 | static inline void 69 | peerkey_rx_eapol_smk(struct wpa_sm *sm, const u8 *src_addr, 70 | struct wpa_eapol_key *key, size_t extra_len, 71 | u16 key_info, u16 ver) 72 | { 73 | } 74 | 75 | static inline void peerkey_deinit(struct wpa_sm *sm) 76 | { 77 | } 78 | 79 | #endif /* CONFIG_PEERKEY */ 80 | 81 | #endif /* PEERKEY_H */ 82 | -------------------------------------------------------------------------------- /hostapd-2.0/README: -------------------------------------------------------------------------------- 1 | wpa_supplicant and hostapd 2 | -------------------------- 3 | 4 | Copyright (c) 2002-2012, Jouni Malinen and contributors 5 | All Rights Reserved. 6 | 7 | These programs are licensed under the BSD license (the one with 8 | advertisement clause removed). 9 | 10 | If you are submitting changes to the project, please see CONTRIBUTIONS 11 | file for more instructions. 12 | 13 | 14 | This package may include either wpa_supplicant, hostapd, or both. See 15 | README file respective subdirectories (wpa_supplicant/README or 16 | hostapd/README) for more details. 17 | 18 | Source code files were moved around in v0.6.x releases and compared to 19 | earlier releases, the programs are now built by first going to a 20 | subdirectory (wpa_supplicant or hostapd) and creating build 21 | configuration (.config) and running 'make' there (for Linux/BSD/cygwin 22 | builds). 23 | 24 | 25 | License 26 | ------- 27 | 28 | This software may be distributed, used, and modified under the terms of 29 | BSD license: 30 | 31 | Redistribution and use in source and binary forms, with or without 32 | modification, are permitted provided that the following conditions are 33 | met: 34 | 35 | 1. Redistributions of source code must retain the above copyright 36 | notice, this list of conditions and the following disclaimer. 37 | 38 | 2. Redistributions in binary form must reproduce the above copyright 39 | notice, this list of conditions and the following disclaimer in the 40 | documentation and/or other materials provided with the distribution. 41 | 42 | 3. Neither the name(s) of the above-listed copyright holder(s) nor the 43 | names of its contributors may be used to endorse or promote products 44 | derived from this software without specific prior written permission. 45 | 46 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 47 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 48 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 49 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 50 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 51 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 52 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 53 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 54 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 55 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 56 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 57 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/ms_funcs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * WPA Supplicant / shared MSCHAPV2 helper functions / RFC 2433 / RFC 2759 3 | * Copyright (c) 2004-2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef MS_FUNCS_H 10 | #define MS_FUNCS_H 11 | 12 | int generate_nt_response(const u8 *auth_challenge, const u8 *peer_challenge, 13 | const u8 *username, size_t username_len, 14 | const u8 *password, size_t password_len, 15 | u8 *response); 16 | int generate_nt_response_pwhash(const u8 *auth_challenge, 17 | const u8 *peer_challenge, 18 | const u8 *username, size_t username_len, 19 | const u8 *password_hash, 20 | u8 *response); 21 | int generate_authenticator_response(const u8 *password, size_t password_len, 22 | const u8 *peer_challenge, 23 | const u8 *auth_challenge, 24 | const u8 *username, size_t username_len, 25 | const u8 *nt_response, u8 *response); 26 | int generate_authenticator_response_pwhash( 27 | const u8 *password_hash, 28 | const u8 *peer_challenge, const u8 *auth_challenge, 29 | const u8 *username, size_t username_len, 30 | const u8 *nt_response, u8 *response); 31 | int nt_challenge_response(const u8 *challenge, const u8 *password, 32 | size_t password_len, u8 *response); 33 | 34 | void challenge_response(const u8 *challenge, const u8 *password_hash, 35 | u8 *response); 36 | int nt_password_hash(const u8 *password, size_t password_len, 37 | u8 *password_hash); 38 | int hash_nt_password_hash(const u8 *password_hash, u8 *password_hash_hash); 39 | int get_master_key(const u8 *password_hash_hash, const u8 *nt_response, 40 | u8 *master_key); 41 | int get_asymetric_start_key(const u8 *master_key, u8 *session_key, 42 | size_t session_key_len, int is_send, 43 | int is_server); 44 | int __must_check encrypt_pw_block_with_password_hash( 45 | const u8 *password, size_t password_len, 46 | const u8 *password_hash, u8 *pw_block); 47 | int __must_check new_password_encrypted_with_old_nt_password_hash( 48 | const u8 *new_password, size_t new_password_len, 49 | const u8 *old_password, size_t old_password_len, 50 | u8 *encrypted_pw_block); 51 | void nt_password_hash_encrypted_with_block(const u8 *password_hash, 52 | const u8 *block, u8 *cypher); 53 | int old_nt_password_hash_encrypted_with_new_nt_password_hash( 54 | const u8 *new_password, size_t new_password_len, 55 | const u8 *old_password, size_t old_password_len, 56 | u8 *encrypted_password_hash); 57 | 58 | #endif /* MS_FUNCS_H */ 59 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/gas_serv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Generic advertisement service (GAS) server 3 | * Copyright (c) 2011-2012, Qualcomm Atheros, Inc. 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef GAS_SERV_H 10 | #define GAS_SERV_H 11 | 12 | #define ANQP_REQ_CAPABILITY_LIST \ 13 | (1 << (ANQP_CAPABILITY_LIST - ANQP_QUERY_LIST)) 14 | #define ANQP_REQ_VENUE_NAME \ 15 | (1 << (ANQP_VENUE_NAME - ANQP_QUERY_LIST)) 16 | #define ANQP_REQ_NETWORK_AUTH_TYPE \ 17 | (1 << (ANQP_NETWORK_AUTH_TYPE - ANQP_QUERY_LIST)) 18 | #define ANQP_REQ_ROAMING_CONSORTIUM \ 19 | (1 << (ANQP_ROAMING_CONSORTIUM - ANQP_QUERY_LIST)) 20 | #define ANQP_REQ_IP_ADDR_TYPE_AVAILABILITY \ 21 | (1 << (ANQP_IP_ADDR_TYPE_AVAILABILITY - ANQP_QUERY_LIST)) 22 | #define ANQP_REQ_NAI_REALM \ 23 | (1 << (ANQP_NAI_REALM - ANQP_QUERY_LIST)) 24 | #define ANQP_REQ_3GPP_CELLULAR_NETWORK \ 25 | (1 << (ANQP_3GPP_CELLULAR_NETWORK - ANQP_QUERY_LIST)) 26 | #define ANQP_REQ_DOMAIN_NAME \ 27 | (1 << (ANQP_DOMAIN_NAME - ANQP_QUERY_LIST)) 28 | #define ANQP_REQ_HS_CAPABILITY_LIST \ 29 | (0x10000 << HS20_STYPE_CAPABILITY_LIST) 30 | #define ANQP_REQ_OPERATOR_FRIENDLY_NAME \ 31 | (0x10000 << HS20_STYPE_OPERATOR_FRIENDLY_NAME) 32 | #define ANQP_REQ_WAN_METRICS \ 33 | (0x10000 << HS20_STYPE_WAN_METRICS) 34 | #define ANQP_REQ_CONNECTION_CAPABILITY \ 35 | (0x10000 << HS20_STYPE_CONNECTION_CAPABILITY) 36 | #define ANQP_REQ_NAI_HOME_REALM \ 37 | (0x10000 << HS20_STYPE_NAI_HOME_REALM_QUERY) 38 | #define ANQP_REQ_OPERATING_CLASS \ 39 | (0x10000 << HS20_STYPE_OPERATING_CLASS) 40 | 41 | /* To account for latencies between hostapd and external ANQP processor */ 42 | #define GAS_SERV_COMEBACK_DELAY_FUDGE 10 43 | #define GAS_SERV_MIN_COMEBACK_DELAY 100 /* in TU */ 44 | 45 | struct gas_dialog_info { 46 | u8 valid; 47 | u8 index; 48 | struct wpabuf *sd_resp; /* Fragmented response */ 49 | u8 dialog_token; 50 | size_t sd_resp_pos; /* Offset in sd_resp */ 51 | u8 sd_frag_id; 52 | u16 comeback_delay; 53 | 54 | unsigned int requested; 55 | unsigned int received; 56 | unsigned int all_requested; 57 | }; 58 | 59 | struct hostapd_data; 60 | 61 | void gas_serv_tx_gas_response(struct hostapd_data *hapd, const u8 *dst, 62 | struct gas_dialog_info *dialog); 63 | struct gas_dialog_info * 64 | gas_serv_dialog_find(struct hostapd_data *hapd, const u8 *addr, 65 | u8 dialog_token); 66 | void gas_serv_dialog_clear(struct gas_dialog_info *dialog); 67 | 68 | int gas_serv_init(struct hostapd_data *hapd); 69 | void gas_serv_deinit(struct hostapd_data *hapd); 70 | 71 | #endif /* GAS_SERV_H */ 72 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_common/eap_pax_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP server/peer: EAP-PAX shared routines 3 | * Copyright (c) 2005-2007, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EAP_PAX_COMMON_H 10 | #define EAP_PAX_COMMON_H 11 | 12 | #ifdef _MSC_VER 13 | #pragma pack(push, 1) 14 | #endif /* _MSC_VER */ 15 | 16 | struct eap_pax_hdr { 17 | u8 op_code; 18 | u8 flags; 19 | u8 mac_id; 20 | u8 dh_group_id; 21 | u8 public_key_id; 22 | /* Followed by variable length payload and ICV */ 23 | } STRUCT_PACKED; 24 | 25 | #ifdef _MSC_VER 26 | #pragma pack(pop) 27 | #endif /* _MSC_VER */ 28 | 29 | 30 | /* op_code: */ 31 | enum { 32 | EAP_PAX_OP_STD_1 = 0x01, 33 | EAP_PAX_OP_STD_2 = 0x02, 34 | EAP_PAX_OP_STD_3 = 0x03, 35 | EAP_PAX_OP_SEC_1 = 0x11, 36 | EAP_PAX_OP_SEC_2 = 0x12, 37 | EAP_PAX_OP_SEC_3 = 0x13, 38 | EAP_PAX_OP_SEC_4 = 0x14, 39 | EAP_PAX_OP_SEC_5 = 0x15, 40 | EAP_PAX_OP_ACK = 0x21 41 | }; 42 | 43 | /* flags: */ 44 | #define EAP_PAX_FLAGS_MF 0x01 45 | #define EAP_PAX_FLAGS_CE 0x02 46 | #define EAP_PAX_FLAGS_AI 0x04 47 | 48 | /* mac_id: */ 49 | #define EAP_PAX_MAC_HMAC_SHA1_128 0x01 50 | #define EAP_PAX_HMAC_SHA256_128 0x02 51 | 52 | /* dh_group_id: */ 53 | #define EAP_PAX_DH_GROUP_NONE 0x00 54 | #define EAP_PAX_DH_GROUP_2048_MODP 0x01 55 | #define EAP_PAX_DH_GROUP_3072_MODP 0x02 56 | #define EAP_PAX_DH_GROUP_NIST_ECC_P_256 0x03 57 | 58 | /* public_key_id: */ 59 | #define EAP_PAX_PUBLIC_KEY_NONE 0x00 60 | #define EAP_PAX_PUBLIC_KEY_RSAES_OAEP 0x01 61 | #define EAP_PAX_PUBLIC_KEY_RSA_PKCS1_V1_5 0x02 62 | #define EAP_PAX_PUBLIC_KEY_EL_GAMAL_NIST_ECC 0x03 63 | 64 | /* ADE type: */ 65 | #define EAP_PAX_ADE_VENDOR_SPECIFIC 0x01 66 | #define EAP_PAX_ADE_CLIENT_CHANNEL_BINDING 0x02 67 | #define EAP_PAX_ADE_SERVER_CHANNEL_BINDING 0x03 68 | 69 | 70 | #define EAP_PAX_RAND_LEN 32 71 | #define EAP_PAX_MAC_LEN 16 72 | #define EAP_PAX_ICV_LEN 16 73 | #define EAP_PAX_AK_LEN 16 74 | #define EAP_PAX_MK_LEN 16 75 | #define EAP_PAX_CK_LEN 16 76 | #define EAP_PAX_ICK_LEN 16 77 | 78 | 79 | int eap_pax_kdf(u8 mac_id, const u8 *key, size_t key_len, 80 | const char *identifier, 81 | const u8 *entropy, size_t entropy_len, 82 | size_t output_len, u8 *output); 83 | int eap_pax_mac(u8 mac_id, const u8 *key, size_t key_len, 84 | const u8 *data1, size_t data1_len, 85 | const u8 *data2, size_t data2_len, 86 | const u8 *data3, size_t data3_len, 87 | u8 *mac); 88 | int eap_pax_initial_key_derivation(u8 mac_id, const u8 *ak, const u8 *e, 89 | u8 *mk, u8 *ck, u8 *ick); 90 | 91 | #endif /* EAP_PAX_COMMON_H */ 92 | -------------------------------------------------------------------------------- /hostapd-2.0/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 software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef EAPOL_COMMON_H 10 | #define EAPOL_COMMON_H 11 | 12 | /* IEEE Std 802.1X-2004 */ 13 | 14 | #ifdef _MSC_VER 15 | #pragma pack(push, 1) 16 | #endif /* _MSC_VER */ 17 | 18 | struct ieee802_1x_hdr { 19 | u8 version; 20 | u8 type; 21 | be16 length; 22 | /* followed by length octets of data */ 23 | } STRUCT_PACKED; 24 | 25 | #ifdef _MSC_VER 26 | #pragma pack(pop) 27 | #endif /* _MSC_VER */ 28 | 29 | #define EAPOL_VERSION 2 30 | 31 | enum { IEEE802_1X_TYPE_EAP_PACKET = 0, 32 | IEEE802_1X_TYPE_EAPOL_START = 1, 33 | IEEE802_1X_TYPE_EAPOL_LOGOFF = 2, 34 | IEEE802_1X_TYPE_EAPOL_KEY = 3, 35 | IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4 36 | }; 37 | 38 | enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2, 39 | EAPOL_KEY_TYPE_WPA = 254 }; 40 | 41 | 42 | #define IEEE8021X_REPLAY_COUNTER_LEN 8 43 | #define IEEE8021X_KEY_SIGN_LEN 16 44 | #define IEEE8021X_KEY_IV_LEN 16 45 | 46 | #define IEEE8021X_KEY_INDEX_FLAG 0x80 47 | #define IEEE8021X_KEY_INDEX_MASK 0x03 48 | 49 | #ifdef _MSC_VER 50 | #pragma pack(push, 1) 51 | #endif /* _MSC_VER */ 52 | 53 | struct ieee802_1x_eapol_key { 54 | u8 type; 55 | /* Note: key_length is unaligned */ 56 | u8 key_length[2]; 57 | /* does not repeat within the life of the keying material used to 58 | * encrypt the Key field; 64-bit NTP timestamp MAY be used here */ 59 | u8 replay_counter[IEEE8021X_REPLAY_COUNTER_LEN]; 60 | u8 key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */ 61 | u8 key_index; /* key flag in the most significant bit: 62 | * 0 = broadcast (default key), 63 | * 1 = unicast (key mapping key); key index is in the 64 | * 7 least significant bits */ 65 | /* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as 66 | * the key */ 67 | u8 key_signature[IEEE8021X_KEY_SIGN_LEN]; 68 | 69 | /* followed by key: if packet body length = 44 + key length, then the 70 | * key field (of key_length bytes) contains the key in encrypted form; 71 | * if packet body length = 44, key field is absent and key_length 72 | * represents the number of least significant octets from 73 | * MS-MPPE-Send-Key attribute to be used as the keying material; 74 | * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */ 75 | } STRUCT_PACKED; 76 | 77 | #ifdef _MSC_VER 78 | #pragma pack(pop) 79 | #endif /* _MSC_VER */ 80 | 81 | #endif /* EAPOL_COMMON_H */ 82 | -------------------------------------------------------------------------------- /hostapd-2.0/src/ap/ieee802_1x.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hostapd / IEEE 802.1X-2004 Authenticator 3 | * Copyright (c) 2002-2012, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef IEEE802_1X_H 10 | #define IEEE802_1X_H 11 | 12 | struct hostapd_data; 13 | struct sta_info; 14 | struct eapol_state_machine; 15 | struct hostapd_config; 16 | struct hostapd_bss_config; 17 | struct hostapd_radius_attr; 18 | struct radius_msg; 19 | 20 | 21 | void ieee802_1x_receive(struct hostapd_data *hapd, const u8 *sa, const u8 *buf, 22 | size_t len); 23 | void ieee802_1x_new_station(struct hostapd_data *hapd, struct sta_info *sta); 24 | void ieee802_1x_free_station(struct sta_info *sta); 25 | 26 | void ieee802_1x_tx_key(struct hostapd_data *hapd, struct sta_info *sta); 27 | void ieee802_1x_abort_auth(struct hostapd_data *hapd, struct sta_info *sta); 28 | void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd, 29 | struct sta_info *sta, int authorized); 30 | void ieee802_1x_dump_state(FILE *f, const char *prefix, struct sta_info *sta); 31 | int ieee802_1x_init(struct hostapd_data *hapd); 32 | void ieee802_1x_deinit(struct hostapd_data *hapd); 33 | int ieee802_1x_tx_status(struct hostapd_data *hapd, struct sta_info *sta, 34 | const u8 *buf, size_t len, int ack); 35 | int ieee802_1x_eapol_tx_status(struct hostapd_data *hapd, struct sta_info *sta, 36 | const u8 *data, int len, int ack); 37 | u8 * ieee802_1x_get_identity(struct eapol_state_machine *sm, size_t *len); 38 | u8 * ieee802_1x_get_radius_class(struct eapol_state_machine *sm, size_t *len, 39 | int idx); 40 | struct wpabuf * ieee802_1x_get_radius_cui(struct eapol_state_machine *sm); 41 | const u8 * ieee802_1x_get_key(struct eapol_state_machine *sm, size_t *len); 42 | void ieee802_1x_notify_port_enabled(struct eapol_state_machine *sm, 43 | int enabled); 44 | void ieee802_1x_notify_port_valid(struct eapol_state_machine *sm, 45 | int valid); 46 | void ieee802_1x_notify_pre_auth(struct eapol_state_machine *sm, int pre_auth); 47 | int ieee802_1x_get_mib(struct hostapd_data *hapd, char *buf, size_t buflen); 48 | int ieee802_1x_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta, 49 | char *buf, size_t buflen); 50 | void hostapd_get_ntp_timestamp(u8 *buf); 51 | char *eap_type_text(u8 type); 52 | 53 | const char *radius_mode_txt(struct hostapd_data *hapd); 54 | int radius_sta_rate(struct hostapd_data *hapd, struct sta_info *sta); 55 | 56 | int add_common_radius_attr(struct hostapd_data *hapd, 57 | struct hostapd_radius_attr *req_attr, 58 | struct sta_info *sta, 59 | struct radius_msg *msg); 60 | 61 | #endif /* IEEE802_1X_H */ 62 | -------------------------------------------------------------------------------- /hostapd-2.0/src/tls/tlsv1_client_i.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TLSv1 client - internal structures 3 | * Copyright (c) 2006-2011, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef TLSV1_CLIENT_I_H 10 | #define TLSV1_CLIENT_I_H 11 | 12 | struct tlsv1_client { 13 | enum { 14 | CLIENT_HELLO, SERVER_HELLO, SERVER_CERTIFICATE, 15 | SERVER_KEY_EXCHANGE, SERVER_CERTIFICATE_REQUEST, 16 | SERVER_HELLO_DONE, CLIENT_KEY_EXCHANGE, CHANGE_CIPHER_SPEC, 17 | SERVER_CHANGE_CIPHER_SPEC, SERVER_FINISHED, ACK_FINISHED, 18 | ESTABLISHED, FAILED 19 | } state; 20 | 21 | struct tlsv1_record_layer rl; 22 | 23 | u8 session_id[TLS_SESSION_ID_MAX_LEN]; 24 | size_t session_id_len; 25 | u8 client_random[TLS_RANDOM_LEN]; 26 | u8 server_random[TLS_RANDOM_LEN]; 27 | u8 master_secret[TLS_MASTER_SECRET_LEN]; 28 | 29 | u8 alert_level; 30 | u8 alert_description; 31 | 32 | unsigned int certificate_requested:1; 33 | unsigned int session_resumed:1; 34 | unsigned int session_ticket_included:1; 35 | unsigned int use_session_ticket:1; 36 | unsigned int disable_time_checks:1; 37 | 38 | struct crypto_public_key *server_rsa_key; 39 | 40 | struct tls_verify_hash verify; 41 | 42 | #define MAX_CIPHER_COUNT 30 43 | u16 cipher_suites[MAX_CIPHER_COUNT]; 44 | size_t num_cipher_suites; 45 | 46 | u16 prev_cipher_suite; 47 | 48 | u8 *client_hello_ext; 49 | size_t client_hello_ext_len; 50 | 51 | /* The prime modulus used for Diffie-Hellman */ 52 | u8 *dh_p; 53 | size_t dh_p_len; 54 | /* The generator used for Diffie-Hellman */ 55 | u8 *dh_g; 56 | size_t dh_g_len; 57 | /* The server's Diffie-Hellman public value */ 58 | u8 *dh_ys; 59 | size_t dh_ys_len; 60 | 61 | struct tlsv1_credentials *cred; 62 | 63 | tlsv1_client_session_ticket_cb session_ticket_cb; 64 | void *session_ticket_cb_ctx; 65 | 66 | struct wpabuf *partial_input; 67 | }; 68 | 69 | 70 | void tls_alert(struct tlsv1_client *conn, u8 level, u8 description); 71 | void tlsv1_client_free_dh(struct tlsv1_client *conn); 72 | int tls_derive_pre_master_secret(u8 *pre_master_secret); 73 | int tls_derive_keys(struct tlsv1_client *conn, 74 | const u8 *pre_master_secret, size_t pre_master_secret_len); 75 | u8 * tls_send_client_hello(struct tlsv1_client *conn, size_t *out_len); 76 | u8 * tlsv1_client_send_alert(struct tlsv1_client *conn, u8 level, 77 | u8 description, size_t *out_len); 78 | u8 * tlsv1_client_handshake_write(struct tlsv1_client *conn, size_t *out_len, 79 | int no_appl_data); 80 | int tlsv1_client_process_handshake(struct tlsv1_client *conn, u8 ct, 81 | const u8 *buf, size_t *len, 82 | u8 **out_data, size_t *out_len); 83 | 84 | #endif /* TLSV1_CLIENT_I_H */ 85 | -------------------------------------------------------------------------------- /hostapd-2.0/src/eap_peer/eap_otp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * EAP peer method: EAP-OTP (RFC 3748) 3 | * Copyright (c) 2004-2006, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "eap_i.h" 13 | 14 | 15 | static void * eap_otp_init(struct eap_sm *sm) 16 | { 17 | /* No need for private data. However, must return non-NULL to indicate 18 | * success. */ 19 | return (void *) 1; 20 | } 21 | 22 | 23 | static void eap_otp_deinit(struct eap_sm *sm, void *priv) 24 | { 25 | } 26 | 27 | 28 | static struct wpabuf * eap_otp_process(struct eap_sm *sm, void *priv, 29 | struct eap_method_ret *ret, 30 | const struct wpabuf *reqData) 31 | { 32 | struct wpabuf *resp; 33 | const u8 *pos, *password; 34 | size_t password_len, len; 35 | int otp; 36 | 37 | pos = eap_hdr_validate(EAP_VENDOR_IETF, EAP_TYPE_OTP, reqData, &len); 38 | if (pos == NULL) { 39 | ret->ignore = TRUE; 40 | return NULL; 41 | } 42 | wpa_hexdump_ascii(MSG_MSGDUMP, "EAP-OTP: Request message", 43 | pos, len); 44 | 45 | password = eap_get_config_otp(sm, &password_len); 46 | if (password) 47 | otp = 1; 48 | else { 49 | password = eap_get_config_password(sm, &password_len); 50 | otp = 0; 51 | } 52 | 53 | if (password == NULL) { 54 | wpa_printf(MSG_INFO, "EAP-OTP: Password not configured"); 55 | eap_sm_request_otp(sm, (const char *) pos, len); 56 | ret->ignore = TRUE; 57 | return NULL; 58 | } 59 | 60 | ret->ignore = FALSE; 61 | 62 | ret->methodState = METHOD_DONE; 63 | ret->decision = DECISION_COND_SUCC; 64 | ret->allowNotifications = FALSE; 65 | 66 | resp = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_OTP, password_len, 67 | EAP_CODE_RESPONSE, eap_get_id(reqData)); 68 | if (resp == NULL) 69 | return NULL; 70 | wpabuf_put_data(resp, password, password_len); 71 | wpa_hexdump_ascii_key(MSG_MSGDUMP, "EAP-OTP: Response", 72 | password, password_len); 73 | 74 | if (otp) { 75 | wpa_printf(MSG_DEBUG, "EAP-OTP: Forgetting used password"); 76 | eap_clear_config_otp(sm); 77 | } 78 | 79 | return resp; 80 | } 81 | 82 | 83 | int eap_peer_otp_register(void) 84 | { 85 | struct eap_method *eap; 86 | int ret; 87 | 88 | eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, 89 | EAP_VENDOR_IETF, EAP_TYPE_OTP, "OTP"); 90 | if (eap == NULL) 91 | return -1; 92 | 93 | eap->init = eap_otp_init; 94 | eap->deinit = eap_otp_deinit; 95 | eap->process = eap_otp_process; 96 | 97 | ret = eap_peer_method_register(eap); 98 | if (ret) 99 | eap_peer_method_free(eap); 100 | return ret; 101 | } 102 | -------------------------------------------------------------------------------- /hostapd-2.0/src/utils/list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Doubly-linked list 3 | * Copyright (c) 2009, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #ifndef LIST_H 10 | #define LIST_H 11 | 12 | /** 13 | * struct dl_list - Doubly-linked list 14 | */ 15 | struct dl_list { 16 | struct dl_list *next; 17 | struct dl_list *prev; 18 | }; 19 | 20 | static inline void dl_list_init(struct dl_list *list) 21 | { 22 | list->next = list; 23 | list->prev = list; 24 | } 25 | 26 | static inline void dl_list_add(struct dl_list *list, struct dl_list *item) 27 | { 28 | item->next = list->next; 29 | item->prev = list; 30 | list->next->prev = item; 31 | list->next = item; 32 | } 33 | 34 | static inline void dl_list_add_tail(struct dl_list *list, struct dl_list *item) 35 | { 36 | dl_list_add(list->prev, item); 37 | } 38 | 39 | static inline void dl_list_del(struct dl_list *item) 40 | { 41 | item->next->prev = item->prev; 42 | item->prev->next = item->next; 43 | item->next = NULL; 44 | item->prev = NULL; 45 | } 46 | 47 | static inline int dl_list_empty(struct dl_list *list) 48 | { 49 | return list->next == list; 50 | } 51 | 52 | static inline unsigned int dl_list_len(struct dl_list *list) 53 | { 54 | struct dl_list *item; 55 | int count = 0; 56 | for (item = list->next; item != list; item = item->next) 57 | count++; 58 | return count; 59 | } 60 | 61 | #ifndef offsetof 62 | #define offsetof(type, member) ((long) &((type *) 0)->member) 63 | #endif 64 | 65 | #define dl_list_entry(item, type, member) \ 66 | ((type *) ((char *) item - offsetof(type, member))) 67 | 68 | #define dl_list_first(list, type, member) \ 69 | (dl_list_empty((list)) ? NULL : \ 70 | dl_list_entry((list)->next, type, member)) 71 | 72 | #define dl_list_last(list, type, member) \ 73 | (dl_list_empty((list)) ? NULL : \ 74 | dl_list_entry((list)->prev, type, member)) 75 | 76 | #define dl_list_for_each(item, list, type, member) \ 77 | for (item = dl_list_entry((list)->next, type, member); \ 78 | &item->member != (list); \ 79 | item = dl_list_entry(item->member.next, type, member)) 80 | 81 | #define dl_list_for_each_safe(item, n, list, type, member) \ 82 | for (item = dl_list_entry((list)->next, type, member), \ 83 | n = dl_list_entry(item->member.next, type, member); \ 84 | &item->member != (list); \ 85 | item = n, n = dl_list_entry(n->member.next, type, member)) 86 | 87 | #define dl_list_for_each_reverse(item, list, type, member) \ 88 | for (item = dl_list_entry((list)->prev, type, member); \ 89 | &item->member != (list); \ 90 | item = dl_list_entry(item->member.prev, type, member)) 91 | 92 | #define DEFINE_DL_LIST(name) \ 93 | struct dl_list name = { &(name), &(name) } 94 | 95 | #endif /* LIST_H */ 96 | -------------------------------------------------------------------------------- /hostapd-2.0/src/crypto/sha1-pbkdf2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA1-based key derivation function (PBKDF2) for IEEE 802.11i 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This software may be distributed under the terms of the BSD license. 6 | * See README for more details. 7 | */ 8 | 9 | #include "includes.h" 10 | 11 | #include "common.h" 12 | #include "sha1.h" 13 | 14 | static int pbkdf2_sha1_f(const char *passphrase, const u8 *ssid, 15 | size_t ssid_len, int iterations, unsigned int count, 16 | u8 *digest) 17 | { 18 | unsigned char tmp[SHA1_MAC_LEN], tmp2[SHA1_MAC_LEN]; 19 | int i, j; 20 | unsigned char count_buf[4]; 21 | const u8 *addr[2]; 22 | size_t len[2]; 23 | size_t passphrase_len = os_strlen(passphrase); 24 | 25 | addr[0] = ssid; 26 | len[0] = ssid_len; 27 | addr[1] = count_buf; 28 | len[1] = 4; 29 | 30 | /* F(P, S, c, i) = U1 xor U2 xor ... Uc 31 | * U1 = PRF(P, S || i) 32 | * U2 = PRF(P, U1) 33 | * Uc = PRF(P, Uc-1) 34 | */ 35 | 36 | count_buf[0] = (count >> 24) & 0xff; 37 | count_buf[1] = (count >> 16) & 0xff; 38 | count_buf[2] = (count >> 8) & 0xff; 39 | count_buf[3] = count & 0xff; 40 | if (hmac_sha1_vector((u8 *) passphrase, passphrase_len, 2, addr, len, 41 | tmp)) 42 | return -1; 43 | os_memcpy(digest, tmp, SHA1_MAC_LEN); 44 | 45 | for (i = 1; i < iterations; i++) { 46 | if (hmac_sha1((u8 *) passphrase, passphrase_len, tmp, 47 | SHA1_MAC_LEN, tmp2)) 48 | return -1; 49 | os_memcpy(tmp, tmp2, SHA1_MAC_LEN); 50 | for (j = 0; j < SHA1_MAC_LEN; j++) 51 | digest[j] ^= tmp2[j]; 52 | } 53 | 54 | return 0; 55 | } 56 | 57 | 58 | /** 59 | * pbkdf2_sha1 - SHA1-based key derivation function (PBKDF2) for IEEE 802.11i 60 | * @passphrase: ASCII passphrase 61 | * @ssid: SSID 62 | * @ssid_len: SSID length in bytes 63 | * @iterations: Number of iterations to run 64 | * @buf: Buffer for the generated key 65 | * @buflen: Length of the buffer in bytes 66 | * Returns: 0 on success, -1 of failure 67 | * 68 | * This function is used to derive PSK for WPA-PSK. For this protocol, 69 | * iterations is set to 4096 and buflen to 32. This function is described in 70 | * IEEE Std 802.11-2004, Clause H.4. The main construction is from PKCS#5 v2.0. 71 | */ 72 | int pbkdf2_sha1(const char *passphrase, const u8 *ssid, size_t ssid_len, 73 | int iterations, u8 *buf, size_t buflen) 74 | { 75 | unsigned int count = 0; 76 | unsigned char *pos = buf; 77 | size_t left = buflen, plen; 78 | unsigned char digest[SHA1_MAC_LEN]; 79 | 80 | while (left > 0) { 81 | count++; 82 | if (pbkdf2_sha1_f(passphrase, ssid, ssid_len, iterations, 83 | count, digest)) 84 | return -1; 85 | plen = left > SHA1_MAC_LEN ? SHA1_MAC_LEN : left; 86 | os_memcpy(pos, digest, plen); 87 | pos += plen; 88 | left -= plen; 89 | } 90 | 91 | return 0; 92 | } 93 | --------------------------------------------------------------------------------