Is there a difference between the UUIDs created by calling UuidCreate and CoCreateGuid from the Win32 API?
The documentation says CoCreateGuid just calls UuidCreate, but the remarks in the documentation are quite different.
Only CoCreateGuid specifically mentions the use case:
[...] absolutely unique number that you will use as a persistent identifier in a distributed environment.
While Uuidcreate is instead focused on explaining the non-traceability:
[...] generates a UUID that cannot be traced to the ethernet address of the computer on which it was generated. It also cannot be associated with other UUIDs created on the same computer.
I assume the difference might just be historic, the doc mentions UuidCreate was changed from MAC-based version 1 UUIDs to random non-traceable version 4 some time in the past for security reasons. UuidCreateSequential was introduced if MAC based UUIDs are needed.
If so, the return values of UuidCreate (RPC_S_OK, RPC_S_UUID_LOCAL_ONLY, RPC_S_UUID_NO_ADDRESS) are nowadays just included for legacy compatibility, and basically obsolete?
Does anyone know more about this? As far as I can tell, there is no difference.
CodePudding user response:
CoCreateGuid calls UuidCreate.
UuidCreate
used to be the only function, and it was a type 1 (mac datetime) uuid.
Later, after a kid was arrested after software he wrote was traced back to his laptop because of his MAC address, Windows Vista changed UuidCreate
to be a type 4 (random) uuid.
And Microsoft added UuidCreateSequential
as the legacy type 1 uuid.
For security reasons, UuidCreate was modified so that it no longer uses a machine's MAC address to generate UUIDs. UuidCreateSequential was introduced to allow creation of UUIDs using the MAC address of a machine's Ethernet card.