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

Side by Side Diff: LayoutTests/crypto/aes-cbc-wrap-rsa-non-extractable.html

Issue 336173002: [webcrypto] Require importKey() for JWK to provide data as a Javascript object rather than a JSON a… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update additional tests Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/crypto/aes-cbc-wrap-rsa.html ('k') | LayoutTests/crypto/aes-export-key.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 wrapping an RSA key with AES-CBC."); 12 description("Test wrapping an RSA key with AES-CBC.");
13 13
14 jsTestIsAsync = true; 14 jsTestIsAsync = true;
15 15
16 var extractable = true; 16 var extractable = true;
17 var nonExtractable = false; 17 var nonExtractable = false;
18 18
19 var publicKeyJSON = { 19 var publicKeyJSON = {
20 kty: "RSA", 20 kty: "RSA",
21 alg: "RS256", 21 alg: "RS256",
22 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLR racT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6 s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPS CnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq7 2KUp02mJDZiiyiglxML_i3-_CeecCw", 22 n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLR racT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6 s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPS CnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq7 2KUp02mJDZiiyiglxML_i3-_CeecCw",
23 e: "AQAB", 23 e: "AQAB",
24 ext: false, 24 ext: false,
25 use: "sig" 25 use: "sig"
26 }; 26 };
27 27
28 var jwkKeyAsArrayBuffer = asciiToUint8Array(JSON.stringify(publicKeyJSON));
29 var wrappingKeyOctets = hexStringToUint8Array("2a00e0e776e94e4dc89bf947cebdebe1" ); 28 var wrappingKeyOctets = hexStringToUint8Array("2a00e0e776e94e4dc89bf947cebdebe1" );
30 29
31 debug("Importing a key to wrap..."); 30 debug("Importing a key to wrap...");
32 31
33 var importAlgorithm = {name: 'RSASSA-PKCS1-v1_5', hash: {name: 'sha-256'} }; 32 var importAlgorithm = {name: 'RSASSA-PKCS1-v1_5', hash: {name: 'sha-256'} };
34 crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, importAlgorithm, nonExtracta ble, ["verify"]).then(function(result) { 33 crypto.subtle.importKey("jwk", publicKeyJSON, importAlgorithm, nonExtractable, [ "verify"]).then(function(result) {
35 key = result; 34 key = result;
36 shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'"); 35 shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'");
37 debug("Importing a key encryption key..."); 36 debug("Importing a key encryption key...");
38 return crypto.subtle.importKey("raw", wrappingKeyOctets, {name: "AES-CBC"}, nonExtractable, ["wrapKey"]); 37 return crypto.subtle.importKey("raw", wrappingKeyOctets, {name: "AES-CBC"}, nonExtractable, ["wrapKey"]);
39 }).then(function(result) { 38 }).then(function(result) {
40 wrappingKey = result; 39 wrappingKey = result;
41 shouldBe("wrappingKey.algorithm.name", "'AES-CBC'"); 40 shouldBe("wrappingKey.algorithm.name", "'AES-CBC'");
42 var wrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("00010203040 5060708090a0b0c0d0e0f")}; 41 var wrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("00010203040 5060708090a0b0c0d0e0f")};
43 debug("wrapping the key..."); 42 debug("wrapping the key...");
44 return crypto.subtle.wrapKey("jwk", key, wrappingKey, wrapAlgorithm); 43 return crypto.subtle.wrapKey("jwk", key, wrappingKey, wrapAlgorithm);
45 }).then(undefined, function(result) { 44 }).then(undefined, function(result) {
46 testPassed("Rejected: " + result); 45 testPassed("Rejected: " + result);
47 }).then(finishJSTest, failAndFinishJSTest); 46 }).then(finishJSTest, failAndFinishJSTest);
48 47
49 </script> 48 </script>
50 49
51 </body> 50 </body>
52 </html> 51 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/aes-cbc-wrap-rsa.html ('k') | LayoutTests/crypto/aes-export-key.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698