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

Side by Side Diff: third_party/WebKit/LayoutTests/crypto/subtle/derive-hkdf-keys.html

Issue 2289033002: Require extractable=false for KDF import (Closed)
Patch Set: update another test Created 4 years, 3 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/js-test.js"></script>
5 <script src="resources/common.js"></script> 5 <script src="resources/common.js"></script>
6 </head> 6 </head>
7 <body> 7 <body>
8 <p id="description"></p> 8 <p id="description"></p>
9 <div id="console"></div> 9 <div id="console"></div>
10 10
11 <script> 11 <script>
12 description("Test deriving HKDF keys with deriveKey()"); 12 description("Test deriving HKDF keys with deriveKey()");
13 13
14 jsTestIsAsync = true; 14 jsTestIsAsync = true;
15 15
16 var extractable = true;
17 var derivingKeyAlgorithm = { 16 var derivingKeyAlgorithm = {
18 name: "HKDF", 17 name: "HKDF",
19 hash: "SHA-256", 18 hash: "SHA-256",
20 salt: new Uint8Array(), 19 salt: new Uint8Array(),
21 info: new Uint8Array() 20 info: new Uint8Array()
22 }; 21 };
23 22
24 var privateKeyJSON = { 23 var privateKeyJSON = {
25 "kty": "EC", 24 "kty": "EC",
26 "crv": "P-256", 25 "crv": "P-256",
(...skipping 21 matching lines...) Expand all
48 Promise.resolve(null).then(function(result) { 47 Promise.resolve(null).then(function(result) {
49 return crypto.subtle.importKey("jwk", privateKeyJSON, {name: "ECDH", namedCu rve: "P-256"}, true, ["deriveKey"]); 48 return crypto.subtle.importKey("jwk", privateKeyJSON, {name: "ECDH", namedCu rve: "P-256"}, true, ["deriveKey"]);
50 }).then(function(result) { 49 }).then(function(result) {
51 privateKey = result; 50 privateKey = result;
52 51
53 return crypto.subtle.importKey("jwk", publicKeyJSON, {name: "ECDH", namedCur ve: "P-256"}, true, []); 52 return crypto.subtle.importKey("jwk", publicKeyJSON, {name: "ECDH", namedCur ve: "P-256"}, true, []);
54 }).then(function(result) { 53 }).then(function(result) {
55 publicKey = result; 54 publicKey = result;
56 55
57 debug("Derive an HKDF key from ECDH keys"); 56 debug("Derive an HKDF key from ECDH keys");
58 return crypto.subtle.deriveKey({name: "ECDH", namedCurve: "P-256", public: p ublicKey}, privateKey, "HKDF", true, ['deriveKey', 'deriveBits']); 57 return crypto.subtle.deriveKey({name: "ECDH", namedCurve: "P-256", public: p ublicKey}, privateKey, "HKDF", false, ['deriveKey', 'deriveBits']);
59 }).then(function(result) { 58 }).then(function(result) {
60 hkdfKey = result; 59 hkdfKey = result;
61 60
62 shouldEvaluateAs("hkdfKey.algorithm.name", "HKDF"); 61 shouldEvaluateAs("hkdfKey.algorithm.name", "HKDF");
63 shouldEvaluateAs("hkdfKey.extractable", true); 62 shouldEvaluateAs("hkdfKey.extractable", false);
64 shouldEvaluateAs("hkdfKey.usages.join(',')", "deriveKey,deriveBits"); 63 shouldEvaluateAs("hkdfKey.usages.join(',')", "deriveKey,deriveBits");
65 64
66 debug("\nDerive 128 bits from the HKDF key"); 65 debug("\nDerive 128 bits from the HKDF key");
67 return crypto.subtle.deriveBits(hkdfAlgorithm, hkdfKey, 128); 66 return crypto.subtle.deriveBits(hkdfAlgorithm, hkdfKey, 128);
68 }).then(function(result) { 67 }).then(function(result) {
69 derivedBits = result; 68 derivedBits = result;
70 69
71 return crypto.subtle.importKey("raw", secret, hkdfAlgorithm, true, ['deriveB its']); 70 return crypto.subtle.importKey("raw", secret, hkdfAlgorithm, false, ['derive Bits']);
72 }).then(function(hkdfKey) { 71 }).then(function(hkdfKey) {
73 return crypto.subtle.deriveBits(hkdfAlgorithm, hkdfKey, 128); 72 return crypto.subtle.deriveBits(hkdfAlgorithm, hkdfKey, 128);
74 }).then(function(result) { 73 }).then(function(result) {
75 expectedDerivedBits = result; 74 expectedDerivedBits = result;
76 75
77 shouldEvaluateAs("bytesToHexString(derivedBits)", bytesToHexString(expectedD erivedBits)); 76 shouldEvaluateAs("bytesToHexString(derivedBits)", bytesToHexString(expectedD erivedBits));
78 }).then(finishJSTest, failAndFinishJSTest); 77 }).then(finishJSTest, failAndFinishJSTest);
79 78
80 </script> 79 </script>
81 80
82 </body> 81 </body>
83 </html> 82 </html>
OLDNEW
« no previous file with comments | « components/webcrypto/status.cc ('k') | third_party/WebKit/LayoutTests/crypto/subtle/derive-hkdf-keys-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698