diff --git a/index.html b/index.html index a09800f..32be7ea 100644 --- a/index.html +++ b/index.html @@ -93,10 +93,114 @@

Extensions to the Crypto interface

         [Exposed=(Window,Worker)]
-        partial interface Crypto {
+        partial interface Crypto {
           DOMString randomUUID();
         };
       
+

Note: + randomUUID() generates a new + version 4 UUID and returns its + namespace specific string representation described in + namespace specific string representation of a UUID described in + RFC4122. + +

+

The randomUUID() method.

+ The + randomUUID() + method steps are: +
    +
  1. +

    + Let array be a list with 16 elements of the type byte. +

    +
  2. +
  3. +

    + Overwrite all elements of array with cryptographically secure random values of + the type byte. +

    +
  4. +
  5. +

    + Let timeLow be the concatenation + of « hexadecimal representation of array[0], + hexadecimal representation of array[1], hexadecimal representation of array[2], hexadecimal representation of array[3] ». +

    +
  6. +
  7. +

    + Let timeMid be the concatenation + of « hexadecimal representation of array[4], + hexadecimal representation of array[5] ». +

    +
  8. +
  9. +

    + Let timeHighAndVersion be a 4 character string + populated as follows: +

    +
      +
    1. +

      + Set the 4 most significant bits of array[6], which represent the UUID version, to 0b0100. +

      +
    2. +
    3. +

      + Set timeHighAndVersion be the concatenation + of « hexadecimal representation of array[6], + hexadecimal representation of array[7] ». +

      +
    4. +
    +
  10. +
  11. +

    + Let clockSeqAndReservedClockSeqLow be a 4 character string + populated as follows: +

    +
      +
    1. +

      + Set the 2 most significant bits of array[8] + to the 0b10 variant. +

      +
    2. +
    3. +

      + Set clockSeqAndReservedClockSeqLow be the concatenation + of « hexadecimal representation array[8], + hexadecimal representation array[9] ». +

      +
    4. +
    +
  12. +
  13. +

    + Let node be the concatenation + of « hexadecimal representation array[10], + hexadecimal representation array[11], hexadecimal representation array[12], hexadecimal representation array[13], + hexadecimal representation array[14], hexadecimal representation array[15] ». +

    +
  14. +
  15. +

    + Return the concatenation of + « timeLow, timeMid, timeHighAndVersion, + clockSeqAndReservedClockSeqLow, node » with separator "-". +

    +
  16. +
+

+ For the steps described in the randomUUID() algorithm, + the hexadecimal representation + of a byte value is the + two-character string created by expressing value in hexadecimal + using ASCII lower hex digits, + left-padded with "0" to reach two characters. +

+