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

Side by Side Diff: LayoutTests/crypto/aes-export-key.html

Issue 325323004: [webcrypto] Remove support for AES 192-bit keys (1 of 2) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
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 exporting an AES key."); 12 description("Test exporting an AES key.");
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 jwkKey = { 19 var jwkKey = {
20 kty: "oct", 20 kty: "oct",
21 k: "jnOw99oOZFLIEPMrgJB55WL46tJSLGt7" 21 k: "jnOw99oOZFLIEPMrgJB55WL46tJSLGt7jnOw99oOZFI"
22 }; 22 };
23 23
24 var jwkKeyAsArrayBuffer = asciiToUint8Array(JSON.stringify(jwkKey)); 24 var jwkKeyAsArrayBuffer = asciiToUint8Array(JSON.stringify(jwkKey));
25 25
26 Promise.resolve(null).then(function(result) { 26 Promise.resolve(null).then(function(result) {
27 return crypto.subtle.exportKey("raw"); 27 return crypto.subtle.exportKey("raw");
28 }).then(failAndFinishJSTest, function(result) { 28 }).then(failAndFinishJSTest, function(result) {
29 logError(result); 29 logError(result);
30 return crypto.subtle.exportKey("raw", null) 30 return crypto.subtle.exportKey("raw", null)
31 }).then(failAndFinishJSTest, function(result) { 31 }).then(failAndFinishJSTest, function(result) {
(...skipping 26 matching lines...) Expand all
58 }).then(failAndFinishJSTest, function(result) { 58 }).then(failAndFinishJSTest, function(result) {
59 logError(result); 59 logError(result);
60 return crypto.subtle.exportKey("foobar", key); 60 return crypto.subtle.exportKey("foobar", key);
61 }).then(failAndFinishJSTest, function(result) { 61 }).then(failAndFinishJSTest, function(result) {
62 logError(result); 62 logError(result);
63 63
64 debug("\nExporting the key as raw data..."); 64 debug("\nExporting the key as raw data...");
65 return crypto.subtle.exportKey("raw", key); 65 return crypto.subtle.exportKey("raw", key);
66 }).then(function(result) { 66 }).then(function(result) {
67 exportedData = result; 67 exportedData = result;
68 shouldBe("bytesToHexString(new Uint8Array(exportedData))", "'8e73b0f7da0e645 2c810f32b809079e562f8ead2522c6b7b'"); 68 shouldBe("bytesToHexString(new Uint8Array(exportedData))", "'8e73b0f7da0e645 2c810f32b809079e562f8ead2522c6b7b8e73b0f7da0e6452'");
69 69
70 debug("Exporting the key as JWK..."); 70 debug("Exporting the key as JWK...");
71 return crypto.subtle.exportKey("jwk", key); 71 return crypto.subtle.exportKey("jwk", key);
72 }).then(function(result) { 72 }).then(function(result) {
73 exportedJWK = JSON.parse(bytesToASCIIString(result)); 73 exportedJWK = JSON.parse(bytesToASCIIString(result));
74 shouldBe("exportedJWK.kty", "'oct'"); 74 shouldBe("exportedJWK.kty", "'oct'");
75 shouldBe("exportedJWK.k", "'jnOw99oOZFLIEPMrgJB55WL46tJSLGt7'"); 75 shouldBe("exportedJWK.k", "'jnOw99oOZFLIEPMrgJB55WL46tJSLGt7jnOw99oOZFI'");
76 shouldBe("exportedJWK.alg", "'A192CBC'"); 76 shouldBe("exportedJWK.alg", "'A256CBC'");
77 shouldBe("exportedJWK.ext", "true"); 77 shouldBe("exportedJWK.ext", "true");
78 shouldBe("exportedJWK.use", "undefined"); 78 shouldBe("exportedJWK.use", "undefined");
79 shouldBe("exportedJWK.key_ops", "['encrypt', 'decrypt', 'wrapKey', 'unwrapKe y']"); 79 shouldBe("exportedJWK.key_ops", "['encrypt', 'decrypt', 'wrapKey', 'unwrapKe y']");
80 80
81 debug("\nImporting a key that's not extractable..."); 81 debug("\nImporting a key that's not extractable...");
82 return crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, {name: "AES-CBC"} , nonExtractable, ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']) 82 return crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, {name: "AES-CBC"} , nonExtractable, ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'])
83 }).then(function(result) { 83 }).then(function(result) {
84 key = result; 84 key = result;
85 85
86 debug("\nTrying to export as raw..."); 86 debug("\nTrying to export as raw...");
(...skipping 13 matching lines...) Expand all
100 }, function(result) { 100 }, function(result) {
101 testPassed("Rejected, as expected"); 101 testPassed("Rejected, as expected");
102 logError(result); 102 logError(result);
103 103
104 finishJSTest(); 104 finishJSTest();
105 }); 105 });
106 </script> 106 </script>
107 107
108 </body> 108 </body>
109 </html> 109 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/aes-cbc-import-jwk-expected.txt ('k') | LayoutTests/crypto/aes-export-key-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698