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

Unified Diff: LayoutTests/crypto/subtle/clone-hkdfKey.html

Issue 822083003: Webcrypto: add layout tests for HKDF algorithm (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: use correct diffbase Created 5 years, 11 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
Index: LayoutTests/crypto/subtle/clone-hkdfKey.html
diff --git a/LayoutTests/crypto/subtle/clone-hmacKey.html b/LayoutTests/crypto/subtle/clone-hkdfKey.html
similarity index 55%
copy from LayoutTests/crypto/subtle/clone-hmacKey.html
copy to LayoutTests/crypto/subtle/clone-hkdfKey.html
index d2ae6512d727a095aba5abd0a851f3fb17fb7ad8..4ba64c3b7274c973e8ed1a514084a69ce72b8e0c 100644
--- a/LayoutTests/crypto/subtle/clone-hmacKey.html
+++ b/LayoutTests/crypto/subtle/clone-hkdfKey.html
@@ -9,7 +9,7 @@
<div id="console"></div>
<script>
-description("Tests structured cloning of HMAC keys");
+description("Tests structured cloning of HKDF keys");
jsTestIsAsync = true;
@@ -22,39 +22,29 @@ var k128BitData = "30112233445566778899aabbccddeeff"
var k256BitData = "00112233445546778899aabbccddeeff000102030405060708090a0b0c0d0e0f";
var kPossibleHashAlgorithms = ['SHA-1', 'SHA-256', 'SHA-512'];
-var kPossibleExtractable = [true, false];
-var kPossibleKeyUsages = [['sign'], ['verify'], ['sign', 'verify']];
+var kPossibleKeyUsages = [['deriveBits'], ['deriveKey'], ['deriveKey', 'deriveBits']];
var kPossibleKeyData = [
k128BitData,
k256BitData
];
-function runTest(hashName, extractable, keyUsages, keyData)
+function runTest(hashName, keyUsages, keyData)
{
var importData = hexStringToUint8Array(keyData);
- var importAlgorithm = { name: 'HMAC', hash: {name: hashName } };
-
- var results = {};
+ var importAlgorithm = { name: 'HKDF', hash: {name: hashName } };
+ var extractable = false;
return crypto.subtle.importKey('raw', importData, importAlgorithm, extractable, keyUsages).then(function(importedKey) {
- results.importedKey = importedKey;
+ window.importedKey = importedKey;
eroman 2015/01/07 01:18:43 why change the code pattern from the original? Usi
nharper 2015/01/09 22:41:46 The reason for the change was because the local va
importedKey.extraProperty = 'hi';
return cloneKey(importedKey);
}).then(function(clonedKey) {
- results.clonedKey = clonedKey;
- if (extractable)
- return crypto.subtle.exportKey('raw', clonedKey);
- return null;
- }).then(function(clonedKeyData) {
- importedKey = results.importedKey;
- clonedKey = results.clonedKey;
+ window.clonedKey = clonedKey;
shouldEvaluateAs("importedKey.extraProperty", "hi");
shouldEvaluateAs("importedKey.type", "secret");
shouldEvaluateAs("importedKey.extractable", extractable);
- shouldEvaluateAs("importedKey.algorithm.name", "HMAC");
- shouldEvaluateAs("importedKey.algorithm.length", importData.length * 8);
- shouldEvaluateAs("importedKey.algorithm.hash.name", hashName);
+ shouldEvaluateAs("importedKey.algorithm.name", "HKDF");
shouldEvaluateAs("importedKey.usages.join(',')", keyUsages.join(","));
shouldNotBe("importedKey", "clonedKey");
@@ -62,16 +52,11 @@ function runTest(hashName, extractable, keyUsages, keyData)
shouldBeUndefined("clonedKey.extraProperty");
shouldEvaluateAs("clonedKey.type", "secret");
shouldEvaluateAs("clonedKey.extractable", extractable);
- shouldEvaluateAs("clonedKey.algorithm.name", "HMAC");
- shouldEvaluateAs("clonedKey.algorithm.length", importData.length * 8);
- shouldEvaluateAs("clonedKey.algorithm.hash.name", hashName);
+ shouldEvaluateAs("clonedKey.algorithm.name", "HKDF");
shouldEvaluateAs("clonedKey.usages.join(',')", keyUsages.join(","));
logSerializedKey(importedKey);
- if (extractable)
- bytesShouldMatchHexString("Cloned key exported data", keyData, clonedKeyData);
-
debug("");
});
}
@@ -79,11 +64,9 @@ function runTest(hashName, extractable, keyUsages, keyData)
var lastPromise = Promise.resolve(null);
kPossibleHashAlgorithms.forEach(function(hashName) {
- kPossibleExtractable.forEach(function(extractable) {
- kPossibleKeyUsages.forEach(function(keyUsages) {
- kPossibleKeyData.forEach(function(keyData) {
- lastPromise = lastPromise.then(runTest.bind(null, hashName, extractable, keyUsages, keyData));
- });
+ kPossibleKeyUsages.forEach(function(keyUsages) {
+ kPossibleKeyData.forEach(function(keyData) {
+ lastPromise = lastPromise.then(runTest.bind(null, hashName, keyUsages, keyData));
});
});
});

Powered by Google App Engine
This is Rietveld 408576698