+/*
+ * Create a version 3 UUID from a unique "name" in the given "name space".
+ * Version 3 UUID are derived using "name" via MD5 checksum.
+ *
+ * Parameters:
+ * result_uuid - resulting UUID.
+ * namespace - namespace in which given name exists and UUID should be created.
+ * name - unique string used to create version 3 UUID.
+ * namelen - length of the name string.
+ */
+static void
+uuid_create_md5_from_name(uuid_t result_uuid, const uuid_t namespace, const void *name, int namelen)
+{
+ MD5_CTX c;
+
+ MD5_Init(&c);
+ MD5_Update(&c, namespace, sizeof(uuid_t));
+ MD5_Update(&c, name, namelen);
+ MD5_Final(result_uuid, &c);
+
+ result_uuid[6] = (result_uuid[6] & 0x0F) | 0x30;
+ result_uuid[8] = (result_uuid[8] & 0x3F) | 0x80;
+}