Index: LayoutTests/crypto/subtle/hkdf-deriveBits.html |
diff --git a/LayoutTests/crypto/subtle/hkdf-deriveBits.html b/LayoutTests/crypto/subtle/hkdf-deriveBits.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..22c243566dab07539c218293d7670645c80fc54d |
--- /dev/null |
+++ b/LayoutTests/crypto/subtle/hkdf-deriveBits.html |
@@ -0,0 +1,52 @@ |
+<!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("Test that HKDF does not support methods it should not support."); |
+ |
+jsTestIsAsync = true; |
+ |
+kHkdfKey = "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"; |
+ |
+kHkdfAlgorithm = { |
+ name: "HKDF", |
+ hash: "SHA-256", |
+ salt: new Uint8Array(), |
+ info: new Uint8Array() |
+}; |
+ |
+var extractable = true; |
+Promise.resolve(null).then(function(result) { |
+ // Set up the test by creating an HKDF key. |
+ return crypto.subtle.importKey("raw", hexStringToUint8Array(kHkdfKey), {name: "HKDF"}, extractable, ['deriveKey', 'deriveBits']); |
+}).then(function(result) { |
+ baseKey = result; |
+ |
+ debug("Derive 0 bits from the HKDF key"); |
+ return crypto.subtle.deriveBits(kHkdfAlgorithm, baseKey, 0); |
+}).then(function(result) { |
+ derivedBits = result; |
+ |
+ shouldBe("derivedBits.byteLength", "0"); |
+ |
+ debug("Derive 4 bits from the HKDF key"); |
+ return crypto.subtle.deriveBits(kHkdfAlgorithm, baseKey, 4); |
+}).then(function(result) { |
+ derivedBits = new DataView(result); |
+ |
+ shouldBe("derivedBits.byteLength", "1"); |
+ shouldBe("derivedBits.getUint8(0) % 16", "0"); |
eroman
2015/01/13 00:45:34
My earlier comment is unresolved. Why not test the
nharper
2015/01/13 01:43:26
My thought was "test that the last 4 bits are zero
eroman
2015/01/14 02:45:11
The reason I want to test the whole byte, is this
nharper
2015/01/14 02:53:42
Ok, that makes sense.
|
+ |
+}).then(finishJSTest, failAndFinishJSTest); |
+ |
+</script> |
+ |
+</body> |
+</html> |