diff mbox series

[Bluez,3/3] adapter: Remove "Master" entry from LTK storage

Message ID 20211101140544.Bluez.3.Idb95ae18113225915b97a4f06983e1e41a7f7a2e@changeid (mailing list archive)
State Superseded
Headers show
Series [Bluez,1/3] adapter: Use PeripheralLongTermKey to store LTK | expand

Checks

Context Check Description
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS

Commit Message

Archie Pusaka Nov. 1, 2021, 6:06 a.m. UTC
From: Archie Pusaka <apusaka@chromium.org>

The entry has been deprecated since 2014 and it's time to remove them
altogether.
---
Hi maintainers,
While cleaning this entry, I found that this entry is involved in some
kind of storage file conversion, probably when upgrading BlueZ 4 to 5.
Should we also remove the file conversion too, since it's dated to
2014 as well?


 src/adapter.c | 12 ------------
 1 file changed, 12 deletions(-)

Comments

Luiz Augusto von Dentz Nov. 2, 2021, 6:13 a.m. UTC | #1
Hi Archie,

On Sun, Oct 31, 2021 at 11:06 PM Archie Pusaka <apusaka@google.com> wrote:
>
> From: Archie Pusaka <apusaka@chromium.org>
>
> The entry has been deprecated since 2014 and it's time to remove them
> altogether.
> ---
> Hi maintainers,
> While cleaning this entry, I found that this entry is involved in some
> kind of storage file conversion, probably when upgrading BlueZ 4 to 5.
> Should we also remove the file conversion too, since it's dated to
> 2014 as well?

Perhaps we can but I'd had such cleanup as a separate patch then.

