1UUID_GENERATE(3) Libuuid API UUID_GENERATE(3)
2
3
4
6 uuid_generate, uuid_generate_random, uuid_generate_time, uuid_gener‐
7 ate_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, size_t len);
17 void uuid_generate_sha1(uuid_t out, const uuid_t ns, const char *name, size_t len);
18
20 The uuid_generate function creates a new universally unique identifier
21 (UUID). The uuid will be generated based on high-quality randomness
22 from /dev/urandom, if available. If it is not available, then
23 uuid_generate will use an alternative algorithm which uses the current
24 time, the local ethernet MAC address (if available), and random data
25 generated using a pseudo-random generator.
26
27 The uuid_generate_random function forces the use of the all-random UUID
28 format, even if a high-quality random number generator (i.e.,
29 /dev/urandom) is not available, in which case a pseudo-random generator
30 will be substituted. Note that the use of a pseudo-random generator
31 may compromise the uniqueness of UUIDs generated in this fashion.
32
33 The uuid_generate_time function forces the use of the alternative algo‐
34 rithm which uses the current time and the local ethernet MAC address
35 (if available). This algorithm used to be the default one used to gen‐
36 erate UUIDs, but because of the use of the ethernet MAC address, it can
37 leak information about when and where the UUID was generated. This can
38 cause privacy problems in some applications, so the uuid_generate func‐
39 tion only uses this algorithm if a high-quality source of randomness is
40 not available. To guarantee uniqueness of UUIDs generated by concur‐
41 rently running processes, the uuid library uses a global clock state
42 counter (if the process has permissions to gain exclusive access to
43 this file) and/or the uuidd daemon, if it is running already or can be
44 spawned by the process (if installed and the process has enough permis‐
45 sions to run it). If neither of these two synchronization mechanisms
46 can be used, it is theoretically possible that two concurrently running
47 processes obtain the same UUID(s). To tell whether the UUID has been
48 generated in a safe manner, use uuid_generate_time_safe.
49
50 The uuid_generate_time_safe function is similar to uuid_generate_time,
51 except that it returns a value which denotes whether any of the syn‐
52 chronization mechanisms (see above) has been used.
53
54 The UUID is 16 bytes (128 bits) long, which gives approximately
55 3.4x10^38 unique values (there are approximately 10^80 elementary par‐
56 ticles in the universe according to Carl Sagan's Cosmos). The new UUID
57 can reasonably be considered unique among all UUIDs created on the
58 local system, and among UUIDs created on other systems in the past and
59 in the future.
60
61 The uuid_generate_md5 and uuid_generate_sha1 functions generate an MD5
62 and SHA1 hashed (predictable) UUID based on a well-known UUID providing
63 the namespace and an arbitrary binary string. The UUIDs conform to V3
64 and V5 UUIDs per RFC-4122.
65
67 The newly created UUID is returned in the memory location pointed to by
68 out. uuid_generate_time_safe returns zero if the UUID has been gener‐
69 ated in a safe manner, -1 otherwise.
70
72 This library generates UUIDs compatible with OSF DCE 1.1, and hash
73 based UUIDs V3 and V5 compatible with RFC-4122.
74
76 Theodore Y. Ts'o
77
79 uuidgen(1), uuid(3), uuid_clear(3), uuid_compare(3), uuid_copy(3),
80 uuid_is_null(3), uuid_parse(3), uuid_time(3), uuid_unparse(3), uuidd(8)
81
83 libuuid is part of the util-linux package since version 2.15.1 and is
84 available from https://www.kernel.org/pub/linux/utils/util-linux/.
85
86
87
88util-linux May 2009 UUID_GENERATE(3)