| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Unified UUID/GUID definition |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2009, 2016 Intel Corp. |
|---|
| 5 | 6 | * 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. |
|---|
| 15 | 7 | */ |
|---|
| 16 | 8 | |
|---|
| 17 | 9 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 48 | 40 | } |
|---|
| 49 | 41 | EXPORT_SYMBOL(generate_random_uuid); |
|---|
| 50 | 42 | |
|---|
| 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 | + |
|---|
| 51 | 53 | static void __uuid_gen_common(__u8 b[16]) |
|---|
| 52 | 54 | { |
|---|
| 53 | 55 | prandom_bytes(b, 16); |
|---|