OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="../resources/js-test.js"></script> | |
5 <script src="resources/common.js"></script> | |
6 <script src="resources/keys.js"></script> | |
7 </head> | |
8 <body> | |
9 <p id="description"></p> | |
10 <div id="console"></div> | |
11 | |
12 <script> | |
13 description("Tests that an unextractable key cannot be exported."); | |
14 | |
15 jsTestIsAsync = true; | |
16 | |
17 // FIXME: Should also test unextractable keys created from generateKey(). | |
18 | |
19 function importUnextractableAesKey() | |
20 { | |
21 var keyData = new Uint8Array(16); | |
22 var usages = ['encrypt']; | |
23 var extractable = false; | |
24 var algorithm = {name: 'aes-cbc'}; | |
25 | |
26 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s); | |
27 } | |
28 | |
29 function importUnextractableHmacKey() | |
30 { | |
31 var keyData = new Uint8Array(16); | |
32 var usages = ['sign']; | |
33 var extractable = false; | |
34 var algorithm = {name: 'HMAC', hash: {name: 'sha-1'}}; | |
35 | |
36 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s); | |
37 } | |
38 | |
39 function importUnextractableRsaPrivateKey() | |
40 { | |
41 var keyData = hexStringToUint8Array(kKeyData.rsa1.pkcs8); | |
42 var usages = ['sign']; | |
43 var extractable = false; | |
44 var algorithm = {name: 'RSASSA-PKCS1-v1_5', hash: {name: "sha-1"}}; | |
45 | |
46 return crypto.subtle.importKey('pkcs8', keyData, algorithm, extractable, usa
ges); | |
47 } | |
48 | |
49 importUnextractableAesKey().then(function(key) { | |
50 return crypto.subtle.exportKey('raw', key); | |
51 }).then(failAndFinishJSTest, function(result) { | |
52 logError(result); | |
53 | |
54 return importUnextractableHmacKey(); | |
55 }).then(function(key) { | |
56 return crypto.subtle.exportKey('raw', key); | |
57 }).then(failAndFinishJSTest, function(result) { | |
58 logError(result); | |
59 | |
60 return importUnextractableRsaPrivateKey(); | |
61 }).then(function(key) { | |
62 return crypto.subtle.exportKey('pkcs8', key); | |
63 }).then(failAndFinishJSTest, function(result) { | |
64 logError(result); | |
65 }).then(finishJSTest, failAndFinishJSTest); | |
66 | |
67 </script> | |
68 | |
69 </body> | |
70 </html> | |
OLD | NEW |