| Index: LayoutTests/crypto/unwrapKey-lacks-usage.html
|
| diff --git a/LayoutTests/crypto/aes-key-algorithm-mismatch.html b/LayoutTests/crypto/unwrapKey-lacks-usage.html
|
| similarity index 35%
|
| copy from LayoutTests/crypto/aes-key-algorithm-mismatch.html
|
| copy to LayoutTests/crypto/unwrapKey-lacks-usage.html
|
| index 9d97be3c1f1b0cac349a5e49617c9a8269fbc064..b79b80cc192b16bd4ab6613b3f745f8ada481152 100644
|
| --- a/LayoutTests/crypto/aes-key-algorithm-mismatch.html
|
| +++ b/LayoutTests/crypto/unwrapKey-lacks-usage.html
|
| @@ -9,26 +9,28 @@
|
| <div id="console"></div>
|
|
|
| <script>
|
| -description("Call encrypt using the wrong AES key");
|
| +description("Tests that unwrapping keys must have the 'unwrapKey' usage.");
|
|
|
| jsTestIsAsync = true;
|
|
|
| -var keyData = hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c");
|
| -var data = asciiToUint8Array("hello");
|
| -var aesCbcKey = null;
|
| +function importUnwrappingKey()
|
| +{
|
| + var data = new Uint8Array(16);
|
| + var extractable = true;
|
| + var keyUsages = ['decrypt'];
|
|
|
| -Promise.resolve(null).then(function(result) {
|
| - var usages = ['encrypt', 'decrypt'];
|
| - var extractable = false;
|
| - var algorithm = {name: 'aes-gcm'};
|
| + return crypto.subtle.importKey('raw', data, {name: 'AES-CBC'}, extractable, keyUsages);
|
| +}
|
|
|
| - return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usages);
|
| -}).then(function(result) {
|
| - key = result;
|
| - shouldEvaluateAs("key.algorithm.name", "AES-GCM");
|
| +importUnwrappingKey().then(function(result) {
|
| + wrappedKey = new Uint8Array(100);
|
| + unwrappingKey = result;
|
| + unwrapAlgorithm = {name: 'aes-cbc', iv: new Uint8Array(16)};
|
| + unwrappedKeyAlgorithm = unwrapAlgorithm;
|
| + extractable = true;
|
| + keyUsages = ['encrypt'];
|
|
|
| - // Can't use an AES-KW key for AES-CBC (even though both are AES keys).
|
| - return crypto.subtle.encrypt({name: 'AES-CBC', iv: new Uint8Array(16)}, key, data);
|
| + return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages);
|
| }).then(failAndFinishJSTest, function(result) {
|
| error = result;
|
| shouldBeNull("error");
|
|
|