diff --git a/spec/Overview.html b/spec/Overview.html index 0933b92..22e69b9 100644 --- a/spec/Overview.html +++ b/spec/Overview.html @@ -27,7 +27,7 @@ github: "https://github.com/w3c/webcrypto", shortName: "WebCryptoAPI", group: "webappsec", - xref: ['html', 'dom', 'webidl', 'infra', 'encoding'], + xref: ['html', 'dom', 'webidl', 'infra', 'encoding', 'streams'], localBiblio: { "JWA": { aliasOf: "RFC7518" @@ -1220,6 +1220,21 @@

Serialization and deserialization steps

+
+

BufferSources

+

+ The BufferSources type represents objects that either are a {{BufferSource}}, + or conform + to the iterable interface + or async iterable interface + and produce {{BufferSource}} values when iterated over. + This is checked by the calling functions rather than by Web IDL. +

+
+typedef object BufferSources;
+        
+
+

SubtleCrypto interface

@@ -1254,7 +1269,7 @@

SubtleCrypto interface

); Promise<ArrayBuffer> digest( AlgorithmIdentifier algorithm, - BufferSource data + BufferSources data ); Promise<(CryptoKey or CryptoKeyPair)> generateKey( @@ -1828,9 +1843,7 @@

The digest method

  • - Let |data| be the result of - [= get a copy of the buffer source | - getting a copy of the bytes held by =] the `data` parameter passed to the + Let |data| be the `data` parameter passed to the {{SubtleCrypto/digest()}} method.

  • @@ -1858,6 +1871,118 @@

    The digest method

    Let |promise| be a new Promise.

    +
  • +
    +
    If |data| is a {{BufferSource}}:
    +
    +

    + Let |bytes| be the result of + [= get a copy of the buffer source | + getting a copy of the bytes held by =] |data|. +

    +
    +
    + Otherwise: +
    +
    +
    +

    + In this case, |data| should conform to the + iterable interface or + async iterable interface. + Otherwise, the call to `GetIterator` below + will throw a `TypeError`. +

    +
    +
      +
    1. +

      + Let |bytes| be an empty [= byte sequence =]. +

      +
    2. +
    3. +

      + Let |iterator| be the result of calling + GetIterator(|data|, ASYNC). +

      +
    4. +
    5. +

      + If an error occurred, return a Promise rejected with + |iterator|. +

      +
    6. +
    7. +

      + [= Queue a microtask =] to perform the remaining steps. +

      +
    8. +
    9. +

      + Repeat: +

      +
        +
      1. +

        + Let |value| be the result of calling + IteratorStepValue(|iterator|). +

        +
      2. +
      3. +

        + If an error occurred, reject |promise| with + |value| and then terminate these steps. +

        +
      4. +
      5. +

        + If |value| is `DONE`, terminate these steps. +

        +
      6. +
      7. +

        + Let |value| be the result of calling + Await(|value|). +

        +
      8. +
      9. +

        + If an error occurred, reject |promise| with + |value| and then terminate these steps. +

        +
      10. +
      11. +

        + If |value| is not a {{BufferSource}}, + reject |promise| with the result of calling + AsyncIteratorClose + with |iterator| and a {{TypeError}}, + and then terminate these steps. +

        +
      12. +
      13. +

        + Append the result of [= get a copy of the buffer source | + getting a copy of the bytes held by =] |value| + to |bytes|. +

        +
      14. +
      +
    10. +
    +
    +

    + If the |iterator| returned by GetIterator(|data|, ASYNC) + is the iterator defined by {{ReadableStream}}, + the implementation may wish to optimize the steps + above, for example by reading the stream directly, + and/or transferring + the stream to the [= in parallel | parallel =] steps below. +

    +
    +
    +
    +
  • Return |promise| and perform the remaining steps [= in parallel =]. @@ -1873,11 +1998,29 @@

    The digest method

    and then [= terminate the algorithm =].

  • +
  • +

    + Wait until the microtask queued above (if any) completes. +

    +
    +

    + The implementation may wish to compute the hash digest + incrementally, instead of waiting until all data is + available, in order to conserve memory. +

    +
    +
  • +
  • +

    + If |promise| was rejected with an error, + [= terminate the algorithm =]. +

    +
  • Let |digest| be the result of performing the digest operation specified by |normalizedAlgorithm| using - |algorithm|, with |data| + |algorithm|, with |bytes| as |message|.