| OLD | NEW |
| 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 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 }).then(function(result) { | 105 }).then(function(result) { |
| 106 key = result; | 106 key = result; |
| 107 shouldBe("key.type", "'private'"); | 107 shouldBe("key.type", "'private'"); |
| 108 shouldBe("key.extractable", "false"); | 108 shouldBe("key.extractable", "false"); |
| 109 shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'"); | 109 shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'"); |
| 110 shouldBe("key.algorithm.hash.name", '"SHA-1"'); | 110 shouldBe("key.algorithm.hash.name", '"SHA-1"'); |
| 111 shouldBe("key.algorithm.modulusLength", '1024'); | 111 shouldBe("key.algorithm.modulusLength", '1024'); |
| 112 bytesShouldMatchHexString("key.algorithm.publicExponent", "010001", key.algo
rithm.publicExponent); | 112 bytesShouldMatchHexString("key.algorithm.publicExponent", "010001", key.algo
rithm.publicExponent); |
| 113 shouldBe("key.usages.join(',')", "''") | 113 shouldBe("key.usages.join(',')", "''") |
| 114 | 114 |
| 115 // Import a "raw" key without specifying the algorithm. | |
| 116 keyFormat = "raw"; | |
| 117 data = asciiToUint8Array("16 bytes of key!"); | |
| 118 algorithm = null; | |
| 119 extractable = false; | |
| 120 keyUsages = []; | |
| 121 | |
| 122 return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU
sages); | |
| 123 }).then(undefined, function(result) { | |
| 124 debug("rejected with " + result); | |
| 125 | |
| 126 keyFormat = "raw"; | 115 keyFormat = "raw"; |
| 127 data = asciiToUint8Array(""); | 116 data = asciiToUint8Array(""); |
| 128 algorithm = aesCbc; | 117 algorithm = aesCbc; |
| 129 extractable = true; | 118 extractable = true; |
| 130 keyUsages = []; | 119 keyUsages = []; |
| 131 | 120 |
| 132 // Invalid format. | 121 // Invalid format. |
| 133 shouldRejectPromiseWithNull("crypto.subtle.importKey('invalid format', data,
algorithm, extractable, keyUsages)"); | 122 shouldRejectPromiseWithNull("crypto.subtle.importKey('invalid format', data,
algorithm, extractable, keyUsages)"); |
| 134 | 123 |
| 135 // Invalid key usage. | 124 // Invalid key usage. |
| 136 shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, algori
thm, extractable, ['SIGN'])"); | 125 shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, algori
thm, extractable, ['SIGN'])"); |
| 137 | 126 |
| 138 // If both the format and key usage are bogus, should complain about the | 127 // If both the format and key usage are bogus, should complain about the |
| 139 // format first. | 128 // format first. |
| 140 shouldRejectPromiseWithNull("crypto.subtle.importKey('invalid format', data,
algorithm, extractable, ['SIGN'])"); | 129 shouldRejectPromiseWithNull("crypto.subtle.importKey('invalid format', data,
algorithm, extractable, ['SIGN'])"); |
| 141 | 130 |
| 142 // Undefined key usage. | 131 // Undefined key usage. |
| 143 // FIXME: http://crbug.com/262383 | 132 // FIXME: http://crbug.com/262383 |
| 144 //shouldThrow("crypto.subtle.importKey(keyFormat, data, algorithm, extractab
le, undefined)"); | 133 //shouldThrow("crypto.subtle.importKey(keyFormat, data, algorithm, extractab
le, undefined)"); |
| 145 | 134 |
| 146 // Invalid data | 135 // Invalid data |
| 147 shouldThrow("crypto.subtle.importKey(keyFormat, [], algorithm, extractable,
keyUsages)"); | 136 shouldThrow("crypto.subtle.importKey(keyFormat, [], algorithm, extractable,
keyUsages)"); |
| 148 shouldThrow("crypto.subtle.importKey(keyFormat, null, algorithm, extractable
, keyUsages)"); | 137 shouldThrow("crypto.subtle.importKey(keyFormat, null, algorithm, extractable
, keyUsages)"); |
| 149 | 138 |
| 139 // Invalid algorithm |
| 140 shouldThrow("crypto.subtle.importKey(keyFormat, data, null, extractable, key
Usages)"); |
| 141 |
| 150 // Missing hash parameter for HMAC. | 142 // Missing hash parameter for HMAC. |
| 151 shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name:
'hmac'}, extractable, keyUsages)"); | 143 shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name:
'hmac'}, extractable, keyUsages)"); |
| 152 | 144 |
| 153 // SHA-1 doesn't support the importKey operation. | 145 // SHA-1 doesn't support the importKey operation. |
| 154 shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name:
'sha-1'}, extractable, keyUsages)"); | 146 shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name:
'sha-1'}, extractable, keyUsages)"); |
| 155 }).then(finishJSTest, failAndFinishJSTest); | 147 }).then(finishJSTest, failAndFinishJSTest); |
| 156 | 148 |
| 157 </script> | 149 </script> |
| 158 | 150 |
| 159 </body> | 151 </body> |
| 160 </html> | 152 </html> |
| OLD | NEW |