PATCH: P2P allow using pre-define passphrase for creating a local group

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

wpas_p2p_group_add could use pre-defined network name, but always generate
passphrase randomly. I would like to provide a way to use pre-defined
passphrase.

Best regards,
Jimmy
From 21cce0f2c97a0b604343b5ceb46ba1610015e16c Mon Sep 17 00:00:00 2001
From: Jimmy Chen <jimmycmchen@xxxxxxxxxx>
Date: Tue, 20 Nov 2018 10:15:16 +0800
Subject: [PATCH] p2p: support using pre-defined passphrase for adding a new
 P2P group

wpas_p2p_group_add could use pre-defined network name, but always generate
passphrase randomly. Provide a way to use pre-defined passphrase.

Change-Id: I08fbfd6542a5c1e76335c3a5911ba09ea6d9ca78
Signed-off-by: Jimmy Chen <jimmycmchen@xxxxxxxxxx>
---
 src/p2p/p2p.c   |  8 +++++++-
 src/p2p/p2p_i.h | 12 ++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index b4660c4f9..dc4a3c439 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -1797,7 +1797,13 @@ int p2p_go_params(struct p2p_data *p2p, struct p2p_go_neg_results *params)
 	}
 	p2p->ssid_set = 0;
 
-	p2p_random(params->passphrase, p2p->cfg->passphrase_len);
+	if (p2p->passphrase_set) {
+		os_memcpy(params->passphrase, p2p->passphrase,
+			  os_strlen(p2p->passphrase));
+	} else {
+		p2p_random(params->passphrase, p2p->cfg->passphrase_len);
+	}
+	p2p->passphrase_set = 0;
 	return 0;
 }
 
diff --git a/src/p2p/p2p_i.h b/src/p2p/p2p_i.h
index 6a4d751c0..f12ae9dd8 100644
--- a/src/p2p/p2p_i.h
+++ b/src/p2p/p2p_i.h
@@ -11,6 +11,7 @@
 
 #include "utils/list.h"
 #include "p2p.h"
+#include "ap/ap_config.h"
 
 #define P2P_GO_NEG_CNF_MAX_RETRY_COUNT 1
 
@@ -357,6 +358,17 @@ struct p2p_data {
 	 */
 	int ssid_set;
 
+	/**
+	 * passphrase - WPA2-Personal passphrase for GO Negotiation (if local
+	 * end will be GO)
+	 */
+	char passphrase[MAX_PASSPHRASE_LEN + 1];
+
+	/**
+	 * passphrase_set - Whether passphrase is already set for GO Negotiation
+	 */
+	int passphrase_set;
+
 	/**
 	 * Regulatory class for own operational channel
 	 */
-- 
2.20.1.321.g9e740568ce-goog

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap

[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux