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

Unified Diff: LayoutTests/crypto/subtle/hkdf-deriveBits.html

Issue 822083003: Webcrypto: add layout tests for HKDF algorithm (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: remove duplicate test case 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/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..140248c580571cd0e44efcd3cbf1f0347a8c9656
--- /dev/null
+++ b/LayoutTests/crypto/subtle/hkdf-deriveBits.html
@@ -0,0 +1,53 @@
+<!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");
+ // The last 4 bits should be zeroes.
+ shouldBe("derivedBits.getUint8(0)", "0x80");
+
+}).then(finishJSTest, failAndFinishJSTest);
+
+</script>
+
+</body>
+</html>
« no previous file with comments | « LayoutTests/crypto/subtle/derive-hkdf-keys-expected.txt ('k') | LayoutTests/crypto/subtle/hkdf-deriveBits-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698