Index: LayoutTests/crypto/subtle/pbkdf2-deriveBits-empty-password-failure.html |
diff --git a/LayoutTests/crypto/subtle/pbkdf2-deriveBits-empty-password-failure.html b/LayoutTests/crypto/subtle/pbkdf2-deriveBits-empty-password-failure.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f807d957ce7a073b4af8c72b2ac2cc4d38764b44 |
--- /dev/null |
+++ b/LayoutTests/crypto/subtle/pbkdf2-deriveBits-empty-password-failure.html |
@@ -0,0 +1,63 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<script src="../../resources/js-test.js"></script> |
+<script src="resources/common.js"></script> |
+</head> |
+<body> |
+<p id="description"></p> |
+<div id="console"></div> |
+ |
+<script> |
+description("Tests importing empty password for PBKDF2"); |
+ |
+jsTestIsAsync = true; |
+ |
+// ------------------------------------------------- |
+// Test importing empty password for PBKDF2 |
+// ------------------------------------------------- |
+ |
+// Empty password |
+var testCase = |
+{ |
+ password: "", |
+ salt: "salt", |
+ c: 1, |
+ dkLen: 20, |
+ hash: "SHA-1", |
+}; |
+ |
+function runPbkdf2SuccessTestCase(testCase) |
+{ |
+ var algorithm = {name: 'PBKDF2'}; |
+ var password = asciiToUint8Array(testCase.password); |
+ var usages = ['deriveBits', 'deriveKey']; |
+ var extractable = false; |
+ |
+ var params = { |
+ name: 'PBKDF2', |
+ salt: asciiToUint8Array(testCase.salt), |
+ iterations: testCase.c, |
+ hash: {name: testCase.hash} |
+ }; |
+ // (1) Import the password |
+ return crypto.subtle.importKey('raw', password, algorithm, extractable, usages).then(function(result) { |
+ // shouldBe() can only resolve variables in global context. |
+ key = result; |
+ shouldEvaluateAs("key.type", "secret"); |
+ shouldEvaluateAs("key.extractable", false); |
+ shouldEvaluateAs("key.algorithm.name", "PBKDF2"); |
+ shouldEvaluateAs("key.usages.join(',')", "deriveKey,deriveBits"); |
+ |
+ return crypto.subtle.deriveBits(params, key, 80); |
+ }).then(failAndFinishJSTest, function(result) { |
+ logError(result); |
+ }).then(finishJSTest, failAndFinishJSTest); |
+} |
+ |
+runPbkdf2SuccessTestCase(testCase); |
+ |
+</script> |
+ |
+</body> |
+</html> |