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

Unified Diff: LayoutTests/crypto/unwrapKey-lacks-usage.html

Issue 214263002: [refactor] Split wrap-unwrap.html into smaller files, and directly check the error result. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
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");
« no previous file with comments | « LayoutTests/crypto/unwrapKey-badParameters-expected.txt ('k') | LayoutTests/crypto/unwrapKey-lacks-usage-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698