2019-06-19 16:25:34

by Pavel Machek

[permalink] [raw]
Subject: (Small) bias in generation of random passkeys for pairing

Hi!

There's a (small) bias in passkey generation in bluetooth:

get_random_bytes(&passkey, sizeof(passkey));
passkey %= 1000000;
put_unaligned_le32(passkey, smp->tk);

(there are at least two places doing this).

All passkeys are not of same probability, passkey "000000" is more
probable than "999999", but difference is small.

Do we care?
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (533.00 B)
signature.asc (188.00 B)
Digital signature
Download all attachments

2019-06-20 12:01:18

by Stefan Seyfried

[permalink] [raw]
Subject: Re: (Small) bias in generation of random passkeys for pairing

Hi Pavel,

Am 19.06.19 um 18:24 schrieb Pavel Machek:
> Hi!
>
> There's a (small) bias in passkey generation in bluetooth:
>
> get_random_bytes(&passkey, sizeof(passkey));
> passkey %= 1000000;
> put_unaligned_le32(passkey, smp->tk);
>
> (there are at least two places doing this).
>
> All passkeys are not of same probability, passkey "000000" is more
> probable than "999999", but difference is small.

It is slightly different IMHO.

Unsigned 32bits passkey assumed (and all users I found were u32),
the passkeys "000000" to "967295" are slightly more probable than
"967296" to "999999".

If my math is right (which I doubt), the difference in probability
for both entities is 4294:4293.

> Do we care?

I, personally, don't (yet).
But then, I'm not a real security expert.

Have fun,
--
Stefan Seyfried

"For a successful technology, reality must take precedence over
public relations, for nature cannot be fooled." -- Richard Feynman