A Universally Unique IDentifier UUID URN Namespace
A Universally Unique IDentifier UUID URN Namespace
net/publication/215758035
CITATIONS READS
481 3,540
3 authors, including:
All content following this page was uploaded by Paul J. Leach on 29 May 2014.
Copyright Notice
Copyright © The Internet Society (2005). All Rights Reserved.
Abstract
This specification defines a Uniform Resource Name namespace for UUIDs (Universally Unique IDentifier),
also known as GUIDs (Globally Unique IDentifier). A UUID is 128 bits long, and can guarantee uniqueness
across space and time. UUIDs were originally used in the Apollo Network Computing System and later in
the Open Software Foundation's (OSF) Distributed Computing Environment (DCE), and then in Microsoft
Windows platforms.
This specification is derived from the DCE specification with the kind permission of the OSF (now known as
The Open Group). Information from earlier versions of the DCE specification have been incorporated into this
document.
RFC 4122 UUID URN July 2005
Table of Contents
1. Introduction.............................................................................................................................................................. 3
2. Motivation.................................................................................................................................................................4
4. Specification..............................................................................................................................................................7
4.1. Format................................................................................................................................................................... 7
4.1.1. Variant..............................................................................................................................................................7
4.1.2. Layout and Byte Order....................................................................................................................................7
4.1.3. Version............................................................................................................................................................. 8
4.1.4. Timestamp........................................................................................................................................................8
4.1.5. Clock Sequence............................................................................................................................................... 9
4.1.6. Node................................................................................................................................................................. 9
4.1.7. Nil UUID......................................................................................................................................................... 9
4.2. Algorithms for Creating a Time-Based UUID.................................................................................................... 9
4.2.1. Basic Algorithm...............................................................................................................................................9
[Link]. Reading Stable Storage.............................................................................................................................. 10
[Link]. System Clock Resolution........................................................................................................................... 10
[Link]. Writing Stable Storage............................................................................................................................... 10
[Link]. Sharing State Across Processes..................................................................................................................11
4.2.2. Generation Details......................................................................................................................................... 11
4.3. Algorithm for Creating a Name-Based UUID...................................................................................................11
4.4. Algorithms for Creating a UUID from Truly Random or Pseudo-Random Numbers.......................................12
4.5. Node IDs that Do Not Identify the Host........................................................................................................... 12
5. Community Considerations.................................................................................................................................. 14
6. Security Considerations........................................................................................................................................ 15
7. Acknowledgments.................................................................................................................................................. 16
8. Normative References........................................................................................................................................... 17
Authors' Addresses.....................................................................................................................................................22
1. Introduction
This specification defines a Uniform Resource Name namespace for UUIDs (Universally Unique IDentifier),
also known as GUIDs (Globally Unique IDentifier). A UUID is 128 bits long, and requires no central
registration process.
The information here is meant to be a concise guide for those wishing to implement services using UUIDs as
URNs. Nothing in this document should be construed to override the DCE standards that defined UUIDs.
There is an ITU-T Recommendation and ISO/IEC Standard [3] that are derived from earlier versions of this
document. Both sets of specifications have been aligned, and are fully technically compatible. In addition, a
global registration function is being provided by the Telecommunications Standardisation Bureau of ITU-T; for
details see <[Link]
2. Motivation
One of the main reasons for using UUIDs is that no centralized authority is required to administer them
(although one format uses IEEE 802 node identifiers, others do not). As a result, generation on demand can
be completely automated, and used for a variety of purposes. The UUID generation algorithm described here
supports very high allocation rates of up to 10 million per second per machine if necessary, so that they could
even be used as transaction IDs.
UUIDs are of a fixed size (128 bits) which is reasonably small compared to other alternatives. This lends
itself well to sorting, ordering, and hashing of all sorts, storing in databases, simple allocation, and ease of
programming in general.
Since UUIDs are unique and persistent, they make excellent Uniform Resource Names. The unique ability to
generate a new UUID without a registration process allows for UUIDs to be one of the URNs with the lowest
minting cost.
urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6
Generating a UUID does not require that a registration authority be contacted. One algorithm requires a
unique value over space for each generator. This value is typically an IEEE 802 MAC address, usually
already available on network-connected hosts. The address can be assigned from an address block
obtained from the IEEE registration authority. If no such address is available, or privacy concerns make its
use undesirable, Section 4.5 specifies two alternatives. Another approach is to use version 3 or version 4
UUIDs as defined below.
Process for identifier resolution:
Since UUIDs are not globally resolvable, this is not applicable.
Rules for Lexical Equivalence:
Consider each field of the UUID to be an unsigned integer as shown in the table in section Section 4.1.2.
Then, to compare a pair of UUIDs, arithmetically compare the corresponding fields from each UUID
in order of significance and according to their data type. Two UUIDs are equal if and only if all the
corresponding fields are equal.
As an implementation note, equality comparison can be performed on many systems by doing the
appropriate byte-order canonicalization, and then treating the two UUIDs as 128-bit unsigned integers.
UUIDs, as defined in this document, can also be ordered lexicographically. For a pair of UUIDs, the first
one follows the second if the most significant field in which the UUIDs differ is greater for the first UUID.
The second precedes the first if the most significant field in which the UUIDs differ is greater for the
second UUID.
Conformance with URN Syntax:
The string representation of a UUID is fully compatible with the URN syntax. When converting from a
bit-oriented, in-memory representation of a UUID into a URN, care must be taken to strictly adhere to the
byte order issues mentioned in the string representation section.
Validation mechanism:
Apart from determining whether the timestamp portion of the UUID is in the future and therefore not yet
assignable, there is no mechanism for determining whether a UUID is 'valid'.
Scope:
UUIDs are global in scope.
4. Specification
4.1. Format
The UUID format is 16 octets; some bits of the eight octet variant field specified below determine finer
structure.
4.1.1. Variant
The variant field determines the layout of the UUID. That is, the interpretation of all other bits in the UUID
depends on the setting of the bits in the variant field. As such, it could more accurately be called a type field;
we retain the original term for compatibility. The variant field consists of a variable number of the most
significant bits of octet 8 of the UUID.
The following table lists the contents of the variant field, where the letter "x" indicates a "don't-care" value.
Interoperability, in any form, with variants other than the one defined here is not guaranteed, and is not likely to
be an issue in practice.
In the absence of explicit application or presentation protocol specification to the contrary, a UUID is encoded
as a 128-bit object, as follows:
The fields are encoded as 16 octets, with the sizes and order of the fields defined above, and with each field
encoded with the Most Significant Byte first (known as network byte order). Note that the field names,
particularly for multiplexed fields, follow historical practice.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| time_low |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| time_mid | time_hi_and_version |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|clk_seq_hi_res | clk_seq_low | node (0-1) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| node (2-5) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4.1.3. Version
The version number is in the most significant 4 bits of the time stamp (bits 4 through 7 of the
time_hi_and_version field).
The following table lists the currently-defined versions for this UUID variant.
The version is more accurately a sub-type; again, we retain the term for compatibility.
4.1.4. Timestamp
The timestamp is a 60-bit value. For UUID version 1, this is represented by Coordinated Universal Time (UTC)
as a count of 100-nanosecond intervals since [Link].00, 15 October 1582 (the date of Gregorian reform to the
Christian calendar).
For systems that do not have UTC available, but do have the local time, they may use that instead of UTC, as
long as they do so consistently throughout the system. However, this is not recommended since generating the
UTC from local time only needs a time zone offset.
For UUID version 3 or 5, the timestamp is a 60-bit value constructed from a name as described in Section 4.3.
For UUID version 4, the timestamp is a randomly or pseudo-randomly generated 60-bit value, as described in
Section 4.4.
4.1.6. Node
For UUID version 1, the node field consists of an IEEE 802 MAC address, usually the host address. For
systems with multiple IEEE 802 addresses, any available one can be used. The lowest addressed octet (octet
number 10) contains the global/local bit and the unicast/multicast bit, and is the first octet of the address
transmitted on an 802.3 LAN.
For systems with no IEEE address, a randomly or pseudo-randomly generated value may be used; see
Section 4.5. The multicast bit must be set in such addresses, in order that they will never conflict with addresses
obtained from network cards.
For UUID version 3 or 5, the node field is a 48-bit value constructed from a name as described in Section 4.3.
For UUID version 4, the node field is a randomly or pseudo-randomly generated 48-bit value as described in
Section 4.4.
• Get the current time as a 60-bit count of 100-nanosecond intervals since [Link].00, 15 October 1582.
• Get the current node ID.
• If the state was unavailable (e.g., non-existent or corrupted), or the saved node ID is different than the
current node ID, generate a random clock sequence value.
• If the state was available, but the saved time stamp is later than the current timestamp, increment the clock
sequence value.
• Save the state (current time stamp, clock sequence, and node ID) back to the stable store.
• Release the global lock.
• Format a UUID from the current timestamp, clock sequence, and node ID values according to the steps in
Section 4.2.2.
If UUIDs do not need to be frequently generated, the above algorithm may be perfectly adequate. For higher
performance requirements, however, issues with the basic algorithm include:
• Reading the state from stable storage each time is inefficient.
• The resolution of the system clock may not be 100-nanoseconds.
• Writing the state to stable storage each time is inefficient.
• Sharing the state across process boundaries may be inefficient.
Each of these issues can be addressed in a modular fashion by local improvements in the functions that read
and write the state and read the clock. We address each of them in turn in the following sections.
shared volatile copy of the state needs to be updated. Furthermore, if the time stamp value in stable store is in
the future by less than the typical time it takes the system to reboot, a crash will not cause a reinitialization of
the clock sequence.
• Allocate a UUID to use as a "name space ID" for all UUIDs generated from names in that name space; see
Appendix C for some pre-defined values.
• Choose either MD5 [4] or SHA-1 [8] as the hash algorithm; If backward compatibility is not an issue,
SHA-1 is preferred.
• Convert the name to a canonical sequence of octets (as defined by the standards or conventions of its name
space); put the name space ID in network byte order.
• Compute the hash of the name space ID concatenated with the name.
• Set octets zero through 3 of the time_low field to octets zero through 3 of the hash.
• Set octets zero and one of the time_mid field to octets 4 and 5 of the hash.
• Set octets zero and one of the time_hi_and_version field to octets 6 and 7 of the hash.
• Set the four most significant bits (bits 12 through 15) of the time_hi_and_version field to the appropriate 4-
bit version number from Section 4.1.3.
• Set the clock_seq_hi_and_reserved field to octet 8 of the hash.
• Set the two most significant bits (bits 6 and 7) of the clock_seq_hi_and_reserved to zero and one,
respectively.
• Set the clock_seq_low field to octet 9 of the hash.
• Set octets zero through five of the node field to octets 10 through 15 of the hash.
• Convert the resulting UUID to local byte order.
4.4. Algorithms for Creating a UUID from Truly Random or Pseudo-Random Numbers
The version 4 UUID is meant for generating UUIDs from truly-random or pseudo-random numbers.
The algorithm is as follows:
• Set the two most significant bits (bits 6 and 7) of the clock_seq_hi_and_reserved to zero and one,
respectively.
• Set the four most significant bits (bits 12 through 15) of the time_hi_and_version field to the 4-bit version
number from Section 4.1.3.
• Set all the other bits to randomly (or pseudo-randomly) chosen values.
See Section 4.5 for a discussion on random numbers.
The exact algorithm to generate a node ID using these data is system specific, because both the data available
and the functions to obtain them are often very system specific. A generic approach, however, is to accumulate
as many sources as possible into a buffer, use a message digest such as MD5 [4] or SHA-1 [8], take an
arbitrary 6 bytes from the hash value, and set the multicast bit as described above.
5. Community Considerations
The use of UUIDs is extremely pervasive in computing. They comprise the core identifier infrastructure for
many operating systems (Microsoft Windows) and applications (the Mozilla browser) and in many cases,
become exposed to the Web in many non-standard ways. This specification attempts to standardize that
practice as openly as possible and in a way that attempts to benefit the entire Internet.
6. Security Considerations
Do not assume that UUIDs are hard to guess; they should not be used as security capabilities (identifiers whose
mere possession grants access), for example. A predictable random number source will exacerbate the situation.
Do not assume that it is easy to determine if a UUID has been slightly transposed in order to redirect a
reference to another object. Humans do not have the ability to easily check the integrity of a UUID by simply
glancing at it.
Distributed applications generating UUIDs at a variety of hosts must be willing to rely on the random number
source at all hosts. If this is not feasible, the namespace variant should be used.
7. Acknowledgments
This document draws heavily on the OSF DCE specification for UUIDs. Ted Ts'o provided helpful comments,
especially on the byte ordering section which we mostly plagiarized from a proposed wording he supplied (all
errors in that section are our responsibility, however).
We are also grateful to the careful reading and bit-twiddling of Ralf S. Engelschall, John Larmouth, and Paul
Thorpe. Professor Larmouth was also invaluable in achieving coordination with ISO/IEC.
8. Normative References
[1] Zahn, L., Dineen, T., and P. Leach, "Network Computing Architecture", ISBN 0-13-611674-4,
January 1990.
[2] "DCE: Remote Procedure Call", Open Group CAE Specification C309, ISBN 1-85912-041-5, August 1994.
[3] ISO/IEC 9834-8:2004 Information Technology, "Procedures for the operation of OSI Registration
Authorities: Generation and registration of Universally Unique Identifiers (UUIDs) and their use as ASN.1
Object Identifier components", ITU-T Rec. X.687, 2004.
[4] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321, April 1992.
[5] Eastlake, D., Schiller, J., and S. Crocker, "Randomness Requirements for Security", BCP 106, RFC 4086,
June 2005.
[6] Moats, R., "URN Syntax", RFC 2141, May 1997.
[7] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", RFC 2234,
November 1997.
[8] National Institute of Standards and Technology, "Secure Hash Standard", FIPS PUB 180-1, April 1995,
<[Link]
copyrt.h
/*
** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
** Digital Equipment Corporation, Maynard, Mass.
** Copyright (c) 1998 Microsoft.
** To anyone who acknowledges that this file is provided "AS IS"
** without any express or implied warranty: permission to use, copy,
** modify, and distribute this file for any purpose is hereby
** granted without fee, provided that the above copyright notices and
** this notice appears in all source code copies, and that none of
** the names of Open Software Foundation, Inc., Hewlett-Packard
** Company, or Digital Equipment Corporation be used in advertising
** or publicity pertaining to distribution of the software without
** specific, written prior permission. Neither Open Software
** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital
** Equipment Corporation makes any representations about the suitability
** of this software for any purpose.
*/
uuid.h
#include "copyrt.h"
#undef uuid_t
typedef struct {
unsigned32 time_low;
unsigned16 time_mid;
unsigned16 time_hi_and_version;
unsigned8 clock_seq_hi_and_reserved;
unsigned8 clock_seq_low;
byte node[6];
} uuid_t;
Intellectual Property
The IETF takes no position regarding the validity or scope of any Intellectual Property Rights or other rights
that might be claimed to pertain to the implementation or use of the technology described in this document or
the extent to which any license under such rights might or might not be available; nor does it represent that
it has made any independent effort to identify any such rights. Information on the procedures with respect to
rights in RFC documents can be found in BCP 78 and BCP 79.
Copies of IPR disclosures made to the IETF Secretariat and any assurances of licenses to be made available, or
the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by
implementers or users of this specification can be obtained from the IETF on-line IPR repository at [Link]
.[Link]/ipr1.
The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications,
or other proprietary rights that may cover technology that may be required to implement this standard. Please
address the information to the IETF at [email protected].
Acknowledgment
Funding for the RFC Editor function is currently provided by the Internet Society.
1
[Link]
2
[Link]