Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(822)

Unified Diff: third_party/WebKit/Source/modules/crypto/SubtleCrypto.cpp

Issue 2316633003: Copy data bytes in Web Crypto's importKey() and verify() operations (Closed)
Patch Set: add layout tests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/crypto/subtle/modify-verify-data-during-normalization-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/crypto/SubtleCrypto.cpp
diff --git a/third_party/WebKit/Source/modules/crypto/SubtleCrypto.cpp b/third_party/WebKit/Source/modules/crypto/SubtleCrypto.cpp
index 5e1f337d47acaf1e78e22eb42caff779de7f9fe1..8dbb331dc1ed73ee86f805e4fc89b9746617bc8e 100644
--- a/third_party/WebKit/Source/modules/crypto/SubtleCrypto.cpp
+++ b/third_party/WebKit/Source/modules/crypto/SubtleCrypto.cpp
@@ -282,16 +282,16 @@ ScriptPromise SubtleCrypto::verifySignature(ScriptState* scriptState, const Algo
// held by the signature parameter passed to the verify method.
WebVector<uint8_t> signature = copyBytes(rawSignature);
- // 14.3.4.3: Let normalizedAlgorithm be the result of normalizing an
+ // 14.3.4.3: Let data be the result of getting a copy of the bytes held by
+ // the data parameter passed to the verify method.
+ WebVector<uint8_t> data = copyBytes(rawData);
+
+ // 14.3.4.4: Let normalizedAlgorithm be the result of normalizing an
// algorithm, with alg set to algorithm and op set to "verify".
WebCryptoAlgorithm normalizedAlgorithm;
if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationVerify, normalizedAlgorithm, result))
return promise;
- // 14.3.4.5: Let data be the result of getting a copy of the bytes held by
- // the data parameter passed to the verify method.
- WebVector<uint8_t> data = copyBytes(rawData);
-
// 14.3.4.9: If the name member of normalizedAlgorithm is not equal to the
// name attribute of the [[algorithm]] internal slot of key then throw an
// InvalidAccessError.
@@ -379,19 +379,12 @@ ScriptPromise SubtleCrypto::importKey(ScriptState* scriptState, const String& ra
if (!CryptoKey::parseUsageMask(rawKeyUsages, keyUsages, result))
return promise;
- // 14.3.9.2: Let normalizedAlgorithm be the result of normalizing an
- // algorithm, with alg set to algorithm and op set to
- // "importKey".
- WebCryptoAlgorithm normalizedAlgorithm;
- if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationImportKey, normalizedAlgorithm, result))
- return promise;
-
// In the case of JWK keyData will hold the UTF8-encoded JSON for the
// JsonWebKey, otherwise it holds a copy of the BufferSource.
WebVector<uint8_t> keyData;
switch (format) {
- // 14.3.9.6: If format is equal to the string "raw", "pkcs8", or "spki":
+ // 14.3.9.2: If format is equal to the string "raw", "pkcs8", or "spki":
//
// (1) If the keyData parameter passed to the importKey method is a
// JsonWebKey dictionary, throw a TypeError.
@@ -410,7 +403,7 @@ ScriptPromise SubtleCrypto::importKey(ScriptState* scriptState, const String& ra
return promise;
}
break;
- // 14.3.9.6: If format is equal to the string "jwk":
+ // 14.3.9.2: If format is equal to the string "jwk":
//
// (1) If the keyData parameter passed to the importKey method is not a
// JsonWebKey dictionary, throw a TypeError.
@@ -430,6 +423,14 @@ ScriptPromise SubtleCrypto::importKey(ScriptState* scriptState, const String& ra
}
break;
}
+
+ // 14.3.9.3: Let normalizedAlgorithm be the result of normalizing an
+ // algorithm, with alg set to algorithm and op set to
+ // "importKey".
+ WebCryptoAlgorithm normalizedAlgorithm;
+ if (!parseAlgorithm(rawAlgorithm, WebCryptoOperationImportKey, normalizedAlgorithm, result))
+ return promise;
+
histogramAlgorithm(scriptState->getExecutionContext(), normalizedAlgorithm);
Platform::current()->crypto()->importKey(format, std::move(keyData), normalizedAlgorithm, extractable, keyUsages, result->result());
return promise;
« no previous file with comments | « third_party/WebKit/LayoutTests/crypto/subtle/modify-verify-data-during-normalization-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698