From patchwork Fri Aug 28 04:38:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avichal Agarwal X-Patchwork-Id: 511751 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B03BB14016A for ; Fri, 28 Aug 2015 14:38:28 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 3DD7F9C1A1; Fri, 28 Aug 2015 00:38:24 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "MIME-Version" Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X7-F744eeX35; Fri, 28 Aug 2015 00:38:23 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 0F2889C17A; Fri, 28 Aug 2015 00:38:18 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id D18289C17A for ; Fri, 28 Aug 2015 00:38:16 -0400 (EDT) X-Quarantine-ID: X-Virus-Scanned: amavisd-new at maxx.shmoo.com X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "MIME-Version" Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U1bJsmtNJYBR for ; Fri, 28 Aug 2015 00:38:10 -0400 (EDT) Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 1D5219C179 for ; Fri, 28 Aug 2015 00:38:10 -0400 (EDT) Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NTR00ED2ZJFWI00@mailout2.samsung.com> for hostap@lists.shmoo.com; Fri, 28 Aug 2015 13:38:03 +0900 (KST) Received: from epcpsbgx3.samsung.com ( [172.20.52.125]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 0E.F5.28411.BA5EFD55; Fri, 28 Aug 2015 13:38:03 +0900 (KST) X-AuditID: cbfee68e-f79c56d000006efb-da-55dfe5ab91a1 Received: from epmailer03 ( [203.254.219.143]) by epcpsbgx3.samsung.com (EPCPMTA) with SMTP id DD.25.18557.BA5EFD55; Fri, 28 Aug 2015 13:38:03 +0900 (KST) Date: Fri, 28 Aug 2015 04:38:03 +0000 (GMT) From: Avichal Agarwal Subject: Subject: [PATCH] Provide the information whether the WPA/RSN EAPOL-Key message sent or failed To: =?windows-1252?Q?=3F=3F=3F?= , Avichal Agarwal , JIJO JACOB , "Purushottam ." , "hostap@lists.shmoo.com" MIME-version: 1.0 X-MTR: 20150828043157523@avichal.a Msgkey: 20150828043157523@avichal.a X-EPLocale: en_US.windows-1252 X-Priority: 3 X-EPWebmail-Msg-Type: personal X-EPWebmail-Reply-Demand: 0 X-EPApproval-Locale: X-EPHeader: ML X-MLAttribute: X-RootMTR: 20150828043157523@avichal.a X-ParentMTR: X-ArchiveUser: X-CPGSPASS: N X-ConfirmMail: N,general MIME-version: 1.0 Message-id: <267041588.1267711440736682924.JavaMail.weblogic@ep2mlwas01c> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMIsWRmVeSWpSXmKPExsWyRsSkVnf10/uhBq+vcVksan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efpjPBmGLSVy4tx7I5gKqmcMo 0fHwFztIgkVAVWJK6xamLkYODjYBPYmpVxVATGGBNIn2E+Eg5SICHxglrrSeZwYpZxbQkTjb O50ZYpe8xJlV18BsXgFBiZMzn7CA9EoIKEm03daHCCtLbD40lx3iBDmJJVMvM0HYvBIz2p+y wMSnfV3DDGFLS5yftYER5uTF3x9Dxfkljt3eAdUrIDH1zEGoGnWJzxP6oN7lk1iz8C0LTP2u U8uZYXbd3zIXqldCYmvLE1aIVxQlpnQ/ZIewDSSOLJrDiu4VXgFPiYbLbhMYZWchycxC0j0L STeymgWMLKsYRVMLkguKk9IrjPWKE3OLS/PS9ZLzczcxgpPQs8U7GP+ftz7EKMDBqMTDa7nh fqgQa2JZcWXuIUYJDmYlEV7Nq0Ah3pTEyqrUovz4otKc1OJDjKbAKJvILCWanA9MkHkl8YbG JuamxqYWBobm5mZK4rz/z+WGCAmkJ5akZqemFqQWwfQxcXBKNTByrw1lkVS7dtG3RG+D4VT5 5g+HYtTSdiVpSmuXWXfc3PK4/+Sb3NTrGr6OJ6Q6OC7Orj53p47R7K1PXMrOArXvunuzgzry vAUepaSfer6NOyMp2sZQcOmThRM6fH+cM933UuCdUoBSUY696/3OqIO/aw+y7Cnb+umug6cs R9Cfd888FO14diixFGckGmoxFxUnAgDB4VLNWAMAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected Cc: Kaushik Saha X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.13 Precedence: list Reply-To: avichal.a@samsung.com List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From 3620326f6e74cc7f9c89924eec64978c215d1358 Mon Sep 17 00:00:00 2001 From: Avichal Agarwal Date: Fri, 28 Aug 2015 09:34:12 +0530 Subject: [PATCH] Provide the information whether the WPA/RSN EAPOL-Key message sent or failed This patch provide the exact information whether WPA/RSN EAPOL-Key message sent successfully or failed. Now wpa_eapol_key_send will return 0 on success and -1 on failure. Signed-off-by: Avichal Agarwal Signed-off-by: Purushottam Kushwaha Signed-off-by: Jijo Jacob --- src/rsn_supp/peerkey.c | 32 +++++++++++++++++--------------- src/rsn_supp/wpa.c | 23 ++++++++++++----------- src/rsn_supp/wpa_i.h | 2 +- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/rsn_supp/peerkey.c b/src/rsn_supp/peerkey.c index 79764d9..8d74744 100644 --- a/src/rsn_supp/peerkey.c +++ b/src/rsn_supp/peerkey.c @@ -114,10 +114,10 @@ static int wpa_supplicant_send_smk_error(struct wpa_sm *sm, const u8 *dst, "(mui %d error_type %d)", mui, error_type); } - wpa_eapol_key_send(sm, sm->ptk.kck, sm->ptk.kck_len, ver, dst, + return wpa_eapol_key_send(sm, sm->ptk.kck, sm->ptk.kck_len, ver, dst, ETH_P_EAPOL, rbuf, rlen, err192->key_mic); - return 0; + } @@ -168,10 +168,10 @@ static int wpa_supplicant_send_smk_m3(struct wpa_sm *sm, wpa_add_kde(pos, RSN_KEY_DATA_NONCE, peerkey->inonce, WPA_NONCE_LEN); wpa_printf(MSG_DEBUG, "RSN: Sending EAPOL-Key SMK M3"); - wpa_eapol_key_send(sm, sm->ptk.kck, sm->ptk.kck_len, ver, src_addr, + return wpa_eapol_key_send(sm, sm->ptk.kck, sm->ptk.kck_len, ver, src_addr, ETH_P_EAPOL, rbuf, rlen, reply192->key_mic); - return 0; + } @@ -319,7 +319,7 @@ static void rsn_smkid(const u8 *smk, const u8 *pnonce, const u8 *mac_p, } -static void wpa_supplicant_send_stk_1_of_4(struct wpa_sm *sm, +static int wpa_supplicant_send_stk_1_of_4(struct wpa_sm *sm, struct wpa_peerkey *peerkey) { size_t mlen; @@ -334,7 +334,7 @@ static void wpa_supplicant_send_stk_1_of_4(struct wpa_sm *sm, sizeof(*msg) + kde_len, &mlen, (void *) &msg); if (mbuf == NULL) - return; + return -1 ; msg->type = EAPOL_KEY_TYPE_RSN; @@ -363,7 +363,7 @@ static void wpa_supplicant_send_stk_1_of_4(struct wpa_sm *sm, wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, "RSN: Failed to get random data for INonce (STK)"); os_free(mbuf); - return; + return -1; } wpa_hexdump(MSG_DEBUG, "RSN: INonce for STK 4-Way Handshake", peerkey->inonce, WPA_NONCE_LEN); @@ -371,12 +371,12 @@ static void wpa_supplicant_send_stk_1_of_4(struct wpa_sm *sm, wpa_printf(MSG_DEBUG, "RSN: Sending EAPOL-Key STK 1/4 to " MACSTR, MAC2STR(peerkey->addr)); - wpa_eapol_key_send(sm, NULL, 0, ver, peerkey->addr, ETH_P_EAPOL, + return wpa_eapol_key_send(sm, NULL, 0, ver, peerkey->addr, ETH_P_EAPOL, mbuf, mlen, NULL); } -static void wpa_supplicant_send_stk_3_of_4(struct wpa_sm *sm, +static int wpa_supplicant_send_stk_3_of_4(struct wpa_sm *sm, struct wpa_peerkey *peerkey) { size_t mlen; @@ -393,7 +393,7 @@ static void wpa_supplicant_send_stk_3_of_4(struct wpa_sm *sm, sizeof(*msg) + kde_len, &mlen, (void *) &msg); if (mbuf == NULL) - return; + return -1 ; msg->type = EAPOL_KEY_TYPE_RSN; @@ -426,7 +426,7 @@ static void wpa_supplicant_send_stk_3_of_4(struct wpa_sm *sm, wpa_printf(MSG_DEBUG, "RSN: Sending EAPOL-Key STK 3/4 to " MACSTR, MAC2STR(peerkey->addr)); - wpa_eapol_key_send(sm, peerkey->stk.kck, peerkey->stk.kck_len, ver, + return wpa_eapol_key_send(sm, peerkey->stk.kck, peerkey->stk.kck_len, ver, peerkey->addr, ETH_P_EAPOL, mbuf, mlen, msg->key_mic); } @@ -517,6 +517,7 @@ static int wpa_supplicant_process_smk_m45( struct wpa_peerkey *peerkey; struct wpa_eapol_ie_parse kde; u32 lifetime; + int ret=0; if (!sm->peerkey_enabled || sm->proto != WPA_PROTO_RSN) { wpa_printf(MSG_DEBUG, "RSN: SMK handshake not allowed for " @@ -577,7 +578,7 @@ static int wpa_supplicant_process_smk_m45( rsn_smkid(peerkey->smk, peerkey->pnonce, peerkey->addr, peerkey->inonce, sm->own_addr, peerkey->smkid, peerkey->akmp); - wpa_supplicant_send_stk_1_of_4(sm, peerkey); + ret = wpa_supplicant_send_stk_1_of_4(sm, peerkey); } else { rsn_smkid(peerkey->smk, peerkey->pnonce, sm->own_addr, peerkey->inonce, peerkey->addr, peerkey->smkid, @@ -585,7 +586,7 @@ static int wpa_supplicant_process_smk_m45( } wpa_hexdump(MSG_DEBUG, "RSN: SMKID", peerkey->smkid, PMKID_LEN); - return 0; + return ret; } @@ -988,6 +989,7 @@ int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer) struct rsn_ie_hdr *hdr; struct wpa_peerkey *peerkey; struct wpa_ie_data ie; + int ret =0; if (sm->proto != WPA_PROTO_RSN || !sm->ptk_set || !sm->peerkey_enabled) return -1; @@ -1084,13 +1086,13 @@ int wpa_sm_stkstart(struct wpa_sm *sm, const u8 *peer) wpa_printf(MSG_INFO, "RSN: Sending EAPOL-Key SMK M1 Request (peer " MACSTR ")", MAC2STR(peer)); - wpa_eapol_key_send(sm, sm->ptk.kck, sm->ptk.kck_len, ver, bssid, + ret = wpa_eapol_key_send(sm, sm->ptk.kck, sm->ptk.kck_len, ver, bssid, ETH_P_EAPOL, rbuf, rlen, req->key_mic); peerkey->next = sm->peerkey; sm->peerkey = peerkey; - return 0; + return ret; } diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c index 52c01b8..4890e48 100644 --- a/src/rsn_supp/wpa.c +++ b/src/rsn_supp/wpa.c @@ -34,11 +34,13 @@ * @msg: EAPOL-Key message * @msg_len: Length of message * @key_mic: Pointer to the buffer to which the EAPOL-Key MIC is written + * Returns: >=0 on success, <0 on failure */ -void wpa_eapol_key_send(struct wpa_sm *sm, const u8 *kck, size_t kck_len, - int ver, const u8 *dest, u16 proto, - u8 *msg, size_t msg_len, u8 *key_mic) +int wpa_eapol_key_send(struct wpa_sm *sm, const u8 *kck, size_t kck_len, + int ver, const u8 *dest, u16 proto, + u8 *msg, size_t msg_len, u8 *key_mic) { + int ret = -1; size_t mic_len = wpa_mic_len(sm->key_mgmt); if (is_zero_ether_addr(dest) && is_zero_ether_addr(sm->bssid)) { @@ -65,14 +67,16 @@ void wpa_eapol_key_send(struct wpa_sm *sm, const u8 *kck, size_t kck_len, "WPA: Failed to generate EAPOL-Key version %d key_mgmt 0x%x MIC", ver, sm->key_mgmt); goto out; + } wpa_hexdump_key(MSG_DEBUG, "WPA: KCK", kck, kck_len); wpa_hexdump(MSG_DEBUG, "WPA: Derived Key MIC", key_mic, mic_len); wpa_hexdump(MSG_MSGDUMP, "WPA: TX EAPOL-Key", msg, msg_len); - wpa_sm_ether_send(sm, dest, proto, msg, msg_len); + ret = wpa_sm_ether_send(sm, dest, proto, msg, msg_len); eapol_sm_notify_tx_eapol_key(sm->eapol); out: os_free(msg); + return ret; } @@ -409,10 +413,10 @@ int wpa_supplicant_send_2_of_4(struct wpa_sm *sm, const unsigned char *dst, os_memcpy(reply->key_nonce, nonce, WPA_NONCE_LEN); wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Sending EAPOL-Key 2/4"); - wpa_eapol_key_send(sm, ptk->kck, ptk->kck_len, ver, dst, ETH_P_EAPOL, + return wpa_eapol_key_send(sm, ptk->kck, ptk->kck_len, ver, dst, ETH_P_EAPOL, rbuf, rlen, key_mic); - return 0; + } @@ -1126,10 +1130,9 @@ int wpa_supplicant_send_4_of_4(struct wpa_sm *sm, const unsigned char *dst, WPA_PUT_BE16(reply->key_data_length, 0); wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Sending EAPOL-Key 4/4"); - wpa_eapol_key_send(sm, ptk->kck, ptk->kck_len, ver, dst, ETH_P_EAPOL, + return wpa_eapol_key_send(sm, ptk->kck, ptk->kck_len, ver, dst, ETH_P_EAPOL, rbuf, rlen, key_mic); - return 0; } @@ -1437,10 +1440,8 @@ static int wpa_supplicant_send_2_of_2(struct wpa_sm *sm, WPA_PUT_BE16(reply->key_data_length, 0); wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG, "WPA: Sending EAPOL-Key 2/2"); - wpa_eapol_key_send(sm, sm->ptk.kck, sm->ptk.kck_len, ver, sm->bssid, + return wpa_eapol_key_send(sm, sm->ptk.kck, sm->ptk.kck_len, ver, sm->bssid, ETH_P_EAPOL, rbuf, rlen, key_mic); - - return 0; } diff --git a/src/rsn_supp/wpa_i.h b/src/rsn_supp/wpa_i.h index 965a9c1..5101fba 100644 --- a/src/rsn_supp/wpa_i.h +++ b/src/rsn_supp/wpa_i.h @@ -349,7 +349,7 @@ static inline int wpa_sm_key_mgmt_set_pmk(struct wpa_sm *sm, return sm->ctx->key_mgmt_set_pmk(sm->ctx->ctx, pmk, pmk_len); } -void wpa_eapol_key_send(struct wpa_sm *sm, const u8 *kck, size_t kck_len, +int wpa_eapol_key_send(struct wpa_sm *sm, const u8 *kck, size_t kck_len, int ver, const u8 *dest, u16 proto, u8 *msg, size_t msg_len, u8 *key_mic); int wpa_supplicant_send_2_of_4(struct wpa_sm *sm, const unsigned char *dst,