hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/lib/uuid.c
....@@ -1,17 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Unified UUID/GUID definition
34 *
45 * Copyright (C) 2009, 2016 Intel Corp.
56 * Huang Ying <ying.huang@intel.com>
6
- *
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License version
9
- * 2 as published by the Free Software Foundation;
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
157 */
168
179 #include <linux/kernel.h>
....@@ -48,6 +40,16 @@
4840 }
4941 EXPORT_SYMBOL(generate_random_uuid);
5042
43
+void generate_random_guid(unsigned char guid[16])
44
+{
45
+ get_random_bytes(guid, 16);
46
+ /* Set GUID version to 4 --- truly random generation */
47
+ guid[7] = (guid[7] & 0x0F) | 0x40;
48
+ /* Set the GUID variant to DCE */
49
+ guid[8] = (guid[8] & 0x3F) | 0x80;
50
+}
51
+EXPORT_SYMBOL(generate_random_guid);
52
+
5153 static void __uuid_gen_common(__u8 b[16])
5254 {
5355 prandom_bytes(b, 16);