From df748b11c34a6bce0d6ab540480f98a104266af7 Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Thu, 29 Jan 2026 14:26:51 +0100 Subject: [PATCH] Reorder reading algorithm and data arguments Read and normalize the algorithm argument(s) before copying the bytes held by data arguments, to enable avoiding the copy if the operation is performed on the same thread (which is currently not possible because the algorithm object getters may modify the data). --- spec/Overview.html | 141 ++++++++++++++++++++++----------------------- 1 file changed, 70 insertions(+), 71 deletions(-) diff --git a/spec/Overview.html b/spec/Overview.html index 8f8fd42..7f88a4c 100644 --- a/spec/Overview.html +++ b/spec/Overview.html @@ -1415,14 +1415,6 @@

The encrypt method

respectively.

-
  • -

    - 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 - {{SubtleCrypto/encrypt()}} method. -

    -
  • Let |normalizedAlgorithm| be the result of @@ -1437,6 +1429,14 @@

    The encrypt method

    |normalizedAlgorithm|.

  • +
  • +

    + 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 + {{SubtleCrypto/encrypt()}} method. +

    +
  • Let |realm| be the [= relevant realm =] of [= this =]. @@ -1522,14 +1522,6 @@

    The decrypt method

    respectively.

  • -
  • -

    - 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 - {{SubtleCrypto/decrypt()}} method. -

    -
  • Let |normalizedAlgorithm| be the result of @@ -1544,6 +1536,14 @@

    The decrypt method

    |normalizedAlgorithm|.

  • +
  • +

    + 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 + {{SubtleCrypto/decrypt()}} method. +

    +
  • Let |realm| be the [= relevant realm =] of [= this =]. @@ -1629,14 +1629,6 @@

    The sign method

    respectively.

  • -
  • -

    - 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 - {{SubtleCrypto/sign()}} method. -

    -
  • Let |normalizedAlgorithm| be the result of @@ -1651,6 +1643,14 @@

    The sign method

    |normalizedAlgorithm|.

  • +
  • +

    + 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 + {{SubtleCrypto/sign()}} method. +

    +
  • Let |realm| be the [= relevant realm =] of [= this =]. @@ -1736,35 +1736,34 @@

    The verify method

  • - Let |signature| be the result of - [= get a copy of the buffer source | - getting a copy of the bytes held by =] the `signature` parameter passed to the - {{SubtleCrypto/verify()}} method. + Let |normalizedAlgorithm| be the result of + normalizing an algorithm, with + `alg` set to |algorithm| and `op` set to + "`verify`".

  • - 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 - {{SubtleCrypto/verify()}} method. + If an error occurred, return a Promise rejected with + |normalizedAlgorithm|.

  • - Let |normalizedAlgorithm| be the result of - normalizing an algorithm, with - `alg` set to |algorithm| and `op` set to - "`verify`". + Let |signature| be the result of + [= get a copy of the buffer source | + getting a copy of the bytes held by =] the `signature` parameter passed to the + {{SubtleCrypto/verify()}} method.

  • - If an error occurred, return a Promise rejected with - |normalizedAlgorithm|. + 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 + {{SubtleCrypto/verify()}} method.

  • -
  • Let |realm| be the [= relevant realm =] of [= this =]. @@ -1843,14 +1842,6 @@

    The digest method

    {{SubtleCrypto/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 - {{SubtleCrypto/digest()}} method. -

    -
  • Let |normalizedAlgorithm| be the result of @@ -1865,6 +1856,14 @@

    The digest method

    |normalizedAlgorithm|.

  • +
  • +

    + 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 + {{SubtleCrypto/digest()}} method. +

    +
  • Let |realm| be the [= relevant realm =] of [= this =]. @@ -2298,6 +2297,20 @@

    The importKey method

    `extractable` and `keyUsages` parameters passed to the {{SubtleCrypto/importKey()}} method, respectively.

  • +
  • +

    + Let |normalizedAlgorithm| be the result of + normalizing an algorithm, with + `alg` set to |algorithm| and `op` set to + "`importKey`". +

    +
  • +
  • +

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

    +
  • @@ -2345,20 +2358,6 @@

    The importKey method

  • -
  • -

    - Let |normalizedAlgorithm| be the result of - normalizing an algorithm, with - `alg` set to |algorithm| and `op` set to - "`importKey`". -

    -
  • -
  • -

    - If an error occurred, return a Promise rejected with - |normalizedAlgorithm|. -

    -
  • Let |realm| be the [= relevant realm =] of [= this =]. @@ -2751,7 +2750,7 @@

    The unwrapKey method

    MUST perform the following steps:

      -
    1. +
    2. Let |format|, |unwrappingKey|, |algorithm|, |unwrappedKeyAlgorithm|, @@ -2764,15 +2763,6 @@

      The unwrapKey method

      respectively.

    3. -
    4. -

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

      -
    5. Let |normalizedAlgorithm| be the result of @@ -2808,6 +2798,15 @@

      The unwrapKey method

      |normalizedKeyAlgorithm|.

    6. +
    7. +

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

      +
    8. Let |realm| be the [= relevant realm =] of [= this =].