ietf-wg-uuidrev / rfc4122bis

revision to RFC4122
Other
57 stars 11 forks source link

Populating all 128 bits #165

Closed jimfenton closed 1 year ago

jimfenton commented 1 year ago

For UUID version 3 (Section 5.3) and version 5 (Section 5.5), the document says, "is used to populate all 128 bits of the UUID layout." But the variant and version fields are not populated, so only 122 bits are used. For MD5 (version 3), it should tell us which bits of the MD5 output are used. For version 5, it should specify the correct number of bits.

danielmarschall commented 1 year ago

I think there could be a confusion because indeed all 128 bits are populated with hash bits, and after that the 6 bits version/variant are written, overwriting some of the hash bits.

kyzer-davis commented 1 year ago

Yeah, the next sentences after states that the 128 bits are then shifted by the ver/var rules.

V3:

This MD5 value is then used to populate all 128 bits of the UUID layout. The UUID version and variant then replace the respective bits as defined by Section 4.2 and Section 4.1. An example of this bit substitution can be found in Appendix B.2.

V5:

The most significant, left-most 128 bits of the SHA-1 value is then used to populate all 128 bits of the UUID layout and the remaining 32 least significant, right-most bits of SHA-1 output are discarded. The UUID version and variant then replace the respective bits as defined by Section 4.2 and Section 4.1. An example of this bit substitution and discarding excess bits can be found in Appendix B.4.

This is how it is being done in current implementations; else yeah, I would have said "generate 122 and then slot in ver/var "...but that isn't reality today (thanks to RFC4122) And it matters because 122 w/6 bits added or 128 with bit overwrite can produce differing final UUIDs.