|
NAMEOSSP uuid - Universally Unique Identifier VERSIONOSSP uuid 1.6.2 (04-Jul-2008) DESCRIPTIONOSSP uuid is a ISO-C:1999 application programming interface (API) and corresponding command line interface (CLI) for the generation of DCE 1.1, ISO/IEC 11578:1996 and IETF RFC-4122 compliant Universally Unique Identifier (UUID). It supports DCE 1.1 variant UUIDs of version 1 (time and node based), version 3 (name based, MD5), version 4 (random number based) and version 5 (name based, SHA-1). Additional API bindings are provided for the languages ISO-C++:1998, Perl:5 and PHP:4/5. Optional backward compatibility exists for the ISO-C DCE-1.1 and Perl Data::UUID APIs. UUIDs are 128 bit numbers which are intended to have a high likelihood of uniqueness over space and time and are computationally difficult to guess. They are globally unique identifiers which can be locally generated without contacting a global registration authority. UUIDs are intended as unique identifiers for both mass tagging objects with an extremely short lifetime and to reliably identifying very persistent objects across a network. This is the ISO-C application programming interface (API) of
OSSP uuid.
UUID Binary Representation According to the DCE 1.1, ISO/IEC 11578:1996 and IETF RFC-4122 standards, a DCE 1.1 variant UUID is a 128 bit number defined out of 7 fields, each field a multiple of an octet in size and stored in network byte order: [4]
version
-->| |<--
| |
| | [16]
[32] [16] | |time_hi
time_low time_mid | _and_version
|<---------------------------->||<------------>||<------------>|
| MSB || || | |
| / || || | |
|/ || || | |
+------++------++------++------++------++------++------++------+~~
| 15 || 14 || 13 || 12 || 11 || 10 |####9 || 8 |
| MSO || || || || || |#### || |
+------++------++------++------++------++------++------++------+~~
7654321076543210765432107654321076543210765432107654321076543210
~~+------++------++------++------++------++------++------++------+
##* 7 || 6 || 5 || 4 || 3 || 2 || 1 || 0 |
##* || || || || || || || LSO |
~~+------++------++------++------++------++------++------++------+
7654321076543210765432107654321076543210765432107654321076543210
| | || || /|
| | || || / |
| | || || LSB |
|<---->||<---->||<-------------------------------------------->|
|clk_seq clk_seq node
|_hi_res _low [48]
|[5-6] [8]
| |
-->| |<--
variant
[2-3]
An example of a UUID binary representation is the octet stream
0xF8 0x1D 0x4F 0xAE 0x7D 0xEC 0x11
0xD0 0xA7 0x65 0x00 0xA0 0xC9 0x1E 0x6B 0xF6.
The binary representation format is exactly what the OSSP uuid API
functions uuid_import() and uuid_export() deal with under
UUID_FMT_BIN.
UUID ASCII String Representation According to the DCE 1.1, ISO/IEC 11578:1996 and IETF RFC-4122 standards, a DCE 1.1 variant UUID is represented as an ASCII string consisting of 8 hexadecimal digits followed by a hyphen, then three groups of 4 hexadecimal digits each followed by a hyphen, then 12 hexadecimal digits. Formally, the string representation is defined by the following grammar: uuid = <time_low> "-"
<time_mid> "-"
<time_high_and_version> "-"
<clock_seq_high_and_reserved>
<clock_seq_low> "-"
<node>
time_low = 4*<hex_octet>
time_mid = 2*<hex_octet>
time_high_and_version = 2*<hex_octet>
clock_seq_high_and_reserved = <hex_octet>
clock_seq_low = <hex_octet>
node = 6*<hex_octet>
hex_octet = <hex_digit> <hex_digit>
hex_digit = "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"
|"a"|"b"|"c"|"d"|"e"|"f"
|"A"|"B"|"C"|"D"|"E"|"F"
An example of a UUID string representation is the ASCII string "f81d4fae-7dec-11d0-a765-00a0c91e6bf6". The string representation format is exactly what the OSSP uuid API functions uuid_import() and uuid_export() deal with under UUID_FMT_STR. Notice: a corresponding URL can be generated out of a ASCII string
representation of an UUID by prefixing with
"urn:uuid:" as in
"urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6".
UUID Single Integer Value Representation According to the ISO/IEC 11578:1996 and ITU-T Rec. X.667 standards, a DCE 1.1 variant UUID can be also represented as a single integer value consisting of a decimal number with up to 39 digits. An example of a UUID single integer value representation is the decimal number "329800735698586629295641978511506172918". The string representation format is exactly what the OSSP uuid API functions uuid_import() and uuid_export() deal with under UUID_FMT_SIV. Notice: a corresponding ISO OID can be generated under the
"{joint-iso-itu-t(2) uuid(25)}" arc out of a single integer
value representation of a UUID by prefixing with
"2.25.". An example OID is
"2.25.329800735698586629295641978511506172918".
Additionally, an URL can be generated by further prefixing with
"urn:oid:" as in
"urn:oid:2.25.329800735698586629295641978511506172918".
UUID Variants and Versions A UUID has a variant and version. The variant defines the layout of the UUID. The version defines the content of the UUID. The UUID variant supported in OSSP uuid is the DCE 1.1 variant only. The DCE 1.1 UUID variant versions supported in OSSP uuid are:
UUID Uniqueness Version 1 UUIDs are guaranteed to be unique through combinations of hardware addresses, time stamps and random seeds. There is a reference in the UUID to the hardware (MAC) address of the first network interface card (NIC) on the host which generated the UUID -- this reference is intended to ensure the UUID will be unique in space as the MAC address of every network card is assigned by a single global authority (IEEE) and is guaranteed to be unique. The next component in a UUID is a timestamp which, as clock always (should) move forward, will be unique in time. Just in case some part of the above goes wrong (the hardware address cannot be determined or the clock moved steps backward), there is a random clock sequence component placed into the UUID as a "catch-all" for uniqueness. Version 3 and version 5 UUIDs are guaranteed to be inherently globally unique if the combination of namespace and name used to generate them is unique. Version 4 UUIDs are not guaranteed to be globally unique, because
they are generated out of locally gathered pseudo-random numbers only.
Nevertheless there is still a high likelihood of uniqueness over space and
time and that they are computationally difficult to guess.
Nil UUID There is a special Nil UUID consisting of all octets set to zero in the binary representation. It can be used as a special UUID value which does not conflict with real UUIDs. APPLICATION PROGRAMMING INTERFACEThe ISO-C Application Programming Interface (API) of OSSP
uuid consists of the following components.
CONSTANTS The following constants are provided:
FUNCTIONS The following functions are provided:
The "ns:XXX" are names of pre-defined name-space UUIDs for use in the generation of DCE 1.1 version 3 and version 5 UUIDs.
EXAMPLEThe following shows an example usage of the API. Error handling is omitted for code simplification and has to be re-added for production code. /* generate a DCE 1.1 v1 UUID from system environment */
char *uuid_v1(void)
{
uuid_t *uuid;
char *str;
uuid_create(&uuid);
uuid_make(uuid, UUID_MAKE_V1);
str = NULL;
uuid_export(uuid, UUID_FMT_STR, &str, NULL);
uuid_destroy(uuid);
return str;
}
/* generate a DCE 1.1 v3 UUID from an URL */
char *uuid_v3(const char *url)
{
uuid_t *uuid;
uuid_t *uuid_ns;
char *str;
uuid_create(&uuid);
uuid_create(&uuid_ns);
uuid_load(uuid_ns, "ns:URL");
uuid_make(uuid, UUID_MAKE_V3, uuid_ns, url);
str = NULL;
uuid_export(uuid, UUID_FMT_STR, &str, NULL);
uuid_destroy(uuid_ns);
uuid_destroy(uuid);
return str;
}
SEE ALSOThe following are references to UUID documentation and specifications:
HISTORYOSSP uuid was implemented in January 2004 by Ralf S. Engelschall <rse@engelschall.com>. It was prompted by the use of UUIDs in the OSSP as and OpenPKG projects. It is a clean room implementation intended to be strictly standards compliant and maximum portable. SEE ALSOuuid(1), uuid-config(1), OSSP::uuid(3).
|