| 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 23 matching lines...) Expand all Loading... |
| 34 // Invalid key | 34 // Invalid key |
| 35 shouldThrow("crypto.subtle.wrapKey('raw', 1, wrappingKey, wrapAlgorithm)"); | 35 shouldThrow("crypto.subtle.wrapKey('raw', 1, wrappingKey, wrapAlgorithm)"); |
| 36 | 36 |
| 37 // Invalid wrappingKey | 37 // Invalid wrappingKey |
| 38 shouldThrow("crypto.subtle.wrapKey('raw', key, '', wrapAlgorithm)"); | 38 shouldThrow("crypto.subtle.wrapKey('raw', key, '', wrapAlgorithm)"); |
| 39 | 39 |
| 40 // Invalid wrapAlgorithm | 40 // Invalid wrapAlgorithm |
| 41 shouldThrow("crypto.subtle.wrapKey('raw', key, wrappingKey, undefined)"); | 41 shouldThrow("crypto.subtle.wrapKey('raw', key, wrappingKey, undefined)"); |
| 42 | 42 |
| 43 // Key is not extractable. | 43 // Key is not extractable. |
| 44 shouldThrow("crypto.subtle.wrapKey('raw', keys.aesCbcJustDecrypt, wrappingKe
y, wrapAlgorithm)"); | 44 shouldRejectPromiseWithNull("crypto.subtle.wrapKey('raw', keys.aesCbcJustDec
rypt, wrappingKey, wrapAlgorithm)"); |
| 45 | 45 |
| 46 // wrappingKey's usage does not include wrapKey. | 46 // wrappingKey's usage does not include wrapKey. |
| 47 shouldThrow("crypto.subtle.wrapKey('raw', key, keys.aesCbcJustDecrypt, wrapA
lgorithm)"); | 47 shouldRejectPromiseWithNull("crypto.subtle.wrapKey('raw', key, keys.aesCbcJu
stDecrypt, wrapAlgorithm)"); |
| 48 | 48 |
| 49 // SHA-1 isn't a valid wrapKey algorithm. | 49 // SHA-1 isn't a valid wrapKey algorithm. |
| 50 shouldThrow("crypto.subtle.wrapKey('raw', key, wrappingKey, {name: 'SHA-1'})
"); | 50 shouldThrow("crypto.subtle.wrapKey('raw', key, wrappingKey, {name: 'SHA-1'})
"); |
| 51 | 51 |
| 52 // Wrap algorithm doesn't match the wrapping key's algorithm (AES-CBC key | 52 // Wrap algorithm doesn't match the wrapping key's algorithm (AES-CBC key |
| 53 // with AES-CTR wrap algorithm) | 53 // with AES-CTR wrap algorithm) |
| 54 aesCtrAlgorithm = {name: 'AES-CTR', counter: new Uint8Array(16), length: 0}; | 54 aesCtrAlgorithm = {name: 'AES-CTR', counter: new Uint8Array(16), length: 0}; |
| 55 shouldThrow("crypto.subtle.wrapKey('raw', key, wrappingKey, aesCtrAlgorithm)
"); | 55 shouldRejectPromiseWithNull("crypto.subtle.wrapKey('raw', key, wrappingKey,
aesCtrAlgorithm)"); |
| 56 | 56 |
| 57 // -------------------------------- | 57 // -------------------------------- |
| 58 // unwrapKey invalid parameters | 58 // unwrapKey invalid parameters |
| 59 // -------------------------------- | 59 // -------------------------------- |
| 60 | 60 |
| 61 wrappedKey = new Uint8Array(100); | 61 wrappedKey = new Uint8Array(100); |
| 62 unwrappingKey = keys.aesCbc; | 62 unwrappingKey = keys.aesCbc; |
| 63 unwrapAlgorithm = {name: 'aes-cbc', iv: new Uint8Array(16)}; | 63 unwrapAlgorithm = {name: 'aes-cbc', iv: new Uint8Array(16)}; |
| 64 unwrappedKeyAlgorithm = unwrapAlgorithm; | 64 unwrappedKeyAlgorithm = unwrapAlgorithm; |
| 65 extractable = true; | 65 extractable = true; |
| 66 keyUsages = ['encrypt']; | 66 keyUsages = ['encrypt']; |
| 67 | 67 |
| 68 // Invalid format | 68 // Invalid format |
| 69 shouldThrow("crypto.subtle.unwrapKey('bad-format', wrappedKey, unwrappingKey
, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)"); | 69 shouldThrow("crypto.subtle.unwrapKey('bad-format', wrappedKey, unwrappingKey
, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)"); |
| 70 | 70 |
| 71 // Invalid wrappedKey | 71 // Invalid wrappedKey |
| 72 shouldThrow("crypto.subtle.unwrapKey('raw', null, unwrappingKey, unwrapAlgor
ithm, unwrappedKeyAlgorithm, extractable, keyUsages)"); | 72 shouldThrow("crypto.subtle.unwrapKey('raw', null, unwrappingKey, unwrapAlgor
ithm, unwrappedKeyAlgorithm, extractable, keyUsages)"); |
| 73 | 73 |
| 74 // Invalid unwrappingKey | 74 // Invalid unwrappingKey |
| 75 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, 'hi', unwrapAlgorith
m, unwrappedKeyAlgorithm, extractable, keyUsages)"); | 75 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, 'hi', unwrapAlgorith
m, unwrappedKeyAlgorithm, extractable, keyUsages)"); |
| 76 | 76 |
| 77 // unwrappingKey does not include unwrapKey usage. | 77 // unwrappingKey does not include unwrapKey usage. |
| 78 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, keys.aesCbcJustDecry
pt, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)"); | 78 shouldRejectPromiseWithNull("crypto.subtle.unwrapKey('raw', wrappedKey, keys
.aesCbcJustDecrypt, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsag
es)"); |
| 79 | 79 |
| 80 // Invalid keyUsages (also, unwrappedKeyAlgorithm is set to null). | 80 // Invalid keyUsages (also, unwrappedKeyAlgorithm is set to null). |
| 81 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, 'hi', unwrapAlgorith
m, null, extractable, 9)"); | 81 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, 'hi', unwrapAlgorith
m, null, extractable, 9)"); |
| 82 | 82 |
| 83 // Invalid unwrapAlgorithm | 83 // Invalid unwrapAlgorithm |
| 84 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, null,
unwrappedKeyAlgorithm, extractable, keyUsages)"); | 84 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, null,
unwrappedKeyAlgorithm, extractable, keyUsages)"); |
| 85 | 85 |
| 86 // Invalid unwrappedKeyAlgorithm (specified but bad). | 86 // Invalid unwrappedKeyAlgorithm (specified but bad). |
| 87 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, unwra
pAlgorithm, 3, extractable, keyUsages)"); | 87 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, unwra
pAlgorithm, 3, extractable, keyUsages)"); |
| 88 | 88 |
| 89 // SHA-1 isn't a valid unwrapKey algorithm. | 89 // SHA-1 isn't a valid unwrapKey algorithm. |
| 90 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, {name
: 'SHA-1'}, unwrappedKeyAlgorithm, extractable, keyUsages)"); | 90 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, {name
: 'SHA-1'}, unwrappedKeyAlgorithm, extractable, keyUsages)"); |
| 91 | 91 |
| 92 // Mismatch between the unwrappingKey's algorithm and unwrapAlgorithm. | 92 // Mismatch between the unwrappingKey's algorithm and unwrapAlgorithm. |
| 93 shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, aesCt
rAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)"); | 93 shouldRejectPromiseWithNull("crypto.subtle.unwrapKey('raw', wrappedKey, unwr
appingKey, aesCtrAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)"); |
| 94 | 94 |
| 95 }).then(finishJSTest, failAndFinishJSTest); | 95 }).then(finishJSTest, failAndFinishJSTest); |
| 96 | 96 |
| 97 | 97 |
| 98 </script> | 98 </script> |
| 99 | 99 |
| 100 </body> | 100 </body> |
| OLD | NEW |