Skip to content

Commit b965a99

Browse files
authored
Remove superfluous copying (#396)
The methods in SubtleCrypto and the "normalize an algorithm" algorithm already make a copy of the provided data, there's no need to make another copy later on in the methods and operations.
1 parent 25d2b15 commit b965a99

File tree

1 file changed

+41
-49
lines changed

1 file changed

+41
-49
lines changed

spec/Overview.html

+41-49
Original file line numberDiff line numberDiff line change
@@ -750,14 +750,6 @@ <h2>Terminology</h2>
750750
</p>
751751
</li>
752752
</ol>
753-
<p>
754-
When this specification states to supply the <dfn id="concept-contents-of-arraybuffer">
755-
contents of an ArrayBuffer</dfn> named |data| to an underlying cryptographic
756-
implementation, the User Agent shall supply a contiguous sequence of bytes that is equal
757-
to the result of
758-
[= get a copy of the buffer source | getting a copy of the bytes =]
759-
held |data|.
760-
</p>
761753
<p>
762754
When this specification says to calculate the <dfn id="concept-usage-intersection">usage
763755
intersection</dfn> of two sequences, |a| and |b| the result shall be a
@@ -1416,7 +1408,7 @@ <h4>The encrypt method</h4>
14161408
<p>
14171409
Let |data| be the result of
14181410
[= get a copy of the buffer source |
1419-
getting a copy of the bytes =] held by the `data` parameter passed to the
1411+
getting a copy of the bytes held by =] the `data` parameter passed to the
14201412
{{SubtleCrypto/encrypt()}} method.
14211413
</p>
14221414
</li>
@@ -1514,7 +1506,7 @@ <h4>The decrypt method</h4>
15141506
<li>
15151507
<p>
15161508
Let |algorithm| and |key| be the
1517-
`algorithm` and `key`parameters
1509+
`algorithm` and `key` parameters
15181510
passed to the {{SubtleCrypto/decrypt()}} method,
15191511
respectively.
15201512
</p>
@@ -3957,7 +3949,7 @@ <h4>Operations</h4>
39573949
<li>
39583950
<p>
39593951
Perform the signature generation operation defined in Section 8.2 of [[RFC3447]] with the key represented by the {{CryptoKey/[[handle]]}} internal slot of |key|
3960-
as the signer's private key and the <a href="#concept-contents-of-arraybuffer">contents of |message|</a> as
3952+
as the signer's private key and |message| as
39613953
|M| and using the hash function specified in the {{RsaHashedKeyAlgorithm/hash}} attribute of the {{CryptoKey/[[algorithm]]}} internal slot of
39623954
|key| as the Hash option for the EMSA-PKCS1-v1_5 encoding method.
39633955
</p>
@@ -3997,9 +3989,9 @@ <h4>Operations</h4>
39973989
Perform the signature verification operation defined in Section 8.2 of
39983990
[[RFC3447]] with the key represented by the
39993991
{{CryptoKey/[[handle]]}} internal slot of
4000-
|key| as the signer's RSA public key and the <a href="#concept-contents-of-arraybuffer">contents of |message|</a> as
4001-
|M| and the <a href="#concept-contents-of-arraybuffer">contents of
4002-
|signature|</a> as |S| and using the hash function specified
3992+
|key| as the signer's RSA public key and |message| as
3993+
|M| and
3994+
|signature| as |S| and using the hash function specified
40033995
in the {{RsaHashedKeyAlgorithm/hash}} attribute of the
40043996
{{CryptoKey/[[algorithm]]}} internal slot of
40053997
|key| as the Hash option for the EMSA-PKCS1-v1_5 encoding method.
@@ -4986,7 +4978,7 @@ <h4>Operations</h4>
49864978
<li>
49874979
<p>
49884980
Perform the signature generation operation defined in Section 8.1 of [[RFC3447]] with the key represented by the {{CryptoKey/[[handle]]}} internal slot of |key|
4989-
as the signer's private key, |K|, and the <a href="#concept-contents-of-arraybuffer">contents of |message|</a> as
4981+
as the signer's private key, |K|, and |message| as
49904982
the message to be signed, |M|, and using the hash function specified
49914983
by the {{RsaHashedKeyAlgorithm/hash}} attribute of the
49924984
{{CryptoKey/[[algorithm]]}} internal slot of
@@ -5030,9 +5022,9 @@ <h4>Operations</h4>
50305022
Perform the signature verification operation defined in Section 8.1 of
50315023
[[RFC3447]] with the key represented by the
50325024
{{CryptoKey/[[handle]]}} internal slot of
5033-
|key| as the signer's RSA public key and the <a href="#concept-contents-of-arraybuffer">contents of |message|</a> as
5034-
|M| and <a href="#concept-contents-of-arraybuffer">the contents of
5035-
|signature|</a> as |S| and using the hash function specified
5025+
|key| as the signer's RSA public key and |message| as
5026+
|M| and
5027+
|signature| as |S| and using the hash function specified
50365028
by the {{RsaHashedKeyAlgorithm/hash}} attribute of the
50375029
{{CryptoKey/[[algorithm]]}} internal slot of
50385030
|key| as the Hash option, MGF1 (defined in Section B.2.1 of [[RFC3447]]) as the MGF option and the <a href="#dfn-RsaPssParams-saltLength">saltLength</a> member of
@@ -6003,7 +5995,7 @@ <h4>Operations</h4>
60035995
</li>
60045996
<li>
60055997
<p>
6006-
Let |label| be the <a href="#concept-contents-of-arraybuffer">contents of</a> the {{RsaOaepParams/label}} member of
5998+
Let |label| be the {{RsaOaepParams/label}} member of
60075999
|normalizedAlgorithm| or the empty octet string if the
60086000
{{RsaOaepParams/label}} member of
60096001
|normalizedAlgorithm| is not present.
@@ -6012,7 +6004,7 @@ <h4>Operations</h4>
60126004
<li>
60136005
<p>
60146006
Perform the encryption operation defined in Section 7.1 of [[RFC3447]] with the key represented by |key|
6015-
as the recipient's RSA public key, the <a href="#concept-contents-of-arraybuffer">contents of |plaintext|</a>
6007+
as the recipient's RSA public key, |plaintext|
60166008
as the message to be encrypted, |M| and |label|
60176009
as the label, |L|, and with the hash
60186010
function specified by the {{RsaHashedKeyAlgorithm/hash}}
@@ -6054,7 +6046,7 @@ <h4>Operations</h4>
60546046
</li>
60556047
<li>
60566048
<p>
6057-
Let |label| be the <a href="#concept-contents-of-arraybuffer">contents of</a> the {{RsaOaepParams/label}} member of
6049+
Let |label| be the {{RsaOaepParams/label}} member of
60586050
|normalizedAlgorithm| or the empty octet string if the
60596051
{{RsaOaepParams/label}} member of
60606052
|normalizedAlgorithm| is not present.
@@ -6063,7 +6055,7 @@ <h4>Operations</h4>
60636055
<li>
60646056
<p>
60656057
Perform the decryption operation defined in Section 7.1 of [[RFC3447]] with the key represented by |key|
6066-
as the recipient's RSA private key, the <a href="#concept-contents-of-arraybuffer">contents of |ciphertext|</a>
6058+
as the recipient's RSA private key, |ciphertext|
60676059
as the ciphertext to be decrypted, C, and |label|
60686060
as the label, |L|, and with the hash
60696061
function specified by the {{RsaHashedKeyAlgorithm/hash}}
@@ -12093,13 +12085,13 @@ <h4>Operations</h4>
1209312085
<li>
1209412086
<p>
1209512087
Let |ciphertext| be the result of performing the CTR Encryption
12096-
operation described in Section 6.5 of [[NIST-SP800-38A]] using AES as the block cipher, <a href="#concept-contents-of-arraybuffer">the contents of</a> the {{AesCtrParams/counter}} member of
12088+
operation described in Section 6.5 of [[NIST-SP800-38A]] using AES as the block cipher, the {{AesCtrParams/counter}} member of
1209712089
|normalizedAlgorithm| as the initial value of the counter block, the
1209812090
{{AesCtrParams/length}} member of
1209912091
|normalizedAlgorithm| as the input parameter |m| to the
1210012092
standard counter block incrementing function defined in Appendix B.1 of
12101-
[[NIST-SP800-38A]] and <a href="#concept-contents-of-arraybuffer">the contents of
12102-
|plaintext|</a> as the input plaintext.
12093+
[[NIST-SP800-38A]] and
12094+
|plaintext| as the input plaintext.
1210312095
</p>
1210412096
</li>
1210512097
<li>
@@ -12133,13 +12125,13 @@ <h4>Operations</h4>
1213312125
<li>
1213412126
<p>
1213512127
Let |plaintext| be the result of performing the CTR Decryption
12136-
operation described in Section 6.5 of [[NIST-SP800-38A]] using AES as the block cipher, <a href="#concept-contents-of-arraybuffer">the contents of</a> the {{AesCtrParams/counter}} member of
12128+
operation described in Section 6.5 of [[NIST-SP800-38A]] using AES as the block cipher, the {{AesCtrParams/counter}} member of
1213712129
|normalizedAlgorithm| as the initial value of the counter block, the
1213812130
{{AesCtrParams/length}} member of
1213912131
|normalizedAlgorithm| as the input parameter |m| to the
1214012132
standard counter block incrementing function defined in Appendix B.1 of
12141-
[[NIST-SP800-38A]] and <a href="#concept-contents-of-arraybuffer">the contents of
12142-
|ciphertext|</a> as the input ciphertext.
12133+
[[NIST-SP800-38A]] and
12134+
|ciphertext| as the input ciphertext.
1214312135
</p>
1214412136
</li>
1214512137
<li>
@@ -12624,7 +12616,7 @@ <h4>Operations</h4>
1262412616
<li>
1262512617
<p>
1262612618
Let |paddedPlaintext| be the result of adding padding octets to
12627-
the <a href="#concept-contents-of-arraybuffer">contents of |plaintext|</a>
12619+
|plaintext|
1262812620
according to the procedure defined in Section 10.3
1262912621
of [[RFC2315]], step 2, with a value of
1263012622
|k| of 16.
@@ -12633,7 +12625,7 @@ <h4>Operations</h4>
1263312625
<li>
1263412626
<p>
1263512627
Let |ciphertext| be the result of performing the CBC Encryption
12636-
operation described in Section 6.2 of [[NIST-SP800-38A]] using AES as the block cipher, <a href="#concept-contents-of-arraybuffer">the contents of</a> the {{AesCbcParams/iv}} member of |normalizedAlgorithm| as
12628+
operation described in Section 6.2 of [[NIST-SP800-38A]] using AES as the block cipher, the {{AesCbcParams/iv}} member of |normalizedAlgorithm| as
1263712629
the |IV| input parameter and |paddedPlaintext|
1263812630
as the input plaintext.
1263912631
</p>
@@ -12660,9 +12652,9 @@ <h4>Operations</h4>
1266012652
<li>
1266112653
<p>
1266212654
Let |paddedPlaintext| be the result of performing the CBC Decryption
12663-
operation described in Section 6.2 of [[NIST-SP800-38A]] using AES as the block cipher, <a href="#concept-contents-of-arraybuffer">the contents of</a> the {{AesCbcParams/iv}} member of |normalizedAlgorithm| as
12664-
the |IV| input parameter and <a href="#concept-contents-of-arraybuffer">the contents of
12665-
|ciphertext|</a> as the input ciphertext.
12655+
operation described in Section 6.2 of [[NIST-SP800-38A]] using AES as the block cipher, the {{AesCbcParams/iv}} member of |normalizedAlgorithm| as
12656+
the |IV| input parameter and
12657+
|ciphertext| as the input ciphertext.
1266612658
</p>
1266712659
</li>
1266812660
<li>
@@ -13193,7 +13185,7 @@ <h4>Operations</h4>
1319313185
</li>
1319413186
<li>
1319513187
<p>
13196-
Let |additionalData| be <a href="#concept-contents-of-arraybuffer">the contents of</a> the {{AesGcmParams/additionalData}} member of
13188+
Let |additionalData| be the {{AesGcmParams/additionalData}} member of
1319713189
|normalizedAlgorithm| if present or the empty octet
1319813190
string otherwise.
1319913191
</p>
@@ -13202,11 +13194,11 @@ <h4>Operations</h4>
1320213194
<p>
1320313195
Let |C| and |T| be the outputs that result from performing
1320413196
the Authenticated Encryption Function described in Section 7.1 of
13205-
[[NIST-SP800-38D]] using AES as the block cipher, <a href="#concept-contents-of-arraybuffer">the contents of</a> the {{AesGcmParams/iv}} member of |normalizedAlgorithm| as
13206-
the |IV| input parameter, <a href="#concept-contents-of-arraybuffer">the contents of
13207-
|additionalData|</a> as the |A| input parameter,
13208-
|tagLength| as the |t| pre-requisite and <a href="#concept-contents-of-arraybuffer">the contents of
13209-
|plaintext|</a> as the input plaintext.
13197+
[[NIST-SP800-38D]] using AES as the block cipher, the {{AesGcmParams/iv}} member of |normalizedAlgorithm| as
13198+
the |IV| input parameter,
13199+
|additionalData| as the |A| input parameter,
13200+
|tagLength| as the |t| pre-requisite and
13201+
|plaintext| as the input plaintext.
1321013202
</p>
1321113203
</li>
1321213204
<li>
@@ -13282,7 +13274,7 @@ <h4>Operations</h4>
1328213274
</li>
1328313275
<li>
1328413276
<p>
13285-
Let |additionalData| be <a href="#concept-contents-of-arraybuffer">the contents</a> of the {{AesGcmParams/additionalData}} member of
13277+
Let |additionalData| be the {{AesGcmParams/additionalData}} member of
1328613278
|normalizedAlgorithm| if present or the empty octet
1328713279
string otherwise.
1328813280
</p>
@@ -13291,11 +13283,11 @@ <h4>Operations</h4>
1329113283
<p>
1329213284
Perform the Authenticated Decryption Function described in Section 7.2 of
1329313285
[[NIST-SP800-38D]] using AES as the block cipher,
13294-
<a href="#concept-contents-of-arraybuffer">the contents of</a> the {{AesGcmParams/iv}} member of |normalizedAlgorithm| as
13295-
the |IV| input parameter, <a href="#concept-contents-of-arraybuffer">the contents of
13296-
|additionalData|</a> as the |A| input parameter,
13297-
|tagLength| as the |t| pre-requisite, <a href="#concept-contents-of-arraybuffer">the contents of
13298-
|actualCiphertext|</a> as the input ciphertext, |C| and <a href="#concept-contents-of-arraybuffer">the contents of |tag|</a> as
13286+
the {{AesGcmParams/iv}} member of |normalizedAlgorithm| as
13287+
the |IV| input parameter,
13288+
|additionalData| as the |A| input parameter,
13289+
|tagLength| as the |t| pre-requisite,
13290+
|actualCiphertext| as the input ciphertext, |C| and |tag| as
1329913291
the authentication tag, |T|.
1330013292
</p>
1330113293
<dl class="switch">
@@ -15110,13 +15102,13 @@ <h4>Operations</h4>
1511015102
</li>
1511115103
<li>
1511215104
<p>
15113-
<a href="#concept-contents-of-arraybuffer">the contents of</a> the {{HkdfParams/salt}} member of
15105+
the {{HkdfParams/salt}} member of
1511415106
|normalizedAlgorithm| as |salt|,
1511515107
</p>
1511615108
</li>
1511715109
<li>
1511815110
<p>
15119-
<a href="#concept-contents-of-arraybuffer">the contents of</a> the {{HkdfParams/info}} member of
15111+
the {{HkdfParams/info}} member of
1512015112
|normalizedAlgorithm| as |info|,
1512115113
</p>
1512215114
</li>
@@ -15327,8 +15319,8 @@ <h4>Operations</h4>
1532715319
Let |result| be the result of performing the PBKDF2 operation defined
1532815320
in Section 5.2 of [[RFC8018]] using |prf| as the
1532915321
pseudo-random function, |PRF|, the password represented by {{CryptoKey/[[handle]]}} internal slot of |key|
15330-
as the password, |P|, <a href="#concept-contents-of-arraybuffer">the
15331-
contents of</a> the {{Pbkdf2Params/salt}} attribute of
15322+
as the password, |P|,
15323+
the {{Pbkdf2Params/salt}} attribute of
1533215324
|normalizedAlgorithm| as the salt, |S|, the value of the {{Pbkdf2Params/iterations}} attribute of
1533315325
|normalizedAlgorithm| as the iteration count, |c|, and
1533415326
|length| divided by 8 as the intended key length, |dkLen|.

0 commit comments

Comments
 (0)