Blame SOURCES/macsec-0031-PAE-Make-KaY-specific-details-available-via-control-.patch

9c84ec
From 7508c2ad99cef6d0691190063ec7735b7759f836 Mon Sep 17 00:00:00 2001
9c84ec
Message-Id: <7508c2ad99cef6d0691190063ec7735b7759f836.1488376602.git.dcaratti@redhat.com>
9c84ec
From: Badrish Adiga H R <badrish.adigahr@gmail.com>
9c84ec
Date: Fri, 16 Dec 2016 01:40:53 +0530
9c84ec
Subject: [PATCH] PAE: Make KaY specific details available via control
9c84ec
 interface
9c84ec
9c84ec
Add KaY details to the STATUS command output.
9c84ec
9c84ec
Signed-off-by: Badrish Adiga H R <badrish.adigahr@hpe.com>
9c84ec
---
9c84ec
 src/pae/ieee802_1x_kay.c    | 49 +++++++++++++++++++++++++++++++++++++++++++++
9c84ec
 src/pae/ieee802_1x_kay.h    |  3 +++
9c84ec
 wpa_supplicant/ctrl_iface.c |  6 ++++++
9c84ec
 3 files changed, 58 insertions(+)
9c84ec
9c84ec
diff --git a/src/pae/ieee802_1x_kay.c b/src/pae/ieee802_1x_kay.c
9c84ec
index 1d6d9a9..cf5782a 100644
9c84ec
--- a/src/pae/ieee802_1x_kay.c
9c84ec
+++ b/src/pae/ieee802_1x_kay.c
9c84ec
@@ -1641,6 +1641,7 @@ ieee802_1x_mka_decode_dist_sak_body(
9c84ec
 	ieee802_1x_cp_signal_newsak(kay->cp);
9c84ec
 	ieee802_1x_cp_sm_step(kay->cp);
9c84ec
 
9c84ec
+	kay->rcvd_keys++;
9c84ec
 	participant->to_use_sak = TRUE;
9c84ec
 
9c84ec
 	return 0;
9c84ec
@@ -3519,3 +3520,51 @@ ieee802_1x_kay_change_cipher_suite(struct ieee802_1x_kay *kay,
9c84ec
 
9c84ec
 	return 0;
9c84ec
 }
9c84ec
+
9c84ec
+
9c84ec
+#ifdef CONFIG_CTRL_IFACE
9c84ec
+/**
9c84ec
+ * ieee802_1x_kay_get_status - Get IEEE 802.1X KaY status details
9c84ec
+ * @sm: Pointer to KaY allocated with ieee802_1x_kay_init()
9c84ec
+ * @buf: Buffer for status information
9c84ec
+ * @buflen: Maximum buffer length
9c84ec
+ * @verbose: Whether to include verbose status information
9c84ec
+ * Returns: Number of bytes written to buf.
9c84ec
+ *
9c84ec
+ * Query KAY status information. This function fills in a text area with current
9c84ec
+ * status information. If the buffer (buf) is not large enough, status
9c84ec
+ * information will be truncated to fit the buffer.
9c84ec
+ */
9c84ec
+int ieee802_1x_kay_get_status(struct ieee802_1x_kay *kay, char *buf,
9c84ec
+			      size_t buflen)
9c84ec
+{
9c84ec
+	int len;
9c84ec
+
9c84ec
+	if (!kay)
9c84ec
+		return 0;
9c84ec
+
9c84ec
+	len = os_snprintf(buf, buflen,
9c84ec
+			  "PAE KaY status=%s\n"
9c84ec
+			  "Authenticated=%s\n"
9c84ec
+			  "Secured=%s\n"
9c84ec
+			  "Failed=%s\n"
9c84ec
+			  "Actor Priority=%u\n"
9c84ec
+			  "Key Server Priority=%u\n"
9c84ec
+			  "Is Key Server=%s\n"
9c84ec
+			  "Number of Keys Distributed=%u\n"
9c84ec
+			  "Number of Keys Received=%u\n",
9c84ec
+			  kay->active ? "Active" : "Not-Active",
9c84ec
+			  kay->authenticated ? "Yes" : "No",
9c84ec
+			  kay->secured ? "Yes" : "No",
9c84ec
+			  kay->failed ? "Yes" : "No",
9c84ec
+			  kay->actor_priority,
9c84ec
+			  kay->key_server_priority,
9c84ec
+			  kay->is_key_server ? "Yes" : "No",
9c84ec
+			  kay->dist_kn - 1,
9c84ec
+			  kay->rcvd_keys);
9c84ec
+	if (os_snprintf_error(buflen, len))
9c84ec
+		return 0;
9c84ec
+
9c84ec
+	return len;
9c84ec
+}
9c84ec
+#endif /* CONFIG_CTRL_IFACE */
9c84ec
diff --git a/src/pae/ieee802_1x_kay.h b/src/pae/ieee802_1x_kay.h
9c84ec
index 9a92d1c..b38e814 100644
9c84ec
--- a/src/pae/ieee802_1x_kay.h
9c84ec
+++ b/src/pae/ieee802_1x_kay.h
9c84ec
@@ -208,6 +208,7 @@ struct ieee802_1x_kay {
9c84ec
 	int mka_algindex;  /* MKA alg table index */
9c84ec
 
9c84ec
 	u32 dist_kn;
9c84ec
+	u32 rcvd_keys;
9c84ec
 	u8 dist_an;
9c84ec
 	time_t dist_time;
9c84ec
 
9c84ec
@@ -267,5 +268,7 @@ int ieee802_1x_kay_enable_tx_sas(struct ieee802_1x_kay *kay,
9c84ec
 int ieee802_1x_kay_enable_rx_sas(struct ieee802_1x_kay *kay,
9c84ec
 				 struct ieee802_1x_mka_ki *lki);
9c84ec
 int ieee802_1x_kay_enable_new_info(struct ieee802_1x_kay *kay);
9c84ec
+int ieee802_1x_kay_get_status(struct ieee802_1x_kay *kay, char *buf,
9c84ec
+			      size_t buflen);
9c84ec
 
9c84ec
 #endif /* IEEE802_1X_KAY_H */
9c84ec
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
9c84ec
index c943dee..624e894 100644
9c84ec
--- a/wpa_supplicant/ctrl_iface.c
9c84ec
+++ b/wpa_supplicant/ctrl_iface.c
9c84ec
@@ -2050,6 +2050,12 @@ static int wpa_supplicant_ctrl_iface_status(struct wpa_supplicant *wpa_s,
9c84ec
 			pos += res;
9c84ec
 	}
9c84ec
 
9c84ec
+#ifdef CONFIG_MACSEC
9c84ec
+	res = ieee802_1x_kay_get_status(wpa_s->kay, pos, end - pos);
9c84ec
+	if (res > 0)
9c84ec
+		pos += res;
9c84ec
+#endif /* CONFIG_MACSEC */
9c84ec
+
9c84ec
 	sess_id = eapol_sm_get_session_id(wpa_s->eapol, &sess_id_len);
9c84ec
 	if (sess_id) {
9c84ec
 		char *start = pos;
9c84ec
-- 
9c84ec
2.7.4
9c84ec