aboutsummaryrefslogtreecommitdiffstats
path: root/lib/uuid.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/uuid.c')
-rw-r--r--lib/uuid.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/uuid.c b/lib/uuid.c
index b6a1edb61d87..e309b4c5be3d 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -40,9 +40,19 @@ void generate_random_uuid(unsigned char uuid[16])
}
EXPORT_SYMBOL(generate_random_uuid);
+void generate_random_guid(unsigned char guid[16])
+{
+ get_random_bytes(guid, 16);
+ /* Set GUID version to 4 --- truly random generation */
+ guid[7] = (guid[7] & 0x0F) | 0x40;
+ /* Set the GUID variant to DCE */
+ guid[8] = (guid[8] & 0x3F) | 0x80;
+}
+EXPORT_SYMBOL(generate_random_guid);
+
static void __uuid_gen_common(__u8 b[16])
{
- prandom_bytes(b, 16);
+ get_random_bytes(b, 16);
/* reversion 0b10 */
b[8] = (b[8] & 0x3F) | 0x80;
}