| Index: LayoutTests/crypto/importKey.html
|
| diff --git a/LayoutTests/crypto/importKey.html b/LayoutTests/crypto/importKey.html
|
| deleted file mode 100644
|
| index 4db882e6c058be5aea30e5b15f3a519933b43f37..0000000000000000000000000000000000000000
|
| --- a/LayoutTests/crypto/importKey.html
|
| +++ /dev/null
|
| @@ -1,153 +0,0 @@
|
| -<!DOCTYPE html>
|
| -<html>
|
| -<head>
|
| -<script src="../resources/js-test.js"></script>
|
| -<script src="resources/common.js"></script>
|
| -<script src="resources/keys.js"></script>
|
| -</head>
|
| -<body>
|
| -<p id="description"></p>
|
| -<div id="console"></div>
|
| -
|
| -<script>
|
| -description("Tests cypto.subtle.importKey.");
|
| -
|
| -jsTestIsAsync = true;
|
| -
|
| -aesCbc = {name: 'aes-cbc'};
|
| -
|
| -Promise.resolve(null).then(function() {
|
| - keyFormat = "raw";
|
| - data = asciiToUint8Array("raw bytes for key");
|
| - algorithm = { name: 'hmac', hash: { name: 'sha-256' } };
|
| - extractable = true;
|
| - // Note there are duplicates
|
| - keyUsages = ['encrypt', 'encrypt', 'encrypt', 'sign'];
|
| -
|
| - return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyUsages);
|
| -}).then(function(result) {
|
| - key = result;
|
| - shouldBe("key.type", "'secret'");
|
| - shouldBe("key.extractable", "true");
|
| - shouldBe("key.algorithm.name", "'HMAC'");
|
| - shouldBe("key.algorithm.hash.name", "'SHA-256'");
|
| - shouldBe("key.usages.join(',')", "'encrypt,sign'");
|
| -
|
| - // Same test as above, but with an keyUsages, and AES-CBC.
|
| - keyFormat = "raw";
|
| - data = asciiToUint8Array("16 bytes of key!");
|
| - algorithm = aesCbc;
|
| - extractable = true;
|
| - keyUsages = [];
|
| -
|
| - return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyUsages);
|
| -}).then(function(result) {
|
| - key = result;
|
| - shouldBe("key.type", "'secret'");
|
| - shouldBe("key.extractable", "true");
|
| - shouldBe("key.algorithm.name", "'AES-CBC'");
|
| - shouldBe("key.algorithm.length", "128");
|
| - shouldBe("key.usages.join(',')", "''");
|
| -
|
| - // Same test as above, but with extractable = false.
|
| - keyFormat = "raw";
|
| - data = asciiToUint8Array("16 bytes of key!");
|
| - algorithm = aesCbc;
|
| - extractable = false;
|
| - keyUsages = [];
|
| -
|
| - return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyUsages);
|
| -}).then(function(result) {
|
| - key = result;
|
| - shouldBe("key.type", "'secret'");
|
| - shouldBe("key.extractable", "false");
|
| - shouldBe("key.algorithm.name", "'AES-CBC'");
|
| - shouldBe("key.algorithm.length", "128");
|
| - shouldBe("key.usages.join(',')", "''");
|
| -
|
| - // Same test as above, but with keyFormat = spki
|
| - keyFormat = "spki";
|
| - data = asciiToUint8Array("16 bytes of key!");
|
| - algorithm = aesCbc;
|
| - extractable = false;
|
| - keyUsages = [];
|
| -
|
| - return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyUsages);
|
| -}).then(undefined, function(result) {
|
| - debug("rejected with " + result);
|
| -
|
| - // Import an spki formatted public key
|
| - keyFormat = "spki";
|
| - data = hexStringToUint8Array(kKeyData.rsa1.spki);
|
| - algorithm = {name: 'RsasSA-pKCS1-v1_5', hash: {name: 'sha-1'}};
|
| - extractable = false;
|
| - keyUsages = [];
|
| -
|
| - return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyUsages);
|
| -}).then(function(result) {
|
| - key = result;
|
| - shouldBe("key.type", "'public'");
|
| - // FIXME: Enable this once updated.
|
| - //shouldBe("key.extractable", "true");
|
| - shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'");
|
| - shouldBe("key.algorithm.hash.name", '"SHA-1"');
|
| - shouldEvaluateAs("key.algorithm.modulusLength", kKeyData.rsa1.modulusLengthBits);
|
| - bytesShouldMatchHexString("key.algorithm.publicExponent", kKeyData.rsa1.publicExponent, key.algorithm.publicExponent);
|
| - shouldBe("key.usages.join(',')", "''");
|
| -
|
| - // Import a pkcs8 formatted private key
|
| - keyFormat = "pkcs8";
|
| - data = hexStringToUint8Array(kKeyData.rsa1.pkcs8);
|
| - algorithm = {name: 'RsasSA-pKCS1-v1_5', hash: {name: 'sha-1'}};
|
| - extractable = false;
|
| - keyUsages = [];
|
| -
|
| - return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyUsages);
|
| -}).then(function(result) {
|
| - key = result;
|
| - shouldBe("key.type", "'private'");
|
| - shouldBe("key.extractable", "false");
|
| - shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'");
|
| - shouldBe("key.algorithm.hash.name", '"SHA-1"');
|
| - shouldEvaluateAs("key.algorithm.modulusLength", kKeyData.rsa1.modulusLengthBits);
|
| - bytesShouldMatchHexString("key.algorithm.publicExponent", kKeyData.rsa1.publicExponent, key.algorithm.publicExponent);
|
| - shouldBe("key.usages.join(',')", "''")
|
| -
|
| - keyFormat = "raw";
|
| - data = asciiToUint8Array("");
|
| - algorithm = aesCbc;
|
| - extractable = true;
|
| - keyUsages = [];
|
| -
|
| - // Invalid format.
|
| - shouldRejectPromiseWithNull("crypto.subtle.importKey('invalid format', data, algorithm, extractable, keyUsages)");
|
| -
|
| - // Invalid key usage.
|
| - shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, algorithm, extractable, ['SIGN'])");
|
| -
|
| - // If both the format and key usage are bogus, should complain about the
|
| - // format first.
|
| - shouldRejectPromiseWithNull("crypto.subtle.importKey('invalid format', data, algorithm, extractable, ['SIGN'])");
|
| -
|
| - // Undefined key usage.
|
| - // FIXME: http://crbug.com/262383
|
| - //shouldThrow("crypto.subtle.importKey(keyFormat, data, algorithm, extractable, undefined)");
|
| -
|
| - // Invalid data
|
| - shouldThrow("crypto.subtle.importKey(keyFormat, [], algorithm, extractable, keyUsages)");
|
| - shouldThrow("crypto.subtle.importKey(keyFormat, null, algorithm, extractable, keyUsages)");
|
| -
|
| - // Invalid algorithm
|
| - shouldThrow("crypto.subtle.importKey(keyFormat, data, null, extractable, keyUsages)");
|
| -
|
| - // Missing hash parameter for HMAC.
|
| - shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name: 'hmac'}, extractable, keyUsages)");
|
| -
|
| - // SHA-1 doesn't support the importKey operation.
|
| - shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name: 'sha-1'}, extractable, keyUsages)");
|
| -}).then(finishJSTest, failAndFinishJSTest);
|
| -
|
| -</script>
|
| -
|
| -</body>
|
| -</html>
|
|
|