libuuid: fix name-based UUIDs
The current version is not fully compatible with RFC4122. It
incorrectly encodes UUID variant
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
where M is UUID version and N is UUID variant.
$ python -c "import uuid ; print(uuid.uuid5(uuid.UUID(int=0), 'foo'))"
aa752cea-8222-5bc8-acd9-
555b090c0ccb
^^
Old version:
$ uuidgen --namespace
00000000-0000-0000-0000-
000000000000 --name 'foo' --sha1
aa752cea-8222-5bc8-8cd9-
555b090c0ccb
^^
Fixed version:
./uuidgen --namespace
00000000-0000-0000-0000-
000000000000 --name 'foo' --sha1;
aa752cea-8222-5bc8-acd9-
555b090c0ccb
^^
The patch uses uuid_unpack and uuid_pack. It makes code more readable
and allow to access proper octens. The same way we already use for
time and random based UUIDs.
Addresses: https://github.com/karelzak/util-linux/issues/683
Signed-off-by: Karel Zak <kzak@redhat.com>