1UUID_GENERATE(3) Programmer's Manual UUID_GENERATE(3)
2
3
4
6 uuid_generate, uuid_generate_random, uuid_generate_time,
7 uuid_generate_time_safe - create a new unique UUID value
8
10 #include <uuid.h>
11
12 void uuid_generate(uuid_t out);
13 void uuid_generate_random(uuid_t out);
14 void uuid_generate_time(uuid_t out);
15 int uuid_generate_time_safe(uuid_t out);
16 void uuid_generate_md5(uuid_t out, const uuid_t ns, const char *name,
17 size_t len);
18 void uuid_generate_sha1(uuid_t out, const uuid_t ns, const char *name,
19 size_t len);
20
22 The uuid_generate() function creates a new universally unique
23 identifier (UUID). The uuid will be generated based on high-quality
24 randomness from getrandom(2), /dev/urandom, or /dev/random if
25 available. If it is not available, then uuid_generate() will use an
26 alternative algorithm which uses the current time, the local ethernet
27 MAC address (if available), and random data generated using a
28 pseudo-random generator.
29
30 The uuid_generate_random() function forces the use of the all-random
31 UUID format, even if a high-quality random number generator is not
32 available, in which case a pseudo-random generator will be substituted.
33 Note that the use of a pseudo-random generator may compromise the
34 uniqueness of UUIDs generated in this fashion.
35
36 The uuid_generate_time() function forces the use of the alternative
37 algorithm which uses the current time and the local ethernet MAC
38 address (if available). This algorithm used to be the default one used
39 to generate UUIDs, but because of the use of the ethernet MAC address,
40 it can leak information about when and where the UUID was generated.
41 This can cause privacy problems in some applications, so the
42 uuid_generate() function only uses this algorithm if a high-quality
43 source of randomness is not available. To guarantee uniqueness of UUIDs
44 generated by concurrently running processes, the uuid library uses a
45 global clock state counter (if the process has permissions to gain
46 exclusive access to this file) and/or the uuidd(8) daemon, if it is
47 running already or can be spawned by the process (if installed and the
48 process has enough permissions to run it). If neither of these two
49 synchronization mechanisms can be used, it is theoretically possible
50 that two concurrently running processes obtain the same UUID(s). To
51 tell whether the UUID has been generated in a safe manner, use
52 uuid_generate_time_safe.
53
54 The uuid_generate_time_safe() function is similar to
55 uuid_generate_time(), except that it returns a value which denotes
56 whether any of the synchronization mechanisms (see above) has been
57 used.
58
59 The UUID is 16 bytes (128 bits) long, which gives approximately
60 3.4x10^38 unique values (there are approximately 10^80 elementary
61 particles in the universe according to Carl Sagan’s Cosmos). The new
62 UUID can reasonably be considered unique among all UUIDs created on the
63 local system, and among UUIDs created on other systems in the past and
64 in the future.
65
66 The uuid_generate_md5() and uuid_generate_sha1() functions generate an
67 MD5 and SHA1 hashed (predictable) UUID based on a well-known UUID
68 providing the namespace and an arbitrary binary string. The UUIDs
69 conform to V3 and V5 UUIDs per RFC-4122
70 <https://tools.ietf.org/html/rfc4122>.
71
73 The newly created UUID is returned in the memory location pointed to by
74 out. uuid_generate_time_safe() returns zero if the UUID has been
75 generated in a safe manner, -1 otherwise.
76
78 This library generates UUIDs compatible with OSF DCE 1.1, and hash
79 based UUIDs V3 and V5 compatible with RFC-4122
80 <https://tools.ietf.org/html/rfc4122>.
81
83 Theodore Y. Ts’o
84
86 uuidgen(1), uuid(3), uuid_clear(3), uuid_compare(3), uuid_copy(3),
87 uuid_is_null(3), uuid_parse(3), uuid_time(3), uuid_unparse(3), uuidd(8)
88
90 For bug reports, use the issue tracker at
91 https://github.com/util-linux/util-linux/issues.
92
94 The libuuid library is part of the util-linux package since version
95 2.15.1. It can be downloaded from Linux Kernel Archive
96 <https://www.kernel.org/pub/linux/utils/util-linux/>.
97
98
99
100util-linux 2.38 2022-02-17 UUID_GENERATE(3)