vipsoft / hhvm-ext-uuid

UUID extension for HipHop VM (HHVM HNI DSO)
Other
4 stars 3 forks source link

Missing UUID types #1

Open robocoder opened 10 years ago

robocoder commented 10 years ago

define UUID_TYPE_DCE 2

define UUID_TYPE_DCE_NAME 3

These are currently mapped to UUID_TYPE_DCE_RANDOM and UUID_TYPE_DCE_TIME, respectively. This leads to an inconsistency if you use uuid_type() to extract the type from a UUID not generated by libuuid.

robocoder commented 10 years ago

UUIDTYPE* corresponds to UUID versions

Do we change the above #defines, add new ones, or switch to UUID_VERSION_n ?

UUID_TYPE_DCE_SECURITY = 2 // 'uid/gid' and 'domain' parameters are passed to uuid_create()
    uuid = uuid_generate();
    uuid[6] = uuid[6] & 0x0f | 0x20 // version is the top nybble
    uuid[0..3] = some 32 bit id // big endian
    uuid[8] = byte(domain) // upper byte of clock sequence; uuid[9] is the lower byte

UUID_TYPE_DCE_NAME_MD5 = 3 (md5-based) // 'name' and 'namespace' parameters are passed to uuid_create()
    uuid = md5(namespace . name)
    uuid[6] = uuid[6] & 0x0f | 0x30 // set type/version (msb0 msb1 msb2 msb3) to:  0 0 1 1
    uuid[8] = uuid[8] & 0x3f | 0x80 // set variant (msb0 msb1) to:  1 0

UUID_TYPE_DCE_NAME_SHA1 = 5 (sha-1 based) // 'name' and 'namespace' parameters are passed to uuid_create()
    uuid = substr(sha1(namespace . name), 0, 16) // truncate to 16 bytes (128 bits)
    uuid[6] = uuid[6] & 0x0f | 0x50 // set type/version (msb0 msb1 msb2 msb3) to:  0 0 1 1
    uuid[8] = uuid[8] & 0x3f | 0x80 // set variant (msb0 msb1) to:  1 0

This appendix lists the name space IDs for some potentially interesting name spaces, as initialized C structures and in the string representation defined above.

   /* Name string is a fully-qualified domain name */
   uuid_t NameSpace_DNS = { /* 6ba7b810-9dad-11d1-80b4-00c04fd430c8 */
       0x6ba7b810,
       0x9dad,
       0x11d1,
       0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8
   };

   /* Name string is a URL */
   uuid_t NameSpace_URL = { /* 6ba7b811-9dad-11d1-80b4-00c04fd430c8 */
       0x6ba7b811,
       0x9dad,
       0x11d1,
       0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8
   };

   /* Name string is an ISO OID */
   uuid_t NameSpace_OID = { /* 6ba7b812-9dad-11d1-80b4-00c04fd430c8 */
       0x6ba7b812,
       0x9dad,
       0x11d1,
       0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8
   };

   /* Name string is an X.500 DN (in DER or a text output format) */
   uuid_t NameSpace_X500 = { /* 6ba7b814-9dad-11d1-80b4-00c04fd430c8 */
       0x6ba7b814,
       0x9dad,
       0x11d1,
       0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8
   };
robocoder commented 10 years ago

We have the added complication that this extension's uuid_create() is a wrapper for uuid_generate()/uuid_generate_time()/uuid_generate_random() which only take an 'out' parameter.

Add a new wrapper method, or extend the current wrapper?

uuid_create_from_name(uuid_type, namespace, name)

uuid_create(uuid_type = 3 or 5, namespace = '', name = '')
uuid_create(uuid_type = 2, uid = 0, domain = 0)