Commit 20890d48 authored by ap@apple.com's avatar ap@apple.com

WebCrypto Key.usages should be ordered alphabetically

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

Reviewed by Darin Adler.

Source/WebCore: 

* crypto/CryptoKey.cpp: (WebCore::CryptoKey::usages): Do it.

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-invalid-length-expected.txt:
* crypto/subtle/aes-cbc-invalid-length.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-postMessage-expected.txt:
* crypto/subtle/hmac-postMessage.html:
* crypto/subtle/jwk-import-use-values-expected.txt:
* crypto/subtle/jwk-import-use-values.html:
* crypto/subtle/postMessage-worker-expected.txt:
* crypto/subtle/postMessage-worker.html:
* crypto/subtle/resources/postMessage-worker.js:
(onmessage):
* 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/rsaes-pkcs1-v1_5-wrap-unwrap-aes-expected.txt:
* crypto/subtle/rsaes-pkcs1-v1_5-wrap-unwrap-aes.html:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160547 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d805dc48
2013-12-13 Alexey Proskuryakov <ap@apple.com>
WebCrypto Key.usages should be ordered alphabetically
https://bugs.webkit.org/show_bug.cgi?id=125696
Reviewed by Darin Adler.
* 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-invalid-length-expected.txt:
* crypto/subtle/aes-cbc-invalid-length.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-postMessage-expected.txt:
* crypto/subtle/hmac-postMessage.html:
* crypto/subtle/jwk-import-use-values-expected.txt:
* crypto/subtle/jwk-import-use-values.html:
* crypto/subtle/postMessage-worker-expected.txt:
* crypto/subtle/postMessage-worker.html:
* crypto/subtle/resources/postMessage-worker.js:
(onmessage):
* 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/rsaes-pkcs1-v1_5-wrap-unwrap-aes-expected.txt:
* crypto/subtle/rsaes-pkcs1-v1_5-wrap-unwrap-aes.html:
2013-12-13 Rob Buis <rob.buis@samsung.com> 2013-12-13 Rob Buis <rob.buis@samsung.com>
Clean up SVGScriptElement Clean up SVGScriptElement
...@@ -8,7 +8,7 @@ PASS key.type is 'secret' ...@@ -8,7 +8,7 @@ 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 ['decrypt', 'encrypt']
Using the key to encrypt plaintext... Using the key to encrypt plaintext...
PASS bytesToHexString(new Uint8Array(encryptionResult)) is '4f021db243bc633d7178183a9fa071e8b4d9ada9ad7dedf4e5e738763f69145a571b242012fb7ae07fa9baac3df102e008b0e27988598881d920a9e64f5615cd612ccd79224b350935d45dd6a98f8176' PASS bytesToHexString(new Uint8Array(encryptionResult)) is '4f021db243bc633d7178183a9fa071e8b4d9ada9ad7dedf4e5e738763f69145a571b242012fb7ae07fa9baac3df102e008b0e27988598881d920a9e64f5615cd612ccd79224b350935d45dd6a98f8176'
Decrypting it back... Decrypting it back...
......
...@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec ...@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
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", "['decrypt', 'encrypt']");
debug("Using the key to encrypt plaintext..."); debug("Using the key to encrypt plaintext...");
return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plaintext); return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plaintext);
......
...@@ -8,7 +8,7 @@ PASS key.type is 'secret' ...@@ -8,7 +8,7 @@ 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 ['decrypt', 'encrypt']
Using the key to encrypt plaintext... Using the key to encrypt plaintext...
PASS bytesToHexString(new Uint8Array(encryptionResult)) is 'f58c4c04d6e5f1ba779eabfb5f7bfbd69cfc4e967edb808d679f777bc6702c7d39f23369a9d9bacfa530e26304231461b2eb05e2c39be9fcda6c19078c6a9d1b3f461796d6b0d6b2e0c2a72b4d80e644' PASS bytesToHexString(new Uint8Array(encryptionResult)) is 'f58c4c04d6e5f1ba779eabfb5f7bfbd69cfc4e967edb808d679f777bc6702c7d39f23369a9d9bacfa530e26304231461b2eb05e2c39be9fcda6c19078c6a9d1b3f461796d6b0d6b2e0c2a72b4d80e644'
Decrypting it back... Decrypting it back...
......
...@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec ...@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
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", "['decrypt', 'encrypt']");
debug("Using the key to encrypt plaintext..."); debug("Using the key to encrypt plaintext...");
return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plaintext); return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plaintext);
......
...@@ -8,7 +8,7 @@ PASS key.type is 'secret' ...@@ -8,7 +8,7 @@ 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 ['decrypt', 'encrypt']
Using the key to encrypt plaintext... Using the key to encrypt plaintext...
PASS bytesToHexString(new Uint8Array(encryptionResult)) is '7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95db113a917678b273bed6b8e3c1743b7116e69e222295163ff1caa1681fac09120eca307586e1a78cb82807230e1321d3fae00d18cc2012' PASS bytesToHexString(new Uint8Array(encryptionResult)) is '7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95db113a917678b273bed6b8e3c1743b7116e69e222295163ff1caa1681fac09120eca307586e1a78cb82807230e1321d3fae00d18cc2012'
Decrypting it back... Decrypting it back...
......
...@@ -8,7 +8,7 @@ PASS key.type is 'secret' ...@@ -8,7 +8,7 @@ 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 ['decrypt', 'encrypt']
Using the key to encrypt plaintext... Using the key to encrypt plaintext...
PASS bytesToHexString(new Uint8Array(cyphertext)) is '630199c5f202cc7167bb84c6c72b349d' PASS bytesToHexString(new Uint8Array(cyphertext)) is '630199c5f202cc7167bb84c6c72b349d'
Decrypting it back... Decrypting it back...
......
...@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec ...@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
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", "['decrypt', 'encrypt']");
debug("Using the key to encrypt plaintext..."); debug("Using the key to encrypt plaintext...");
return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plaintext); return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plaintext);
......
...@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec ...@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
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", "['decrypt', 'encrypt']");
debug("Using the key to encrypt plaintext..."); debug("Using the key to encrypt plaintext...");
return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plaintext); return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plaintext);
......
...@@ -12,7 +12,7 @@ PASS key.type is 'secret' ...@@ -12,7 +12,7 @@ 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 ['decrypt', 'encrypt']
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -28,7 +28,7 @@ crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["encrypt ...@@ -28,7 +28,7 @@ crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["encrypt
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", "['decrypt', 'encrypt']");
finishJSTest(); finishJSTest();
}); });
......
...@@ -8,7 +8,7 @@ PASS key.type is 'secret' ...@@ -8,7 +8,7 @@ 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 ['decrypt', 'encrypt']
Using the key to encrypt plaintext... Using the key to encrypt plaintext...
Failed, as expected. Note that the spec doesn't appear to clearly define which step should fail. Failed, as expected. Note that the spec doesn't appear to clearly define which step should fail.
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec ...@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
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", "['decrypt', 'encrypt']");
debug("Using the key to encrypt plaintext..."); debug("Using the key to encrypt plaintext...");
return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, [plaintext]); return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, [plaintext]);
......
...@@ -13,7 +13,7 @@ PASS unwrappedKey.type is 'secret' ...@@ -13,7 +13,7 @@ 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 ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
Exporting it... Exporting it...
PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(keyData) PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(keyData)
...@@ -24,7 +24,7 @@ PASS unwrappedKey.type is 'secret' ...@@ -24,7 +24,7 @@ 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 ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
Exporting it... Exporting it...
PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(keyData) PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(keyData)
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -41,7 +41,7 @@ crypto.subtle.importKey("raw", kekData, "aes-kw", extractable, ["wrapKey", "unwr ...@@ -41,7 +41,7 @@ crypto.subtle.importKey("raw", kekData, "aes-kw", extractable, ["wrapKey", "unwr
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", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
debug("Exporting it..."); debug("Exporting it...");
return crypto.subtle.exportKey("raw", unwrappedKey); return crypto.subtle.exportKey("raw", unwrappedKey);
...@@ -63,7 +63,7 @@ crypto.subtle.importKey("raw", kekData, "aes-kw", extractable, ["wrapKey", "unwr ...@@ -63,7 +63,7 @@ crypto.subtle.importKey("raw", kekData, "aes-kw", extractable, ["wrapKey", "unwr
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", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
debug("Exporting it..."); debug("Exporting it...");
return crypto.subtle.exportKey("raw", unwrappedKey); return crypto.subtle.exportKey("raw", unwrappedKey);
......
...@@ -7,7 +7,7 @@ PASS key.type is 'secret' ...@@ -7,7 +7,7 @@ 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 ["decrypt", "encrypt", "sign", "verify"]
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -18,7 +18,7 @@ window.addEventListener("message", function(evt) { ...@@ -18,7 +18,7 @@ window.addEventListener("message", function(evt) {
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", '["decrypt", "encrypt", "sign", "verify"]');
finishJSTest(); finishJSTest();
}, false); }, false);
......
...@@ -7,7 +7,7 @@ PASS key.type is 'secret' ...@@ -7,7 +7,7 @@ PASS key.type is 'secret'
PASS key.extractable is true 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.algorithm.length is 16
PASS key.usages is ["encrypt", "decrypt", "sign", "verify"] PASS key.usages is ["decrypt", "encrypt", "sign", "verify"]
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -18,7 +18,7 @@ window.addEventListener("message", function(evt) { ...@@ -18,7 +18,7 @@ window.addEventListener("message", function(evt) {
shouldBe("key.extractable", "true"); shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'HMAC'"); shouldBe("key.algorithm.name", "'HMAC'");
shouldBe("key.algorithm.length", "16"); shouldBe("key.algorithm.length", "16");
shouldBe("key.usages", '["encrypt", "decrypt", "sign", "verify"]'); shouldBe("key.usages", '["decrypt", "encrypt", "sign", "verify"]');
finishJSTest(); finishJSTest();
}, false); }, false);
......
...@@ -10,7 +10,7 @@ deconly: ...@@ -10,7 +10,7 @@ deconly:
PASS key.usages is ["decrypt"] PASS key.usages is ["decrypt"]
enconly,deconly: enconly,deconly:
PASS key.usages is ["encrypt","decrypt"] PASS key.usages is ["decrypt","encrypt"]
wrap: wrap:
PASS key.usages is ["wrapKey"] PASS key.usages is ["wrapKey"]
...@@ -19,13 +19,13 @@ unwrap: ...@@ -19,13 +19,13 @@ unwrap:
PASS key.usages is ["unwrapKey"] PASS key.usages is ["unwrapKey"]
wrap,unwrap: wrap,unwrap:
PASS key.usages is ["wrapKey","unwrapKey"] PASS key.usages is ["unwrapKey","wrapKey"]
enconly,deconly,wrap: enconly,deconly,wrap:
PASS key.usages is ["encrypt","decrypt","wrapKey"] PASS key.usages is ["decrypt","encrypt","wrapKey"]
enc: enc:
PASS key.usages is ["encrypt","decrypt","wrapKey","unwrapKey"] PASS key.usages is ["decrypt","encrypt","unwrapKey","wrapKey"]
sigonly: sigonly:
PASS key.usages is ["sign"] PASS key.usages is ["sign"]
...@@ -49,7 +49,7 @@ enconly, deconly: ...@@ -49,7 +49,7 @@ enconly, deconly:
PASS key.usages is ["encrypt"] PASS key.usages is ["encrypt"]
enconly,,deconly: enconly,,deconly:
PASS key.usages is ["encrypt","decrypt"] PASS key.usages is ["decrypt","encrypt"]
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -54,12 +54,12 @@ function testWithHMAC(expectedUsages, use) ...@@ -54,12 +54,12 @@ function testWithHMAC(expectedUsages, use)
Promise.all([ Promise.all([
testWithAESCBC(["encrypt"], "enconly"), testWithAESCBC(["encrypt"], "enconly"),
testWithAESCBC(["decrypt"], "deconly"), testWithAESCBC(["decrypt"], "deconly"),
testWithAESCBC(["encrypt", "decrypt"], "enconly,deconly"), testWithAESCBC(["decrypt", "encrypt"], "enconly,deconly"),
testWithAESCBC(["wrapKey"], "wrap"), testWithAESCBC(["wrapKey"], "wrap"),
testWithAESCBC(["unwrapKey"], "unwrap"), testWithAESCBC(["unwrapKey"], "unwrap"),
testWithAESCBC(["wrapKey", "unwrapKey"], "wrap,unwrap"), testWithAESCBC(["unwrapKey", "wrapKey"], "wrap,unwrap"),
testWithAESCBC(["encrypt", "decrypt", "wrapKey"], "enconly,deconly,wrap"), testWithAESCBC(["decrypt", "encrypt", "wrapKey"], "enconly,deconly,wrap"),
testWithAESCBC(["encrypt", "decrypt", "wrapKey", "unwrapKey"], "enc"), testWithAESCBC(["decrypt", "encrypt", "unwrapKey", "wrapKey"], "enc"),
testWithHMAC(["sign"], "sigonly"), testWithHMAC(["sign"], "sigonly"),
testWithHMAC(["verify"], "vfyonly"), testWithHMAC(["verify"], "vfyonly"),
testWithHMAC(["sign", "verify"], "sig"), testWithHMAC(["sign", "verify"], "sig"),
...@@ -69,7 +69,7 @@ Promise.all([ ...@@ -69,7 +69,7 @@ Promise.all([
testWithAESCBC([], "enconly "), testWithAESCBC([], "enconly "),
testWithAESCBC([], "EncOnly"), testWithAESCBC([], "EncOnly"),
testWithAESCBC(["encrypt"], "enconly, deconly"), testWithAESCBC(["encrypt"], "enconly, deconly"),
testWithAESCBC(["encrypt", "decrypt"], "enconly,,deconly"), testWithAESCBC(["decrypt","encrypt"], "enconly,,deconly"),
]).then(function() { finishJSTest(); } ); ]).then(function() { finishJSTest(); } );
</script> </script>
......
...@@ -8,7 +8,7 @@ PASS key.type is 'secret' ...@@ -8,7 +8,7 @@ PASS key.type is 'secret'
PASS key.extractable is true 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.algorithm.length is 16
PASS key.usages is ["encrypt", "decrypt", "sign", "verify"] PASS key.usages is ["decrypt", "encrypt", "sign", "verify"]
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -24,7 +24,7 @@ importTestKeys().then(function(keys) { ...@@ -24,7 +24,7 @@ importTestKeys().then(function(keys) {
shouldBe("key.extractable", "true"); shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'HMAC'"); shouldBe("key.algorithm.name", "'HMAC'");
shouldBe("key.algorithm.length", "16"); shouldBe("key.algorithm.length", "16");
shouldBe("key.usages", '["encrypt", "decrypt", "sign", "verify"]'); shouldBe("key.usages", '["decrypt", "encrypt", "sign", "verify"]');
} }
finishJSTest(); finishJSTest();
} }
......
...@@ -7,8 +7,8 @@ onmessage = function(evt) ...@@ -7,8 +7,8 @@ onmessage = function(evt)
postMessage({ result:false, message:'key.extractable should be true' }); postMessage({ result:false, message:'key.extractable should be true' });
else if (key.algorithm.name != "HMAC") else if (key.algorithm.name != "HMAC")
postMessage({ result:false, message:'key.algorithm.name should be "HMAC"' }); postMessage({ result:false, message:'key.algorithm.name should be "HMAC"' });
else if (key.usages.toString() != "encrypt,decrypt,sign,verify") else if (key.usages.toString() != "decrypt,encrypt,sign,verify")
postMessage({ result:false, message:'key.usages should be ["encrypt", "decrypt", "sign", "verify"]' }); postMessage({ result:false, message:'key.usages should be ["decrypt", "encrypt", "sign", "verify"]' });
else else
postMessage({ result:true, key:key }); postMessage({ result:true, key:key });
} }
...@@ -38,7 +38,7 @@ PASS exportedPublicKey.algorithm.modulusLength is 2048 ...@@ -38,7 +38,7 @@ PASS exportedPublicKey.algorithm.modulusLength is 2048
PASS bytesToHexString(exportedPublicKey.algorithm.publicExponent) is '010001' 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.extractable is true
PASS exportedPublicKey.usages is ['encrypt','decrypt','wrapKey','unwrapKey'] PASS exportedPublicKey.usages is ['decrypt','encrypt','unwrapKey','wrapKey']
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -70,7 +70,7 @@ crypto.subtle.generateKey(algorithmKeyGen, extractable, ["encrypt", "decrypt", " ...@@ -70,7 +70,7 @@ crypto.subtle.generateKey(algorithmKeyGen, extractable, ["encrypt", "decrypt", "
shouldBe("bytesToHexString(exportedPublicKey.algorithm.publicExponent)", "'010001'"); 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.extractable", "true");
shouldBe("exportedPublicKey.usages", "['encrypt','decrypt','wrapKey','unwrapKey']"); shouldBe("exportedPublicKey.usages", "['decrypt','encrypt','unwrapKey','wrapKey']");
finishJSTest(); finishJSTest();
}); });
......
...@@ -13,7 +13,7 @@ PASS unwrappedKey.type is 'secret' ...@@ -13,7 +13,7 @@ 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 256 PASS unwrappedKey.algorithm.length is 256
PASS unwrappedKey.usages is ['encrypt', 'decrypt'] PASS unwrappedKey.usages is ['decrypt', 'encrypt']
Exporting it... Exporting it...
PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData) PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData)
...@@ -25,7 +25,7 @@ PASS unwrappedKey.type is 'secret' ...@@ -25,7 +25,7 @@ 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 256 PASS unwrappedKey.algorithm.length is 256
PASS unwrappedKey.usages is ['encrypt', 'decrypt'] PASS unwrappedKey.usages is ['decrypt', 'encrypt']
Exporting it... Exporting it...
PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData) PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData)
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -64,7 +64,7 @@ crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)), ...@@ -64,7 +64,7 @@ crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)),
shouldBe("unwrappedKey.extractable", "true"); shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'"); shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "256"); shouldBe("unwrappedKey.algorithm.length", "256");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt']"); shouldBe("unwrappedKey.usages", "['decrypt', 'encrypt']");
debug("Exporting it..."); debug("Exporting it...");
return crypto.subtle.exportKey("raw", unwrappedKey); return crypto.subtle.exportKey("raw", unwrappedKey);
...@@ -87,7 +87,7 @@ crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)), ...@@ -87,7 +87,7 @@ crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)),
shouldBe("unwrappedKey.extractable", "true"); shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'"); shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "256"); shouldBe("unwrappedKey.algorithm.length", "256");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt']"); shouldBe("unwrappedKey.usages", "['decrypt', 'encrypt']");
debug("Exporting it..."); debug("Exporting it...");
return crypto.subtle.exportKey("raw", unwrappedKey); return crypto.subtle.exportKey("raw", unwrappedKey);
......
...@@ -13,7 +13,7 @@ PASS unwrappedKey.type is 'secret' ...@@ -13,7 +13,7 @@ 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 256 PASS unwrappedKey.algorithm.length is 256
PASS unwrappedKey.usages is ['encrypt', 'decrypt'] PASS unwrappedKey.usages is ['decrypt', 'encrypt']
Exporting it... Exporting it...
PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData) PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData)
...@@ -25,7 +25,7 @@ PASS unwrappedKey.type is 'secret' ...@@ -25,7 +25,7 @@ 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 256 PASS unwrappedKey.algorithm.length is 256
PASS unwrappedKey.usages is ['encrypt', 'decrypt'] PASS unwrappedKey.usages is ['decrypt', 'encrypt']
Exporting it... Exporting it...
PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData) PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData)
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -64,7 +64,7 @@ crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)), ...@@ -64,7 +64,7 @@ crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)),
shouldBe("unwrappedKey.extractable", "true"); shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'"); shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "256"); shouldBe("unwrappedKey.algorithm.length", "256");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt']"); shouldBe("unwrappedKey.usages", "['decrypt', 'encrypt']");
debug("Exporting it..."); debug("Exporting it...");
return crypto.subtle.exportKey("raw", unwrappedKey); return crypto.subtle.exportKey("raw", unwrappedKey);
...@@ -87,7 +87,7 @@ crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)), ...@@ -87,7 +87,7 @@ crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)),
shouldBe("unwrappedKey.extractable", "true"); shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'"); shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "256"); shouldBe("unwrappedKey.algorithm.length", "256");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt']");