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

Side by Side 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: use correct diffbase 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 <script src="resources/common.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10
11 <script>
12 description("Test unwrapping an HKDF key");
13
14 jsTestIsAsync = true;
15
16 kHkdfKey = hexStringToUint8Array("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b") ;
17 kIv = new Uint8Array(16);
18
19 var extractable = true;
20 var derivingKeyAlgorithm = {
21 name: "HKDF",
22 hash: "SHA-256",
23 salt: new Uint8Array(),
24 info: new Uint8Array()
25 };
26
27 Promise.resolve(null).then(function(result) {
28 // Create a key to use for wrapping/unwrapping
29 return crypto.subtle.generateKey({name: "AES-GCM", length: 256}, false, ['en crypt', 'unwrapKey']);
30 }).then(function(result) {
31 wrappingKey = result;
32
33 shouldEvaluateAs("wrappingKey.algorithm.name", "AES-GCM");
34 shouldEvaluateAs("wrappingKey.extractable", false);
35 shouldEvaluateAs("wrappingKey.usages.join(',')", "encrypt,unwrapKey");
36
37 // Wrap the HKDF key. Since the HKDF algorithm does not support the export
38 // key operation, I wrap it by calling encrypt.
eroman 2015/01/07 01:18:44 Same comment as in another review: Avoid the use o
nharper 2015/01/09 22:41:47 Done.
39 return crypto.subtle.encrypt({name: "AES-GCM", length: 256, iv: kIv}, wrappi ngKey, kHkdfKey);
40 }).then(function(result) {
41 wrappedKey = result;
42
43 // Unwrap it as a raw key.
44 return crypto.subtle.unwrapKey("raw", wrappedKey, wrappingKey, {name: "AES-G CM", length: 256, iv: kIv}, "HKDF", false, ['deriveBits']);
45 }).then(function(result) {
46 unwrappedHkdfKey = result;
47
48 shouldEvaluateAs("unwrappedHkdfKey.algorithm.name", "HKDF");
49 shouldEvaluateAs("unwrappedHkdfKey.extractable", false);
50 shouldEvaluateAs("unwrappedHkdfKey.usages.join(',')", "deriveBits");
51
52 debug("\nUnwrapping an HKDF key from a format other than raw should fail.");
53 return crypto.subtle.unwrapKey("pkcs8", wrappedKey, wrappingKey, {name: "AES -GCM", length: 256, iv: kIv}, "HKDF", false, ['deriveBits']);
54 }).then(failAndFinishJSTest, function(result) {
55 logError(result);
56 }).then(finishJSTest, failAndFinishJSTest);
57
58 </script>
59
60 </body>
61 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698