WPS: Add option for using random UUID

If the uuid configuration parameter is not set, wpa_supplicant generates
an UUID automatically to allow WPS operations to proceed. This was
previously always using an UUID generated from the MAC address. This
commit adds an option to use a random UUID instead. The type of the
automatically generated UUID is set with the auto_uuid parameter: 0 =
based on MAC address (default; old behavior), 1 = random UUID.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2017-04-13 13:22:56 +03:00 committed by Jouni Malinen
parent c27a6c6252
commit 183d3924cf
8 changed files with 49 additions and 1 deletions

View file

@ -9,6 +9,7 @@
#include "includes.h"
#include "common.h"
#include "crypto/sha256.h"
#include "uuid.h"
int uuid_str2bin(const char *str, u8 *bin)
@ -69,3 +70,27 @@ int is_nil_uuid(const u8 *uuid)
return 0;
return 1;
}
int uuid_random(u8 *uuid)
{
struct os_time t;
u8 hash[SHA256_MAC_LEN];
/* Use HMAC-SHA256 and timestamp as context to avoid exposing direct
* os_get_random() output in the UUID field. */
os_get_time(&t);
if (os_get_random(uuid, UUID_LEN) < 0 ||
hmac_sha256(uuid, UUID_LEN, (const u8 *) &t, sizeof(t), hash) < 0)
return -1;
os_memcpy(uuid, hash, UUID_LEN);
/* Version: 4 = random */
uuid[6] = (4 << 4) | (uuid[6] & 0x0f);
/* Variant specified in RFC 4122 */
uuid[8] = 0x80 | (uuid[8] & 0x3f);
return 0;
}

View file

@ -14,5 +14,6 @@
int uuid_str2bin(const char *str, u8 *bin);
int uuid_bin2str(const u8 *bin, char *str, size_t max_len);
int is_nil_uuid(const u8 *uuid);
int uuid_random(u8 *uuid);
#endif /* UUID_H */