From: Brian Gix <brian.gix@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: inga.stotland@intel.com, brian.gix@intel.com
Subject: [PATCH BlueZ v3 5/6] mesh: Implement Key Refresh Phasing in keyring
Date: Thu, 23 May 2019 09:13:28 -0700 [thread overview]
Message-ID: <20190523161329.13017-6-brian.gix@intel.com> (raw)
In-Reply-To: <20190523161329.13017-1-brian.gix@intel.com>
Implements following org.bluez.mesh.Management1 methods:
CompleteAppKeyUpdate()
SetKeyPhase()
These methods are used to maintain Key Refresh settings
in the keyring storage.
---
mesh/manager.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 50 insertions(+), 3 deletions(-)
diff --git a/mesh/manager.c b/mesh/manager.c
index c79c873f2..234ab5e2f 100644
--- a/mesh/manager.c
+++ b/mesh/manager.c
@@ -289,6 +289,34 @@ static struct l_dbus_message *update_appkey_call(struct l_dbus *dbus,
return l_dbus_message_new_method_return(msg);
}
+static struct l_dbus_message *complete_update_appkey_call(struct l_dbus *dbus,
+ struct l_dbus_message *msg,
+ void *user_data)
+{
+ struct mesh_node *node = user_data;
+ struct keyring_net_key net_key;
+ struct keyring_app_key app_key;
+ uint16_t app_idx;
+
+ if (!l_dbus_message_get_arguments(msg, "q", &app_idx) ||
+ app_idx > MAX_KEY_IDX)
+ return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL);
+
+ if (!keyring_get_app_key(node, app_idx, &app_key) ||
+ !keyring_get_net_key(node, app_key.net_idx, &net_key))
+ return dbus_error(msg, MESH_ERROR_DOES_NOT_EXIST, NULL);
+
+ if (net_key.phase != KEY_REFRESH_PHASE_TWO)
+ return dbus_error(msg, MESH_ERROR_FAILED, "Invalid phase");
+
+ memcpy(app_key.old_key, app_key.new_key, 16);
+
+ if (!keyring_put_app_key(node, app_idx, app_key.net_idx, &app_key))
+ return dbus_error(msg, MESH_ERROR_FAILED, NULL);
+
+ return l_dbus_message_new_method_return(msg);
+}
+
static struct l_dbus_message *delete_appkey_call(struct l_dbus *dbus,
struct l_dbus_message *msg,
void *user_data)
@@ -330,14 +358,30 @@ static struct l_dbus_message *set_key_phase_call(struct l_dbus *dbus,
struct l_dbus_message *msg,
void *user_data)
{
+ struct mesh_node *node = user_data;
+ struct keyring_net_key key;
uint16_t net_idx;
uint8_t phase;
- if (!l_dbus_message_get_arguments(msg, "qy", &net_idx, &phase))
+ if (!l_dbus_message_get_arguments(msg, "qy", &net_idx, &phase) ||
+ phase == KEY_REFRESH_PHASE_ONE ||
+ phase > KEY_REFRESH_PHASE_THREE)
return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL);
- /* TODO */
- return dbus_error(msg, MESH_ERROR_NOT_IMPLEMENTED, NULL);
+ if (!keyring_get_net_key(node, net_idx, &key))
+ return dbus_error(msg, MESH_ERROR_DOES_NOT_EXIST, NULL);
+
+ if (phase == KEY_REFRESH_PHASE_THREE &&
+ key.phase != KEY_REFRESH_PHASE_NONE) {
+ memcpy(key.old_key, key.new_key, 16);
+ key.phase = KEY_REFRESH_PHASE_NONE;
+ } else
+ key.phase = phase;
+
+ if (!keyring_put_net_key(node, net_idx, &key))
+ return dbus_error(msg, MESH_ERROR_FAILED, NULL);
+
+ return l_dbus_message_new_method_return(msg);
}
static void setup_management_interface(struct l_dbus_interface *iface)
@@ -362,6 +406,9 @@ static void setup_management_interface(struct l_dbus_interface *iface)
"", "qq", "", "net_index", "app_index");
l_dbus_interface_method(iface, "UpdateAppKey", 0, update_appkey_call,
"", "q", "", "app_index");
+ l_dbus_interface_method(iface, "CompleteAppKeyUpdate", 0,
+ complete_update_appkey_call, "", "q",
+ "", "app_index");
l_dbus_interface_method(iface, "DeleteAppKey", 0, delete_appkey_call,
"", "q", "", "app_index");
l_dbus_interface_method(iface, "ImportAppKey", 0, import_appkey_call,
--
2.14.5
next prev parent reply other threads:[~2019-05-23 16:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-23 16:13 [PATCH BlueZ v3 0/6] mesh: Add App and Net Key Refresh keyring back-end Brian Gix
2019-05-23 16:13 ` [PATCH BlueZ v3 1/6] mesh: Add new method for Key Refresh procedure Brian Gix
2019-05-23 16:13 ` [PATCH BlueZ v3 2/6] mesh: Centralize definition of PRIMARY_NET_IDX Brian Gix
2019-05-23 16:13 ` [PATCH BlueZ v3 3/6] mesh: Implement Net Key keyring storage handling Brian Gix
2019-05-23 16:13 ` [PATCH BlueZ v3 4/6] mesh: Implement App " Brian Gix
2019-05-23 16:13 ` Brian Gix [this message]
2019-05-23 16:13 ` [PATCH BlueZ v3 6/6] mesh: Implement remote dev key methods for keyring Brian Gix
2019-05-24 15:07 ` [PATCH BlueZ v3 0/6] mesh: Add App and Net Key Refresh keyring back-end Gix, Brian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190523161329.13017-6-brian.gix@intel.com \
--to=brian.gix@intel.com \
--cc=inga.stotland@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).