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

Unified Diff: LayoutTests/crypto/importKey.html

Issue 179353002: [webcrypto] Add the KeyAlgorithm interface. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase yet again (another conflict) Created 6 years, 10 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
« no previous file with comments | « LayoutTests/crypto/generateKey-expected.txt ('k') | LayoutTests/crypto/importKey-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/crypto/importKey.html
diff --git a/LayoutTests/crypto/importKey.html b/LayoutTests/crypto/importKey.html
index 7679c363210f4391885a313464a865991d1b9387..a7481ccdd286bfbbcf57b209221c9045cb816d90 100644
--- a/LayoutTests/crypto/importKey.html
+++ b/LayoutTests/crypto/importKey.html
@@ -26,10 +26,11 @@ Promise.resolve(null).then(function() {
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.usages.join(',')", "'encrypt,sign'")
+ 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";
@@ -41,10 +42,11 @@ Promise.resolve(null).then(function() {
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.usages.join(',')", "''")
+ 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";
@@ -56,10 +58,11 @@ Promise.resolve(null).then(function() {
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.usages.join(',')", "''")
+ 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";
@@ -70,9 +73,45 @@ Promise.resolve(null).then(function() {
return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyUsages);
}).then(undefined, function(result) {
- // TODO(eroman): Only "raw" key format is supported at the moment.
debug("rejected with " + result);
+ // Import an spki formatted public key
+ keyFormat = "spki";
+ data = hexStringToUint8Array(kPublicKeySpkiDerHex);
+ 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"');
+ shouldBe("key.algorithm.modulusLength", '1024');
+ bytesShouldMatchHexString("key.algorithm.publicExponent", "010001", key.algorithm.publicExponent);
+ shouldBe("key.usages.join(',')", "''");
+
+ // Import a pkcs8 formatted private key
+ keyFormat = "pkcs8";
+ data = hexStringToUint8Array(kPrivateKeyPkcs8DerHex);
+ 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"');
+ shouldBe("key.algorithm.modulusLength", '1024');
+ bytesShouldMatchHexString("key.algorithm.publicExponent", "010001", key.algorithm.publicExponent);
+ shouldBe("key.usages.join(',')", "''")
+
// Import a "raw" key without specifying the algorithm.
keyFormat = "raw";
data = asciiToUint8Array("16 bytes of key!");
« no previous file with comments | « LayoutTests/crypto/generateKey-expected.txt ('k') | LayoutTests/crypto/importKey-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698