Changeset 8cffdf5 in mainline


Ignore:
Timestamp:
2014-03-11T07:08:41Z (10 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b0b4592e, d52ab7b
Parents:
c60e9ee
git-author:
Agnieszka Tabaka <> (2014-03-11 07:08:41)
git-committer:
Vojtech Horky <vojtechhorky@…> (2014-03-11 07:08:41)
Message:

libgpt: random UUID conforms to RFC (thx Agnieszka Tabaka)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gpt/libgpt.c

    rc60e9ee r8cffdf5  
    707707}
    708708
    709 /** Generate a new pseudo-random UUID
    710  *
    711  * FIXME: This UUID generator is not compliant with RFC 4122.
    712  *
    713  */
     709/** Generate a new pseudo-random UUID compliant with RFC 4122 */
    714710void gpt_set_random_uuid(uint8_t *uuid)
    715711{
     
    718714        for (size_t i = 0; i < 16; i++)
    719715                uuid[i] = random();
     716
     717        /*
     718         * Set version (stored in bits 4-7 of seventh byte) to 4 (random
     719         * UUID) and bits 6 and 7 of ninth byte to 0 and 1 respectively -
     720         * according to RFC 4122, section 4.4.
     721         */
     722        uuid[6] &= 0x0f;
     723        uuid[6] |= (0x4 << 4);
     724        uuid[8] &= 0x3f;
     725        uuid[8] |= (1 << 7);
    720726}
    721727
Note: See TracChangeset for help on using the changeset viewer.