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> 2013-12-12 Michał Pakuła vel Rutka <m.pakula@samsung.com>
Unreviewed EFL gardening Unreviewed EFL gardening
...@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -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... Importing a raw AES key from string literal...
PASS key.type is 'secret' PASS key.type is 'secret'
PASS key.extractable is true 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.algorithm.length is 192
PASS key.usages is ['encrypt', 'decrypt'] PASS key.usages is ['encrypt', 'decrypt']
Using the key to encrypt plaintext... Using the key to encrypt plaintext...
......
...@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec ...@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
key = result; key = result;
shouldBe("key.type", "'secret'"); shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true"); shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'"); shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "192"); shouldBe("key.algorithm.length", "192");
shouldBe("key.usages", "['encrypt', 'decrypt']"); shouldBe("key.usages", "['encrypt', 'decrypt']");
......
...@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -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... Importing a raw AES key from string literal...
PASS key.type is 'secret' PASS key.type is 'secret'
PASS key.extractable is true 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.algorithm.length is 256
PASS key.usages is ['encrypt', 'decrypt'] PASS key.usages is ['encrypt', 'decrypt']
Using the key to encrypt plaintext... Using the key to encrypt plaintext...
......
...@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec ...@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
key = result; key = result;
shouldBe("key.type", "'secret'"); shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true"); shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'"); shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "256"); shouldBe("key.algorithm.length", "256");
shouldBe("key.usages", "['encrypt', 'decrypt']"); shouldBe("key.usages", "['encrypt', 'decrypt']");
......
...@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -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... Importing a raw AES key from string literal...
PASS key.type is 'secret' PASS key.type is 'secret'
PASS key.extractable is true 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.algorithm.length is 128
PASS key.usages is ['encrypt', 'decrypt'] PASS key.usages is ['encrypt', 'decrypt']
Using the key to encrypt plaintext... Using the key to encrypt plaintext...
......
...@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -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... Importing a raw AES key from string literal...
PASS key.type is 'secret' PASS key.type is 'secret'
PASS key.extractable is true 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.algorithm.length is 128
PASS key.usages is ['encrypt', 'decrypt'] PASS key.usages is ['encrypt', 'decrypt']
Using the key to encrypt plaintext... Using the key to encrypt plaintext...
......
...@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec ...@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
key = result; key = result;
shouldBe("key.type", "'secret'"); shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true"); shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'"); shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "128"); shouldBe("key.algorithm.length", "128");
shouldBe("key.usages", "['encrypt', 'decrypt']"); shouldBe("key.usages", "['encrypt', 'decrypt']");
......
...@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec ...@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
key = result; key = result;
shouldBe("key.type", "'secret'"); shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true"); shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'"); shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "128"); shouldBe("key.algorithm.length", "128");
shouldBe("key.usages", "['encrypt', 'decrypt']"); shouldBe("key.usages", "['encrypt', 'decrypt']");
......
...@@ -10,7 +10,7 @@ PASS crypto.subtle.generateKey({name: "aes-cbc", length: {}}, extractable, ["enc ...@@ -10,7 +10,7 @@ PASS crypto.subtle.generateKey({name: "aes-cbc", length: {}}, extractable, ["enc
Generating a key... Generating a key...
PASS key.type is 'secret' PASS key.type is 'secret'
PASS key.extractable is true 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.algorithm.length is 128
PASS key.usages is ['encrypt', 'decrypt'] PASS key.usages is ['encrypt', 'decrypt']
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -26,7 +26,7 @@ crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["encrypt ...@@ -26,7 +26,7 @@ crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["encrypt
shouldBe("key.type", "'secret'"); shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true"); shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'"); shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "128"); shouldBe("key.algorithm.length", "128");
shouldBe("key.usages", "['encrypt', 'decrypt']"); shouldBe("key.usages", "['encrypt', 'decrypt']");
......
...@@ -7,7 +7,7 @@ Importing a key... ...@@ -7,7 +7,7 @@ Importing a key...
PASS key.type is 'secret' PASS key.type is 'secret'
PASS key.extractable is false 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.algorithm.length is 192
PASS key.usages is ["encrypt"] PASS key.usages is ["encrypt"]
......
...@@ -34,7 +34,7 @@ crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, null, false, ["encrypt"]).th ...@@ -34,7 +34,7 @@ crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, null, false, ["encrypt"]).th
shouldBe("key.type", "'secret'"); shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "false"); shouldBe("key.extractable", "false");
shouldBe("key.algorithm.name", "'aes-cbc'"); shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "192"); shouldBe("key.algorithm.length", "192");
shouldBe("key.usages", '["encrypt"]'); shouldBe("key.usages", '["encrypt"]');
......
...@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -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... Importing a raw AES key from string literal...
PASS key.type is 'secret' PASS key.type is 'secret'
PASS key.extractable is true 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.algorithm.length is 176
PASS key.usages is ['encrypt', 'decrypt'] PASS key.usages is ['encrypt', 'decrypt']
Using the key to encrypt plaintext... Using the key to encrypt plaintext...
......
...@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec ...@@ -23,7 +23,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
key = result; key = result;
shouldBe("key.type", "'secret'"); shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true"); shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'"); shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "176"); shouldBe("key.algorithm.length", "176");
shouldBe("key.usages", "['encrypt', 'decrypt']"); shouldBe("key.usages", "['encrypt', 'decrypt']");
......
...@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing an unwrapping key... Importing an unwrapping key...
PASS unwrappingKey.algorithm.name is 'aes-cbc' PASS unwrappingKey.algorithm.name is 'AES-CBC'
Unwrapping a key... Unwrapping a key...
PASS Promise rejected PASS Promise rejected
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -22,7 +22,7 @@ var wrappedKey = hexStringToUint8Array("b490dedb3abc3fd545e146538e6cc3ca"); // A ...@@ -22,7 +22,7 @@ var wrappedKey = hexStringToUint8Array("b490dedb3abc3fd545e146538e6cc3ca"); // A
debug("Importing an unwrapping key..."); debug("Importing an unwrapping key...");
crypto.subtle.importKey("raw", unwrappingKeyOctets, "AES-CBC", nonExtractable, ["unwrapKey"]).then(function(result) { crypto.subtle.importKey("raw", unwrappingKeyOctets, "AES-CBC", nonExtractable, ["unwrapKey"]).then(function(result) {
unwrappingKey = result; unwrappingKey = result;
shouldBe("unwrappingKey.algorithm.name", "'aes-cbc'"); shouldBe("unwrappingKey.algorithm.name", "'AES-CBC'");
var unwrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")}; var unwrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")};
debug("Unwrapping a key..."); debug("Unwrapping a key...");
return crypto.subtle.unwrapKey("jwk", wrappedKey, unwrappingKey, unwrapAlgorithm, null, extractable, ["sign", "verify", "encrypt", "decrypt", "wrap", "unwrap"]); 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 ...@@ -4,15 +4,15 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing an unwrapping key... Importing an unwrapping key...
PASS unwrappingKey.algorithm.name is 'aes-cbc' PASS unwrappingKey.algorithm.name is 'AES-CBC'
Unwrapping a key... Unwrapping a key...
PASS unwrappedKey.toString() is '[object Key]' PASS unwrappedKey.toString() is '[object Key]'
PASS unwrappedKey.type is 'public' PASS unwrappedKey.type is 'public'
PASS unwrappedKey.usages is ['sign','verify'] 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 unwrappedKey.algorithm.modulusLength is 2048
PASS Base64URL.stringify(unwrappedKey.algorithm.publicExponent) is publicKeyJSON.e 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 unwrappedKey.extractable is false
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -31,7 +31,7 @@ var wrappedKey = hexStringToUint8Array("3511f6028db04ea97e7cfad3c4cc60837bceff25 ...@@ -31,7 +31,7 @@ var wrappedKey = hexStringToUint8Array("3511f6028db04ea97e7cfad3c4cc60837bceff25
debug("Importing an unwrapping key..."); debug("Importing an unwrapping key...");
crypto.subtle.importKey("raw", unwrappingKeyOctets, "AES-CBC", nonExtractable, ["unwrapKey"]).then(function(result) { crypto.subtle.importKey("raw", unwrappingKeyOctets, "AES-CBC", nonExtractable, ["unwrapKey"]).then(function(result) {
unwrappingKey = result; unwrappingKey = result;
shouldBe("unwrappingKey.algorithm.name", "'aes-cbc'"); shouldBe("unwrappingKey.algorithm.name", "'AES-CBC'");
var unwrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")}; var unwrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")};
debug("Unwrapping a key..."); debug("Unwrapping a key...");
return crypto.subtle.unwrapKey("jwk", wrappedKey, unwrappingKey, unwrapAlgorithm, null, extractable, ["sign", "verify", "encrypt", "decrypt", "wrap", "unwrap"]); 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, [ ...@@ -41,10 +41,10 @@ crypto.subtle.importKey("raw", unwrappingKeyOctets, "AES-CBC", nonExtractable, [
shouldBe("unwrappedKey.toString()", "'[object Key]'"); shouldBe("unwrappedKey.toString()", "'[object Key]'");
shouldBe("unwrappedKey.type", "'public'"); shouldBe("unwrappedKey.type", "'public'");
shouldBe("unwrappedKey.usages", "['sign','verify']"); 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("unwrappedKey.algorithm.modulusLength", "2048");
shouldBe("Base64URL.stringify(unwrappedKey.algorithm.publicExponent)", "publicKeyJSON.e"); 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"); shouldBe("unwrappedKey.extractable", "false");
finishJSTest(); finishJSTest();
}); });
......
...@@ -4,9 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -4,9 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing a key to wrap... 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... 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 wrappedKey.toString() is '[object ArrayBuffer]'
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -4,9 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -4,9 +4,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Importing a key to wrap... 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... Importing a key encryption key...
PASS wrappingKey.algorithm.name is 'aes-cbc' PASS wrappingKey.algorithm.name is 'AES-CBC'
wrapping the key... wrapping the key...
PASS Rejected PASS Rejected
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -31,12 +31,12 @@ var wrappingKeyOctets = hexStringToUint8Array("2a00e0e776e94e4dc89bf947cebdebe1" ...@@ -31,12 +31,12 @@ var wrappingKeyOctets = hexStringToUint8Array("2a00e0e776e94e4dc89bf947cebdebe1"
debug("Importing a key to wrap..."); debug("Importing a key to wrap...");
crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, null, extractable, ["sign", "verify"]).then(function(result) { crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, null, extractable, ["sign", "verify"]).then(function(result) {
key = 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..."); debug("Importing a key encryption key...");
return crypto.subtle.importKey("raw", wrappingKeyOctets, "AES-CBC", nonExtractable, ["wrapKey"]); return crypto.subtle.importKey("raw", wrappingKeyOctets, "AES-CBC", nonExtractable, ["wrapKey"]);
}).then(function(result) { }).then(function(result) {
wrappingKey = result; wrappingKey = result;
shouldBe("wrappingKey.algorithm.name", "'aes-cbc'"); shouldBe("wrappingKey.algorithm.name", "'AES-CBC'");
var wrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")}; var wrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")};
debug("wrapping the key..."); debug("wrapping the key...");
return crypto.subtle.wrapKey("jwk", key, wrappingKey, wrapAlgorithm); return crypto.subtle.wrapKey("jwk", key, wrappingKey, wrapAlgorithm);
......
...@@ -31,12 +31,12 @@ var wrappingKeyOctets = hexStringToUint8Array("2a00e0e776e94e4dc89bf947cebdebe1" ...@@ -31,12 +31,12 @@ var wrappingKeyOctets = hexStringToUint8Array("2a00e0e776e94e4dc89bf947cebdebe1"
debug("Importing a key to wrap..."); debug("Importing a key to wrap...");
crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, null, extractable, ["sign", "verify"]).then(function(result) { crypto.subtle.importKey("jwk", jwkKeyAsArrayBuffer, null, extractable, ["sign", "verify"]).then(function(result) {
key = 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..."); debug("Importing a key encryption key...");
return crypto.subtle.importKey("raw", wrappingKeyOctets, "AES-CBC", nonExtractable, ["wrapKey"]); return crypto.subtle.importKey("raw", wrappingKeyOctets, "AES-CBC", nonExtractable, ["wrapKey"]);
}).then(function(result) { }).then(function(result) {
wrappingKey = result; wrappingKey = result;
shouldBe("wrappingKey.algorithm.name", "'aes-cbc'"); shouldBe("wrappingKey.algorithm.name", "'AES-CBC'");
var wrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")}; var wrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")};
return crypto.subtle.wrapKey("jwk", key, wrappingKey, wrapAlgorithm); return crypto.subtle.wrapKey("jwk", key, wrappingKey, wrapAlgorithm);
}).then(function(result) { }).then(function(result) {
......
...@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Generating a key... Generating a key...
PASS key.toString() is '[object Key]' PASS key.toString() is '[object Key]'
PASS key.type is 'secret' 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 PASS key.algorithm.length is 256
Testing that the key can't be used with AES-CBC... Testing that the key can't be used with AES-CBC...
...@@ -17,7 +17,7 @@ PASS exportedKey.toString() is '[object ArrayBuffer]' ...@@ -17,7 +17,7 @@ PASS exportedKey.toString() is '[object ArrayBuffer]'
Importing it back... Importing it back...
PASS importedKey.toString() is '[object Key]' PASS importedKey.toString() is '[object Key]'
PASS importedKey.type is 'secret' 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 importedKey.algorithm.length is 256
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -20,7 +20,7 @@ crypto.subtle.generateKey({name: "aes-kw", length: 256}, extractable, ["encrypt" ...@@ -20,7 +20,7 @@ crypto.subtle.generateKey({name: "aes-kw", length: 256}, extractable, ["encrypt"
key = result; key = result;
shouldBe("key.toString()", "'[object Key]'"); shouldBe("key.toString()", "'[object Key]'");
shouldBe("key.type", "'secret'"); shouldBe("key.type", "'secret'");
shouldBe("key.algorithm.name", "'aes-kw'"); shouldBe("key.algorithm.name", "'AES-KW'");
shouldBe("key.algorithm.length", "256"); shouldBe("key.algorithm.length", "256");
debug("\nTesting that the key can't be used with AES-CBC..."); 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" ...@@ -39,7 +39,7 @@ crypto.subtle.generateKey({name: "aes-kw", length: 256}, extractable, ["encrypt"
shouldBe("importedKey.toString()", "'[object Key]'"); shouldBe("importedKey.toString()", "'[object Key]'");
shouldBe("importedKey.type", "'secret'"); shouldBe("importedKey.type", "'secret'");
shouldBe("importedKey.algorithm.name", "'aes-kw'"); shouldBe("importedKey.algorithm.name", "'AES-KW'");
shouldBe("importedKey.algorithm.length", "256"); shouldBe("importedKey.algorithm.length", "256");
finishJSTest(); finishJSTest();
......
...@@ -11,7 +11,7 @@ Unwrapping it... ...@@ -11,7 +11,7 @@ Unwrapping it...
PASS unwrappedKey.toString() is '[object Key]' PASS unwrappedKey.toString() is '[object Key]'
PASS unwrappedKey.type is 'secret' PASS unwrappedKey.type is 'secret'
PASS unwrappedKey.extractable is true 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.algorithm.length is 128
PASS unwrappedKey.usages is ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'] PASS unwrappedKey.usages is ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']
Exporting it... Exporting it...
...@@ -22,7 +22,7 @@ Unwrapping it... ...@@ -22,7 +22,7 @@ Unwrapping it...
PASS unwrappedKey.toString() is '[object Key]' PASS unwrappedKey.toString() is '[object Key]'
PASS unwrappedKey.type is 'secret' PASS unwrappedKey.type is 'secret'
PASS unwrappedKey.extractable is true 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.algorithm.length is 128
PASS unwrappedKey.usages is ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'] PASS unwrappedKey.usages is ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']
Exporting it... Exporting it...
......
...@@ -39,7 +39,7 @@ crypto.subtle.importKey("raw", kekData, "aes-kw", extractable, ["wrapKey", "unwr ...@@ -39,7 +39,7 @@ crypto.subtle.importKey("raw", kekData, "aes-kw", extractable, ["wrapKey", "unwr
shouldBe("unwrappedKey.toString()", "'[object Key]'"); shouldBe("unwrappedKey.toString()", "'[object Key]'");
shouldBe("unwrappedKey.type", "'secret'"); shouldBe("unwrappedKey.type", "'secret'");
shouldBe("unwrappedKey.extractable", "true"); shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'aes-cbc'"); shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "128"); shouldBe("unwrappedKey.algorithm.length", "128");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']"); shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']");
...@@ -61,7 +61,7 @@ crypto.subtle.importKey("raw", kekData, "aes-kw", extractable, ["wrapKey", "unwr ...@@ -61,7 +61,7 @@ crypto.subtle.importKey("raw", kekData, "aes-kw", extractable, ["wrapKey", "unwr
shouldBe("unwrappedKey.toString()", "'[object Key]'"); shouldBe("unwrappedKey.toString()", "'[object Key]'");
shouldBe("unwrappedKey.type", "'secret'"); shouldBe("unwrappedKey.type", "'secret'");
shouldBe("unwrappedKey.extractable", "true"); shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'aes-cbc'"); shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "128"); shouldBe("unwrappedKey.algorithm.length", "128");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']"); 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 ...@@ -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.type is 'secret'
PASS key.extractable is true 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.algorithm.length is 128
PASS key.usages is ["encrypt", "decrypt", "sign", "verify"] PASS key.usages is ["encrypt", "decrypt", "sign", "verify"]
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -16,7 +16,7 @@ window.addEventListener("message", function(evt) { ...@@ -16,7 +16,7 @@ window.addEventListener("message", function(evt) {
key = evt.data; key = evt.data;
shouldBe("key.type", "'secret'"); shouldBe("key.type", "'secret'");
shouldBe("key.extractable", "true"); shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'aes-cbc'"); shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "128"); shouldBe("key.algorithm.length", "128");
shouldBe("key.usages", '["encrypt", "decrypt", "sign", "verify"]'); shouldBe("key.usages", '["encrypt", "decrypt", "sign", "verify"]');