Commit 8199d8e9 authored by ap@apple.com's avatar ap@apple.com

Make algorithm.name return registered name, not normalized one

https://bugs.webkit.org/show_bug.cgi?id=125641

Reviewed by Anders Carlsson.

Source/WebCore: 

Currently, WebCrypto editor's draft stipulates that algorithm name is lowercased
as part of normalization.

But it makes little sense to register algorithms as mixed (mostly upper) case, yet
return the name lowercased. Other implementations don't bother respecting this,
and signs are that the spec will change.

I'd like to match other implementations here, because sticking to the spec only
makes us fail 3rd party test suites for no good reason.

Updated many existing tests.

* crypto/CryptoAlgorithmRegistry.cpp:
(WebCore::CryptoAlgorithmRegistry::getIdentifierForName):
(WebCore::CryptoAlgorithmRegistry::registerAlgorithm):
* crypto/CryptoAlgorithmRegistry.h:
* crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
* crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
* crypto/algorithms/CryptoAlgorithmSHA1.cpp:
* crypto/algorithms/CryptoAlgorithmSHA224.cpp:
* crypto/algorithms/CryptoAlgorithmSHA256.cpp:
* crypto/algorithms/CryptoAlgorithmSHA384.cpp:
* crypto/algorithms/CryptoAlgorithmSHA512.cpp:

LayoutTests: 

