Skip to content

Commit df748b1

Browse files
committed
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).
1 parent 9d98db7 commit df748b1

File tree

1 file changed

+70
-71
lines changed

1 file changed

+70
-71
lines changed

spec/Overview.html

Lines changed: 70 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,14 +1415,6 @@ <h4>The encrypt method</h4>
14151415
respectively.
14161416
</p>
14171417
</li>
1418-
<li>
1419-
<p>
1420-
Let |data| be the result of
1421-
[= get a copy of the buffer source |
1422-
getting a copy of the bytes held by =] the `data` parameter passed to the
1423-
{{SubtleCrypto/encrypt()}} method.
1424-
</p>
1425-
</li>
14261418
<li>
14271419
<p>
14281420
Let |normalizedAlgorithm| be the result of
@@ -1437,6 +1429,14 @@ <h4>The encrypt method</h4>
14371429
|normalizedAlgorithm|.
14381430
</p>
14391431
</li>
1432+
<li>
1433+
<p>
1434+
Let |data| be the result of
1435+
[= get a copy of the buffer source |
1436+
getting a copy of the bytes held by =] the `data` parameter passed to the
1437+
{{SubtleCrypto/encrypt()}} method.
1438+
</p>
1439+
</li>
14401440
<li>
14411441
<p>
14421442
Let |realm| be the [= relevant realm =] of [= this =].
@@ -1522,14 +1522,6 @@ <h4>The decrypt method</h4>
15221522
respectively.
15231523
</p>
15241524
</li>
1525-
<li>
1526-
<p>
1527-
Let |data| be the result of
1528-
[= get a copy of the buffer source |
1529-
getting a copy of the bytes held by =] the `data` parameter passed to the
1530-
{{SubtleCrypto/decrypt()}} method.
1531-
</p>
1532-
</li>
15331525
<li>
15341526
<p>
15351527
Let |normalizedAlgorithm| be the result of
@@ -1544,6 +1536,14 @@ <h4>The decrypt method</h4>
15441536
|normalizedAlgorithm|.
15451537
</p>
15461538
</li>
1539+
<li>
1540+
<p>
1541+
Let |data| be the result of
1542+
[= get a copy of the buffer source |
1543+
getting a copy of the bytes held by =] the `data` parameter passed to the
1544+
{{SubtleCrypto/decrypt()}} method.
1545+
</p>
1546+
</li>
15471547
<li>
15481548
<p>
15491549
Let |realm| be the [= relevant realm =] of [= this =].
@@ -1629,14 +1629,6 @@ <h4>The sign method</h4>
16291629
respectively.
16301630
</p>
16311631
</li>
1632-
<li>
1633-
<p>
1634-
Let |data| be the result of
1635-
[= get a copy of the buffer source |
1636-
getting a copy of the bytes held by =] the `data` parameter passed to the
1637-
{{SubtleCrypto/sign()}} method.
1638-
</p>
1639-
</li>
16401632
<li>
16411633
<p>
16421634
Let |normalizedAlgorithm| be the result of
@@ -1651,6 +1643,14 @@ <h4>The sign method</h4>
16511643
|normalizedAlgorithm|.
16521644
</p>
16531645
</li>
1646+
<li>
1647+
<p>
1648+
Let |data| be the result of
1649+
[= get a copy of the buffer source |
1650+
getting a copy of the bytes held by =] the `data` parameter passed to the
1651+
{{SubtleCrypto/sign()}} method.
1652+
</p>
1653+
</li>
16541654
<li>
16551655
<p>
16561656
Let |realm| be the [= relevant realm =] of [= this =].
@@ -1736,35 +1736,34 @@ <h4>The verify method</h4>
17361736
</li>
17371737
<li>
17381738
<p>
1739-
Let |signature| be the result of
1740-
[= get a copy of the buffer source |
1741-
getting a copy of the bytes held by =] the `signature` parameter passed to the
1742-
{{SubtleCrypto/verify()}} method.
1739+
Let |normalizedAlgorithm| be the result of
1740+
<a href="#dfn-normalize-an-algorithm">normalizing an algorithm</a>, with
1741+
`alg` set to |algorithm| and `op` set to
1742+
"`verify`".
17431743
</p>
17441744
</li>
17451745
<li>
17461746
<p>
1747-
Let |data| be the result of
1748-
[= get a copy of the buffer source |
1749-
getting a copy of the bytes held by =] the `data` parameter passed to the
1750-
{{SubtleCrypto/verify()}} method.
1747+
If an error occurred, return a Promise rejected with
1748+
|normalizedAlgorithm|.
17511749
</p>
17521750
</li>
17531751
<li>
17541752
<p>
1755-
Let |normalizedAlgorithm| be the result of
1756-
<a href="#dfn-normalize-an-algorithm">normalizing an algorithm</a>, with
1757-
`alg` set to |algorithm| and `op` set to
1758-
"`verify`".
1753+
Let |signature| be the result of
1754+
[= get a copy of the buffer source |
1755+
getting a copy of the bytes held by =] the `signature` parameter passed to the
1756+
{{SubtleCrypto/verify()}} method.
17591757
</p>
17601758
</li>
17611759
<li>
17621760
<p>
1763-
If an error occurred, return a Promise rejected with
1764-
|normalizedAlgorithm|.
1761+
Let |data| be the result of
1762+
[= get a copy of the buffer source |
1763+
getting a copy of the bytes held by =] the `data` parameter passed to the
1764+
{{SubtleCrypto/verify()}} method.
17651765
</p>
17661766
</li>
1767-
17681767
<li>
17691768
<p>
17701769
Let |realm| be the [= relevant realm =] of [= this =].
@@ -1843,14 +1842,6 @@ <h4>The digest method</h4>
18431842
{{SubtleCrypto/digest()}} method.
18441843
</p>
18451844
</li>
1846-
<li>
1847-
<p>
1848-
Let |data| be the result of
1849-
[= get a copy of the buffer source |
1850-
getting a copy of the bytes held by =] the `data` parameter passed to the
1851-
{{SubtleCrypto/digest()}} method.
1852-
</p>
1853-
</li>
18541845
<li>
18551846
<p>
18561847
Let |normalizedAlgorithm| be the result of
@@ -1865,6 +1856,14 @@ <h4>The digest method</h4>
18651856
|normalizedAlgorithm|.
18661857
</p>
18671858
</li>
1859+
<li>
1860+
<p>
1861+
Let |data| be the result of
1862+
[= get a copy of the buffer source |
1863+
getting a copy of the bytes held by =] the `data` parameter passed to the
1864+
{{SubtleCrypto/digest()}} method.
1865+
</p>
1866+
</li>
18681867
<li>
18691868
<p>
18701869
Let |realm| be the [= relevant realm =] of [= this =].
@@ -2298,6 +2297,20 @@ <h4>The importKey method</h4>
22982297
`extractable` and `keyUsages` parameters passed to the {{SubtleCrypto/importKey()}} method, respectively.
22992298
</p>
23002299
</li>
2300+
<li>
2301+
<p>
2302+
Let |normalizedAlgorithm| be the result of
2303+
<a href="#dfn-normalize-an-algorithm">normalizing an algorithm</a>, with
2304+
`alg` set to |algorithm| and `op` set to
2305+
"`importKey`".
2306+
</p>
2307+
</li>
2308+
<li>
2309+
<p>
2310+
If an error occurred, return a Promise rejected with
2311+
|normalizedAlgorithm|.
2312+
</p>
2313+
</li>
23012314
<li>
23022315
<dl class="switch">
23032316
<dt>
@@ -2345,20 +2358,6 @@ <h4>The importKey method</h4>
23452358
</dd>
23462359
</dl>
23472360
</li>
2348-
<li>
2349-
<p>
2350-
Let |normalizedAlgorithm| be the result of
2351-
<a href="#dfn-normalize-an-algorithm">normalizing an algorithm</a>, with
2352-
`alg` set to |algorithm| and `op` set to
2353-
"`importKey`".
2354-
</p>
2355-
</li>
2356-
<li>
2357-
<p>
2358-
If an error occurred, return a Promise rejected with
2359-
|normalizedAlgorithm|.
2360-
</p>
2361-
</li>
23622361
<li>
23632362
<p>
23642363
Let |realm| be the [= relevant realm =] of [= this =].
@@ -2751,7 +2750,7 @@ <h4>The unwrapKey method</h4>
27512750
MUST perform the following steps:
27522751
</p>
27532752
<ol>
2754-
<li>
2753+
<li>
27552754
<p>
27562755
Let |format|, |unwrappingKey|,
27572756
|algorithm|, |unwrappedKeyAlgorithm|,
@@ -2764,15 +2763,6 @@ <h4>The unwrapKey method</h4>
27642763
respectively.
27652764
</p>
27662765
</li>
2767-
<li>
2768-
<p>
2769-
Let |wrappedKey| be the result of
2770-
[= get a copy of the buffer source |
2771-
getting a copy of the bytes held by =] the
2772-
`wrappedKey` parameter passed to the
2773-
{{SubtleCrypto/unwrapKey()}} method.
2774-
</p>
2775-
</li>
27762766
<li>
27772767
<p>
27782768
Let |normalizedAlgorithm| be the result of
@@ -2808,6 +2798,15 @@ <h4>The unwrapKey method</h4>
28082798
|normalizedKeyAlgorithm|.
28092799
</p>
28102800
</li>
2801+
<li>
2802+
<p>
2803+
Let |wrappedKey| be the result of
2804+
[= get a copy of the buffer source |
2805+
getting a copy of the bytes held by =] the
2806+
`wrappedKey` parameter passed to the
2807+
{{SubtleCrypto/unwrapKey()}} method.
2808+
</p>
2809+
</li>
28112810
<li>
28122811
<p>
28132812
Let |realm| be the [= relevant realm =] of [= this =].

0 commit comments

Comments
 (0)