Test vectors for version 5 UUID generation algorithm (hash conversion to guid)?

I am trying to find some test vectors to test my implementation of RFC 4122 UUID version 5 .

4.3 Algorithm for creating UUIDs based on name

Version 3 of the UUID is designed to host the MD5 hash in the GUID.

Version 5 of the UUID is designed to host the SHA1 hash file in a GUID.

RFC has an example implementation in C:

void uuid_create_sha1_from_name( uuid_t *uuid, /* resulting UUID */ uuid_t nsid, /* UUID of the namespace */ void *name, /* the name from which to generate a UUID */ int namelen /* the length of the name */ ); 

I wrote my own implementation in the language I use. Given the number of headaches caused by the endian vs network order, I'm sure my implementation is wrong.

I need some sample data, for example:

 uuid = NameToGUID( {6ba7b811-9dad-11d1-80b4-00c04fd430c8}, //Namespace_URL "https://stackoverflow.com/questions/5515880"); //a url CheckEquals( {8ABAD867-F515-3CF6-BB62-5F0C88B3BB11}, //expected uuid uuid); 

see also

+4
source share
1 answer

A German Wikipedia entry for UUID provided an example for www.example.org :

 6ba7b810-9dad-11d1-80b4-00c04fd430c8 // namespace UUID www.example.org // url 74738ff5-5367-5958-9aee-98fffdcd1876 // expected UUID 

In addition, Java offers a UUID class that can be used to generate test data . (EDIT: This seems to only be able to generate versions 1,2,3 and 4 UUIDs.)

There, the answer in your question mentions some libraries that can generate UUIDs with version 3/5:

It seems that there are several libraries out there for generating version 3/5 of the UUID, including the python uuid module boost.uuid (C ++) and OSSP UUID. (I have not searched for any .net ones)


OP Edit

The example in DE wikipedia has a slight error:

  • he claims to use the DNS name www.example.org
  • given ASCII byte sequence for www.example.com
  • but the SHA1 hash uses www.example.org .

I would edit the page to change the sequence of bytes from
0x63 0x6f 0x6d "com"
for the image 0x6f 0x72 0x67 "org"

but I don’t speak German, I don’t want to create an account, and I'm just too lazy

Example comes down to

 Namespace_DNS: {6ba7b810-9dad-11d1-80b4-00c04fd430c8} Name: "www.example.org" 

combine byte sequences:

 Bytes: 6b a7 b8 10 9d ad 11 d1 80 b4 00 c0 4f d4 30 c8 {6ba7b810-9dad-11d1-80b4-00c04fd430c8} 77 77 77 2e 65 78 61 6d 70 6c 65 2e 6f 72 67 "www.example.org" 

Hash the byte sequence with SHA1 and copy most of it directly to the UUID:

 SHA1 Digest: 74738ff5 5367 e958 9aee98fffdcd187694028007 UUID (v5): 74738ff5-5367-5958-9aee-98fffdcd1876 ^ ^ 

And pay attention to the conversion of one of the nibbles to 5 (to indicate version 5).
And the upper 2 bits of another byte are set to binary 10xxxxxx .

+2
source

Source: https://habr.com/ru/post/1346260/


All Articles