<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[213628] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/213628">213628</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2017-03-08 21:50:31 -0800 (Wed, 08 Mar 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>[WebCrypto] Implement SubtleCrypto::DeriveKey method
https://bugs.webkit.org/show_bug.cgi?id=169386
<rdar://problem/23789585>
Reviewed by Brent Fulgham.
Source/WebCore:
This patch does following few things:
1. It implements SubtleCrypto::DeriveKey method according to the spec:
https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-deriveKey.
2. It implements getKeyLength operations for AES-CBC, AES-KW, AES-CFB,
AES-GCM, and HMAC, which is needed by the SubtleCrypto::DeriveKey method.
3. It enables ECDH DeriveKey operation.
4. It replaces unigned long with size_t in all the crypto codes.
Tests: crypto/subtle/derive-key-malformed-parameters.html
crypto/subtle/ecdh-import-key-derive-aes-key.html
crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html
crypto/subtle/unwrap-key-malformed-parameters.html
crypto/subtle/wrap-key-malformed-parameters.html
crypto/workers/subtle/ecdh-import-key-derive-key.html
* CMakeLists.txt:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::normalizeCryptoAlgorithmParameters):
(WebCore::jsSubtleCryptoFunctionEncryptPromise):
(WebCore::jsSubtleCryptoFunctionDecryptPromise):
(WebCore::jsSubtleCryptoFunctionSignPromise):
(WebCore::jsSubtleCryptoFunctionVerifyPromise):
(WebCore::jsSubtleCryptoFunctionDigestPromise):
(WebCore::jsSubtleCryptoFunctionDeriveKeyPromise):
(WebCore::jsSubtleCryptoFunctionDeriveBitsPromise):
Remove unnecessary return statement from callbacks.
* crypto/CryptoAlgorithm.cpp:
(WebCore::CryptoAlgorithm::deriveBits):
(WebCore::CryptoAlgorithm::getKeyLength):
* crypto/CryptoAlgorithm.h:
* crypto/CryptoAlgorithmParameters.h:
* crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
(WebCore::CryptoAlgorithmAES_CBC::generateKey):
(WebCore::CryptoAlgorithmAES_CBC::getKeyLength):
* crypto/algorithms/CryptoAlgorithmAES_CBC.h:
* crypto/algorithms/CryptoAlgorithmAES_CFB.cpp:
(WebCore::CryptoAlgorithmAES_CFB::generateKey):
(WebCore::CryptoAlgorithmAES_CFB::getKeyLength):
* crypto/algorithms/CryptoAlgorithmAES_CFB.h:
* crypto/algorithms/CryptoAlgorithmAES_GCM.cpp:
(WebCore::CryptoAlgorithmAES_GCM::generateKey):
(WebCore::CryptoAlgorithmAES_GCM::getKeyLength):
* crypto/algorithms/CryptoAlgorithmAES_GCM.h:
* crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
(WebCore::CryptoAlgorithmAES_KW::generateKey):
(WebCore::CryptoAlgorithmAES_KW::getKeyLength):
* crypto/algorithms/CryptoAlgorithmAES_KW.h:
* crypto/algorithms/CryptoAlgorithmECDH.cpp:
(WebCore::CryptoAlgorithmECDH::deriveBits):
* crypto/algorithms/CryptoAlgorithmECDH.h:
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
(WebCore::CryptoAlgorithmHMAC::getKeyLength):
* crypto/algorithms/CryptoAlgorithmHMAC.h:
* crypto/keys/CryptoKeyAES.cpp:
(WebCore::CryptoKeyAES::getKeyLength):
* crypto/keys/CryptoKeyAES.h:
* crypto/keys/CryptoKeyHMAC.cpp:
(WebCore::getKeyLengthFromHash):
(WebCore::CryptoKeyHMAC::generate):
(WebCore::CryptoKeyHMAC::getKeyLength):
* crypto/keys/CryptoKeyHMAC.h:
* crypto/mac/CryptoAlgorithmECDHMac.cpp:
(WebCore::CryptoAlgorithmECDH::platformDeriveBits):
* crypto/parameters/AesKeyParams.idl: Renamed from Source/WebCore/crypto/parameters/AesKeyGenParams.idl.
* crypto/parameters/CryptoAlgorithmAesKeyParams.h: Renamed from Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h.
Rename AesKeyGenParams to AesKeyParams to represent a unified dictionary for AesKeyGenParams and AesDerivedKeyParams.
* crypto/parameters/CryptoAlgorithmHmacKeyParams.h:
* crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h:
LayoutTests:
* crypto/subtle/aes-generate-key-malformed-parameters-expected.txt:
* crypto/subtle/derive-key-malformed-parameters-expected.txt: Added.
* crypto/subtle/derive-key-malformed-parameters.html: Added.
* crypto/subtle/deriveKey-malformed-parameters-expected.txt: Removed.
* crypto/subtle/deriveKey-malformed-parameters.html: Removed.
* crypto/subtle/ecdh-import-key-derive-aes-key-expected.txt: Added.
* crypto/subtle/ecdh-import-key-derive-aes-key.html: Added.
* crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length-expected.txt: Added.
* crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html: Added.
* crypto/subtle/unwrap-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/unwrapKey-malformed-parameters-expected.txt.
* crypto/subtle/unwrap-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/unwrapKey-malformed-parameters.html.
* crypto/subtle/wrap-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/wrapKey-malformed-parameters-expected.txt.
* crypto/subtle/wrap-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/wrapKey-malformed-parameters.html.
A bit renaming.
* crypto/workers/subtle/ecdh-import-key-derive-key-expected.txt: Added.
* crypto/workers/subtle/ecdh-import-key-derive-key.html: Added.
* crypto/workers/subtle/resources/ecdh-import-key-derive-key.js: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaesgeneratekeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-generate-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesmake">trunk/Source/WebCore/DerivedSources.make</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp">trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoAlgorithmcpp">trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoAlgorithmh">trunk/Source/WebCore/crypto/CryptoAlgorithm.h</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoAlgorithmParametersh">trunk/Source/WebCore/crypto/CryptoAlgorithmParameters.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CFBcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CFBh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_GCMcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_GCMh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_KWcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_KWh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmECDHcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmECDHh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyAEScpp">trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyAESh">trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyHMACcpp">trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyHMACh">trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoAlgorithmECDHMaccpp">trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDHMac.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoparametersCryptoAlgorithmHmacKeyParamsh">trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyParams.h</a></li>
<li><a href="#trunkSourceWebCorecryptoparametersCryptoAlgorithmRsaKeyGenParamsh">trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtlederivekeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/derive-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlederivekeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/derive-key-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportkeyderiveaeskeyexpectedtxt">trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-aes-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportkeyderiveaeskeyhtml">trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-aes-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportkeyderivehmackeycustomlengthexpectedtxt">trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportkeyderivehmackeycustomlengthhtml">trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleunwrapkeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/unwrap-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleunwrapkeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/unwrap-key-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlewrapkeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/wrap-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlewrapkeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/wrap-key-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleecdhimportkeyderivekeyexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/ecdh-import-key-derive-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleecdhimportkeyderivekeyhtml">trunk/LayoutTests/crypto/workers/subtle/ecdh-import-key-derive-key.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesecdhimportkeyderivekeyjs">trunk/LayoutTests/crypto/workers/subtle/resources/ecdh-import-key-derive-key.js</a></li>
<li><a href="#trunkSourceWebCorecryptoparametersAesKeyParamsidl">trunk/Source/WebCore/crypto/parameters/AesKeyParams.idl</a></li>
<li><a href="#trunkSourceWebCorecryptoparametersCryptoAlgorithmAesKeyParamsh">trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyParams.h</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtlederiveKeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlederiveKeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleunwrapKeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/unwrapKey-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleunwrapKeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/unwrapKey-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlewrapKeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/wrapKey-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlewrapKeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/wrapKey-malformed-parameters.html</a></li>
<li><a href="#trunkSourceWebCorecryptoparametersAesKeyGenParamsidl">trunk/Source/WebCore/crypto/parameters/AesKeyGenParams.idl</a></li>
<li><a href="#trunkSourceWebCorecryptoparametersCryptoAlgorithmAesKeyGenParamsh">trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/LayoutTests/ChangeLog        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2017-03-08 Jiewen Tan <jiewen_tan@apple.com>
+
+ [WebCrypto] Implement SubtleCrypto::DeriveKey method
+ https://bugs.webkit.org/show_bug.cgi?id=169386
+ <rdar://problem/23789585>
+
+ Reviewed by Brent Fulgham.
+
+ * crypto/subtle/aes-generate-key-malformed-parameters-expected.txt:
+ * crypto/subtle/derive-key-malformed-parameters-expected.txt: Added.
+ * crypto/subtle/derive-key-malformed-parameters.html: Added.
+ * crypto/subtle/deriveKey-malformed-parameters-expected.txt: Removed.
+ * crypto/subtle/deriveKey-malformed-parameters.html: Removed.
+ * crypto/subtle/ecdh-import-key-derive-aes-key-expected.txt: Added.
+ * crypto/subtle/ecdh-import-key-derive-aes-key.html: Added.
+ * crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length-expected.txt: Added.
+ * crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html: Added.
+ * crypto/subtle/unwrap-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/unwrapKey-malformed-parameters-expected.txt.
+ * crypto/subtle/unwrap-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/unwrapKey-malformed-parameters.html.
+ * crypto/subtle/wrap-key-malformed-parameters-expected.txt: Renamed from LayoutTests/crypto/subtle/wrapKey-malformed-parameters-expected.txt.
+ * crypto/subtle/wrap-key-malformed-parameters.html: Renamed from LayoutTests/crypto/subtle/wrapKey-malformed-parameters.html.
+ A bit renaming.
+ * crypto/workers/subtle/ecdh-import-key-derive-key-expected.txt: Added.
+ * crypto/workers/subtle/ecdh-import-key-derive-key.html: Added.
+ * crypto/workers/subtle/resources/ecdh-import-key-derive-key.js: Added.
+
</ins><span class="cx"> 2017-03-08 Matt Baker <mattbaker@apple.com>
</span><span class="cx">
</span><span class="cx"> Web Inspector: Add DOM breakpoints UI for node/subtree modification events
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaesgeneratekeymalformedparametersexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/aes-generate-key-malformed-parameters-expected.txt (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-generate-key-malformed-parameters-expected.txt        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/LayoutTests/crypto/subtle/aes-generate-key-malformed-parameters-expected.txt        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -3,11 +3,11 @@
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span><span class="cx">
</span><span class="cx">
</span><del>-PASS crypto.subtle.generateKey("aes-cbc", extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKeyGenParams.length is required and must be an instance of unsigned short.
-PASS crypto.subtle.generateKey({name: "aes-cbc"}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKeyGenParams.length is required and must be an instance of unsigned short.
</del><ins>+PASS crypto.subtle.generateKey("aes-cbc", extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKeyParams.length is required and must be an instance of unsigned short.
+PASS crypto.subtle.generateKey({name: "aes-cbc"}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKeyParams.length is required and must be an instance of unsigned short.
</ins><span class="cx"> PASS crypto.subtle.generateKey({name: "aes-cbc", length: true}, extractable, ["encrypt", "decrypt"]) rejected promise with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
</span><span class="cx"> PASS crypto.subtle.generateKey({name: "aes-cbc", length: null}, extractable, ["encrypt", "decrypt"]) rejected promise with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
</span><del>-PASS crypto.subtle.generateKey({name: "aes-cbc", length: undefined}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKeyGenParams.length is required and must be an instance of unsigned short.
</del><ins>+PASS crypto.subtle.generateKey({name: "aes-cbc", length: undefined}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Member AesKeyParams.length is required and must be an instance of unsigned short.
</ins><span class="cx"> PASS crypto.subtle.generateKey({name: "aes-cbc", length: Symbol()}, extractable, ["encrypt", "decrypt"]) rejected promise with TypeError: Cannot convert a symbol to a number.
</span><span class="cx"> PASS crypto.subtle.generateKey({name: "aes-cbc", length: { }}, extractable, ["encrypt", "decrypt"]) rejected promise with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
</span><span class="cx"> PASS crypto.subtle.generateKey({name: "aes-cbc", length: "foo"}, extractable, ["encrypt", "decrypt"]) rejected promise with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlederivekeymalformedparametersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/derive-key-malformed-parameters-expected.txt (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/derive-key-malformed-parameters-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/derive-key-malformed-parameters-expected.txt        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+Test deriveKey operation with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.deriveKey() rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.deriveKey(1) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.deriveKey(1, 2) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.deriveKey(1, 2, 3) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.deriveKey(1, 2, 3, 4) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, "AES-CBC", extractable, ["encrypt"]) rejected promise with TypeError: Member AesKeyParams.length is required and must be an instance of unsigned short.
+PASS crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, "RSAES-PKCS1-v1_5", extractable, ["encrypt"]) rejected promise with NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt"]) rejected promise with NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "ECDH", namedCurve: "P-256"}, extractable, ["encrypt"]) rejected promise with NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, wrongKey, {name: "aes-cbc", length: 128}, extractable, ["encrypt"]) rejected promise with InvalidAccessError (DOM Exception 15): CryptoKey doesn't match AlgorithmIdentifier.
+PASS crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, wrongKey, {name: "aes-cbc", length: 128}, extractable, ["encrypt"]) rejected promise with InvalidAccessError (DOM Exception 15): CryptoKey doesn't support CryptoKey derivation.
+PASS crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "aes-cbc", length: 1}, extractable, ["encrypt"]) rejected promise with OperationError (DOM Exception 34): Cannot get key length from derivedKeyType.
+PASS crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "hmac", hash: "hmac"}, extractable, ["sign"]) rejected promise with NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "hmac", hash: "sha-1", length: 0}, extractable, ["sign"]) rejected promise with TypeError: Cannot get key length from derivedKeyType.
+PASS crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "aes-cbc", length: 128}, extractable, []) rejected promise with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlederivekeymalformedparametershtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/derive-key-malformed-parameters.html (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/derive-key-malformed-parameters.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/derive-key-malformed-parameters.html        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,78 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test deriveKey operation with malformed parameters");
+
+jsTestIsAsync = true;
+
+var extractable = true;
+var jwkPrivateKey = {
+ kty: "EC",
+ crv: "P-256",
+ x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA",
+ y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI",
+ d: "ppxBSov3N8_AUcisAuvmLV4yE8e_L_BLE8bZb9Z1Xjg",
+};
+var jwkPublicKey = {
+ kty: "EC",
+ crv: "P-256",
+ x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA",
+ y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI",
+};
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+
+// Not enough arguments.
+shouldReject('crypto.subtle.deriveKey()');
+shouldReject('crypto.subtle.deriveKey(1)');
+shouldReject('crypto.subtle.deriveKey(1, 2)');
+shouldReject('crypto.subtle.deriveKey(1, 2, 3)');
+shouldReject('crypto.subtle.deriveKey(1, 2, 3, 4)');
+
+crypto.subtle.importKey("jwk", jwkPrivateKey, { name: "ECDH", namedCurve: "P-256" }, extractable, ["deriveKey"]).then(function(result) {
+ privateKey = result;
+ return crypto.subtle.importKey("jwk", jwkPublicKey, { name: "ECDH", namedCurve: "P-256" }, extractable, [ ]);
+}).then(function(result) {
+ publicKey = result;
+
+ // Malformed GetKeyLength AlgorithmIdentifier.
+ shouldReject('crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, "AES-CBC", extractable, ["encrypt"])');
+ // Not support GetKeyLength AlgorithmIdentifier.
+ shouldReject('crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, "RSAES-PKCS1-v1_5", extractable, ["encrypt"])');
+ shouldReject('crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt"])');
+ shouldReject('crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "ECDH", namedCurve: "P-256"}, extractable, ["encrypt"])');
+
+ return crypto.subtle.importKey("raw", rawKey, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"])
+}).then(function(result) {
+ wrongKey = result;
+
+ // Mismatched AlgorithmIdentifier.
+ shouldReject('crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, wrongKey, {name: "aes-cbc", length: 128}, extractable, ["encrypt"])');
+
+ return crypto.subtle.importKey("jwk", jwkPrivateKey, { name: "ECDH", namedCurve: "P-256" }, extractable, ["deriveBits"]);
+}).then(function(result) {
+ wrongKey = result;
+
+ // Wrong usage.
+ shouldReject('crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, wrongKey, {name: "aes-cbc", length: 128}, extractable, ["encrypt"])');
+ // derivedKeyType with wrong AES params.
+ shouldReject('crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "aes-cbc", length: 1}, extractable, ["encrypt"])');
+ // derivedKeyType with wrong HMAC params.
+ shouldReject('crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "hmac", hash: "hmac"}, extractable, ["sign"])');
+ shouldReject('crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "hmac", hash: "sha-1", length: 0}, extractable, ["sign"])');
+ // Null usages
+ return shouldReject('crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "aes-cbc", length: 128}, extractable, [])');
+}).then(finishJSTest, finishJSTest);
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlederiveKeymalformedparametersexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters-expected.txt (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters-expected.txt        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters-expected.txt        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -1,15 +0,0 @@
</span><del>-Test deriveKey operation with malformed parameters
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS crypto.subtle.deriveKey() rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.deriveKey(1) rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.deriveKey(1, 2) rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.deriveKey(1, 2, 3) rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.deriveKey(1, 2, 3, 4) rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.deriveKey("ECDH", 2, 3, 4, 5) rejected promise with NotSupportedError (DOM Exception 9): The operation is not supported..
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
</del></span></pre></div>
<a id="trunkLayoutTestscryptosubtlederiveKeymalformedparametershtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters.html (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters.html        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/LayoutTests/crypto/subtle/deriveKey-malformed-parameters.html        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -1,26 +0,0 @@
</span><del>-<!DOCTYPE html>
-<html>
-<head>
-<script src="../../resources/js-test-pre.js"></script>
-<script src="../resources/common.js"></script>
-</head>
-<body>
-<p id="description"></p>
-<div id="console"></div>
-
-<script>
-description("Test deriveKey operation with malformed parameters");
-
-// Not enough arguments.
-shouldReject('crypto.subtle.deriveKey()');
-shouldReject('crypto.subtle.deriveKey(1)');
-shouldReject('crypto.subtle.deriveKey(1, 2)');
-shouldReject('crypto.subtle.deriveKey(1, 2, 3)');
-shouldReject('crypto.subtle.deriveKey(1, 2, 3, 4)');
-// Not support.
-shouldReject('crypto.subtle.deriveKey("ECDH", 2, 3, 4, 5)');
-</script>
-
-<script src="../../resources/js-test-post.js"></script>
-</body>
-</html>
</del></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportkeyderiveaeskeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-aes-key-expected.txt (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-aes-key-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-aes-key-expected.txt        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+Test deriving AES Keys with imported ECDH base key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS derivedKey.type is 'secret'
+PASS derivedKey.extractable is true
+PASS derivedKey.algorithm.name is 'AES-CBC'
+PASS derivedKey.algorithm.length is 128
+PASS derivedKey.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportkeyderiveaeskeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-aes-key.html (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-aes-key.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-aes-key.html        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test deriving AES Keys with imported ECDH base key");
+
+jsTestIsAsync = true;
+
+var extractable = true;
+var jwkPrivateKey = {
+ kty: "EC",
+ crv: "P-256",
+ x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA",
+ y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI",
+ d: "ppxBSov3N8_AUcisAuvmLV4yE8e_L_BLE8bZb9Z1Xjg",
+};
+var jwkPublicKey = {
+ kty: "EC",
+ crv: "P-256",
+ x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA",
+ y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI",
+};
+
+crypto.subtle.importKey("jwk", jwkPrivateKey, { name: "ECDH", namedCurve: "P-256" }, extractable, ["deriveKey"]).then(function(result) {
+ privateKey = result;
+ return crypto.subtle.importKey("jwk", jwkPublicKey, { name: "ECDH", namedCurve: "P-256" }, extractable, [ ]);
+}).then(function(result) {
+ publicKey = result;
+ return crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "aes-cbc", length: 128}, extractable, ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']);
+}).then(function(result) {
+ derivedKey = result;
+
+ shouldBe("derivedKey.type", "'secret'");
+ shouldBe("derivedKey.extractable", "true");
+ shouldBe("derivedKey.algorithm.name", "'AES-CBC'");
+ shouldBe("derivedKey.algorithm.length", "128");
+ shouldBe("derivedKey.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportkeyderivehmackeycustomlengthexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length-expected.txt (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length-expected.txt        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+Test deriving HMAC Keys with imported ECDH base key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS derivedKey.type is 'secret'
+PASS derivedKey.extractable is true
+PASS derivedKey.algorithm.name is 'HMAC'
+PASS derivedKey.algorithm.length is 128
+PASS derivedKey.algorithm.hash.name is 'SHA-1'
+PASS derivedKey.usages is ['sign', 'verify']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportkeyderivehmackeycustomlengthhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test deriving HMAC Keys with imported ECDH base key");
+
+jsTestIsAsync = true;
+
+var extractable = true;
+var jwkPrivateKey = {
+ kty: "EC",
+ crv: "P-256",
+ x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA",
+ y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI",
+ d: "ppxBSov3N8_AUcisAuvmLV4yE8e_L_BLE8bZb9Z1Xjg",
+};
+var jwkPublicKey = {
+ kty: "EC",
+ crv: "P-256",
+ x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA",
+ y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI",
+};
+
+crypto.subtle.importKey("jwk", jwkPrivateKey, { name: "ECDH", namedCurve: "P-256" }, extractable, ["deriveKey"]).then(function(result) {
+ privateKey = result;
+ return crypto.subtle.importKey("jwk", jwkPublicKey, { name: "ECDH", namedCurve: "P-256" }, extractable, [ ]);
+}).then(function(result) {
+ publicKey = result;
+ return crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "hmac", hash: "sha-1", length: 128}, extractable, ['sign', 'verify']);
+}).then(function(result) {
+ derivedKey = result;
+
+ shouldBe("derivedKey.type", "'secret'");
+ shouldBe("derivedKey.extractable", "true");
+ shouldBe("derivedKey.algorithm.name", "'HMAC'");
+ shouldBe("derivedKey.algorithm.length", "128");
+ shouldBe("derivedKey.algorithm.hash.name", "'SHA-1'");
+ shouldBe("derivedKey.usages", "['sign', 'verify']");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleunwrapkeymalformedparametersexpectedtxtfromrev213627trunkLayoutTestscryptosubtleunwrapKeymalformedparametersexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/crypto/subtle/unwrap-key-malformed-parameters-expected.txt (from rev 213627, trunk/LayoutTests/crypto/subtle/unwrapKey-malformed-parameters-expected.txt) (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/unwrap-key-malformed-parameters-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/unwrap-key-malformed-parameters-expected.txt        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+Test UnwrapKey operation with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.unwrapKey() rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.unwrapKey(1) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.unwrapKey(1, 2) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.unwrapKey(1, 2, 3) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.unwrapKey(1, 2, 3, 4) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.unwrapKey(1, 2, 3, 4, 5) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.unwrapKey(1, 2, 3, 4, 5, 6) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, "HMAC", "AES-CBC", extractable, ["encrypt", "decrypt"]) rejected promise with NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, aesCbcParams, "AES-CBC", extractable, ["encrypt", "decrypt"]) rejected promise with InvalidAccessError (DOM Exception 15): Unwrapping CryptoKey doesn't match unwrap AlgorithmIdentifier.
+PASS crypto.subtle.unwrapKey("jwk", wrappedRawKey, unwrappingKey, "AES-KW", "AES-CBC", extractable, ["encrypt", "decrypt"]) rejected promise with DataError (DOM Exception 30): WrappedKey cannot be converted to a JSON object.
+PASS crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, "AES-KW", "AES-CBC", extractable, [ ]) rejected promise with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.unwrapKey("jwk", wrappedJwkKey, unwrappingKey, aesCbcParams, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, [ ]) rejected promise with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, "AES-KW", "AES-CBC", extractable, ["encrypt", "decrypt"]) rejected promise with InvalidAccessError (DOM Exception 15): Unwrapping CryptoKey doesn't support unwrapKey operation.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleunwrapkeymalformedparametershtmlfromrev213627trunkLayoutTestscryptosubtleunwrapKeymalformedparametershtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/crypto/subtle/unwrap-key-malformed-parameters.html (from rev 213627, trunk/LayoutTests/crypto/subtle/unwrapKey-malformed-parameters.html) (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/unwrap-key-malformed-parameters.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/unwrap-key-malformed-parameters.html        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,65 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test UnwrapKey operation with malformed parameters");
+
+jsTestIsAsync = true;
+
+var extractable = true;
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var aesCbcParams = {
+ name: "aes-cbc",
+ iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
+}
+var wrappedRawKey = hexStringToUint8Array("d64787ab3e048dbdc30bb62781c9f18e58ad7dbfc64aab16");
+var wrappedJwkKey = hexStringToUint8Array( "848aa2f70ee18e2953520132a79cf479b03a8732a3cc73f8c51c68456d3c2557e8be9d5911b2a74267e282a87ffeed88dfbac38a22c26ba621f83915d7539420a4dc0b2329c585b442967367c1ea6c1126f98c4f13b7c8cb7402b86a5844c19420ea333dc33d908be89172f8bac59b403fe202f32c8eed19f431cedfc3383f536f3557163b1311ae42ee5486c6dafee968640d6b6999c687f37fba8d65cc662f1c84f16245665e4af41c98e8b63632cc1d19e2bece2154c7eab1905f3f6ab17b495cefec3508e9b451f2ea1422b97f275dfdc118f46af02040250d0e55d8d8d172b969bbcf7314a257f10b98d2c47c6c72a727acaf4c96340d590ebcebc61f73b7a868b490f3c1e17c59ea479a3b8db5574153de46cfdbb07cfc5e95ebcf7ad3d5fa057ba946d6da872c4bef3af6d7013e222c227650d0022c94d306cb14e203aad378d171c7c24f824c31b81fd18265e0de2f4b415584ebc4adeb5880c4eddbc88b854699f7aa74d6a10ca5df8978f27b5d1372b31ea67a9c4841ae101ea6ad78df0580b70358e6933ac92f7faee5320af329d8349a7b98690708a388737604be0affaa0669410d8d93dc4e4f57e14583253f11e5b27c89b84f1f3038bae6d9b37e3eb64b63ad1880627aef3b19e3e851cfae639ec4
6dd06fd131b51f530b37260b836d9013d8ad7c8640096070f96984c528ee5e20b69f3cd98a269621cd886ccb16d9c526a87cd5c458541309bb7fa4f3337305d76fc050d39ca8b1fdb0675a11a40ffde9cebb33ddc485e5dc5e7667b08c2a3e0136d063a447aee5a8f650429c5e422a706c4c240a4d11f4a9b5782f2cba2575f0c32cb477a9f0cef97fa993977104181315ff90e46f3b12b8b00f4a7611c42b1bb53d0e6021ab21ee8ae606d9f06dfedb891763007e020977c28b46d5f33bc35c12061d90ebbe02cab58783c0cac0c6f14ed735204f23d0eb6a9fe9edea2aecb1ac213f58b42d5d96374ec70ca288a31016ba02adef43250d717e9fab8982a1a180b1f3944d450c159010fd23f354d88502ec702882ae3edd567c6a6edf3cb2e34edc13f410a25d97298ab9062ddb566576fa8b6599bba205bab55aa5f3f37edaf7733cf249e69c74da975ef249ca673da749d86babebdf55410a389720ac943f1e9d921f5d69c5789636cb904fb9263744236eade9acae889a01c237ab3436101463dfa9d92f936c1b652c80f3abba76023ebe5b9bfdd54735e3a3494de18a456967f58758e546021feef3fa3e6c239981aa06f1f7ddc415d957ff9919bbec5f36af092a81ba6c14fe644d2ee98a2fcdee2ed70b87a53ffa327b25b4569c5886b15f2bd583d6f5bd7e951a915142b
aa08c6a9c343c200678a005fad22a337d2c5627f8c816db2525a7e121849b9da756eee68a240452849ffdb9651f998257c62e8fdcdc48dadfc3ebb18f7eb5461442008846a629ec8149c052f357bf5889095047b272bce0ff505953e7cd525b24c838ba6e9ed91922a30eeb858de8556f19f761d0287d768876346a5dcac3dbadd7a30072c9338162be5812166d961f4031f962ef668781d39d0fc69fe5f4494e31ec082d4a0140e368b69975beeba120ef9b651ead531b4d44296bd3cfe2ce7f97bb5bb4921061b12c2e1c4c10928c0980ff8d488a2282d0c056a40260167410e39664f75ff1f1249820e174eed978318a05e654b8aa6c60b70001a7a04f0aff17597dd9ab3ccc34f5ba2e352b7244dd3dccb462d7175b95ae3970ec5858e2312aac7c2c79a37b53d089f988720a4c04df6328a384004d0d51eafb9486623099a98e69be5169201c88824acc2bb0e1790889014a1797c168e98d19f0787c2935cfbc3bf24c4adad69a81e0e6adf8c21e3c4789064aa31a025dff5cc6eaba3f3e43f10a9d531f47963372120e2366b84c281ed968d9d11c1d103826c9362741e1267d1a3e8d2188761fa876b7b09617df14130c07209f1f1188ff40971b86607dee14d556a880447901c69d29cb16c027c3aae316ff00132bdfcd0e39c5e201252c9771483ccb275b0c67b3cb4dcd
19198c7718634460254dfd6f8df4374b8bedee7dd20ce411b5f987cac2ce17492aa78f919c6d5e555000f47f7b8a9896d448bc4fc13e40a9e5c02258d509a7289f44d7250e89260233bf96702bb3d350451f03d802e0e37d9f01cce4c78869403493eb9890c2c09109d1f427f59cf091cd1c836e25a9bb065041407c2183f643bce2e72db1e7caeac42e2d8379f8b84df2cc7b1d055f42d6f62e0cb5771a14ae8872792350e5f770115a86564f60a785c53325c8c084afe214da3cac1783e2be9099d96ddbe9cc3ea3dd1d3ae50526b4afe24397420a3e4fa697613421");
+
+// Not enough arguments.
+shouldReject('crypto.subtle.unwrapKey()');
+shouldReject('crypto.subtle.unwrapKey(1)');
+shouldReject('crypto.subtle.unwrapKey(1, 2)');
+shouldReject('crypto.subtle.unwrapKey(1, 2, 3)');
+shouldReject('crypto.subtle.unwrapKey(1, 2, 3, 4)');
+shouldReject('crypto.subtle.unwrapKey(1, 2, 3, 4, 5)');
+shouldReject('crypto.subtle.unwrapKey(1, 2, 3, 4, 5, 6)');
+
+crypto.subtle.importKey("raw", rawKey, "aes-kw", extractable, ["wrapKey", "unwrapKey"]).then(function(result) {
+ unwrappingKey = result;
+
+ // Wrong AlgorithmIdentifier
+ shouldReject('crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, "HMAC", "AES-CBC", extractable, ["encrypt", "decrypt"])');
+ shouldReject('crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, aesCbcParams, "AES-CBC", extractable, ["encrypt", "decrypt"])');
+ // Wrong format
+ return shouldReject('crypto.subtle.unwrapKey("jwk", wrappedRawKey, unwrappingKey, "AES-KW", "AES-CBC", extractable, ["encrypt", "decrypt"])');
+}).then(function() {
+ // Empty usages
+ return shouldReject('crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, "AES-KW", "AES-CBC", extractable, [ ])');
+}).then(function() {
+ return crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["wrapKey", "unwrapKey"]);
+}).then(function(result) {
+ unwrappingKey = result;
+
+ // Empty usages
+ return shouldReject('crypto.subtle.unwrapKey("jwk", wrappedJwkKey, unwrappingKey, aesCbcParams, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, [ ])');
+}).then(function() {
+ return crypto.subtle.importKey("raw", rawKey, "aes-kw", extractable, ["wrapKey"]);
+}).then(function(result) {
+ unwrappingKey = result;
+
+ // Wrong usage
+ shouldReject('crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, "AES-KW", "AES-CBC", extractable, ["encrypt", "decrypt"])').then(finishJSTest);
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleunwrapKeymalformedparametersexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/crypto/subtle/unwrapKey-malformed-parameters-expected.txt (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/unwrapKey-malformed-parameters-expected.txt        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/LayoutTests/crypto/subtle/unwrapKey-malformed-parameters-expected.txt        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -1,22 +0,0 @@
</span><del>-Test UnwrapKey operation with malformed parameters
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS crypto.subtle.unwrapKey() rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.unwrapKey(1) rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.unwrapKey(1, 2) rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.unwrapKey(1, 2, 3) rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.unwrapKey(1, 2, 3, 4) rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.unwrapKey(1, 2, 3, 4, 5) rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.unwrapKey(1, 2, 3, 4, 5, 6) rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, "HMAC", "AES-CBC", extractable, ["encrypt", "decrypt"]) rejected promise with NotSupportedError (DOM Exception 9): The operation is not supported..
-PASS crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, aesCbcParams, "AES-CBC", extractable, ["encrypt", "decrypt"]) rejected promise with InvalidAccessError (DOM Exception 15): Unwrapping CryptoKey doesn't match unwrap AlgorithmIdentifier.
-PASS crypto.subtle.unwrapKey("jwk", wrappedRawKey, unwrappingKey, "AES-KW", "AES-CBC", extractable, ["encrypt", "decrypt"]) rejected promise with DataError (DOM Exception 30): WrappedKey cannot be converted to a JSON object.
-PASS crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, "AES-KW", "AES-CBC", extractable, [ ]) rejected promise with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
-PASS crypto.subtle.unwrapKey("jwk", wrappedJwkKey, unwrappingKey, aesCbcParams, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, [ ]) rejected promise with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
-PASS crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, "AES-KW", "AES-CBC", extractable, ["encrypt", "decrypt"]) rejected promise with InvalidAccessError (DOM Exception 15): Unwrapping CryptoKey doesn't support unwrapKey operation.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
</del></span></pre></div>
<a id="trunkLayoutTestscryptosubtleunwrapKeymalformedparametershtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/crypto/subtle/unwrapKey-malformed-parameters.html (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/unwrapKey-malformed-parameters.html        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/LayoutTests/crypto/subtle/unwrapKey-malformed-parameters.html        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -1,65 +0,0 @@
</span><del>-<!DOCTYPE html>
-<html>
-<head>
-<script src="../../resources/js-test-pre.js"></script>
-<script src="../resources/common.js"></script>
-</head>
-<body>
-<p id="description"></p>
-<div id="console"></div>
-
-<script>
-description("Test UnwrapKey operation with malformed parameters");
-
-jsTestIsAsync = true;
-
-var extractable = true;
-var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
-var aesCbcParams = {
- name: "aes-cbc",
- iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
-}
-var wrappedRawKey = hexStringToUint8Array("d64787ab3e048dbdc30bb62781c9f18e58ad7dbfc64aab16");
-var wrappedJwkKey = hexStringToUint8Array( "848aa2f70ee18e2953520132a79cf479b03a8732a3cc73f8c51c68456d3c2557e8be9d5911b2a74267e282a87ffeed88dfbac38a22c26ba621f83915d7539420a4dc0b2329c585b442967367c1ea6c1126f98c4f13b7c8cb7402b86a5844c19420ea333dc33d908be89172f8bac59b403fe202f32c8eed19f431cedfc3383f536f3557163b1311ae42ee5486c6dafee968640d6b6999c687f37fba8d65cc662f1c84f16245665e4af41c98e8b63632cc1d19e2bece2154c7eab1905f3f6ab17b495cefec3508e9b451f2ea1422b97f275dfdc118f46af02040250d0e55d8d8d172b969bbcf7314a257f10b98d2c47c6c72a727acaf4c96340d590ebcebc61f73b7a868b490f3c1e17c59ea479a3b8db5574153de46cfdbb07cfc5e95ebcf7ad3d5fa057ba946d6da872c4bef3af6d7013e222c227650d0022c94d306cb14e203aad378d171c7c24f824c31b81fd18265e0de2f4b415584ebc4adeb5880c4eddbc88b854699f7aa74d6a10ca5df8978f27b5d1372b31ea67a9c4841ae101ea6ad78df0580b70358e6933ac92f7faee5320af329d8349a7b98690708a388737604be0affaa0669410d8d93dc4e4f57e14583253f11e5b27c89b84f1f3038bae6d9b37e3eb64b63ad1880627aef3b19e3e851cfae639ec4
6dd06fd131b51f530b37260b836d9013d8ad7c8640096070f96984c528ee5e20b69f3cd98a269621cd886ccb16d9c526a87cd5c458541309bb7fa4f3337305d76fc050d39ca8b1fdb0675a11a40ffde9cebb33ddc485e5dc5e7667b08c2a3e0136d063a447aee5a8f650429c5e422a706c4c240a4d11f4a9b5782f2cba2575f0c32cb477a9f0cef97fa993977104181315ff90e46f3b12b8b00f4a7611c42b1bb53d0e6021ab21ee8ae606d9f06dfedb891763007e020977c28b46d5f33bc35c12061d90ebbe02cab58783c0cac0c6f14ed735204f23d0eb6a9fe9edea2aecb1ac213f58b42d5d96374ec70ca288a31016ba02adef43250d717e9fab8982a1a180b1f3944d450c159010fd23f354d88502ec702882ae3edd567c6a6edf3cb2e34edc13f410a25d97298ab9062ddb566576fa8b6599bba205bab55aa5f3f37edaf7733cf249e69c74da975ef249ca673da749d86babebdf55410a389720ac943f1e9d921f5d69c5789636cb904fb9263744236eade9acae889a01c237ab3436101463dfa9d92f936c1b652c80f3abba76023ebe5b9bfdd54735e3a3494de18a456967f58758e546021feef3fa3e6c239981aa06f1f7ddc415d957ff9919bbec5f36af092a81ba6c14fe644d2ee98a2fcdee2ed70b87a53ffa327b25b4569c5886b15f2bd583d6f5bd7e951a915142b
aa08c6a9c343c200678a005fad22a337d2c5627f8c816db2525a7e121849b9da756eee68a240452849ffdb9651f998257c62e8fdcdc48dadfc3ebb18f7eb5461442008846a629ec8149c052f357bf5889095047b272bce0ff505953e7cd525b24c838ba6e9ed91922a30eeb858de8556f19f761d0287d768876346a5dcac3dbadd7a30072c9338162be5812166d961f4031f962ef668781d39d0fc69fe5f4494e31ec082d4a0140e368b69975beeba120ef9b651ead531b4d44296bd3cfe2ce7f97bb5bb4921061b12c2e1c4c10928c0980ff8d488a2282d0c056a40260167410e39664f75ff1f1249820e174eed978318a05e654b8aa6c60b70001a7a04f0aff17597dd9ab3ccc34f5ba2e352b7244dd3dccb462d7175b95ae3970ec5858e2312aac7c2c79a37b53d089f988720a4c04df6328a384004d0d51eafb9486623099a98e69be5169201c88824acc2bb0e1790889014a1797c168e98d19f0787c2935cfbc3bf24c4adad69a81e0e6adf8c21e3c4789064aa31a025dff5cc6eaba3f3e43f10a9d531f47963372120e2366b84c281ed968d9d11c1d103826c9362741e1267d1a3e8d2188761fa876b7b09617df14130c07209f1f1188ff40971b86607dee14d556a880447901c69d29cb16c027c3aae316ff00132bdfcd0e39c5e201252c9771483ccb275b0c67b3cb4dcd
19198c7718634460254dfd6f8df4374b8bedee7dd20ce411b5f987cac2ce17492aa78f919c6d5e555000f47f7b8a9896d448bc4fc13e40a9e5c02258d509a7289f44d7250e89260233bf96702bb3d350451f03d802e0e37d9f01cce4c78869403493eb9890c2c09109d1f427f59cf091cd1c836e25a9bb065041407c2183f643bce2e72db1e7caeac42e2d8379f8b84df2cc7b1d055f42d6f62e0cb5771a14ae8872792350e5f770115a86564f60a785c53325c8c084afe214da3cac1783e2be9099d96ddbe9cc3ea3dd1d3ae50526b4afe24397420a3e4fa697613421");
-
-// Not enough arguments.
-shouldReject('crypto.subtle.unwrapKey()');
-shouldReject('crypto.subtle.unwrapKey(1)');
-shouldReject('crypto.subtle.unwrapKey(1, 2)');
-shouldReject('crypto.subtle.unwrapKey(1, 2, 3)');
-shouldReject('crypto.subtle.unwrapKey(1, 2, 3, 4)');
-shouldReject('crypto.subtle.unwrapKey(1, 2, 3, 4, 5)');
-shouldReject('crypto.subtle.unwrapKey(1, 2, 3, 4, 5, 6)');
-
-crypto.subtle.importKey("raw", rawKey, "aes-kw", extractable, ["wrapKey", "unwrapKey"]).then(function(result) {
- unwrappingKey = result;
-
- // Wrong AlgorithmIdentifier
- shouldReject('crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, "HMAC", "AES-CBC", extractable, ["encrypt", "decrypt"])');
- shouldReject('crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, aesCbcParams, "AES-CBC", extractable, ["encrypt", "decrypt"])');
- // Wrong format
- return shouldReject('crypto.subtle.unwrapKey("jwk", wrappedRawKey, unwrappingKey, "AES-KW", "AES-CBC", extractable, ["encrypt", "decrypt"])');
-}).then(function() {
- // Empty usages
- return shouldReject('crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, "AES-KW", "AES-CBC", extractable, [ ])');
-}).then(function() {
- return crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["wrapKey", "unwrapKey"]);
-}).then(function(result) {
- unwrappingKey = result;
-
- // Empty usages
- return shouldReject('crypto.subtle.unwrapKey("jwk", wrappedJwkKey, unwrappingKey, aesCbcParams, {name: "RSA-OAEP", hash: "SHA-1"}, extractable, [ ])');
-}).then(function() {
- return crypto.subtle.importKey("raw", rawKey, "aes-kw", extractable, ["wrapKey"]);
-}).then(function(result) {
- unwrappingKey = result;
-
- // Wrong usage
- shouldReject('crypto.subtle.unwrapKey("raw", wrappedRawKey, unwrappingKey, "AES-KW", "AES-CBC", extractable, ["encrypt", "decrypt"])').then(finishJSTest);
-});
-
-</script>
-
-<script src="../../resources/js-test-post.js"></script>
-</body>
-</html>
</del></span></pre></div>
<a id="trunkLayoutTestscryptosubtlewrapkeymalformedparametersexpectedtxtfromrev213627trunkLayoutTestscryptosubtlewrapKeymalformedparametersexpectedtxt"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/crypto/subtle/wrap-key-malformed-parameters-expected.txt (from rev 213627, trunk/LayoutTests/crypto/subtle/wrapKey-malformed-parameters-expected.txt) (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/wrap-key-malformed-parameters-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/wrap-key-malformed-parameters-expected.txt        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+Test WrapKey operation with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.wrapKey() rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.wrapKey(1) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.wrapKey(1, 2) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.wrapKey(1, 2, 3) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.wrapKey("raw", key, wrappingKey, "HMAC") rejected promise with NotSupportedError (DOM Exception 9): The operation is not supported..
+PASS crypto.subtle.wrapKey("raw", key, wrappingKey, aesCbcParams) rejected promise with InvalidAccessError (DOM Exception 15): Wrapping CryptoKey doesn't match AlgorithmIdentifier.
+PASS crypto.subtle.wrapKey("raw", key, wrappingKey, "AES-KW") rejected promise with InvalidAccessError (DOM Exception 15): The CryptoKey is nonextractable.
+PASS crypto.subtle.wrapKey("raw", key, wrappingKey, "AES-KW") rejected promise with InvalidAccessError (DOM Exception 15): Wrapping CryptoKey doesn't support wrapKey operation.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlewrapkeymalformedparametershtmlfromrev213627trunkLayoutTestscryptosubtlewrapKeymalformedparametershtml"></a>
<div class="copfile"><h4>Copied: trunk/LayoutTests/crypto/subtle/wrap-key-malformed-parameters.html (from rev 213627, trunk/LayoutTests/crypto/subtle/wrapKey-malformed-parameters.html) (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/wrap-key-malformed-parameters.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/wrap-key-malformed-parameters.html        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+description("Test WrapKey operation with malformed parameters");
+
+jsTestIsAsync = true;
+
+var extractable = true;
+var nonExtractable = false;
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var aesCbcParams = {
+ name: "aes-cbc",
+ iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
+}
+
+// Not enough arguments.
+shouldReject('crypto.subtle.wrapKey()');
+shouldReject('crypto.subtle.wrapKey(1)');
+shouldReject('crypto.subtle.wrapKey(1, 2)');
+shouldReject('crypto.subtle.wrapKey(1, 2, 3)');
+
+crypto.subtle.importKey("raw", rawKey, "aes-kw", extractable, ["wrapKey", "unwrapKey"]).then(function(result) {
+ wrappingKey = result;
+ return crypto.subtle.importKey("raw", rawKey, "aes-cbc", nonExtractable, ["encrypt", "decrypt"]);
+}).then(function(result) {
+ key = result;
+
+ // Wrong AlgorithmIdentifier
+ shouldReject('crypto.subtle.wrapKey("raw", key, wrappingKey, "HMAC")');
+ shouldReject('crypto.subtle.wrapKey("raw", key, wrappingKey, aesCbcParams)');
+ // Non-extractable
+ shouldReject('crypto.subtle.wrapKey("raw", key, wrappingKey, "AES-KW")');
+
+ return crypto.subtle.importKey("raw", rawKey, "aes-kw", extractable, ["unwrapKey"]);
+}).then(function(result) {
+ wrappingKey = result;
+
+ // Wrong usage
+ shouldReject('crypto.subtle.wrapKey("raw", key, wrappingKey, "AES-KW")').then(finishJSTest);
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlewrapKeymalformedparametersexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/crypto/subtle/wrapKey-malformed-parameters-expected.txt (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/wrapKey-malformed-parameters-expected.txt        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/LayoutTests/crypto/subtle/wrapKey-malformed-parameters-expected.txt        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -1,17 +0,0 @@
</span><del>-Test WrapKey operation with malformed parameters
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS crypto.subtle.wrapKey() rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.wrapKey(1) rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.wrapKey(1, 2) rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.wrapKey(1, 2, 3) rejected promise with TypeError: Not enough arguments.
-PASS crypto.subtle.wrapKey("raw", key, wrappingKey, "HMAC") rejected promise with NotSupportedError (DOM Exception 9): The operation is not supported..
-PASS crypto.subtle.wrapKey("raw", key, wrappingKey, aesCbcParams) rejected promise with InvalidAccessError (DOM Exception 15): Wrapping CryptoKey doesn't match AlgorithmIdentifier.
-PASS crypto.subtle.wrapKey("raw", key, wrappingKey, "AES-KW") rejected promise with InvalidAccessError (DOM Exception 15): The CryptoKey is nonextractable.
-PASS crypto.subtle.wrapKey("raw", key, wrappingKey, "AES-KW") rejected promise with InvalidAccessError (DOM Exception 15): Wrapping CryptoKey doesn't support wrapKey operation.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
</del></span></pre></div>
<a id="trunkLayoutTestscryptosubtlewrapKeymalformedparametershtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/crypto/subtle/wrapKey-malformed-parameters.html (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/wrapKey-malformed-parameters.html        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/LayoutTests/crypto/subtle/wrapKey-malformed-parameters.html        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -1,54 +0,0 @@
</span><del>-<!DOCTYPE html>
-<html>
-<head>
-<script src="../../resources/js-test-pre.js"></script>
-<script src="../resources/common.js"></script>
-</head>
-<body>
-<p id="description"></p>
-<div id="console"></div>
-
-<script>
-description("Test WrapKey operation with malformed parameters");
-
-jsTestIsAsync = true;
-
-var extractable = true;
-var nonExtractable = false;
-var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
-var aesCbcParams = {
- name: "aes-cbc",
- iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
-}
-
-// Not enough arguments.
-shouldReject('crypto.subtle.wrapKey()');
-shouldReject('crypto.subtle.wrapKey(1)');
-shouldReject('crypto.subtle.wrapKey(1, 2)');
-shouldReject('crypto.subtle.wrapKey(1, 2, 3)');
-
-crypto.subtle.importKey("raw", rawKey, "aes-kw", extractable, ["wrapKey", "unwrapKey"]).then(function(result) {
- wrappingKey = result;
- return crypto.subtle.importKey("raw", rawKey, "aes-cbc", nonExtractable, ["encrypt", "decrypt"]);
-}).then(function(result) {
- key = result;
-
- // Wrong AlgorithmIdentifier
- shouldReject('crypto.subtle.wrapKey("raw", key, wrappingKey, "HMAC")');
- shouldReject('crypto.subtle.wrapKey("raw", key, wrappingKey, aesCbcParams)');
- // Non-extractable
- shouldReject('crypto.subtle.wrapKey("raw", key, wrappingKey, "AES-KW")');
-
- return crypto.subtle.importKey("raw", rawKey, "aes-kw", extractable, ["unwrapKey"]);
-}).then(function(result) {
- wrappingKey = result;
-
- // Wrong usage
- shouldReject('crypto.subtle.wrapKey("raw", key, wrappingKey, "AES-KW")').then(finishJSTest);
-});
-
-</script>
-
-<script src="../../resources/js-test-post.js"></script>
-</body>
-</html>
</del></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleecdhimportkeyderivekeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/ecdh-import-key-derive-key-expected.txt (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/ecdh-import-key-derive-key-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/ecdh-import-key-derive-key-expected.txt        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+[Worker] Test deriving AES Keys with imported ECDH base key in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/ecdh-import-key-derive-key.js
+PASS [Worker] derivedKey.type is 'secret'
+PASS [Worker] derivedKey.extractable is true
+PASS [Worker] derivedKey.algorithm.name is 'AES-CBC'
+PASS [Worker] derivedKey.algorithm.length is 128
+PASS [Worker] derivedKey.usages is ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleecdhimportkeyderivekeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/ecdh-import-key-derive-key.html (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/ecdh-import-key-derive-key.html         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/ecdh-import-key-derive-key.html        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+ <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/ecdh-import-key-derive-key.js');
+ </script>
+ <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesecdhimportkeyderivekeyjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/ecdh-import-key-derive-key.js (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/ecdh-import-key-derive-key.js         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/ecdh-import-key-derive-key.js        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts("../../../resources/common.js");
+
+description("Test deriving AES Keys with imported ECDH base key in workers");
+
+jsTestIsAsync = true;
+
+var extractable = true;
+var jwkPrivateKey = {
+ kty: "EC",
+ crv: "P-256",
+ x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA",
+ y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI",
+ d: "ppxBSov3N8_AUcisAuvmLV4yE8e_L_BLE8bZb9Z1Xjg",
+};
+var jwkPublicKey = {
+ kty: "EC",
+ crv: "P-256",
+ x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA",
+ y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI",
+};
+
+crypto.subtle.importKey("jwk", jwkPrivateKey, { name: "ECDH", namedCurve: "P-256" }, extractable, ["deriveKey"]).then(function(result) {
+ privateKey = result;
+ return crypto.subtle.importKey("jwk", jwkPublicKey, { name: "ECDH", namedCurve: "P-256" }, extractable, [ ]);
+}).then(function(result) {
+ publicKey = result;
+ return crypto.subtle.deriveKey({ name:"ECDH", public:publicKey }, privateKey, {name: "aes-cbc", length: 128}, extractable, ['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']);
+}).then(function(result) {
+ derivedKey = result;
+
+ shouldBe("derivedKey.type", "'secret'");
+ shouldBe("derivedKey.extractable", "true");
+ shouldBe("derivedKey.algorithm.name", "'AES-CBC'");
+ shouldBe("derivedKey.algorithm.length", "128");
+ shouldBe("derivedKey.usages", "['decrypt', 'encrypt', 'unwrapKey', 'wrapKey']");
+
+ finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/CMakeLists.txt        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -342,7 +342,7 @@
</span><span class="cx">
</span><span class="cx"> crypto/parameters/AesCbcCfbParams.idl
</span><span class="cx"> crypto/parameters/AesGcmParams.idl
</span><del>- crypto/parameters/AesKeyGenParams.idl
</del><ins>+ crypto/parameters/AesKeyParams.idl
</ins><span class="cx"> crypto/parameters/EcKeyParams.idl
</span><span class="cx"> crypto/parameters/EcdhKeyDeriveParams.idl
</span><span class="cx"> crypto/parameters/HmacKeyParams.idl
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/ChangeLog        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -1,3 +1,82 @@
</span><ins>+2017-03-08 Jiewen Tan <jiewen_tan@apple.com>
+
+ [WebCrypto] Implement SubtleCrypto::DeriveKey method
+ https://bugs.webkit.org/show_bug.cgi?id=169386
+ <rdar://problem/23789585>
+
+ Reviewed by Brent Fulgham.
+
+ This patch does following few things:
+ 1. It implements SubtleCrypto::DeriveKey method according to the spec:
+ https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-deriveKey.
+ 2. It implements getKeyLength operations for AES-CBC, AES-KW, AES-CFB,
+ AES-GCM, and HMAC, which is needed by the SubtleCrypto::DeriveKey method.
+ 3. It enables ECDH DeriveKey operation.
+ 4. It replaces unigned long with size_t in all the crypto codes.
+
+ Tests: crypto/subtle/derive-key-malformed-parameters.html
+ crypto/subtle/ecdh-import-key-derive-aes-key.html
+ crypto/subtle/ecdh-import-key-derive-hmac-key-custom-length.html
+ crypto/subtle/unwrap-key-malformed-parameters.html
+ crypto/subtle/wrap-key-malformed-parameters.html
+ crypto/workers/subtle/ecdh-import-key-derive-key.html
+
+ * CMakeLists.txt:
+ * DerivedSources.make:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSSubtleCryptoCustom.cpp:
+ (WebCore::normalizeCryptoAlgorithmParameters):
+ (WebCore::jsSubtleCryptoFunctionEncryptPromise):
+ (WebCore::jsSubtleCryptoFunctionDecryptPromise):
+ (WebCore::jsSubtleCryptoFunctionSignPromise):
+ (WebCore::jsSubtleCryptoFunctionVerifyPromise):
+ (WebCore::jsSubtleCryptoFunctionDigestPromise):
+ (WebCore::jsSubtleCryptoFunctionDeriveKeyPromise):
+ (WebCore::jsSubtleCryptoFunctionDeriveBitsPromise):
+ Remove unnecessary return statement from callbacks.
+ * crypto/CryptoAlgorithm.cpp:
+ (WebCore::CryptoAlgorithm::deriveBits):
+ (WebCore::CryptoAlgorithm::getKeyLength):
+ * crypto/CryptoAlgorithm.h:
+ * crypto/CryptoAlgorithmParameters.h:
+ * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
+ (WebCore::CryptoAlgorithmAES_CBC::generateKey):
+ (WebCore::CryptoAlgorithmAES_CBC::getKeyLength):
+ * crypto/algorithms/CryptoAlgorithmAES_CBC.h:
+ * crypto/algorithms/CryptoAlgorithmAES_CFB.cpp:
+ (WebCore::CryptoAlgorithmAES_CFB::generateKey):
+ (WebCore::CryptoAlgorithmAES_CFB::getKeyLength):
+ * crypto/algorithms/CryptoAlgorithmAES_CFB.h:
+ * crypto/algorithms/CryptoAlgorithmAES_GCM.cpp:
+ (WebCore::CryptoAlgorithmAES_GCM::generateKey):
+ (WebCore::CryptoAlgorithmAES_GCM::getKeyLength):
+ * crypto/algorithms/CryptoAlgorithmAES_GCM.h:
+ * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
+ (WebCore::CryptoAlgorithmAES_KW::generateKey):
+ (WebCore::CryptoAlgorithmAES_KW::getKeyLength):
+ * crypto/algorithms/CryptoAlgorithmAES_KW.h:
+ * crypto/algorithms/CryptoAlgorithmECDH.cpp:
+ (WebCore::CryptoAlgorithmECDH::deriveBits):
+ * crypto/algorithms/CryptoAlgorithmECDH.h:
+ * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
+ (WebCore::CryptoAlgorithmHMAC::getKeyLength):
+ * crypto/algorithms/CryptoAlgorithmHMAC.h:
+ * crypto/keys/CryptoKeyAES.cpp:
+ (WebCore::CryptoKeyAES::getKeyLength):
+ * crypto/keys/CryptoKeyAES.h:
+ * crypto/keys/CryptoKeyHMAC.cpp:
+ (WebCore::getKeyLengthFromHash):
+ (WebCore::CryptoKeyHMAC::generate):
+ (WebCore::CryptoKeyHMAC::getKeyLength):
+ * crypto/keys/CryptoKeyHMAC.h:
+ * crypto/mac/CryptoAlgorithmECDHMac.cpp:
+ (WebCore::CryptoAlgorithmECDH::platformDeriveBits):
+ * crypto/parameters/AesKeyParams.idl: Renamed from Source/WebCore/crypto/parameters/AesKeyGenParams.idl.
+ * crypto/parameters/CryptoAlgorithmAesKeyParams.h: Renamed from Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h.
+ Rename AesKeyGenParams to AesKeyParams to represent a unified dictionary for AesKeyGenParams and AesDerivedKeyParams.
+ * crypto/parameters/CryptoAlgorithmHmacKeyParams.h:
+ * crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h:
+
</ins><span class="cx"> 2017-03-08 Wenson Hsieh <wenson_hsieh@apple.com>
</span><span class="cx">
</span><span class="cx"> Add plumbing for WebCore to notify WebKit2 when an edit drag has concluded
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources.make (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources.make        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/DerivedSources.make        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -274,7 +274,7 @@
</span><span class="cx"> $(WebCore)/crypto/WebKitSubtleCrypto.idl \
</span><span class="cx"> $(WebCore)/crypto/parameters/AesCbcCfbParams.idl \
</span><span class="cx"> $(WebCore)/crypto/parameters/AesGcmParams.idl \
</span><del>- $(WebCore)/crypto/parameters/AesKeyGenParams.idl \
</del><ins>+ $(WebCore)/crypto/parameters/AesKeyParams.idl \
</ins><span class="cx"> $(WebCore)/crypto/parameters/EcKeyParams.idl \
</span><span class="cx"> $(WebCore)/crypto/parameters/EcdhKeyDeriveParams.idl \
</span><span class="cx"> $(WebCore)/crypto/parameters/HmacKeyParams.idl \
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -2382,11 +2382,11 @@
</span><span class="cx">                 576814351E6FE3E800E77754 /* CryptoAlgorithmECDHMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 576814341E6FE3E800E77754 /* CryptoAlgorithmECDHMac.cpp */; };
</span><span class="cx">                 576814401E709FA100E77754 /* JSEcdhKeyDeriveParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5768143D1E709C3600E77754 /* JSEcdhKeyDeriveParams.cpp */; };
</span><span class="cx">                 576814411E709FA400E77754 /* JSEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5768143E1E709C3600E77754 /* JSEcdhKeyDeriveParams.h */; };
</span><ins>+                576814441E70CB1B00E77754 /* JSAesKeyParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 576814421E70CB1000E77754 /* JSAesKeyParams.cpp */; };
+                576814451E70CB1F00E77754 /* JSAesKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814431E70CB1000E77754 /* JSAesKeyParams.h */; };
</ins><span class="cx">                 5768E4341DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5768E4331DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h */; };
</span><span class="cx">                 5768E4361DB7527400D0A4F7 /* JSRsaHashedKeyGenParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5768E4351DB7527300D0A4F7 /* JSRsaHashedKeyGenParams.cpp */; };
</span><del>-                577483121DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h */; };
-                577483141DAEC2EB00716EF9 /* JSAesKeyGenParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 577483131DAEC2EA00716EF9 /* JSAesKeyGenParams.h */; };
-                577483161DAEC32300716EF9 /* JSAesKeyGenParams.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 577483151DAEC32200716EF9 /* JSAesKeyGenParams.cpp */; };
</del><ins>+                577483121DADC55D00716EF9 /* CryptoAlgorithmAesKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyParams.h */; };
</ins><span class="cx">                 577483191DB4491F00716EF9 /* CryptoAlgorithmHmacKeyParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 577483181DB4491F00716EF9 /* CryptoAlgorithmHmacKeyParams.h */; };
</span><span class="cx">                 5778BD821DA4806C009E3009 /* SubtleCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 5778BD811DA4802C009E3009 /* SubtleCrypto.h */; };
</span><span class="cx">                 5778BD841DA4817B009E3009 /* SubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5778BD831DA4817B009E3009 /* SubtleCrypto.cpp */; };
</span><span class="lines">@@ -9816,12 +9816,12 @@
</span><span class="cx">                 576814341E6FE3E800E77754 /* CryptoAlgorithmECDHMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmECDHMac.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 5768143D1E709C3600E77754 /* JSEcdhKeyDeriveParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSEcdhKeyDeriveParams.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 5768143E1E709C3600E77754 /* JSEcdhKeyDeriveParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEcdhKeyDeriveParams.h; sourceTree = "<group>"; };
</span><ins>+                576814421E70CB1000E77754 /* JSAesKeyParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAesKeyParams.cpp; sourceTree = "<group>"; };
+                576814431E70CB1000E77754 /* JSAesKeyParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAesKeyParams.h; sourceTree = "<group>"; };
</ins><span class="cx">                 5768E4331DB7524500D0A4F7 /* JSRsaHashedKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRsaHashedKeyGenParams.h; sourceTree = "<group>"; };
</span><span class="cx">                 5768E4351DB7527300D0A4F7 /* JSRsaHashedKeyGenParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRsaHashedKeyGenParams.cpp; sourceTree = "<group>"; };
</span><del>-                577483101DADC49900716EF9 /* AesKeyGenParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AesKeyGenParams.idl; sourceTree = "<group>"; };
-                577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesKeyGenParams.h; sourceTree = "<group>"; };
-                577483131DAEC2EA00716EF9 /* JSAesKeyGenParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAesKeyGenParams.h; sourceTree = "<group>"; };
-                577483151DAEC32200716EF9 /* JSAesKeyGenParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAesKeyGenParams.cpp; sourceTree = "<group>"; };
</del><ins>+                577483101DADC49900716EF9 /* AesKeyParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AesKeyParams.idl; sourceTree = "<group>"; };
+                577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmAesKeyParams.h; sourceTree = "<group>"; };
</ins><span class="cx">                 577483171DB1FE8900716EF9 /* HmacKeyParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = HmacKeyParams.idl; sourceTree = "<group>"; };
</span><span class="cx">                 577483181DB4491F00716EF9 /* CryptoAlgorithmHmacKeyParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmHmacKeyParams.h; sourceTree = "<group>"; };
</span><span class="cx">                 5778BD801DA4733E009E3009 /* SubtleCrypto.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SubtleCrypto.idl; sourceTree = "<group>"; };
</span><span class="lines">@@ -10001,8 +10001,8 @@
</span><span class="cx">                 5DB1BC6810715A6400EFAA49 /* TransformSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransformSource.h; sourceTree = "<group>"; };
</span><span class="cx">                 5DB1BC6910715A6400EFAA49 /* TransformSourceLibxslt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransformSourceLibxslt.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 5DFEBAB618592B6D00C75BEB /* WebKitAvailability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitAvailability.h; sourceTree = "<group>"; };
</span><del>-                5E16A2E21BFA64FB0029A21E /* MediaEndpointPeerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = MediaEndpointPeerConnection.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
-                5E16A2E31BFA64FB0029A21E /* MediaEndpointPeerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MediaEndpointPeerConnection.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
</del><ins>+                5E16A2E21BFA64FB0029A21E /* MediaEndpointPeerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaEndpointPeerConnection.cpp; sourceTree = "<group>"; };
+                5E16A2E31BFA64FB0029A21E /* MediaEndpointPeerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaEndpointPeerConnection.h; sourceTree = "<group>"; };
</ins><span class="cx">                 5E2C434D1BCEE2E50001E2BC /* PeerConnectionBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PeerConnectionBackend.h; sourceTree = "<group>"; };
</span><span class="cx">                 5E2C43541BCEE30D0001E2BC /* RTCPeerConnection.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = RTCPeerConnection.js; sourceTree = "<group>"; };
</span><span class="cx">                 5E2C43551BCEE30D0001E2BC /* RTCPeerConnectionInternals.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = RTCPeerConnectionInternals.js; sourceTree = "<group>"; };
</span><span class="lines">@@ -23682,11 +23682,11 @@
</span><span class="cx">                         children = (
</span><span class="cx">                                 572093D11DDCEA4B00310AB0 /* AesCbcCfbParams.idl */,
</span><span class="cx">                                 57B5F8071E5D19F200F34F90 /* AesGcmParams.idl */,
</span><del>-                                577483101DADC49900716EF9 /* AesKeyGenParams.idl */,
</del><ins>+                                577483101DADC49900716EF9 /* AesKeyParams.idl */,
</ins><span class="cx">                                 572093D21DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcCfbParams.h */,
</span><span class="cx">                                 E125F8391824104800D84CD9 /* CryptoAlgorithmAesCbcParamsDeprecated.h */,
</span><span class="cx">                                 57B5F8081E5D1A9800F34F90 /* CryptoAlgorithmAesGcmParams.h */,
</span><del>-                                577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h */,
</del><ins>+                                577483111DADC55D00716EF9 /* CryptoAlgorithmAesKeyParams.h */,
</ins><span class="cx">                                 E19AC3F61824E5D100349426 /* CryptoAlgorithmAesKeyGenParamsDeprecated.h */,
</span><span class="cx">                                 5750A97D1E6A13EF00705C4A /* CryptoAlgorithmEcKeyParams.h */,
</span><span class="cx">                                 576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */,
</span><span class="lines">@@ -23867,8 +23867,8 @@
</span><span class="cx">                                 570440591E53936200356601 /* JSAesCbcCfbParams.h */,
</span><span class="cx">                                 57B5F80A1E5D22DA00F34F90 /* JSAesGcmParams.cpp */,
</span><span class="cx">                                 57B5F80B1E5D22DA00F34F90 /* JSAesGcmParams.h */,
</span><del>-                                577483151DAEC32200716EF9 /* JSAesKeyGenParams.cpp */,
-                                577483131DAEC2EA00716EF9 /* JSAesKeyGenParams.h */,
</del><ins>+                                576814421E70CB1000E77754 /* JSAesKeyParams.cpp */,
+                                576814431E70CB1000E77754 /* JSAesKeyParams.h */,
</ins><span class="cx">                                 5739E1301DAC7FD100E14383 /* JSCryptoAlgorithmParameters.cpp */,
</span><span class="cx">                                 5739E12E1DAC7F7800E14383 /* JSCryptoAlgorithmParameters.h */,
</span><span class="cx">                                 E157A8DE1817331C009F821D /* JSCryptoKey.cpp */,
</span><span class="lines">@@ -25882,7 +25882,7 @@
</span><span class="cx">                                 E1FE137B184D21BB00892F13 /* CryptoAlgorithmAES_KW.h in Headers */,
</span><span class="cx">                                 572093D31DDCEB9A00310AB0 /* CryptoAlgorithmAesCbcCfbParams.h in Headers */,
</span><span class="cx">                                 E125F83A1824104800D84CD9 /* CryptoAlgorithmAesCbcParamsDeprecated.h in Headers */,
</span><del>-                                577483121DADC55D00716EF9 /* CryptoAlgorithmAesKeyGenParams.h in Headers */,
</del><ins>+                                577483121DADC55D00716EF9 /* CryptoAlgorithmAesKeyParams.h in Headers */,
</ins><span class="cx">                                 E19AC3F71824E5D100349426 /* CryptoAlgorithmAesKeyGenParamsDeprecated.h in Headers */,
</span><span class="cx">                                 E125F8321822F11B00D84CD9 /* CryptoAlgorithmHMAC.h in Headers */,
</span><span class="cx">                                 577483191DB4491F00716EF9 /* CryptoAlgorithmHmacKeyParams.h in Headers */,
</span><span class="lines">@@ -26737,7 +26737,6 @@
</span><span class="cx">                                 44EFF6431A6FF92700D45EEC /* IOTypesSPI.h in Headers */,
</span><span class="cx">                                 07AC47021952102100EE9723 /* ISOVTTCue.h in Headers */,
</span><span class="cx">                                 418F88050FF957AF0080F045 /* JSAbstractWorker.h in Headers */,
</span><del>-                                577483141DAEC2EB00716EF9 /* JSAesKeyGenParams.h in Headers */,
</del><span class="cx">                                 FDA15ECA12B03F50003A583A /* JSAnalyserNode.h in Headers */,
</span><span class="cx">                                 12A253E31C8FFF6600C22295 /* JSAnimatable.h in Headers */,
</span><span class="cx">                                 120DE3FD1C87E18400B6D4DD /* JSAnimationEffect.h in Headers */,
</span><span class="lines">@@ -26749,6 +26748,7 @@
</span><span class="cx">                                 7C6523161E00DBB500677F22 /* JSApplePayPaymentContact.h in Headers */,
</span><span class="cx">                                 7C6523181E00DBB500677F22 /* JSApplePayPaymentMethod.h in Headers */,
</span><span class="cx">                                 1AE96A8D1D1A0DDD00B86768 /* JSApplePayPaymentMethodSelectedEvent.h in Headers */,
</span><ins>+                                576814451E70CB1F00E77754 /* JSAesKeyParams.h in Headers */,
</ins><span class="cx">                                 7C65231A1E00DBB500677F22 /* JSApplePayPaymentPass.h in Headers */,
</span><span class="cx">                                 7C6579F21E00856600E3A27A /* JSApplePayPaymentRequest.h in Headers */,
</span><span class="cx">                                 1AE96A8F1D1A0DDD00B86768 /* JSApplePaySession.h in Headers */,
</span><span class="lines">@@ -30584,7 +30584,6 @@
</span><span class="cx">                                 AD9FF6E11908391D003B61E0 /* IOSurfacePoolCocoa.mm in Sources */,
</span><span class="cx">                                 07AC47011952102100EE9723 /* ISOVTTCue.cpp in Sources */,
</span><span class="cx">                                 418F88040FF957AE0080F045 /* JSAbstractWorker.cpp in Sources */,
</span><del>-                                577483161DAEC32300716EF9 /* JSAesKeyGenParams.cpp in Sources */,
</del><span class="cx">                                 FDA15EC912B03F50003A583A /* JSAnalyserNode.cpp in Sources */,
</span><span class="cx">                                 31A795C61888BADC00382F90 /* JSANGLEInstancedArrays.cpp in Sources */,
</span><span class="cx">                                 12A253E21C8FFF6600C22295 /* JSAnimatable.cpp in Sources */,
</span><span class="lines">@@ -30847,6 +30846,7 @@
</span><span class="cx">                                 A80E7E980A1A83E3007FB8C5 /* JSHTMLInputElement.cpp in Sources */,
</span><span class="cx">                                 A6148A7812E41E3B0044A784 /* JSHTMLKeygenElement.cpp in Sources */,
</span><span class="cx">                                 1AE2AB210A1CE63B00B42B25 /* JSHTMLLabelElement.cpp in Sources */,
</span><ins>+                                576814441E70CB1B00E77754 /* JSAesKeyParams.cpp in Sources */,
</ins><span class="cx">                                 1AE2AB230A1CE63B00B42B25 /* JSHTMLLegendElement.cpp in Sources */,
</span><span class="cx">                                 1AE2AB250A1CE63B00B42B25 /* JSHTMLLIElement.cpp in Sources */,
</span><span class="cx">                                 A80E7B100A19D606007FB8C5 /* JSHTMLLinkElement.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx"> #include "CryptoAlgorithmRegistry.h"
</span><span class="cx"> #include "JSAesCbcCfbParams.h"
</span><span class="cx"> #include "JSAesGcmParams.h"
</span><del>-#include "JSAesKeyGenParams.h"
</del><ins>+#include "JSAesKeyParams.h"
</ins><span class="cx"> #include "JSCryptoAlgorithmParameters.h"
</span><span class="cx"> #include "JSCryptoKey.h"
</span><span class="cx"> #include "JSCryptoKeyPair.h"
</span><span class="lines">@@ -61,12 +61,12 @@
</span><span class="cx"> Sign,
</span><span class="cx"> Verify,
</span><span class="cx"> Digest,
</span><del>- DeriveKey,
</del><ins>+ GenerateKey,
</ins><span class="cx"> DeriveBits,
</span><del>- GenerateKey,
</del><span class="cx"> ImportKey,
</span><span class="cx"> WrapKey,
</span><del>- UnwrapKey
</del><ins>+ UnwrapKey,
+ GetKeyLength
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static std::unique_ptr<CryptoAlgorithmParameters> normalizeCryptoAlgorithmParameters(ExecState&, JSValue, Operations);
</span><span class="lines">@@ -160,9 +160,6 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx"> break;
</span><del>- case Operations::DeriveKey:
- throwNotSupportedError(state, scope);
- return nullptr;
</del><span class="cx"> case Operations::DeriveBits:
</span><span class="cx"> switch (*identifier) {
</span><span class="cx"> case CryptoAlgorithmIdentifier::ECDH: {
</span><span class="lines">@@ -207,9 +204,9 @@
</span><span class="cx"> case CryptoAlgorithmIdentifier::AES_GCM:
</span><span class="cx"> case CryptoAlgorithmIdentifier::AES_CFB:
</span><span class="cx"> case CryptoAlgorithmIdentifier::AES_KW: {
</span><del>- auto params = convertDictionary<CryptoAlgorithmAesKeyGenParams>(state, value);
</del><ins>+ auto params = convertDictionary<CryptoAlgorithmAesKeyParams>(state, value);
</ins><span class="cx"> RETURN_IF_EXCEPTION(scope, nullptr);
</span><del>- result = std::make_unique<CryptoAlgorithmAesKeyGenParams>(params);
</del><ins>+ result = std::make_unique<CryptoAlgorithmAesKeyParams>(params);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> case CryptoAlgorithmIdentifier::HMAC: {
</span><span class="lines">@@ -286,6 +283,32 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx"> break;
</span><ins>+ case Operations::GetKeyLength:
+ switch (*identifier) {
+ case CryptoAlgorithmIdentifier::AES_CTR:
+ case CryptoAlgorithmIdentifier::AES_CBC:
+ case CryptoAlgorithmIdentifier::AES_CMAC:
+ case CryptoAlgorithmIdentifier::AES_GCM:
+ case CryptoAlgorithmIdentifier::AES_CFB:
+ case CryptoAlgorithmIdentifier::AES_KW: {
+ auto params = convertDictionary<CryptoAlgorithmAesKeyParams>(state, value);
+ RETURN_IF_EXCEPTION(scope, nullptr);
+ result = std::make_unique<CryptoAlgorithmAesKeyParams>(params);
+ break;
+ }
+ case CryptoAlgorithmIdentifier::HMAC: {
+ auto params = convertDictionary<CryptoAlgorithmHmacKeyParams>(state, value);
+ RETURN_IF_EXCEPTION(scope, nullptr);
+ params.hashIdentifier = toHashIdentifier(state, params.hash);
+ RETURN_IF_EXCEPTION(scope, nullptr);
+ result = std::make_unique<CryptoAlgorithmHmacKeyParams>(params);
+ break;
+ }
+ default:
+ throwNotSupportedError(state, scope);
+ return nullptr;
+ }
+ break;
</ins><span class="cx"> default:
</span><span class="cx"> ASSERT_NOT_REACHED();
</span><span class="cx"> return nullptr;
</span><span class="lines">@@ -487,7 +510,6 @@
</span><span class="cx">
</span><span class="cx"> auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& cipherText) mutable {
</span><span class="cx"> fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), cipherText.data(), cipherText.size());
</span><del>- return;
</del><span class="cx"> };
</span><span class="cx"> auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
</span><span class="cx"> rejectWithException(WTFMove(capturedPromise), ec);
</span><span class="lines">@@ -535,7 +557,6 @@
</span><span class="cx">
</span><span class="cx"> auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& plainText) mutable {
</span><span class="cx"> fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), plainText.data(), plainText.size());
</span><del>- return;
</del><span class="cx"> };
</span><span class="cx"> auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
</span><span class="cx"> rejectWithException(WTFMove(capturedPromise), ec);
</span><span class="lines">@@ -583,7 +604,6 @@
</span><span class="cx">
</span><span class="cx"> auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& signature) mutable {
</span><span class="cx"> fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), signature.data(), signature.size());
</span><del>- return;
</del><span class="cx"> };
</span><span class="cx"> auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
</span><span class="cx"> rejectWithException(WTFMove(capturedPromise), ec);
</span><span class="lines">@@ -634,7 +654,6 @@
</span><span class="cx">
</span><span class="cx"> auto callback = [capturedPromise = promise.copyRef()](bool result) mutable {
</span><span class="cx"> capturedPromise->resolve<IDLBoolean>(result);
</span><del>- return;
</del><span class="cx"> };
</span><span class="cx"> auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
</span><span class="cx"> rejectWithException(WTFMove(capturedPromise), ec);
</span><span class="lines">@@ -669,7 +688,6 @@
</span><span class="cx">
</span><span class="cx"> auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& digest) mutable {
</span><span class="cx"> fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), digest.data(), digest.size());
</span><del>- return;
</del><span class="cx"> };
</span><span class="cx"> auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
</span><span class="cx"> rejectWithException(WTFMove(capturedPromise), ec);
</span><span class="lines">@@ -743,11 +761,81 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(0), Operations::DeriveKey);
</del><ins>+ auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(0), Operations::DeriveBits);
</ins><span class="cx"> RETURN_IF_EXCEPTION(scope, void());
</span><span class="cx">
</span><del>- // We should always return a NOT_SUPPORTED_ERR since we currently don't support any algorithms that has deriveKey operation.
- ASSERT_NOT_REACHED();
</del><ins>+ auto baseKey = toCryptoKey(state, state.uncheckedArgument(1));
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto importParams = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(2), Operations::ImportKey);
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto getLengthParams = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(2), Operations::GetKeyLength);
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto extractable = state.uncheckedArgument(3).toBoolean(&state);
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto keyUsages = cryptoKeyUsageBitmapFromJSValue(state, state.uncheckedArgument(4));
+ RETURN_IF_EXCEPTION(scope, void());
+
+ if (params->identifier != baseKey->algorithmIdentifier()) {
+ promise->reject(INVALID_ACCESS_ERR, ASCIILiteral("CryptoKey doesn't match AlgorithmIdentifier"));
+ return;
+ }
+
+ if (!baseKey->allows(CryptoKeyUsageDeriveKey)) {
+ promise->reject(INVALID_ACCESS_ERR, ASCIILiteral("CryptoKey doesn't support CryptoKey derivation"));
+ return;
+ }
+
+ auto getLengthAlgorithm = CryptoAlgorithmRegistry::singleton().create(getLengthParams->identifier);
+ if (UNLIKELY(!getLengthAlgorithm)) {
+ throwNotSupportedError(state, scope);
+ return;
+ }
+ auto result = getLengthAlgorithm->getKeyLength(*getLengthParams);
+ if (result.hasException()) {
+ promise->reject(result.releaseException().code(), ASCIILiteral("Cannot get key length from derivedKeyType"));
+ return;
+ }
+ size_t length = result.releaseReturnValue();
+
+ auto importAlgorithm = CryptoAlgorithmRegistry::singleton().create(importParams->identifier);
+ if (UNLIKELY(!importAlgorithm)) {
+ throwNotSupportedError(state, scope);
+ return;
+ }
+
+ auto algorithm = CryptoAlgorithmRegistry::singleton().create(params->identifier);
+ if (UNLIKELY(!algorithm)) {
+ throwNotSupportedError(state, scope);
+ return;
+ }
+
+ auto callback = [promise = promise.copyRef(), importAlgorithm, importParams = WTFMove(importParams), extractable, keyUsages](const Vector<uint8_t>& derivedKey) mutable {
+ // FIXME: https://bugs.webkit.org/show_bug.cgi?id=169395
+ KeyData data = derivedKey;
+ auto callback = [capturedPromise = promise.copyRef()](CryptoKey& key) mutable {
+ if ((key.type() == CryptoKeyType::Private || key.type() == CryptoKeyType::Secret) && !key.usagesBitmap()) {
+ rejectWithException(WTFMove(capturedPromise), SYNTAX_ERR);
+ return;
+ }
+ capturedPromise->resolve<IDLInterface<CryptoKey>>(key);
+ };
+ auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
+ rejectWithException(WTFMove(capturedPromise), ec);
+ };
+
+ importAlgorithm->importKey(SubtleCrypto::KeyFormat::Raw, WTFMove(data), WTFMove(importParams), extractable, keyUsages, WTFMove(callback), WTFMove(exceptionCallback));
+ };
+ auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
+ rejectWithException(WTFMove(capturedPromise), ec);
+ };
+
+ auto subtle = jsDynamicDowncast<JSSubtleCrypto*>(vm, state.thisValue());
+ ASSERT(subtle);
+ algorithm->deriveBits(WTFMove(params), baseKey.releaseNonNull(), length, WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state), subtle->wrapped().workQueue());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void jsSubtleCryptoFunctionDeriveBitsPromise(ExecState& state, Ref<DeferredPromise>&& promise)
</span><span class="lines">@@ -787,7 +875,6 @@
</span><span class="cx">
</span><span class="cx"> auto callback = [capturedPromise = promise.copyRef()](const Vector<uint8_t>& derivedKey) mutable {
</span><span class="cx"> fulfillPromiseWithArrayBuffer(WTFMove(capturedPromise), derivedKey.data(), derivedKey.size());
</span><del>- return;
</del><span class="cx"> };
</span><span class="cx"> auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
</span><span class="cx"> rejectWithException(WTFMove(capturedPromise), ec);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoAlgorithmcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx"> exceptionCallback(NOT_SUPPORTED_ERR);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void CryptoAlgorithm::deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, unsigned long, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
</del><ins>+void CryptoAlgorithm::deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, size_t, VectorCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
</ins><span class="cx"> {
</span><span class="cx"> exceptionCallback(NOT_SUPPORTED_ERR);
</span><span class="cx"> }
</span><span class="lines">@@ -87,6 +87,11 @@
</span><span class="cx"> exceptionCallback(NOT_SUPPORTED_ERR);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ExceptionOr<size_t> CryptoAlgorithm::getKeyLength(const CryptoAlgorithmParameters&)
+{
+ return Exception { NOT_SUPPORTED_ERR };
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithm::encrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&&)
</span><span class="cx"> {
</span><span class="cx"> return Exception { NOT_SUPPORTED_ERR };
</span><span class="lines">@@ -122,7 +127,7 @@
</span><span class="cx"> return Exception { NOT_SUPPORTED_ERR };
</span><span class="cx"> }
</span><span class="cx">
</span><del>-ExceptionOr<void> CryptoAlgorithm::deriveBits(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, unsigned long, VectorCallback&&, VoidCallback&&)
</del><ins>+ExceptionOr<void> CryptoAlgorithm::deriveBits(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, size_t, VectorCallback&&, VoidCallback&&)
</ins><span class="cx"> {
</span><span class="cx"> return Exception { NOT_SUPPORTED_ERR };
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoAlgorithmh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoAlgorithm.h (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithm.h        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx"> using BoolCallback = WTF::Function<void(bool)>;
</span><span class="cx"> using KeyCallback = WTF::Function<void(CryptoKey&)>;
</span><span class="cx"> using KeyOrKeyPairCallback = WTF::Function<void(KeyOrKeyPair&&)>;
</span><ins>+ // FIXME: https://bugs.webkit.org/show_bug.cgi?id=169395
</ins><span class="cx"> using VectorCallback = WTF::Function<void(const Vector<uint8_t>&)>;
</span><span class="cx"> using VoidCallback = WTF::Function<void()>;
</span><span class="cx"> using ExceptionCallback = WTF::Function<void(ExceptionCode)>;
</span><span class="lines">@@ -72,12 +73,13 @@
</span><span class="cx"> virtual void verify(Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span><span class="cx"> virtual void digest(Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span><span class="cx"> virtual void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&);
</span><del>- virtual void deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, unsigned long length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</del><ins>+ virtual void deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, size_t length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</ins><span class="cx"> // FIXME: https://bugs.webkit.org/show_bug.cgi?id=169262
</span><span class="cx"> virtual void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&);
</span><span class="cx"> virtual void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&);
</span><span class="cx"> virtual void wrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&);
</span><span class="cx"> virtual void unwrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&);
</span><ins>+ virtual ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&);
</ins><span class="cx">
</span><span class="cx"> // The following will be deprecated.
</span><span class="cx"> virtual ExceptionOr<void> encrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
</span><span class="lines">@@ -87,7 +89,7 @@
</span><span class="cx"> virtual ExceptionOr<void> digest(const CryptoAlgorithmParametersDeprecated&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
</span><span class="cx"> virtual ExceptionOr<void> generateKey(const CryptoAlgorithmParametersDeprecated&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, VoidCallback&& failureCallback, ScriptExecutionContext&);
</span><span class="cx"> virtual ExceptionOr<void> deriveKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKey& baseKey, CryptoAlgorithm* derivedKeyType, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, VoidCallback&& failureCallback);
</span><del>- virtual ExceptionOr<void> deriveBits(const CryptoAlgorithmParametersDeprecated&, const CryptoKey& baseKey, unsigned long length, VectorCallback&&, VoidCallback&& failureCallback);
</del><ins>+ virtual ExceptionOr<void> deriveBits(const CryptoAlgorithmParametersDeprecated&, const CryptoKey& baseKey, size_t length, VectorCallback&&, VoidCallback&& failureCallback);
</ins><span class="cx"> virtual ExceptionOr<void> importKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKeyData&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, VoidCallback&& failureCallback);
</span><span class="cx">
</span><span class="cx"> // These are only different from encrypt/decrypt because some algorithms may not expose encrypt/decrypt.
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoAlgorithmParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoAlgorithmParameters.h (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithmParameters.h        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithmParameters.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx"> None,
</span><span class="cx"> AesCbcCfbParams,
</span><span class="cx"> AesGcmParams,
</span><del>- AesKeyGenParams,
</del><ins>+ AesKeyParams,
</ins><span class="cx"> EcKeyParams,
</span><span class="cx"> EcdhKeyDeriveParams,
</span><span class="cx"> HmacKeyParams,
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -30,8 +30,8 @@
</span><span class="cx">
</span><span class="cx"> #include "CryptoAlgorithmAesCbcCfbParams.h"
</span><span class="cx"> #include "CryptoAlgorithmAesCbcParamsDeprecated.h"
</span><del>-#include "CryptoAlgorithmAesKeyGenParams.h"
</del><span class="cx"> #include "CryptoAlgorithmAesKeyGenParamsDeprecated.h"
</span><ins>+#include "CryptoAlgorithmAesKeyParams.h"
</ins><span class="cx"> #include "CryptoKeyAES.h"
</span><span class="cx"> #include "CryptoKeyDataOctetSequence.h"
</span><span class="cx"> #include "ExceptionCode.h"
</span><span class="lines">@@ -90,7 +90,7 @@
</span><span class="cx">
</span><span class="cx"> void CryptoAlgorithmAES_CBC::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)
</span><span class="cx"> {
</span><del>- const auto& aesParameters = downcast<CryptoAlgorithmAesKeyGenParams>(parameters);
</del><ins>+ const auto& aesParameters = downcast<CryptoAlgorithmAesKeyParams>(parameters);
</ins><span class="cx">
</span><span class="cx"> if (usagesAreInvalidForCryptoAlgorithmAES_CBC(usages)) {
</span><span class="cx"> exceptionCallback(SYNTAX_ERR);
</span><span class="lines">@@ -186,6 +186,11 @@
</span><span class="cx"> callback(format, WTFMove(result));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ExceptionOr<size_t> CryptoAlgorithmAES_CBC::getKeyLength(const CryptoAlgorithmParameters& parameters)
+{
+ return CryptoKeyAES::getKeyLength(parameters);
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmAES_CBC::encrypt(const CryptoAlgorithmParametersDeprecated& parameters, const CryptoKey& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
</span><span class="cx"> {
</span><span class="cx"> auto& aesCBCParameters = downcast<CryptoAlgorithmAesCbcParamsDeprecated>(parameters);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CBCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
</span><span class="cx"> void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
</span><span class="cx"> void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
</span><ins>+ ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
</ins><span class="cx">
</span><span class="cx"> ExceptionOr<void> encrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
</span><span class="cx"> ExceptionOr<void> decrypt(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CFBcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.cpp (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.cpp        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.cpp        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx">
</span><span class="cx"> #include "CryptoAlgorithmAesCbcCfbParams.h"
</span><del>-#include "CryptoAlgorithmAesKeyGenParams.h"
</del><ins>+#include "CryptoAlgorithmAesKeyParams.h"
</ins><span class="cx"> #include "CryptoKeyAES.h"
</span><span class="cx"> #include "ExceptionCode.h"
</span><span class="cx">
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx">
</span><span class="cx"> void CryptoAlgorithmAES_CFB::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)
</span><span class="cx"> {
</span><del>- const auto& aesParameters = downcast<CryptoAlgorithmAesKeyGenParams>(parameters);
</del><ins>+ const auto& aesParameters = downcast<CryptoAlgorithmAesKeyParams>(parameters);
</ins><span class="cx">
</span><span class="cx"> if (usagesAreInvalidForCryptoAlgorithmAES_CFB(usages)) {
</span><span class="cx"> exceptionCallback(SYNTAX_ERR);
</span><span class="lines">@@ -175,6 +175,11 @@
</span><span class="cx"> callback(format, WTFMove(result));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ExceptionOr<size_t> CryptoAlgorithmAES_CFB::getKeyLength(const CryptoAlgorithmParameters& parameters)
+{
+ return CryptoKeyAES::getKeyLength(parameters);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+}
+
</ins><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_CFBh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.h (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.h        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CFB.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx"> void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
</span><span class="cx"> void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
</span><span class="cx"> void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
</span><ins>+ ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
</ins><span class="cx">
</span><span class="cx"> void platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span><span class="cx"> void platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_GCMcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx">
</span><span class="cx"> #include "CryptoAlgorithmAesGcmParams.h"
</span><del>-#include "CryptoAlgorithmAesKeyGenParams.h"
</del><ins>+#include "CryptoAlgorithmAesKeyParams.h"
</ins><span class="cx"> #include "CryptoKeyAES.h"
</span><span class="cx"> #include "ExceptionCode.h"
</span><span class="cx">
</span><span class="lines">@@ -128,7 +128,7 @@
</span><span class="cx">
</span><span class="cx"> void CryptoAlgorithmAES_GCM::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)
</span><span class="cx"> {
</span><del>- const auto& aesParameters = downcast<CryptoAlgorithmAesKeyGenParams>(parameters);
</del><ins>+ const auto& aesParameters = downcast<CryptoAlgorithmAesKeyParams>(parameters);
</ins><span class="cx">
</span><span class="cx"> if (usagesAreInvalidForCryptoAlgorithmAES_GCM(usages)) {
</span><span class="cx"> exceptionCallback(SYNTAX_ERR);
</span><span class="lines">@@ -224,6 +224,11 @@
</span><span class="cx"> callback(format, WTFMove(result));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ExceptionOr<size_t> CryptoAlgorithmAES_GCM::getKeyLength(const CryptoAlgorithmParameters& parameters)
+{
+ return CryptoKeyAES::getKeyLength(parameters);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+}
+
</ins><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_GCMh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.h (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.h        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx"> void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
</span><span class="cx"> void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
</span><span class="cx"> void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
</span><ins>+ ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
</ins><span class="cx">
</span><span class="cx"> void platformEncrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span><span class="cx"> void platformDecrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_KWcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -28,8 +28,8 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx">
</span><del>-#include "CryptoAlgorithmAesKeyGenParams.h"
</del><span class="cx"> #include "CryptoAlgorithmAesKeyGenParamsDeprecated.h"
</span><ins>+#include "CryptoAlgorithmAesKeyParams.h"
</ins><span class="cx"> #include "CryptoKeyAES.h"
</span><span class="cx"> #include "CryptoKeyDataOctetSequence.h"
</span><span class="cx"> #include "ExceptionCode.h"
</span><span class="lines">@@ -71,7 +71,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- auto result = CryptoKeyAES::generate(CryptoAlgorithmIdentifier::AES_KW, downcast<CryptoAlgorithmAesKeyGenParams>(parameters).length, extractable, usages);
</del><ins>+ auto result = CryptoKeyAES::generate(CryptoAlgorithmIdentifier::AES_KW, downcast<CryptoAlgorithmAesKeyParams>(parameters).length, extractable, usages);
</ins><span class="cx"> if (!result) {
</span><span class="cx"> exceptionCallback(OperationError);
</span><span class="cx"> return;
</span><span class="lines">@@ -173,6 +173,11 @@
</span><span class="cx"> platformUnwrapKey(WTFMove(key), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ExceptionOr<size_t> CryptoAlgorithmAES_KW::getKeyLength(const CryptoAlgorithmParameters& parameters)
+{
+ return CryptoKeyAES::getKeyLength(parameters);
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmAES_KW::encryptForWrapKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKey& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
</span><span class="cx"> {
</span><span class="cx"> if (!keyAlgorithmMatches(key))
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmAES_KWh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx"> void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
</span><span class="cx"> void wrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&) final;
</span><span class="cx"> void unwrapKey(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&) final;
</span><ins>+ ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
</ins><span class="cx">
</span><span class="cx"> ExceptionOr<void> encryptForWrapKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
</span><span class="cx"> ExceptionOr<void> decryptForUnwrapKey(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmECDHcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx"> callback(WTFMove(pair));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void CryptoAlgorithmECDH::deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& baseKey, unsigned long length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
</del><ins>+void CryptoAlgorithmECDH::deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&& parameters, Ref<CryptoKey>&& baseKey, size_t length, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
</ins><span class="cx"> {
</span><span class="cx"> // We only accept length that is a multiple of 8.
</span><span class="cx"> if (length % 8) {
</span><span class="lines">@@ -97,7 +97,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- auto unifiedCallback = [callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](std::optional<Vector<uint8_t>>&& derivedKey, unsigned long length) mutable {
</del><ins>+ auto unifiedCallback = [callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback)](std::optional<Vector<uint8_t>>&& derivedKey, size_t length) mutable {
</ins><span class="cx"> if (!derivedKey) {
</span><span class="cx"> exceptionCallback(OperationError);
</span><span class="cx"> return;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmECDHh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -42,12 +42,12 @@
</span><span class="cx"> CryptoAlgorithmIdentifier identifier() const final;
</span><span class="cx">
</span><span class="cx"> void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
</span><del>- void deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, unsigned long length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
</del><ins>+ void deriveBits(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, size_t length, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
</ins><span class="cx"> void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
</span><span class="cx"> void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
</span><span class="cx">
</span><del>- using Callback = Function<void(std::optional<Vector<uint8_t>>&&, unsigned long)>;
- void platformDeriveBits(Ref<CryptoKey>&& baseKey, Ref<CryptoKey>&& publicKey, unsigned long length, Callback&&, ScriptExecutionContext&, WorkQueue&);
</del><ins>+ using Callback = Function<void(std::optional<Vector<uint8_t>>&&, size_t)>;
+ void platformDeriveBits(Ref<CryptoKey>&& baseKey, Ref<CryptoKey>&& publicKey, size_t length, Callback&&, ScriptExecutionContext&, WorkQueue&);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -197,6 +197,11 @@
</span><span class="cx"> callback(format, WTFMove(result));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ExceptionOr<size_t> CryptoAlgorithmHMAC::getKeyLength(const CryptoAlgorithmParameters& parameters)
+{
+ return CryptoKeyHMAC::getKeyLength(parameters);
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmHMAC::sign(const CryptoAlgorithmParametersDeprecated& parameters, const CryptoKey& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
</span><span class="cx"> {
</span><span class="cx"> auto& hmacParameters = downcast<CryptoAlgorithmHmacParamsDeprecated>(parameters);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
</span><span class="cx"> void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
</span><span class="cx"> void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
</span><ins>+ ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&) final;
</ins><span class="cx">
</span><span class="cx"> // The following will be deprecated.
</span><span class="cx"> ExceptionOr<void> sign(const CryptoAlgorithmParametersDeprecated&, const CryptoKey&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback) final;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyAEScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.cpp        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -28,8 +28,11 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx">
</span><ins>+#include "CryptoAlgorithmAesKeyParams.h"
</ins><span class="cx"> #include "CryptoAlgorithmRegistry.h"
</span><span class="cx"> #include "CryptoKeyDataOctetSequence.h"
</span><ins>+#include "ExceptionCode.h"
+#include "ExceptionOr.h"
</ins><span class="cx"> #include "JsonWebKey.h"
</span><span class="cx"> #include <wtf/text/Base64.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="lines">@@ -114,6 +117,14 @@
</span><span class="cx"> return result;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ExceptionOr<size_t> CryptoKeyAES::getKeyLength(const CryptoAlgorithmParameters& parameters)
+{
+ auto& aesParameters = downcast<CryptoAlgorithmAesKeyParams>(parameters);
+ if (!lengthIsValid(aesParameters.length))
+ return Exception { OperationError };
+ return aesParameters.length;
+}
+
</ins><span class="cx"> std::unique_ptr<KeyAlgorithm> CryptoKeyAES::buildAlgorithm() const
</span><span class="cx"> {
</span><span class="cx"> return std::make_unique<AesKeyAlgorithm>(CryptoAlgorithmRegistry::singleton().name(algorithmIdentifier()), m_key.size() * 8);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyAESh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyAES.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx">
</span><span class="cx"> #include "CryptoAlgorithmIdentifier.h"
</span><span class="cx"> #include "CryptoKey.h"
</span><ins>+#include "ExceptionOr.h"
</ins><span class="cx"> #include <wtf/Function.h>
</span><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx">
</span><span class="lines">@@ -34,6 +35,8 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+class CryptoAlgorithmParameters;
+
</ins><span class="cx"> struct JsonWebKey;
</span><span class="cx">
</span><span class="cx"> class AesKeyAlgorithm final : public KeyAlgorithm {
</span><span class="lines">@@ -76,6 +79,8 @@
</span><span class="cx"> const Vector<uint8_t>& key() const { return m_key; }
</span><span class="cx"> JsonWebKey exportJwk() const;
</span><span class="cx">
</span><ins>+ static ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&);
+
</ins><span class="cx"> private:
</span><span class="cx"> CryptoKeyAES(CryptoAlgorithmIdentifier, const Vector<uint8_t>& key, bool extractable, CryptoKeyUsageBitmap);
</span><span class="cx"> CryptoKeyAES(CryptoAlgorithmIdentifier, Vector<uint8_t>&& key, bool extractable, CryptoKeyUsageBitmap);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyHMACcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -31,6 +31,8 @@
</span><span class="cx"> #include "CryptoAlgorithmHmacKeyParams.h"
</span><span class="cx"> #include "CryptoAlgorithmRegistry.h"
</span><span class="cx"> #include "CryptoKeyDataOctetSequence.h"
</span><ins>+#include "ExceptionCode.h"
+#include "ExceptionOr.h"
</ins><span class="cx"> #include "JsonWebKey.h"
</span><span class="cx"> #include <wtf/text/Base64.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="lines">@@ -37,6 +39,22 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+static size_t getKeyLengthFromHash(CryptoAlgorithmIdentifier hash)
+{
+ switch (hash) {
+ case CryptoAlgorithmIdentifier::SHA_1:
+ case CryptoAlgorithmIdentifier::SHA_224:
+ case CryptoAlgorithmIdentifier::SHA_256:
+ return 512;
+ case CryptoAlgorithmIdentifier::SHA_384:
+ case CryptoAlgorithmIdentifier::SHA_512:
+ return 1024;
+ default:
+ ASSERT_NOT_REACHED();
+ return 0;
+ }
+}
+
</ins><span class="cx"> CryptoKeyHMAC::CryptoKeyHMAC(const Vector<uint8_t>& key, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsageBitmap usage)
</span><span class="cx"> : CryptoKey(CryptoAlgorithmIdentifier::HMAC, CryptoKeyType::Secret, extractable, usage)
</span><span class="cx"> , m_hash(hash)
</span><span class="lines">@@ -58,19 +76,9 @@
</span><span class="cx"> RefPtr<CryptoKeyHMAC> CryptoKeyHMAC::generate(size_t lengthBits, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsageBitmap usages)
</span><span class="cx"> {
</span><span class="cx"> if (!lengthBits) {
</span><del>- switch (hash) {
- case CryptoAlgorithmIdentifier::SHA_1:
- case CryptoAlgorithmIdentifier::SHA_224:
- case CryptoAlgorithmIdentifier::SHA_256:
- lengthBits = 512;
- break;
- case CryptoAlgorithmIdentifier::SHA_384:
- case CryptoAlgorithmIdentifier::SHA_512:
- lengthBits = 1024;
- break;
- default:
</del><ins>+ lengthBits = getKeyLengthFromHash(hash);
+ if (!lengthBits)
</ins><span class="cx"> return nullptr;
</span><del>- }
</del><span class="cx"> }
</span><span class="cx"> // CommonHMAC only supports key length that is a multiple of 8. Therefore, here we are a little bit different
</span><span class="cx"> // from the spec as of 11 December 2014: https://www.w3.org/TR/WebCryptoAPI/#hmac-operations
</span><span class="lines">@@ -124,6 +132,17 @@
</span><span class="cx"> return result;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ExceptionOr<size_t> CryptoKeyHMAC::getKeyLength(const CryptoAlgorithmParameters& parameters)
+{
+ auto& aesParameters = downcast<CryptoAlgorithmHmacKeyParams>(parameters);
+
+ size_t result = aesParameters.length ? *(aesParameters.length) : getKeyLengthFromHash(aesParameters.hashIdentifier);
+ if (result)
+ return result;
+
+ return Exception { TypeError };
+}
+
</ins><span class="cx"> std::unique_ptr<KeyAlgorithm> CryptoKeyHMAC::buildAlgorithm() const
</span><span class="cx"> {
</span><span class="cx"> return std::make_unique<HmacKeyAlgorithm>(CryptoAlgorithmRegistry::singleton().name(algorithmIdentifier()),
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyHMACh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -28,11 +28,14 @@
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx">
</span><span class="cx"> #include "CryptoKey.h"
</span><ins>+#include "ExceptionOr.h"
</ins><span class="cx"> #include <wtf/Function.h>
</span><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+class CryptoAlgorithmParameters;
+
</ins><span class="cx"> struct JsonWebKey;
</span><span class="cx">
</span><span class="cx"> class HmacKeyAlgorithm final : public KeyAlgorithm {
</span><span class="lines">@@ -74,6 +77,8 @@
</span><span class="cx">
</span><span class="cx"> CryptoAlgorithmIdentifier hashAlgorithmIdentifier() const { return m_hash; }
</span><span class="cx">
</span><ins>+ static ExceptionOr<size_t> getKeyLength(const CryptoAlgorithmParameters&);
+
</ins><span class="cx"> private:
</span><span class="cx"> CryptoKeyHMAC(const Vector<uint8_t>& key, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsageBitmap);
</span><span class="cx"> CryptoKeyHMAC(Vector<uint8_t>&& key, CryptoAlgorithmIdentifier hash, bool extractable, CryptoKeyUsageBitmap);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoAlgorithmECDHMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDHMac.cpp (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDHMac.cpp        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmECDHMac.cpp        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-void CryptoAlgorithmECDH::platformDeriveBits(Ref<CryptoKey>&& baseKey, Ref<CryptoKey>&& publicKey, unsigned long length, Callback&& callback, ScriptExecutionContext& context, WorkQueue& workQueue)
</del><ins>+void CryptoAlgorithmECDH::platformDeriveBits(Ref<CryptoKey>&& baseKey, Ref<CryptoKey>&& publicKey, size_t length, Callback&& callback, ScriptExecutionContext& context, WorkQueue& workQueue)
</ins><span class="cx"> {
</span><span class="cx"> context.ref();
</span><span class="cx"> workQueue.dispatch([baseKey = WTFMove(baseKey), publicKey = WTFMove(publicKey), length, callback = WTFMove(callback), &context]() mutable {
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoparametersAesKeyGenParamsidl"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/crypto/parameters/AesKeyGenParams.idl (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/parameters/AesKeyGenParams.idl        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/parameters/AesKeyGenParams.idl        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -1,32 +0,0 @@
</span><del>-/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-[
- Conditional=SUBTLE_CRYPTO,
- ImplementedAs=CryptoAlgorithmAesKeyGenParams
-] dictionary AesKeyGenParams : CryptoAlgorithmParameters {
- // The length, in bits, of the key.
- [EnforceRange] required unsigned short length;
-};
</del></span></pre></div>
<a id="trunkSourceWebCorecryptoparametersAesKeyParamsidlfromrev213627trunkSourceWebCorecryptoparametersAesKeyGenParamsidl"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/crypto/parameters/AesKeyParams.idl (from rev 213627, trunk/Source/WebCore/crypto/parameters/AesKeyGenParams.idl) (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/parameters/AesKeyParams.idl         (rev 0)
+++ trunk/Source/WebCore/crypto/parameters/AesKeyParams.idl        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// This is a unified dictionary for AesDerivedKeyParams and AesKeyGenParams.
+// https://www.w3.org/TR/WebCryptoAPI/#aes-derivedkey-params, and
+// https://www.w3.org/TR/WebCryptoAPI/#aes-keygen-params
+[
+ Conditional=SUBTLE_CRYPTO,
+ ImplementedAs=CryptoAlgorithmAesKeyParams
+] dictionary AesKeyParams : CryptoAlgorithmParameters {
+ // The length, in bits, of the key.
+ [EnforceRange] required unsigned short length;
+};
</ins></span></pre></div>
<a id="trunkSourceWebCorecryptoparametersCryptoAlgorithmAesKeyGenParamsh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -1,45 +0,0 @@
</span><del>-/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "CryptoAlgorithmParameters.h"
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-namespace WebCore {
-
-class CryptoAlgorithmAesKeyGenParams final : public CryptoAlgorithmParameters {
-public:
- unsigned short length;
-
- Class parametersClass() const final { return Class::AesKeyGenParams; }
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS(AesKeyGenParams)
-
-#endif // ENABLE(SUBTLE_CRYPTO)
</del></span></pre></div>
<a id="trunkSourceWebCorecryptoparametersCryptoAlgorithmAesKeyParamshfromrev213627trunkSourceWebCorecryptoparametersCryptoAlgorithmAesKeyGenParamsh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyParams.h (from rev 213627, trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyGenParams.h) (0 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyParams.h         (rev 0)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmAesKeyParams.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "CryptoAlgorithmParameters.h"
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+class CryptoAlgorithmAesKeyParams final : public CryptoAlgorithmParameters {
+public:
+ unsigned short length;
+
+ Class parametersClass() const final { return Class::AesKeyParams; }
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_CRYPTO_ALGORITHM_PARAMETERS(AesKeyParams)
+
+#endif // ENABLE(SUBTLE_CRYPTO)
</ins></span></pre></div>
<a id="trunkSourceWebCorecryptoparametersCryptoAlgorithmHmacKeyParamsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyParams.h (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyParams.h        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmHmacKeyParams.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx"> // FIXME: Consider merging hash and hashIdentifier.
</span><span class="cx"> JSC::JSValue hash;
</span><span class="cx"> CryptoAlgorithmIdentifier hashIdentifier;
</span><del>- std::optional<unsigned long> length;
</del><ins>+ std::optional<size_t> length;
</ins><span class="cx">
</span><span class="cx"> Class parametersClass() const final { return Class::HmacKeyParams; }
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoparametersCryptoAlgorithmRsaKeyGenParamsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h (213627 => 213628)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h        2017-03-09 05:16:20 UTC (rev 213627)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaKeyGenParams.h        2017-03-09 05:50:31 UTC (rev 213628)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx">
</span><span class="cx"> class CryptoAlgorithmRsaKeyGenParams : public CryptoAlgorithmParameters {
</span><span class="cx"> public:
</span><del>- unsigned long modulusLength;
</del><ins>+ size_t modulusLength;
</ins><span class="cx"> RefPtr<Uint8Array> publicExponent;
</span><span class="cx">
</span><span class="cx"> Class parametersClass() const override { return Class::RsaKeyGenParams; }
</span></span></pre>
</div>
</div>
</body>
</html>