>
>  src/adapter.c | 12 ------------
>  1 file changed, 12 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 6b12c9e793..3a3c957a6c 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -3779,8 +3779,6 @@ static struct smp_ltk_info *get_ltk(GKeyFile *key_file, const char *peer,
>                                         uint8_t peer_type, const char *group)
>  {
>         struct smp_ltk_info *ltk = NULL;
> -       GError *gerr = NULL;
> -       bool central;
>         char *key;
>         char *rand = NULL;
>
> @@ -3836,12 +3834,6 @@ static struct smp_ltk_info *get_ltk(GKeyFile *key_file, const char *peer,
>                                                                         NULL);
>         ltk->ediv = g_key_file_get_integer(key_file, group, "EDiv", NULL);
>
> -       central = g_key_file_get_boolean(key_file, group, "Master", &gerr);
> -       if (gerr)
> -               g_error_free(gerr);
> -       else
> -               ltk->central = central;
> -
>         ltk->is_blocked = is_blocked_key(HCI_BLOCKED_KEY_TYPE_LTK,
>                                                                 ltk->val);
>
> @@ -5904,7 +5896,6 @@ static void convert_ltk_entry(GKeyFile *key_file, void *value)
>         g_free(str);
>
>         g_key_file_set_integer(key_file, "LongTermKey", "Authenticated", auth);
> -       g_key_file_set_integer(key_file, "LongTermKey", "Master", central);

Weird that it still was setting the "Master" even though this is meant
to convert the old format into the new one.

>         g_key_file_set_integer(key_file, "LongTermKey", "EncSize", enc_size);
>         g_key_file_set_integer(key_file, "LongTermKey", "EDiv", ediv);
>
> @@ -8445,9 +8436,6 @@ static void store_ltk_group(struct btd_adapter *adapter, const bdaddr_t *peer,
>                 g_error_free(gerr);
>         }
>
> -       /* Old files may contain this so remove it in case it exists */
> -       g_key_file_remove_key(key_file, "LongTermKey", "Master", NULL);
> -
>         for (i = 0; i < 16; i++)
>                 sprintf(key_str + (i * 2), "%2.2X", key[i]);
>
> --
> 2.33.1.1089.g2158813163f-goog
>
Archie Pusaka Nov. 2, 2021, 9:17 a.m. UTC | #2
Hi Luiz,

On Tue, 2 Nov 2021 at 14:13, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> Hi Archie,
>
> On Sun, Oct 31, 2021 at 11:06 PM Archie Pusaka <apusaka@google.com> wrote:
> >
> > From: Archie Pusaka <apusaka@chromium.org>
> >
> > The entry has been deprecated since 2014 and it's time to remove them
> > altogether.
> > ---
> > Hi maintainers,
> > While cleaning this entry, I found that this entry is involved in some
> > kind of storage file conversion, probably when upgrading BlueZ 4 to 5.
> > Should we also remove the file conversion too, since it's dated to
> > 2014 as well?
>
> Perhaps we can but I'd had such cleanup as a separate patch then.
>
Got it. Then I would prefer to wait until this series of patches is
merged before removing the file conversion.

> >
> >  src/adapter.c | 12 ------------
> >  1 file changed, 12 deletions(-)
> >
> > diff --git a/src/adapter.c b/src/adapter.c
> > index 6b12c9e793..3a3c957a6c 100644
> > --- a/src/adapter.c
> > +++ b/src/adapter.c
> > @@ -3779,8 +3779,6 @@ static struct smp_ltk_info *get_ltk(GKeyFile *key_file, const char *peer,
> >                                         uint8_t peer_type, const char *group)
> >  {
> >         struct smp_ltk_info *ltk = NULL;
> > -       GError *gerr = NULL;
> > -       bool central;
> >         char *key;
> >         char *rand = NULL;
> >
> > @@ -3836,12 +3834,6 @@ static struct smp_ltk_info *get_ltk(GKeyFile *key_file, const char *peer,
> >                                                                         NULL);
> >         ltk->ediv = g_key_file_get_integer(key_file, group, "EDiv", NULL);
> >
> > -       central = g_key_file_get_boolean(key_file, group, "Master", &gerr);
> > -       if (gerr)
> > -               g_error_free(gerr);
> > -       else
> > -               ltk->central = central;
> > -
> >         ltk->is_blocked = is_blocked_key(HCI_BLOCKED_KEY_TYPE_LTK,
> >                                                                 ltk->val);
> >
> > @@ -5904,7 +5896,6 @@ static void convert_ltk_entry(GKeyFile *key_file, void *value)
> >         g_free(str);
> >
> >         g_key_file_set_integer(key_file, "LongTermKey", "Authenticated", auth);
> > -       g_key_file_set_integer(key_file, "LongTermKey", "Master", central);
>
> Weird that it still was setting the "Master" even though this is meant
> to convert the old format into the new one.
>
Probably these "convert" methods precedes the "split LTK entries into
central and peripheral" decision, and this setting is unintentionally
left out when splitting LTKs.

> >         g_key_file_set_integer(key_file, "LongTermKey", "EncSize", enc_size);
> >         g_key_file_set_integer(key_file, "LongTermKey", "EDiv", ediv);
> >
> > @@ -8445,9 +8436,6 @@ static void store_ltk_group(struct btd_adapter *adapter, const bdaddr_t *peer,
> >                 g_error_free(gerr);
> >         }
> >
> > -       /* Old files may contain this so remove it in case it exists */
> > -       g_key_file_remove_key(key_file, "LongTermKey", "Master", NULL);
> > -
> >         for (i = 0; i < 16; i++)
> >                 sprintf(key_str + (i * 2), "%2.2X", key[i]);
> >
> > --
> > 2.33.1.1089.g2158813163f-goog
> >
>
>
> --
> Luiz Augusto von Dentz

Thanks,
Archie
diff mbox series

Patch

diff --git a/src/adapter.c b/src/adapter.c
index 6b12c9e793..3a3c957a6c 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3779,8 +3779,6 @@  static struct smp_ltk_info *get_ltk(GKeyFile *key_file, const char *peer,
 					uint8_t peer_type, const char *group)
 {
 	struct smp_ltk_info *ltk = NULL;
-	GError *gerr = NULL;
-	bool central;
 	char *key;
 	char *rand = NULL;
 
@@ -3836,12 +3834,6 @@  static struct smp_ltk_info *get_ltk(GKeyFile *key_file, const char *peer,
 									NULL);
 	ltk->ediv = g_key_file_get_integer(key_file, group, "EDiv", NULL);
 
-	central = g_key_file_get_boolean(key_file, group, "Master", &gerr);
-	if (gerr)
-		g_error_free(gerr);
-	else
-		ltk->central = central;
-
 	ltk->is_blocked = is_blocked_key(HCI_BLOCKED_KEY_TYPE_LTK,
 								ltk->val);
 
@@ -5904,7 +5896,6 @@  static void convert_ltk_entry(GKeyFile *key_file, void *value)
 	g_free(str);
 
 	g_key_file_set_integer(key_file, "LongTermKey", "Authenticated", auth);
-	g_key_file_set_integer(key_file, "LongTermKey", "Master", central);
 	g_key_file_set_integer(key_file, "LongTermKey", "EncSize", enc_size);
 	g_key_file_set_integer(key_file, "LongTermKey", "EDiv", ediv);
 
@@ -8445,9 +8436,6 @@  static void store_ltk_group(struct btd_adapter *adapter, const bdaddr_t *peer,
 		g_error_free(gerr);
 	}
 
-	/* Old files may contain this so remove it in case it exists */
-	g_key_file_remove_key(key_file, "LongTermKey", "Master", NULL);
-
 	for (i = 0; i < 16; i++)
 		sprintf(key_str + (i * 2), "%2.2X", key[i]);