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>
Clean up SVGScriptElement
......@@ -8,7 +8,7 @@ PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 192
PASS key.usages is ['encrypt', 'decrypt']
PASS key.usages is ['decrypt', 'encrypt']
Using the key to encrypt plaintext...
PASS bytesToHexString(new Uint8Array(encryptionResult)) is '4f021db243bc633d7178183a9fa071e8b4d9ada9ad7dedf4e5e738763f69145a571b242012fb7ae07fa9baac3df102e008b0e27988598881d920a9e64f5615cd612ccd79224b350935d45dd6a98f8176'
Decrypting it back...
......
......@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "192");
shouldBe("key.usages", "['encrypt', 'decrypt']");
shouldBe("key.usages", "['decrypt', 'encrypt']");
debug("Using the key to encrypt plaintext...");
return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plaintext);
......
......@@ -8,7 +8,7 @@ PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 256
PASS key.usages is ['encrypt', 'decrypt']
PASS key.usages is ['decrypt', 'encrypt']
Using the key to encrypt plaintext...
PASS bytesToHexString(new Uint8Array(encryptionResult)) is 'f58c4c04d6e5f1ba779eabfb5f7bfbd69cfc4e967edb808d679f777bc6702c7d39f23369a9d9bacfa530e26304231461b2eb05e2c39be9fcda6c19078c6a9d1b3f461796d6b0d6b2e0c2a72b4d80e644'
Decrypting it back...
......
......@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "256");
shouldBe("key.usages", "['encrypt', 'decrypt']");
shouldBe("key.usages", "['decrypt', 'encrypt']");
debug("Using the key to encrypt plaintext...");
return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plaintext);
......
......@@ -8,7 +8,7 @@ PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 128
PASS key.usages is ['encrypt', 'decrypt']
PASS key.usages is ['decrypt', 'encrypt']
Using the key to encrypt plaintext...
PASS bytesToHexString(new Uint8Array(encryptionResult)) is '7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95db113a917678b273bed6b8e3c1743b7116e69e222295163ff1caa1681fac09120eca307586e1a78cb82807230e1321d3fae00d18cc2012'
Decrypting it back...
......
......@@ -8,7 +8,7 @@ PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 128
PASS key.usages is ['encrypt', 'decrypt']
PASS key.usages is ['decrypt', 'encrypt']
Using the key to encrypt plaintext...
PASS bytesToHexString(new Uint8Array(cyphertext)) is '630199c5f202cc7167bb84c6c72b349d'
Decrypting it back...
......
......@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "128");
shouldBe("key.usages", "['encrypt', 'decrypt']");
shouldBe("key.usages", "['decrypt', 'encrypt']");
debug("Using the key to encrypt 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
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "128");
shouldBe("key.usages", "['encrypt', 'decrypt']");
shouldBe("key.usages", "['decrypt', 'encrypt']");
debug("Using the key to encrypt plaintext...");
return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, plaintext);
......
......@@ -12,7 +12,7 @@ PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 128
PASS key.usages is ['encrypt', 'decrypt']
PASS key.usages is ['decrypt', 'encrypt']
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -28,7 +28,7 @@ crypto.subtle.generateKey({name: "aes-cbc", length: 128}, extractable, ["encrypt
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "128");
shouldBe("key.usages", "['encrypt', 'decrypt']");
shouldBe("key.usages", "['decrypt', 'encrypt']");
finishJSTest();
});
......
......@@ -8,7 +8,7 @@ PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'AES-CBC'
PASS key.algorithm.length is 176
PASS key.usages is ['encrypt', 'decrypt']
PASS key.usages is ['decrypt', 'encrypt']
Using the key to encrypt plaintext...
Failed, as expected. Note that the spec doesn't appear to clearly define which step should fail.
PASS successfullyParsed is true
......
......@@ -25,7 +25,7 @@ crypto.subtle.importKey("raw", keyData, "aes-cbc", extractable, ["encrypt", "dec
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "176");
shouldBe("key.usages", "['encrypt', 'decrypt']");
shouldBe("key.usages", "['decrypt', 'encrypt']");
debug("Using the key to encrypt plaintext...");
return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, key, [plaintext]);
......
......@@ -13,7 +13,7 @@ PASS unwrappedKey.type is 'secret'
PASS unwrappedKey.extractable is true
PASS unwrappedKey.algorithm.name is 'AES-CBC'
PASS unwrappedKey.algorithm.length is 128
PASS unwrappedKey.usages is ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']
PASS unwrappedKey.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
Exporting it...
PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(keyData)
......@@ -24,7 +24,7 @@ PASS unwrappedKey.type is 'secret'
PASS unwrappedKey.extractable is true
PASS unwrappedKey.algorithm.name is 'AES-CBC'
PASS unwrappedKey.algorithm.length is 128
PASS unwrappedKey.usages is ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']
PASS unwrappedKey.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
Exporting it...
PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(keyData)
PASS successfullyParsed is true
......
......@@ -41,7 +41,7 @@ crypto.subtle.importKey("raw", kekData, "aes-kw", extractable, ["wrapKey", "unwr
shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "128");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']");
shouldBe("unwrappedKey.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
debug("Exporting it...");
return crypto.subtle.exportKey("raw", unwrappedKey);
......@@ -63,7 +63,7 @@ crypto.subtle.importKey("raw", kekData, "aes-kw", extractable, ["wrapKey", "unwr
shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "128");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt', 'wrapKey', 'unwrapKey']");
shouldBe("unwrappedKey.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
debug("Exporting it...");
return crypto.subtle.exportKey("raw", unwrappedKey);
......
......@@ -7,7 +7,7 @@ PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'AES-CBC'
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
TEST COMPLETE
......
......@@ -18,7 +18,7 @@ window.addEventListener("message", function(evt) {
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'AES-CBC'");
shouldBe("key.algorithm.length", "128");
shouldBe("key.usages", '["encrypt", "decrypt", "sign", "verify"]');
shouldBe("key.usages", '["decrypt", "encrypt", "sign", "verify"]');
finishJSTest();
}, false);
......
......@@ -7,7 +7,7 @@ PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'HMAC'
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
TEST COMPLETE
......
......@@ -18,7 +18,7 @@ window.addEventListener("message", function(evt) {
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'HMAC'");
shouldBe("key.algorithm.length", "16");
shouldBe("key.usages", '["encrypt", "decrypt", "sign", "verify"]');
shouldBe("key.usages", '["decrypt", "encrypt", "sign", "verify"]');
finishJSTest();
}, false);
......
......@@ -10,7 +10,7 @@ deconly:
PASS key.usages is ["decrypt"]
enconly,deconly:
PASS key.usages is ["encrypt","decrypt"]
PASS key.usages is ["decrypt","encrypt"]
wrap:
PASS key.usages is ["wrapKey"]
......@@ -19,13 +19,13 @@ unwrap:
PASS key.usages is ["unwrapKey"]
wrap,unwrap:
PASS key.usages is ["wrapKey","unwrapKey"]
PASS key.usages is ["unwrapKey","wrapKey"]
enconly,deconly,wrap:
PASS key.usages is ["encrypt","decrypt","wrapKey"]
PASS key.usages is ["decrypt","encrypt","wrapKey"]
enc:
PASS key.usages is ["encrypt","decrypt","wrapKey","unwrapKey"]
PASS key.usages is ["decrypt","encrypt","unwrapKey","wrapKey"]
sigonly:
PASS key.usages is ["sign"]
......@@ -49,7 +49,7 @@ enconly, deconly:
PASS key.usages is ["encrypt"]
enconly,,deconly:
PASS key.usages is ["encrypt","decrypt"]
PASS key.usages is ["decrypt","encrypt"]
PASS successfullyParsed is true
......
......@@ -54,12 +54,12 @@ function testWithHMAC(expectedUsages, use)
Promise.all([
testWithAESCBC(["encrypt"], "enconly"),
testWithAESCBC(["decrypt"], "deconly"),
testWithAESCBC(["encrypt", "decrypt"], "enconly,deconly"),
testWithAESCBC(["decrypt", "encrypt"], "enconly,deconly"),
testWithAESCBC(["wrapKey"], "wrap"),
testWithAESCBC(["unwrapKey"], "unwrap"),
testWithAESCBC(["wrapKey", "unwrapKey"], "wrap,unwrap"),
testWithAESCBC(["encrypt", "decrypt", "wrapKey"], "enconly,deconly,wrap"),
testWithAESCBC(["encrypt", "decrypt", "wrapKey", "unwrapKey"], "enc"),
testWithAESCBC(["unwrapKey", "wrapKey"], "wrap,unwrap"),
testWithAESCBC(["decrypt", "encrypt", "wrapKey"], "enconly,deconly,wrap"),
testWithAESCBC(["decrypt", "encrypt", "unwrapKey", "wrapKey"], "enc"),
testWithHMAC(["sign"], "sigonly"),
testWithHMAC(["verify"], "vfyonly"),
testWithHMAC(["sign", "verify"], "sig"),
......@@ -69,7 +69,7 @@ Promise.all([
testWithAESCBC([], "enconly "),
testWithAESCBC([], "EncOnly"),
testWithAESCBC(["encrypt"], "enconly, deconly"),
testWithAESCBC(["encrypt", "decrypt"], "enconly,,deconly"),
testWithAESCBC(["decrypt","encrypt"], "enconly,,deconly"),
]).then(function() { finishJSTest(); } );
</script>
......
......@@ -8,7 +8,7 @@ PASS key.type is 'secret'
PASS key.extractable is true
PASS key.algorithm.name is 'HMAC'
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
TEST COMPLETE
......
......@@ -24,7 +24,7 @@ importTestKeys().then(function(keys) {
shouldBe("key.extractable", "true");
shouldBe("key.algorithm.name", "'HMAC'");
shouldBe("key.algorithm.length", "16");
shouldBe("key.usages", '["encrypt", "decrypt", "sign", "verify"]');
shouldBe("key.usages", '["decrypt", "encrypt", "sign", "verify"]');
}
finishJSTest();
}
......
......@@ -7,8 +7,8 @@ onmessage = function(evt)
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.usages.toString() != "encrypt,decrypt,sign,verify")
postMessage({ result:false, message:'key.usages should be ["encrypt", "decrypt", "sign", "verify"]' });
else if (key.usages.toString() != "decrypt,encrypt,sign,verify")
postMessage({ result:false, message:'key.usages should be ["decrypt", "encrypt", "sign", "verify"]' });
else
postMessage({ result:true, key:key });
}
......@@ -38,7 +38,7 @@ PASS exportedPublicKey.algorithm.modulusLength is 2048
PASS bytesToHexString(exportedPublicKey.algorithm.publicExponent) is '010001'
PASS exportedPublicKey.algorithm.hash.name is 'SHA-1'
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
TEST COMPLETE
......
......@@ -70,7 +70,7 @@ crypto.subtle.generateKey(algorithmKeyGen, extractable, ["encrypt", "decrypt", "
shouldBe("bytesToHexString(exportedPublicKey.algorithm.publicExponent)", "'010001'");
shouldBe("exportedPublicKey.algorithm.hash.name", "'SHA-1'");
shouldBe("exportedPublicKey.extractable", "true");
shouldBe("exportedPublicKey.usages", "['encrypt','decrypt','wrapKey','unwrapKey']");
shouldBe("exportedPublicKey.usages", "['decrypt','encrypt','unwrapKey','wrapKey']");
finishJSTest();
});
......
......@@ -13,7 +13,7 @@ PASS unwrappedKey.type is 'secret'
PASS unwrappedKey.extractable is true
PASS unwrappedKey.algorithm.name is 'AES-CBC'
PASS unwrappedKey.algorithm.length is 256
PASS unwrappedKey.usages is ['encrypt', 'decrypt']
PASS unwrappedKey.usages is ['decrypt', 'encrypt']
Exporting it...
PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData)
......@@ -25,7 +25,7 @@ PASS unwrappedKey.type is 'secret'
PASS unwrappedKey.extractable is true
PASS unwrappedKey.algorithm.name is 'AES-CBC'
PASS unwrappedKey.algorithm.length is 256
PASS unwrappedKey.usages is ['encrypt', 'decrypt']
PASS unwrappedKey.usages is ['decrypt', 'encrypt']
Exporting it...
PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData)
PASS successfullyParsed is true
......
......@@ -64,7 +64,7 @@ crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)),
shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "256");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt']");
shouldBe("unwrappedKey.usages", "['decrypt', 'encrypt']");
debug("Exporting it...");
return crypto.subtle.exportKey("raw", unwrappedKey);
......@@ -87,7 +87,7 @@ crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)),
shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "256");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt']");
shouldBe("unwrappedKey.usages", "['decrypt', 'encrypt']");
debug("Exporting it...");
return crypto.subtle.exportKey("raw", unwrappedKey);
......
......@@ -13,7 +13,7 @@ PASS unwrappedKey.type is 'secret'
PASS unwrappedKey.extractable is true
PASS unwrappedKey.algorithm.name is 'AES-CBC'
PASS unwrappedKey.algorithm.length is 256
PASS unwrappedKey.usages is ['encrypt', 'decrypt']
PASS unwrappedKey.usages is ['decrypt', 'encrypt']
Exporting it...
PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData)
......@@ -25,7 +25,7 @@ PASS unwrappedKey.type is 'secret'
PASS unwrappedKey.extractable is true
PASS unwrappedKey.algorithm.name is 'AES-CBC'
PASS unwrappedKey.algorithm.length is 256
PASS unwrappedKey.usages is ['encrypt', 'decrypt']
PASS unwrappedKey.usages is ['decrypt', 'encrypt']
Exporting it...
PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData)
PASS successfullyParsed is true
......
......@@ -64,7 +64,7 @@ crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)),
shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "256");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt']");
shouldBe("unwrappedKey.usages", "['decrypt', 'encrypt']");
debug("Exporting it...");
return crypto.subtle.exportKey("raw", unwrappedKey);
......@@ -87,7 +87,7 @@ crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)),
shouldBe("unwrappedKey.extractable", "true");
shouldBe("unwrappedKey.algorithm.name", "'AES-CBC'");
shouldBe("unwrappedKey.algorithm.length", "256");
shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt']");
shouldBe("unwrappedKey.usages", "['decrypt', 'encrypt']");
debug("Exporting it...");
return crypto.subtle.exportKey("raw", unwrappedKey);
......
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/CryptoKey.cpp: (WebCore::CryptoKey::usages): Do it.
2013-12-13 Darin Adler <darin@apple.com>
Make some optimizations for DOM bindings involving vectors
......@@ -67,23 +67,24 @@ void CryptoKey::buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder& bui
Vector<String> CryptoKey::usages() const
{
// The result is ordered alphabetically.
Vector<String> result;
if (m_usages & CryptoKeyUsageEncrypt)
result.append(ASCIILiteral("encrypt"));
if (m_usages & CryptoKeyUsageDecrypt)
result.append(ASCIILiteral("decrypt"));
if (m_usages & CryptoKeyUsageDeriveBits)
result.append(ASCIILiteral("deriveBits"));
if (m_usages & CryptoKeyUsageDeriveKey)
result.append(ASCIILiteral("deriveKey"));
if (m_usages & CryptoKeyUsageEncrypt)
result.append(ASCIILiteral("encrypt"));
if (m_usages & CryptoKeyUsageSign)
result.append(ASCIILiteral("sign"));
if (m_usages & CryptoKeyUsageUnwrapKey)
result.append(ASCIILiteral("unwrapKey"));
if (m_usages & CryptoKeyUsageVerify)
result.append(ASCIILiteral("verify"));
if (m_usages & CryptoKeyUsageDeriveKey)
result.append(ASCIILiteral("deriveKey"));
if (m_usages & CryptoKeyUsageDeriveBits)
result.append(ASCIILiteral("deriveBits"));
if (m_usages & CryptoKeyUsageWrapKey)
result.append(ASCIILiteral("wrapKey"));
if (m_usages & CryptoKeyUsageUnwrapKey)
result.append(ASCIILiteral("unwrapKey"));
return result;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment