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

Unified Diff: LayoutTests/crypto/subtle/hkdf-unwrapKey.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-unwrapKey.html
diff --git a/LayoutTests/crypto/subtle/hkdf-unwrapKey.html b/LayoutTests/crypto/subtle/hkdf-unwrapKey.html
new file mode 100644
index 0000000000000000000000000000000000000000..8b5a58668d8ecb2e217486143066601cbd593eba
--- /dev/null
+++ b/LayoutTests/crypto/subtle/hkdf-unwrapKey.html
@@ -0,0 +1,61 @@
+<!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 unwrapping an HKDF key");
+
+jsTestIsAsync = true;
+
+kHkdfKey = hexStringToUint8Array("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b");
+kIv = new Uint8Array(16);
+
+var extractable = true;
+var derivingKeyAlgorithm = {
+ name: "HKDF",
+ hash: "SHA-256",
+ salt: new Uint8Array(),
+ info: new Uint8Array()
+};
+
+Promise.resolve(null).then(function(result) {
+ // Create a key to use for wrapping/unwrapping
+ return crypto.subtle.generateKey({name: "AES-GCM", length: 256}, false, ['encrypt', 'unwrapKey']);
+}).then(function(result) {
+ wrappingKey = result;
+
+ shouldEvaluateAs("wrappingKey.algorithm.name", "AES-GCM");
+ shouldEvaluateAs("wrappingKey.extractable", false);
+ shouldEvaluateAs("wrappingKey.usages.join(',')", "encrypt,unwrapKey");
+
+ // Wrap the HKDF key. Since the HKDF algorithm does not support the export
+ // key operation, it is wrapped by calling encrypt.
+ return crypto.subtle.encrypt({name: "AES-GCM", length: 256, iv: kIv}, wrappingKey, kHkdfKey);
+}).then(function(result) {
+ wrappedKey = result;
+
+ // Unwrap it as a raw key.
+ return crypto.subtle.unwrapKey("raw", wrappedKey, wrappingKey, {name: "AES-GCM", length: 256, iv: kIv}, "HKDF", false, ['deriveBits']);
+}).then(function(result) {
+ unwrappedHkdfKey = result;
+
+ shouldEvaluateAs("unwrappedHkdfKey.algorithm.name", "HKDF");
+ shouldEvaluateAs("unwrappedHkdfKey.extractable", false);
+ shouldEvaluateAs("unwrappedHkdfKey.usages.join(',')", "deriveBits");
+
+ debug("\nUnwrap an HKDF key using pkcs8 as the format.");
+ return crypto.subtle.unwrapKey("pkcs8", wrappedKey, wrappingKey, {name: "AES-GCM", length: 256, iv: kIv}, "HKDF", false, ['deriveBits']);
+}).then(failAndFinishJSTest, function(result) {
+ logError(result);
+}).then(finishJSTest, failAndFinishJSTest);
+
+</script>
+
+</body>
+</html>
« no previous file with comments | « LayoutTests/crypto/subtle/hkdf-importKey-failures-expected.txt ('k') | LayoutTests/crypto/subtle/hkdf-unwrapKey-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698