Index: LayoutTests/crypto/subtle/pbkdf2-deriveBits-failures.html |
diff --git a/LayoutTests/crypto/subtle/pbkdf2-deriveBits-failures.html b/LayoutTests/crypto/subtle/pbkdf2-deriveBits-failures.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..035ceb5e3d0f5c7d7bfa3dd77aa8b09c19036c8d |
--- /dev/null |
+++ b/LayoutTests/crypto/subtle/pbkdf2-deriveBits-failures.html |
@@ -0,0 +1,64 @@ |
+<!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 deriveBits() with various bad parameters for PBKDF2"); |
+ |
+jsTestIsAsync = true; |
+ |
+var testCase = { |
+ password: "password", |
+ salt: "salt", |
+ c: 1, |
+ dkLen: 20, |
+ hash: "SHA-1", |
+ derived_key_full_length: "0c60c80f961f0e71f3a9b524af6012062fe037a6" |
+ }; |
+ |
+function importPbkdf2Key() { |
+ var key = null; |
+ |
+ debug("Importing the password..."); |
+ |
+ var algorithm = {name: 'PBKDF2'}; |
+ |
+ var password = asciiToUint8Array(testCase.password); |
+ var usages = ['deriveBits', 'deriveKey']; |
+ var extractable = false; |
+ |
+ // (1) Import the password |
+ return crypto.subtle.importKey('raw', password, algorithm, extractable, usages).then(function(result) { |
+ key = result; |
+ return key; |
+ }); |
+} |
+ |
+var pbkdf2Key = null; |
+ |
+var params = { |
+ name: 'PBKDF2', |
+ salt: asciiToUint8Array(testCase.salt), |
+ iterations: testCase.c, |
+ hash: {name: testCase.hash} |
+}; |
+importPbkdf2Key().then(function(result) { |
+ pbkdf2Key = result; |
+ debug("\nDeriving 100 bits..."); |
+ return crypto.subtle.deriveBits(params, pbkdf2Key, 100); |
+}).then(failAndFinishJSTest, function(result) { |
+ logError(result); |
+ |
+ debug(""); |
+}).then(finishJSTest, failAndFinishJSTest); |
+ |
+</script> |
+ |
+</body> |
+</html> |