Skip to content

Commit

Permalink
Remove superfluous copying
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
twiss committed Jan 7, 2025
1 parent 1a2a431 commit 0e53a7a
Showing 1 changed file with 22 additions and 30 deletions.
52 changes: 22 additions & 30 deletions spec/Overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -750,14 +750,6 @@ <h2>Terminology</h2>
</p>
</li>
</ol>
<p>
When this specification states to supply the <dfn id="concept-contents-of-arraybuffer">
contents of an ArrayBuffer</dfn> named |data| to an underlying cryptographic
implementation, the User Agent shall supply a contiguous sequence of bytes that is equal
to the result of
[= get a copy of the buffer source | getting a copy of the bytes =]
held |data|.
</p>
<p>
When this specification says to calculate the <dfn id="concept-usage-intersection">usage
intersection</dfn> of two sequences, |a| and |b| the result shall be a
Expand Down Expand Up @@ -1402,7 +1394,7 @@ <h4>The encrypt method</h4>
<p>
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
getting a copy of the bytes held by =] the `data` parameter passed to the
{{SubtleCrypto/encrypt()}} method.
</p>
</li>
Expand Down Expand Up @@ -1500,7 +1492,7 @@ <h4>The decrypt method</h4>
<li>
<p>
Let |algorithm| and |key| be the
`algorithm` and `key`parameters
`algorithm` and `key` parameters
passed to the {{SubtleCrypto/decrypt()}} method,
respectively.
</p>
Expand Down Expand Up @@ -3943,7 +3935,7 @@ <h4>Operations</h4>
<li>
<p>
Perform the signature generation operation defined in Section 8.2 of [[RFC3447]] with the key represented by the {{CryptoKey/[[handle]]}} internal slot of |key|
as the signer's private key and the <a href="#concept-contents-of-arraybuffer">contents of |message|</a> as
as the signer's private key and |message| as
|M| and using the hash function specified in the {{RsaHashedKeyAlgorithm/hash}} attribute of the {{CryptoKey/[[algorithm]]}} internal slot of
|key| as the Hash option for the EMSA-PKCS1-v1_5 encoding method.
</p>
Expand Down Expand Up @@ -3983,7 +3975,7 @@ <h4>Operations</h4>
Perform the signature verification operation defined in Section 8.2 of
[[RFC3447]] with the key represented by the
{{CryptoKey/[[handle]]}} internal slot of
|key| as the signer's RSA public key and the <a href="#concept-contents-of-arraybuffer">contents of |message|</a> as
|key| as the signer's RSA public key and |message| as
|M| and the <a href="#concept-contents-of-arraybuffer">contents of
|signature|</a> as |S| and using the hash function specified
in the {{RsaHashedKeyAlgorithm/hash}} attribute of the
Expand Down Expand Up @@ -4972,7 +4964,7 @@ <h4>Operations</h4>
<li>
<p>
Perform the signature generation operation defined in Section 8.1 of [[RFC3447]] with the key represented by the {{CryptoKey/[[handle]]}} internal slot of |key|
as the signer's private key, |K|, and the <a href="#concept-contents-of-arraybuffer">contents of |message|</a> as
as the signer's private key, |K|, and |message| as
the message to be signed, |M|, and using the hash function specified
by the {{RsaHashedKeyAlgorithm/hash}} attribute of the
{{CryptoKey/[[algorithm]]}} internal slot of
Expand Down Expand Up @@ -5016,7 +5008,7 @@ <h4>Operations</h4>
Perform the signature verification operation defined in Section 8.1 of
[[RFC3447]] with the key represented by the
{{CryptoKey/[[handle]]}} internal slot of
|key| as the signer's RSA public key and the <a href="#concept-contents-of-arraybuffer">contents of |message|</a> as
|key| as the signer's RSA public key and |message| as
|M| and <a href="#concept-contents-of-arraybuffer">the contents of
|signature|</a> as |S| and using the hash function specified
by the {{RsaHashedKeyAlgorithm/hash}} attribute of the
Expand Down Expand Up @@ -5989,7 +5981,7 @@ <h4>Operations</h4>
</li>
<li>
<p>
Let |label| be the <a href="#concept-contents-of-arraybuffer">contents of</a> the {{RsaOaepParams/label}} member of
Let |label| be the {{RsaOaepParams/label}} member of
|normalizedAlgorithm| or the empty octet string if the
{{RsaOaepParams/label}} member of
|normalizedAlgorithm| is not present.
Expand All @@ -5998,7 +5990,7 @@ <h4>Operations</h4>
<li>
<p>
Perform the encryption operation defined in Section 7.1 of [[RFC3447]] with the key represented by |key|
as the recipient's RSA public key, the <a href="#concept-contents-of-arraybuffer">contents of |plaintext|</a>
as the recipient's RSA public key, |plaintext|
as the message to be encrypted, |M| and |label|
as the label, |L|, and with the hash
function specified by the {{RsaHashedKeyAlgorithm/hash}}
Expand Down Expand Up @@ -6040,7 +6032,7 @@ <h4>Operations</h4>
</li>
<li>
<p>
Let |label| be the <a href="#concept-contents-of-arraybuffer">contents of</a> the {{RsaOaepParams/label}} member of
Let |label| be the {{RsaOaepParams/label}} member of
|normalizedAlgorithm| or the empty octet string if the
{{RsaOaepParams/label}} member of
|normalizedAlgorithm| is not present.
Expand All @@ -6049,7 +6041,7 @@ <h4>Operations</h4>
<li>
<p>
Perform the decryption operation defined in Section 7.1 of [[RFC3447]] with the key represented by |key|
as the recipient's RSA private key, the <a href="#concept-contents-of-arraybuffer">contents of |ciphertext|</a>
as the recipient's RSA private key, |ciphertext|
as the ciphertext to be decrypted, C, and |label|
as the label, |L|, and with the hash
function specified by the {{RsaHashedKeyAlgorithm/hash}}
Expand Down Expand Up @@ -12079,7 +12071,7 @@ <h4>Operations</h4>
<li>
<p>
Let |ciphertext| be the result of performing the CTR Encryption
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
operation described in Section 6.5 of [[NIST-SP800-38A]] using AES as the block cipher, the {{AesCtrParams/counter}} member of
|normalizedAlgorithm| as the initial value of the counter block, the
{{AesCtrParams/length}} member of
|normalizedAlgorithm| as the input parameter |m| to the
Expand Down Expand Up @@ -12119,7 +12111,7 @@ <h4>Operations</h4>
<li>
<p>
Let |plaintext| be the result of performing the CTR Decryption
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
operation described in Section 6.5 of [[NIST-SP800-38A]] using AES as the block cipher, the {{AesCtrParams/counter}} member of
|normalizedAlgorithm| as the initial value of the counter block, the
{{AesCtrParams/length}} member of
|normalizedAlgorithm| as the input parameter |m| to the
Expand Down Expand Up @@ -12610,7 +12602,7 @@ <h4>Operations</h4>
<li>
<p>
Let |paddedPlaintext| be the result of adding padding octets to
the <a href="#concept-contents-of-arraybuffer">contents of |plaintext|</a>
|plaintext|
according to the procedure defined in Section 10.3
of [[RFC2315]], step 2, with a value of
|k| of 16.
Expand All @@ -12619,7 +12611,7 @@ <h4>Operations</h4>
<li>
<p>
Let |ciphertext| be the result of performing the CBC Encryption
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
operation described in Section 6.2 of [[NIST-SP800-38A]] using AES as the block cipher, the {{AesCbcParams/iv}} member of |normalizedAlgorithm| as
the |IV| input parameter and |paddedPlaintext|
as the input plaintext.
</p>
Expand All @@ -12646,7 +12638,7 @@ <h4>Operations</h4>
<li>
<p>
Let |paddedPlaintext| be the result of performing the CBC Decryption
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
operation described in Section 6.2 of [[NIST-SP800-38A]] using AES as the block cipher, the {{AesCbcParams/iv}} member of |normalizedAlgorithm| as
the |IV| input parameter and <a href="#concept-contents-of-arraybuffer">the contents of
|ciphertext|</a> as the input ciphertext.
</p>
Expand Down Expand Up @@ -13179,7 +13171,7 @@ <h4>Operations</h4>
</li>
<li>
<p>
Let |additionalData| be <a href="#concept-contents-of-arraybuffer">the contents of</a> the {{AesGcmParams/additionalData}} member of
Let |additionalData| be the {{AesGcmParams/additionalData}} member of
|normalizedAlgorithm| if present or the empty octet
string otherwise.
</p>
Expand All @@ -13188,7 +13180,7 @@ <h4>Operations</h4>
<p>
Let |C| and |T| be the outputs that result from performing
the Authenticated Encryption Function described in Section 7.1 of
[[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
[[NIST-SP800-38D]] using AES as the block cipher, the {{AesGcmParams/iv}} member of |normalizedAlgorithm| as
the |IV| input parameter, <a href="#concept-contents-of-arraybuffer">the contents of
|additionalData|</a> as the |A| input parameter,
|tagLength| as the |t| pre-requisite and <a href="#concept-contents-of-arraybuffer">the contents of
Expand Down Expand Up @@ -13268,7 +13260,7 @@ <h4>Operations</h4>
</li>
<li>
<p>
Let |additionalData| be <a href="#concept-contents-of-arraybuffer">the contents</a> of the {{AesGcmParams/additionalData}} member of
Let |additionalData| be the {{AesGcmParams/additionalData}} member of
|normalizedAlgorithm| if present or the empty octet
string otherwise.
</p>
Expand All @@ -13277,11 +13269,11 @@ <h4>Operations</h4>
<p>
Perform the Authenticated Decryption Function described in Section 7.2 of
[[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
the {{AesGcmParams/iv}} member of |normalizedAlgorithm| as
the |IV| input parameter, <a href="#concept-contents-of-arraybuffer">the contents of
|additionalData|</a> as the |A| input parameter,
|tagLength| as the |t| pre-requisite, <a href="#concept-contents-of-arraybuffer">the contents of
|actualCiphertext|</a> as the input ciphertext, |C| and <a href="#concept-contents-of-arraybuffer">the contents of |tag|</a> as
|actualCiphertext|</a> as the input ciphertext, |C| and |tag| as
the authentication tag, |T|.
</p>
<dl class="switch">
Expand Down Expand Up @@ -15096,13 +15088,13 @@ <h4>Operations</h4>
</li>
<li>
<p>
<a href="#concept-contents-of-arraybuffer">the contents of</a> the {{HkdfParams/salt}} member of
the {{HkdfParams/salt}} member of
|normalizedAlgorithm| as |salt|,
</p>
</li>
<li>
<p>
<a href="#concept-contents-of-arraybuffer">the contents of</a> the {{HkdfParams/info}} member of
the {{HkdfParams/info}} member of
|normalizedAlgorithm| as |info|,
</p>
</li>
Expand Down

0 comments on commit 0e53a7a

Please sign in to comment.