From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: Archie Pusaka <apusaka@google.com>
Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>,
Marcel Holtmann <marcel@holtmann.org>,
CrosBT Upstreaming <chromeos-bluetooth-upstreaming@chromium.org>,
Archie Pusaka <apusaka@chromium.org>,
Sonny Sasaka <sonnysasaka@chromium.org>
Subject: Re: [Bluez PATCH 1/3] adapter: Use PeripheralLongTermKey to store LTK
Date: Mon, 1 Nov 2021 23:17:19 -0700 [thread overview]
Message-ID: <CABBYNZJg=Acx_BLyq=RzbkvfWOj-Rik3t7B1Z-XZqemo2LMykQ@mail.gmail.com> (raw)
In-Reply-To: <20211101140544.Bluez.1.I515833d2764b8ec2ac2bb1f87313de80ebb497cd@changeid>
Hi Archie,
On Sun, Oct 31, 2021 at 11:06 PM Archie Pusaka <apusaka@google.com> wrote:
>
> From: Archie Pusaka <apusaka@chromium.org>
>
> Introducing PeripheralLongTermKey group for storing LTK info to
> replace the less inclusive term. Currently we still need to write/read
> from both to ensure smooth transition, but later we should deprecate
> the old term.
>
> Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
> ---
>
> src/adapter.c | 41 ++++++++++++++++++++++++++++++++---------
> 1 file changed, 32 insertions(+), 9 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index d0d38621b8..6b12c9e793 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -3868,7 +3868,11 @@ static struct smp_ltk_info *get_peripheral_ltk_info(GKeyFile *key_file,
>
> DBG("%s", peer);
>
> - ltk = get_ltk(key_file, peer, bdaddr_type, "SlaveLongTermKey");
> + /* Read from both entries. Later we should deprecate Slave. */
> + ltk = get_ltk(key_file, peer, bdaddr_type, "PeripheralLongTermKey");
> + if (!ltk)
> + ltk = get_ltk(key_file, peer, bdaddr_type, "SlaveLongTermKey");
If you find the old name being used you better replace it with the new
one and erase the old.
> if (ltk)
> ltk->central = false;
>
> @@ -8415,13 +8419,12 @@ static void new_link_key_callback(uint16_t index, uint16_t length,
> bonding_complete(adapter, &addr->bdaddr, addr->type, 0);
> }
>
> -static void store_longtermkey(struct btd_adapter *adapter, const bdaddr_t *peer,
> +static void store_ltk_group(struct btd_adapter *adapter, const bdaddr_t *peer,
> uint8_t bdaddr_type, const unsigned char *key,
> - uint8_t central, uint8_t authenticated,
> + const char *group, uint8_t authenticated,
> uint8_t enc_size, uint16_t ediv,
> uint64_t rand)
> {
> - const char *group = central ? "LongTermKey" : "SlaveLongTermKey";
> char device_addr[18];
> char filename[PATH_MAX];
> GKeyFile *key_file;
> @@ -8431,11 +8434,6 @@ static void store_longtermkey(struct btd_adapter *adapter, const bdaddr_t *peer,
> char *str;
> int i;
>
> - if (central != 0x00 && central != 0x01) {
> - error("Unsupported LTK type %u", central);
> - return;
> - }
> -
> ba2str(peer, device_addr);
>
> snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info",
> @@ -8475,6 +8473,31 @@ static void store_longtermkey(struct btd_adapter *adapter, const bdaddr_t *peer,
> g_key_file_free(key_file);
> }
>
> +static void store_longtermkey(struct btd_adapter *adapter, const bdaddr_t *peer,
> + uint8_t bdaddr_type, const unsigned char *key,
> + uint8_t central, uint8_t authenticated,
> + uint8_t enc_size, uint16_t ediv,
> + uint64_t rand)
> +{
> + if (central != 0x00 && central != 0x01) {
> + error("Unsupported LTK type %u", central);
> + return;
> + }
> +
> + if (central) {
> + store_ltk_group(adapter, peer, bdaddr_type, key, "LongTermKey",
> + authenticated, enc_size, ediv, rand);
> + } else {
> + /* Store duplicates for now. Later we should deprecate Slave. */
> + store_ltk_group(adapter, peer, bdaddr_type, key,
> + "PeripheralLongTermKey", authenticated,
> + enc_size, ediv, rand);
> + store_ltk_group(adapter, peer, bdaddr_type, key,
> + "SlaveLongTermKey", authenticated,
> + enc_size, ediv, rand);
In not following why you want to keep duplicate entries?
> + }
> +}
> +
> static void new_long_term_key_callback(uint16_t index, uint16_t length,
> const void *param, void *user_data)
> {
> --
> 2.33.1.1089.g2158813163f-goog
>
--
Luiz Augusto von Dentz
next prev parent reply other threads:[~2021-11-02 6:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-01 6:06 [Bluez PATCH 1/3] adapter: Use PeripheralLongTermKey to store LTK Archie Pusaka
2021-11-01 6:06 ` [Bluez PATCH 2/3] doc: Add PeripheralLongTermKey for storing LTK Archie Pusaka
2021-11-01 6:06 ` [Bluez PATCH 3/3] adapter: Remove "Master" entry from LTK storage Archie Pusaka
2021-11-02 6:13 ` Luiz Augusto von Dentz
2021-11-02 9:17 ` Archie Pusaka
2021-11-01 6:41 ` [Bluez,1/3] adapter: Use PeripheralLongTermKey to store LTK bluez.test.bot
2021-11-02 6:17 ` Luiz Augusto von Dentz [this message]
2021-11-02 9:10 ` [Bluez PATCH 1/3] " Archie Pusaka
2021-11-02 22:39 ` Luiz Augusto von Dentz
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='CABBYNZJg=Acx_BLyq=RzbkvfWOj-Rik3t7B1Z-XZqemo2LMykQ@mail.gmail.com' \
--to=luiz.dentz@gmail.com \
--cc=apusaka@chromium.org \
--cc=apusaka@google.com \
--cc=chromeos-bluetooth-upstreaming@chromium.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=sonnysasaka@chromium.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).