* crypto/subtle/aes-cbc-192-encrypt-decrypt-expected.txt:
* crypto/subtle/aes-cbc-192-encrypt-decrypt.html:
* crypto/subtle/aes-cbc-256-encrypt-decrypt-expected.txt:
* crypto/subtle/aes-cbc-256-encrypt-decrypt.html:
* crypto/subtle/aes-cbc-encrypt-decrypt-expected.txt:
* crypto/subtle/aes-cbc-encrypt-decrypt-with-padding-expected.txt:
* crypto/subtle/aes-cbc-encrypt-decrypt-with-padding.html:
* crypto/subtle/aes-cbc-encrypt-decrypt.html:
* crypto/subtle/aes-cbc-generate-key-expected.txt:
* crypto/subtle/aes-cbc-generate-key.html:
* crypto/subtle/aes-cbc-import-jwk-expected.txt:
* crypto/subtle/aes-cbc-import-jwk.html:
* crypto/subtle/aes-cbc-invalid-length-expected.txt:
* crypto/subtle/aes-cbc-invalid-length.html:
* crypto/subtle/aes-cbc-unwrap-failure-expected.txt:
* crypto/subtle/aes-cbc-unwrap-failure.html:
* crypto/subtle/aes-cbc-unwrap-rsa-expected.txt:
* crypto/subtle/aes-cbc-unwrap-rsa.html:
* crypto/subtle/aes-cbc-wrap-rsa-expected.txt:
* crypto/subtle/aes-cbc-wrap-rsa-non-extractable-expected.txt:
* crypto/subtle/aes-cbc-wrap-rsa-non-extractable.html:
* crypto/subtle/aes-cbc-wrap-rsa.html:
* crypto/subtle/aes-kw-key-manipulation-expected.txt:
* crypto/subtle/aes-kw-key-manipulation.html:
* crypto/subtle/aes-kw-wrap-unwrap-aes-expected.txt:
* crypto/subtle/aes-kw-wrap-unwrap-aes.html:
* crypto/subtle/aes-postMessage-expected.txt:
* crypto/subtle/aes-postMessage.html:
* crypto/subtle/hmac-generate-key-expected.txt:
* crypto/subtle/hmac-generate-key.html:
* crypto/subtle/hmac-import-jwk-expected.txt:
* crypto/subtle/hmac-import-jwk.html:
* crypto/subtle/hmac-postMessage-expected.txt:
* crypto/subtle/hmac-postMessage.html:
* crypto/subtle/hmac-sign-verify-empty-key-expected.txt:
* crypto/subtle/hmac-sign-verify-empty-key.html:
* crypto/subtle/hmac-sign-verify-expected.txt:
* crypto/subtle/hmac-sign-verify.html:
* crypto/subtle/postMessage-worker-expected.txt:
* crypto/subtle/postMessage-worker.html:
* crypto/subtle/resources/postMessage-worker.js:
* crypto/subtle/rsa-oaep-key-manipulation-expected.txt:
* crypto/subtle/rsa-oaep-key-manipulation.html:
* crypto/subtle/rsa-oaep-wrap-unwrap-aes-expected.txt:
* crypto/subtle/rsa-oaep-wrap-unwrap-aes.html:
* crypto/subtle/rsa-postMessage-expected.txt:
* crypto/subtle/rsa-postMessage.html:
* crypto/subtle/rsassa-pkcs1-v1_5-generate-key-expected.txt:
* crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html:
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-expected.txt:
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk.html:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160491 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0d422e8f
2013-12-12 Alexey Proskuryakov <ap@apple.com>
Make algorithm.name return registered name, not normalized one
https://bugs.webkit.org/show_bug.cgi?id=125641
Reviewed by Anders Carlsson.
* crypto/subtle/aes-cbc-192-encrypt-decrypt-expected.txt:
* crypto/subtle/aes-cbc-192-encrypt-decrypt.html:
* crypto/subtle/aes-cbc-256-encrypt-decrypt-expected.txt:
* crypto/subtle/aes-cbc-256-encrypt-decrypt.html:
* crypto/subtle/aes-cbc-encrypt-decrypt-expected.txt:
* crypto/subtle/aes-cbc-encrypt-decrypt-with-padding-expected.txt:
* crypto/subtle/aes-cbc-encrypt-decrypt-with-padding.html:
* crypto/subtle/aes-cbc-encrypt-decrypt.html:
* crypto/subtle/aes-cbc-generate-key-expected.txt:
* crypto/subtle/aes-cbc-generate-key.html:
* crypto/subtle/aes-cbc-import-jwk-expected.txt:
* crypto/subtle/aes-cbc-import-jwk.html:
* crypto/subtle/aes-cbc-invalid-length-expected.txt:
* crypto/subtle/aes-cbc-invalid-length.html:
* crypto/subtle/aes-cbc-unwrap-failure-expected.txt:
* crypto/subtle/aes-cbc-unwrap-failure.html:
* crypto/subtle/aes-cbc-unwrap-rsa-expected.txt:
* crypto/subtle/aes-cbc-unwrap-rsa.html:
* crypto/subtle/aes-cbc-wrap-rsa-expected.txt:
* crypto/subtle/aes-cbc-wrap-rsa-non-extractable-expected.txt:
* crypto/subtle/aes-cbc-wrap-rsa-non-extractable.html:
* crypto/subtle/aes-cbc-wrap-rsa.html:
* crypto/subtle/aes-kw-key-manipulation-expected.txt:
* crypto/subtle/aes-kw-key-manipulation.html:
* crypto/subtle/aes-kw-wrap-unwrap-aes-expected.txt:
* crypto/subtle/aes-kw-wrap-unwrap-aes.html:
* crypto/subtle/aes-postMessage-expected.txt:
* crypto/subtle/aes-postMessage.html:
* crypto/subtle/hmac-generate-key-expected.txt:
* crypto/subtle/hmac-generate-key.html:
* crypto/subtle/hmac-import-jwk-expected.txt:
* crypto/subtle/hmac-import-jwk.html:
* crypto/subtle/hmac-postMessage-expected.txt:
* crypto/subtle/hmac-postMessage.html:
* crypto/subtle/hmac-sign-verify-empty-key-expected.txt:
* crypto/subtle/hmac-sign-verify-empty-key.html:
* crypto/subtle/hmac-sign-verify-expected.txt:
* crypto/subtle/hmac-sign-verify.html:
* crypto/subtle/postMessage-worker-expected.txt:
* crypto/subtle/postMessage-worker.html:
* crypto/subtle/resources/postMessage-worker.js:
* crypto/subtle/rsa-oaep-key-manipulation-expected.txt:
* crypto/subtle/rsa-oaep-key-manipulation.html:
* crypto/subtle/rsa-oaep-wrap-unwrap-aes-expected.txt:
* crypto/subtle/rsa-oaep-wrap-unwrap-aes.html:
* crypto/subtle/rsa-postMessage-expected.txt:
* crypto/subtle/rsa-postMessage.html:
* crypto/subtle/rsassa-pkcs1-v1_5-generate-key-expected.txt:
* crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html:
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk-expected.txt:
* crypto/subtle/rsassa-pkcs1-v1_5-import-jwk.html:
2013-12-12 Michał Pakuła vel Rutka <m.pakula@samsung.com>
Unreviewed EFL gardening
......@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing a raw AES key from string literal...
PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'aes-cbc'
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 192
PASS key.usages is ['encrypt', 'decrypt']
Using the key to encrypt plaintext...
......
......@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
key = result;
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "192");
shouldBe("key.usages", "['encrypt', 'decrypt']");
......
......@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing a raw AES key from string literal...
PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'aes-cbc'
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 256
PASS key.usages is ['encrypt', 'decrypt']
Using the key to encrypt plaintext...
......
......@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
key = result;
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "256");
shouldBe("key.usages", "['encrypt', 'decrypt']");
......
......@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing a raw AES key from string literal...
PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'aes-cbc'
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 128
PASS key.usages is ['encrypt', 'decrypt']
Using the key to encrypt plaintext...
......
......@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing a raw AES key from string literal...
PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'aes-cbc'
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 128
PASS key.usages is ['encrypt', 'decrypt']
Using the key to encrypt plaintext...
......
......@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
key = result;
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "128");
shouldBe("key.usages", "['encrypt', 'decrypt']");
......
......@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
key = result;
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "128");
shouldBe("key.usages", "['encrypt', 'decrypt']");
......
......@@ -10,7 +10,7 @@ PASS crypto.subtle.generateKey({name: "aes-cbc", length: {}}, extractable, ["enc
Generating a key...
PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'aes-cbc'
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 128
PASS key.usages is ['encrypt', 'decrypt']
PASS successfullyParsed is true
......
......@@ -26,7 +26,7 @@ crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["encrypt
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "128");
shouldBe("key.usages", "['encrypt', 'decrypt']");
......
......@@ -7,7 +7,7 @@ Importing a key...
PASS key.type is 'secret'
PASS key.extractable is false
PASS key.algorithm.name is 'aes-cbc'
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 192
PASS key.usages is ["encrypt"]
......
......@@ -34,7 +34,7 @@ crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, null, false, ["encrypt"]).th
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "false");
shouldBe("key.algorithm.name", "'aes-cbc'");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "192");
shouldBe("key.usages", '["encrypt"]');
......
......@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing a raw AES key from string literal...
PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'aes-cbc'
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 176
PASS key.usages is ['encrypt', 'decrypt']
Using the key to encrypt plaintext...
......
......@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
key = result;
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "176");
shouldBe("key.usages", "['encrypt', 'decrypt']");
......
......@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing an unwrapping key...
PASS unwrappingKey.algorithm.name is 'aes-cbc'
PASS unwrappingKey.algorithm.name is 'AES-CBC'
Unwrapping a key...
PASS Promise rejected
PASS successfullyParsed is true
......
......@@ -22,7 +22,7 @@ var wrappedKey = hexStringToUint8Array("b490dedb3abc3fd545e146538e6cc3ca"); // A
debug("Importing an unwrapping key...");
crypto.subtle.importKey("raw", unwrappingKeyOctets, "AES-CBC", nonExtractable, ["unwrapKey"]).then(function(result) {
unwrappingKey = result;
shouldBe("unwrappingKey.algorithm.name", "'aes-cbc'");
shouldBe("unwrappingKey.algorithm.name", "'AES-CBC'");
var unwrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")};
debug("Unwrapping a key...");
return crypto.subtle.unwrapKey("jwk", wrappedKey, unwrappingKey, unwrapAlgorithm, null, extractable, ["sign", "verify", "encrypt", "decrypt", "wrap", "unwrap"]);
......
......@@ -4,15 +4,15 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing an unwrapping key...
PASS unwrappingKey.algorithm.name is 'aes-cbc'
PASS unwrappingKey.algorithm.name is 'AES-CBC'
Unwrapping a key...
PASS unwrappedKey.toString() is '[object Key]'
PASS unwrappedKey.type is 'public'
PASS unwrappedKey.usages is ['sign','verify']
PASS unwrappedKey.algorithm.name is 'rsassa-pkcs1-v1_5'
PASS unwrappedKey.algorithm.name is 'RSASSA-PKCS1-v1_5'
PASS unwrappedKey.algorithm.modulusLength is 2048
PASS Base64URL.stringify(unwrappedKey.algorithm.publicExponent) is publicKeyJSON.e
PASS unwrappedKey.algorithm.hash.name is 'sha-256'
PASS unwrappedKey.algorithm.hash.name is 'SHA-256'
PASS unwrappedKey.extractable is false
PASS successfullyParsed is true
......
......@@ -31,7 +31,7 @@ var wrappedKey = hexStringToUint8Array("3511f6028db04ea97e7cfad3c4cc60837bceff25
debug("Importing an unwrapping key...");
crypto.subtle.importKey("raw", unwrappingKeyOctets, "AES-CBC", nonExtractable, ["unwrapKey"]).then(function(result) {
unwrappingKey = result;
shouldBe("unwrappingKey.algorithm.name", "'aes-cbc'");
shouldBe("unwrappingKey.algorithm.name", "'AES-CBC'");
var unwrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")};
debug("Unwrapping a key...");
return crypto.subtle.unwrapKey("jwk", wrappedKey, unwrappingKey, unwrapAlgorithm, null, extractable, ["sign", "verify", "encrypt", "decrypt", "wrap", "unwrap"]);
......@@ -41,10 +41,10 @@ crypto.subtle.importKey("raw", unwrappingKeyOctets, "AES-CBC", nonExtractable, [
shouldBe("unwrappedKey.toString()", "'[object Key]'");
shouldBe("unwrappedKey.type", "'public'");
shouldBe("unwrappedKey.usages", "['sign','verify']");
shouldBe("unwrappedKey.algorithm.name", "'rsassa-pkcs1-v1_5'");
shouldBe("unwrappedKey.algorithm.name", "'RSASSA-PKCS1-v1_5'");
shouldBe("unwrappedKey.algorithm.modulusLength", "2048");
shouldBe("Base64URL.stringify(unwrappedKey.algorithm.publicExponent)", "publicKeyJSON.e");
shouldBe("unwrappedKey.algorithm.hash.name", "'sha-256'");
shouldBe("unwrappedKey.algorithm.hash.name", "'SHA-256'");
shouldBe("unwrappedKey.extractable", "false");
finishJSTest();
});
......
......@@ -4,9 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing a key to wrap...
PASS key.algorithm.name is 'rsassa-pkcs1-v1_5'
PASS key.algorithm.name is 'RSASSA-PKCS1-v1_5'
Importing a key encryption key...
PASS wrappingKey.algorithm.name is 'aes-cbc'
PASS wrappingKey.algorithm.name is 'AES-CBC'
PASS wrappedKey.toString() is '[object ArrayBuffer]'
PASS successfullyParsed is true
......
......@@ -4,9 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing a key to wrap...
PASS key.algorithm.name is 'rsassa-pkcs1-v1_5'
PASS key.algorithm.name is 'RSASSA-PKCS1-v1_5'
Importing a key encryption key...
PASS wrappingKey.algorithm.name is 'aes-cbc'
PASS wrappingKey.algorithm.name is 'AES-CBC'
wrapping the key...
PASS Rejected
PASS successfullyParsed is true
......
......@@ -31,12 +31,12 @@ var wrappingKeyOctets = hexStringToUint8Array("2a00e0e776e94e4dc89bf947cebdebe1"
debug("Importing a key to wrap...");
crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, null, extractable, ["sign", "verify"]).then(function(result) {
key = result;
shouldBe("key.algorithm.name", "'rsassa-pkcs1-v1_5'");
shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'");
debug("Importing a key encryption key...");
return crypto.subtle.importKey("raw", wrappingKeyOctets, "AES-CBC", nonExtractable, ["wrapKey"]);
}).then(function(result) {
wrappingKey = result;
shouldBe("wrappingKey.algorithm.name", "'aes-cbc'");
shouldBe("wrappingKey.algorithm.name", "'AES-CBC'");
var wrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")};
debug("wrapping the key...");
return crypto.subtle.wrapKey("jwk", key, wrappingKey, wrapAlgorithm);
......
......@@ -31,12 +31,12 @@ var wrappingKeyOctets = hexStringToUint8Array("2a00e0e776e94e4dc89bf947cebdebe1"
debug("Importing a key to wrap...");
crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, null, extractable, ["sign", "verify"]).then(function(result) {
key = result;
shouldBe("key.algorithm.name", "'rsassa-pkcs1-v1_5'");
shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'");
debug("Importing a key encryption key...");
return crypto.subtle.importKey("raw", wrappingKeyOctets, "AES-CBC", nonExtractable, ["wrapKey"]);
}).then(function(result) {
wrappingKey = result;
shouldBe("wrappingKey.algorithm.name", "'aes-cbc'");
shouldBe("wrappingKey.algorithm.name", "'AES-CBC'");
var wrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")};
return crypto.subtle.wrapKey("jwk", key, wrappingKey, wrapAlgorithm);
}).then(function(result) {
......
......@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Generating a key...
PASS key.toString() is '[object Key]'
PASS key.type is 'secret'
PASS key.algorithm.name is 'aes-kw'
PASS key.algorithm.name is 'AES-KW'
PASS key.algorithm.length is 256
Testing that the key can't be used with AES-CBC...
......@@ -17,7 +17,7 @@ PASS exportedKey.toString() is '[object ArrayBuffer]'
Importing it back...
PASS importedKey.toString() is '[object Key]'
PASS importedKey.type is 'secret'
PASS importedKey.algorithm.name is 'aes-kw'
PASS importedKey.algorithm.name is 'AES-KW'
PASS importedKey.algorithm.length is 256
PASS successfullyParsed is true
......
......@@ -20,7 +20,7 @@ crypto.subtle.generateKey({name: "aes-kw", length: 256}, extractable, ["encrypt"
key = result;
shouldBe("key.toString()", "'[object Key]'");
shouldBe("key.type", "'secret'");
shouldBe("key.algorithm.name", "'aes-kw'");
shouldBe("key.algorithm.name", "'AES-KW'");
shouldBe("key.algorithm.length", "256");
debug("\nTesting that the key can't be used with AES-CBC...");
......@@ -39,7 +39,7 @@ crypto.subtle.generateKey({name: "aes-kw", length: 256}, extractable, ["encrypt"
shouldBe("importedKey.toString()", "'[object Key]'");
shouldBe("importedKey.type", "'secret'");
shouldBe("importedKey.algorithm.name", "'aes-kw'");
shouldBe("importedKey.algorithm.name", "'AES-KW'");
shouldBe("importedKey.algorithm.length", "256");
finishJSTest();
......
......@@ -11,7 +11,7 @@ Unwrapping it...
PASS unwrappedKey.toString() is '[object Key]'
PASS unwrappedKey.type is 'secret'
PASS unwrappedKey.extractable is true
PASS unwrappedKey.algorithm.name is 'aes-cbc'
PASS unwrappedKey.algorithm.name is 'AES-CBC'
PASS unwrappedKey.algorithm.length is 128
PASS unwrappedKey.usages is ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']
Exporting it...
......@@ -22,7 +22,7 @@ Unwrapping it...
PASS unwrappedKey.toString() is '[object Key]'
PASS unwrappedKey.type is 'secret'
PASS unwrappedKey.extractable is true
PASS unwrappedKey.algorithm.name is 'aes-cbc'
PASS unwrappedKey.algorithm.name is 'AES-CBC'
PASS unwrappedKey.algorithm.length is 128
PASS unwrappedKey.usages is ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']
Exporting it...
......
......@@ -39,7 +39,7 @@ crypto.subtle.importKey("raw", kekData, "aes-kw", extractable, ["wrapKey", "unwr
shouldBe("unwrappedKey.toString()", "'[object Key]'");
shouldBe("unwrappedKey.type", "'secret'");
shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'aes-cbc'");
shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "128");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']");
......@@ -61,7 +61,7 @@ crypto.subtle.importKey("raw", kekData, "aes-kw", extractable, ["wrapKey", "unwr
shouldBe("unwrappedKey.toString()", "'[object Key]'");
shouldBe("unwrappedKey.type", "'secret'");
shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'aes-cbc'");
shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "128");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']");
......
......@@ -5,7 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'aes-cbc'
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 128
PASS key.usages is ["encrypt", "decrypt", "sign", "verify"]
PASS successfullyParsed is true
......
......@@ -16,7 +16,7 @@ window.addEventListener("message", function(evt) {
key = evt.data;
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "128");
shouldBe("key.usages", '["encrypt", "decrypt", "sign", "verify"]');
......
......@@ -11,14 +11,14 @@ PASS crypto.subtle.generateKey({name: "hmac", length: {}}, extractable, ["sign",
Generating a key with default length...
PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'hmac'
PASS key.algorithm.name is 'HMAC'
PASS key.algorithm.length is 64
PASS key.usages is ["sign", "verify"]
Generating a key with custom length...
PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'hmac'
PASS key.algorithm.name is 'HMAC'
PASS key.algorithm.length is 5
PASS key.usages is ["sign"]
PASS successfullyParsed is true
......
......@@ -26,7 +26,7 @@ crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["sign", "
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'hmac'");
shouldBe("key.algorithm.name", "'HMAC'");
shouldBe("key.algorithm.length", "64");
shouldBe("key.usages", '["sign", "verify"]');
......@@ -37,7 +37,7 @@ crypto.subtle.generateKey({name: "hmac", hash: "sha-1"}, extractable, ["sign", "
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'hmac'");
shouldBe("key.algorithm.name", "'HMAC'");
shouldBe("key.algorithm.length", "5");
shouldBe("key.usages", '["sign"]');
finishJSTest();
......
......@@ -7,7 +7,7 @@ Importing a key...
PASS key.type is 'secret'
PASS key.extractable is false
PASS key.algorithm.name is 'hmac'
PASS key.algorithm.name is 'HMAC'
PASS key.algorithm.length is 32
PASS key.usages is ["sign", "verify"]
......
......@@ -31,7 +31,7 @@ crypto.subtle.importKey("jwk", hmacKeyAsArrayBuffer, null, extractable, ["sign",
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "false");
shouldBe("key.algorithm.name", "'hmac'");
shouldBe("key.algorithm.name", "'HMAC'");
shouldBe("key.algorithm.length", "32");
shouldBe("key.usages", '["sign", "verify"]');
......
......@@ -5,7 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'hmac'
PASS key.algorithm.name is 'HMAC'
PASS key.algorithm.length is 16
PASS key.usages is ["encrypt", "decrypt", "sign", "verify"]
PASS successfullyParsed is true
......
......@@ -16,7 +16,7 @@ window.addEventListener("message", function(evt) {
key = evt.data;
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'hmac'");
shouldBe("key.algorithm.name", "'HMAC'");
shouldBe("key.algorithm.length", "16");
shouldBe("key.usages", '["encrypt", "decrypt", "sign", "verify"]');
......
......@@ -6,9 +6,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing a raw HMAC key from string literal...
PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'hmac'
PASS key.algorithm.name is 'HMAC'
PASS key.algorithm.length is 0
PASS key.algorithm.hash.name is 'sha-1'
PASS key.algorithm.hash.name is 'SHA-1'
PASS key.usages is ['sign', 'verify']
Using the key to sign 'foo'...
PASS bytesToHexString(new Uint8Array(signature)) is 'a3cc770fc033e2cb419d42b64e0081a3bd3be30e'
......
......@@ -21,9 +21,9 @@ crypto.subtle.importKey("raw", hmacKey, {name: 'hmac', hash: {name: 'sha-1'}}, e
key = result;
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'hmac'");
shouldBe("key.algorithm.name", "'HMAC'");
shouldBe("key.algorithm.length", "0"); // See <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23098>.
shouldBe("key.algorithm.hash.name", "'sha-1'");
shouldBe("key.algorithm.hash.name", "'SHA-1'");
shouldBe("key.usages", "['sign', 'verify']");
debug("Using the key to sign 'foo'...");
......
......@@ -6,9 +6,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing a raw HMAC key from string literal...
PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'hmac'
PASS key.algorithm.name is 'HMAC'
PASS key.algorithm.length is 1
PASS key.algorithm.hash.name is 'sha-1'
PASS key.algorithm.hash.name is 'SHA-1'
PASS key.usages is ['sign', 'verify']
Using the key to sign 'foo'...
PASS bytesToHexString(new Uint8Array(signature)) is 'bebbc02e46b0f81183f40c25dce23e5045d65519'
......
......@@ -21,9 +21,9 @@ crypto.subtle.importKey("raw", hmacKey, {name: 'hmac', hash: {name: 'sha-1'}}, e
key = result;
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'hmac'");
shouldBe("key.algorithm.name", "'HMAC'");
shouldBe("key.algorithm.length", "1"); // See <https://www.w3.org/Bugs/Public/show_bug.cgi?id=23098>.
shouldBe("key.algorithm.hash.name", "'sha-1'");
shouldBe("key.algorithm.hash.name", "'SHA-1'");
shouldBe("key.usages", "['sign', 'verify']");
debug("Using the key to sign 'foo'...");
......
......@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS All checks passed in worker
PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'hmac'
PASS key.algorithm.name is 'HMAC'
PASS key.algorithm.length is 16
PASS key.usages is ["encrypt", "decrypt", "sign", "verify"]
PASS successfullyParsed is true
......
......@@ -22,7 +22,7 @@ importTestKeys().then(function(keys) {
key = evt.data.key;
shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'hmac'");
shouldBe("key.algorithm.name", "'HMAC'");
shouldBe("key.algorithm.length", "16");
shouldBe("key.usages", '["encrypt", "decrypt", "sign", "verify"]');
}
......
......@@ -5,8 +5,8 @@ onmessage = function(evt)
postMessage({ result:false, message:'key.type should be "secret"' });
else if (!key.extractable)
postMessage({ result:false, message:'key.extractable should be true' });
else if (key.algorithm.name != "hmac")
postMessage({ result:false, message:'key.algorithm.name should be "hmac"' });
else if (key.algorithm.name != "HMAC")
postMessage({ result:false, message:'key.algorithm.name should be "HMAC"' });
else if (key.usages.toString() != "encrypt,decrypt,sign,verify")
postMessage({ result:false, message:'key.usages should be ["encrypt", "decrypt", "sign", "verify"]' });
else
......
......@@ -6,12 +6,12 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Generating a key pair...
PASS keyPair.toString() is '[object KeyPair]'
PASS keyPair.publicKey.type is 'public'
PASS keyPair.publicKey.algorithm.name is 'rsa-oaep'
PASS keyPair.publicKey.algorithm.name is 'RSA-OAEP'
PASS keyPair.publicKey.algorithm.modulusLength is 2048
PASS bytesToHexString(keyPair.publicKey.algorithm.publicExponent) is '010001'
PASS keyPair.publicKey.algorithm.hash is undefined.
PASS keyPair.privateKey.type is 'private'
PASS keyPair.privateKey.algorithm.name is 'rsa-oaep'
PASS keyPair.privateKey.algorithm.name is 'RSA-OAEP'
PASS keyPair.privateKey.algorithm.modulusLength is 2048
PASS bytesToHexString(keyPair.privateKey.algorithm.publicExponent) is '010001'
PASS keyPair.privateKey.algorithm.hash is undefined.
......@@ -33,10 +33,10 @@ PASS bytesToHexString(Base64URL.parse(jwkPublicKey.e)) is '010001'
Importing it back...
PASS exportedPublicKey.type is 'public'
PASS exportedPublicKey.algorithm.name is 'rsa-oaep'
PASS exportedPublicKey.algorithm.name is 'RSA-OAEP'
PASS exportedPublicKey.algorithm.modulusLength is 2048
PASS bytesToHexString(exportedPublicKey.algorithm.publicExponent) is '010001'
PASS exportedPublicKey.algorithm.hash.name is 'sha-1'
PASS exportedPublicKey.algorithm.hash.name is 'SHA-1'
PASS exportedPublicKey.extractable is true
PASS exportedPublicKey.usages is ['encrypt','decrypt','wrapKey','unwrapKey']
PASS successfullyParsed is true
......
......@@ -26,12 +26,12 @@ crypto.subtle.generateKey(algorithmKeyGen, extractable, ["encrypt", "decrypt", "
keyPair = result;
shouldBe("keyPair.toString()", "'[object KeyPair]'");
shouldBe("keyPair.publicKey.type", "'public'");
shouldBe("keyPair.publicKey.algorithm.name", "'rsa-oaep'");
shouldBe("keyPair.publicKey.algorithm.name", "'RSA-OAEP'");
shouldBe("keyPair.publicKey.algorithm.modulusLength", "2048");
shouldBe("bytesToHexString(keyPair.publicKey.algorithm.publicExponent)", "'010001'");
shouldBeUndefined("keyPair.publicKey.algorithm.hash");
shouldBe("keyPair.privateKey.type", "'private'");
shouldBe("keyPair.privateKey.algorithm.name", "'rsa-oaep'");
shouldBe("keyPair.privateKey.algorithm.name", "'RSA-OAEP'");
shouldBe("keyPair.privateKey.algorithm.modulusLength", "2048");
shouldBe("bytesToHexString(keyPair.privateKey.algorithm.publicExponent)", "'010001'");
shouldBeUndefined("keyPair.privateKey.algorithm.hash");
......@@ -65,10 +65,10 @@ crypto.subtle.generateKey(algorithmKeyGen, extractable, ["encrypt", "decrypt", "
}).then(function(result) {
exportedPublicKey = result;
shouldBe("exportedPublicKey.type", "'public'");
shouldBe("exportedPublicKey.algorithm.name", "'rsa-oaep'");
shouldBe("exportedPublicKey.algorithm.name", "'RSA-OAEP'");
shouldBe("exportedPublicKey.algorithm.modulusLength", "2048");
shouldBe("bytesToHexString(exportedPublicKey.algorithm.publicExponent)", "'010001'");
shouldBe("exportedPublicKey.algorithm.hash.name", "'sha-1'");
shouldBe("exportedPublicKey.algorithm.hash.name", "'SHA-1'");
shouldBe("exportedPublicKey.extractable", "true");
shouldBe("exportedPublicKey.usages", "['encrypt','decrypt','wrapKey','unwrapKey']");
......
......@@ -11,7 +11,7 @@ Unwrapping it...
PASS unwrappedKey.toString() is '[object Key]'
PASS unwrappedKey.type is 'secret'