From: "Frédéric Danis" <frederic.danis@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC V3 10/12] adapter: Convert storage longtermkeys file
Date: Fri, 30 Nov 2012 15:47:04 +0100 [thread overview]
Message-ID: <1354286826-24016-10-git-send-email-frederic.danis@linux.intel.com> (raw)
In-Reply-To: <1354286826-24016-1-git-send-email-frederic.danis@linux.intel.com>
---
src/adapter.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/src/adapter.c b/src/adapter.c
index 17f478c..ff9d2e7 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2655,6 +2655,46 @@ static void convert_linkkey_entry(GKeyFile *key_file, void *value)
g_key_file_set_integer(key_file, "LinkKey", "PINLength", val);
}
+static void convert_ltk_entry(GKeyFile *key_file, void *value)
+{
+ char *auth_str, *rand_str, *str;
+ int i, ret;
+ unsigned char auth, master, enc_size;
+ unsigned short ediv;
+
+ auth_str = strchr(value, ' ');
+ if (!auth_str)
+ return;
+
+ *(auth_str++) = 0;
+
+ for (i = 0, rand_str = auth_str; i < 4; i++) {
+ rand_str = strchr(rand_str, ' ');
+ if (!rand_str || rand_str[1] == '\0')
+ return;
+
+ rand_str++;
+ }
+
+ ret = sscanf(auth_str, " %hhd %hhd %hhd %hd", &auth, &master,
+ &enc_size, &ediv);
+ if (ret < 4)
+ return;
+
+ str = g_strconcat("0x", value, NULL);
+ g_key_file_set_string(key_file, "LongTermKey", "Key", str);
+ g_free(str);
+
+ g_key_file_set_integer(key_file, "LongTermKey", "Authenticated", auth);
+ g_key_file_set_integer(key_file, "LongTermKey", "Master", master);
+ g_key_file_set_integer(key_file, "LongTermKey", "EncSize", enc_size);
+ g_key_file_set_integer(key_file, "LongTermKey", "EDiv", ediv);
+
+ str = g_strconcat("0x", rand_str, NULL);
+ g_key_file_set_string(key_file, "LongTermKey", "Rand", str);
+ g_free(str);
+}
+
static void convert_entry(char *key, char *value, void *user_data)
{
struct device_converter *converter = user_data;
@@ -2766,6 +2806,9 @@ static void convert_device_storage(struct btd_adapter *adapter)
/* Convert linkkeys */
convert_file("linkkeys", address, convert_linkkey_entry, TRUE);
+ /* Convert longtermkeys */
+ convert_file("longtermkeys", address, convert_ltk_entry, TRUE);
+
/* Convert classes */
convert_file("classes", address, convert_classes_entry, FALSE);
--
1.7.9.5
next prev parent reply other threads:[~2012-11-30 14:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-30 14:46 [RFC V3 01/12] doc: Update settings-storage.txt Frédéric Danis
2012-11-30 14:46 ` [RFC V3 02/12] device: Load device info before updating info file Frédéric Danis
2012-11-30 14:46 ` [RFC V3 03/12] adapter: Fix device storage creation Frédéric Danis
2012-11-30 14:46 ` [RFC V3 04/12] adapter: Add force dir creation to convert_file() Frédéric Danis
2012-11-30 14:46 ` [RFC V3 05/12] adapter: Convert device type Frédéric Danis
2012-11-30 14:47 ` [RFC V3 06/12] adapter: Load devices from new storage architecture Frédéric Danis
2012-11-30 14:47 ` [RFC V3 07/12] adapter: Convert storage linkkeys file Frédéric Danis
2012-11-30 14:47 ` [RFC V3 08/12] adapter: Upload link keys from new storage Frédéric Danis
2012-11-30 14:47 ` [RFC V3 09/12] event: Store link key infos in device info file Frédéric Danis
2012-11-30 14:47 ` Frédéric Danis [this message]
2012-11-30 14:47 ` [RFC V3 11/12] adapter: Upload long term keys from new storage Frédéric Danis
2012-11-30 14:47 ` [RFC V3 12/12] event: Store long term key infos in device info file Frédéric Danis
2012-12-04 8:18 ` [RFC V3 01/12] doc: Update settings-storage.txt Johan Hedberg
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=1354286826-24016-10-git-send-email-frederic.danis@linux.intel.com \
--to=frederic.danis@linux.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.