36 lines
941 B
HTML
36 lines
941 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
<script src="../resources/common.js"></script>
|
|
</head>
|
|
<body>
|
|
<p id="description"></p>
|
|
<div id="console"></div>
|
|
|
|
<script>
|
|
description("Test PBKDF2 deriveBits operation with an imported raw key");
|
|
|
|
jsTestIsAsync = true;
|
|
|
|
var nonExtractable = false;
|
|
var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
|
|
var salt = asciiToUint8Array("jnOw99oO");
|
|
var expectedDerivedKey = "a0b6531f2b2c917a14238d7f01f5004c";
|
|
|
|
crypto.subtle.importKey("raw", rawKey, "PBKDF2", nonExtractable, ["deriveBits"]).then(function(baseKey) {
|
|
return crypto.subtle.deriveBits({name: "PBKDF2", salt: salt, iterations: 100000, hash: "sha-1"}, baseKey, 128);
|
|
}).then(function(result) {
|
|
derivedKey = result;
|
|
|
|
shouldBe("bytesToHexString(derivedKey)", "expectedDerivedKey");
|
|
|
|
finishJSTest();
|
|
});
|
|
|
|
</script>
|
|
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|