<!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>[160534] 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/160534">160534</a></dd>
<dt>Author</dt> <dd>ap@apple.com</dd>
<dt>Date</dt> <dd>2013-12-13 00:56:06 -0800 (Fri, 13 Dec 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>WebCrypto wrapKey operation doesn't check key usage
https://bugs.webkit.org/show_bug.cgi?id=125675
Reviewed by Darin Adler.
Source/WebCore:
Tests: crypto/subtle/unwrapKey-check-usage.html
crypto/subtle/wrapKey-check-usage.html
* bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::JSSubtleCrypto::wrapKey):
Added accidentally omitted code. Other operations are fine.
LayoutTests:
* crypto/subtle/unwrapKey-check-usage-expected.txt: Added.
* crypto/subtle/unwrapKey-check-usage.html: Added.
* crypto/subtle/wrapKey-check-usage-expected.txt: Added.
* crypto/subtle/wrapKey-check-usage.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp">trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtleunwrapKeycheckusageexpectedtxt">trunk/LayoutTests/crypto/subtle/unwrapKey-check-usage-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleunwrapKeycheckusagehtml">trunk/LayoutTests/crypto/subtle/unwrapKey-check-usage.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlewrapKeycheckusageexpectedtxt">trunk/LayoutTests/crypto/subtle/wrapKey-check-usage-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlewrapKeycheckusagehtml">trunk/LayoutTests/crypto/subtle/wrapKey-check-usage.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (160533 => 160534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2013-12-13 08:35:21 UTC (rev 160533)
+++ trunk/LayoutTests/ChangeLog        2013-12-13 08:56:06 UTC (rev 160534)
</span><span class="lines">@@ -1,5 +1,17 @@
</span><span class="cx"> 2013-12-12 Alexey Proskuryakov <ap@apple.com>
</span><span class="cx">
</span><ins>+ WebCrypto wrapKey operation doesn't check key usage
+ https://bugs.webkit.org/show_bug.cgi?id=125675
+
+ Reviewed by Darin Adler.
+
+ * crypto/subtle/unwrapKey-check-usage-expected.txt: Added.
+ * crypto/subtle/unwrapKey-check-usage.html: Added.
+ * crypto/subtle/wrapKey-check-usage-expected.txt: Added.
+ * crypto/subtle/wrapKey-check-usage.html: Added.
+
+2013-12-12 Alexey Proskuryakov <ap@apple.com>
+
</ins><span class="cx"> Add support for RSAES-PKCS1-v1_5
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=125647
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleunwrapKeycheckusageexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/unwrapKey-check-usage-expected.txt (0 => 160534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/unwrapKey-check-usage-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/unwrapKey-check-usage-expected.txt        2013-12-13 08:56:06 UTC (rev 160534)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+CONSOLE MESSAGE: Key usages do not include 'unwrapKey'
+Verify that usage is respected in unwrapKey operation.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing RSA keys...
+Importing an AES key...
+Wrapping it...
+Unwrapping it...
+PASS crypto.subtle.unwrapKey("raw", wrappedKey, privateKey, wrapAlgorithm, "aes-cbc", extractable, ["encrypt", "decrypt"]) threw exception Error: NotSupportedError: DOM Exception 9.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/unwrapKey-check-usage-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestscryptosubtleunwrapKeycheckusagehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/unwrapKey-check-usage.html (0 => 160534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/unwrapKey-check-usage.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/unwrapKey-check-usage.html        2013-12-13 08:56:06 UTC (rev 160534)
</span><span class="lines">@@ -0,0 +1,67 @@
</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("Verify that usage is respected in unwrapKey operation.");
+
+jsTestIsAsync = true;
+
+var publicKeyJSON = {
+ kty: "RSA",
+ alg: "RSA-OAEP",
+ n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+ e: "AQAB"
+};
+
+var privateKeyJSON = {
+ kty: "RSA",
+ alg: "RSA-OAEP",
+ n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-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KwBZFC4FCG2hg_zE",
+ qi: "YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk"
+};
+var wrapAlgorithm = {name: "RSA-OAEP", hash: "sha-1"};
+var extractable = true;
+var nonExtractable = false;
+
+debug("Importing RSA keys...");
+crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)), null, extractable, ["wrapKey"]).then(function(result) {
+ publicKey = result;
+ return crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(privateKeyJSON)), null, extractable, ["encrypt", "decrypt", "wrapKey"]);
+}).then(function(result) {
+ privateKey = result;
+
+ debug("Importing an AES key...");
+ aesKeyData = hexStringToUint8Array("603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4");
+ return crypto.subtle.importKey("raw", aesKeyData, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])
+}).then(function(result) {
+ aesKey = result;
+
+ debug("Wrapping it...");
+ return crypto.subtle.wrapKey("raw", aesKey, publicKey, wrapAlgorithm);
+}).then(function(result) {
+ wrappedKey = result;
+
+ debug("Unwrapping it...");
+ // privateKey lacks unwrapKey usage.
+ shouldThrow('crypto.subtle.unwrapKey("raw", wrappedKey, privateKey, wrapAlgorithm, "aes-cbc", extractable, ["encrypt", "decrypt"])');
+
+ finishJSTest();
+});
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/unwrapKey-check-usage.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestscryptosubtlewrapKeycheckusageexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/wrapKey-check-usage-expected.txt (0 => 160534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/wrapKey-check-usage-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/wrapKey-check-usage-expected.txt        2013-12-13 08:56:06 UTC (rev 160534)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+CONSOLE MESSAGE: Key usages do not include 'wrapKey'
+Verify that usage is respected in wrapKey operation.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing an RSA key...
+Importing an AES key...
+Wrapping it...
+PASS crypto.subtle.wrapKey("raw", aesKey, publicKey, wrapAlgorithm) threw exception Error: NotSupportedError: DOM Exception 9.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/wrapKey-check-usage-expected.txt
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkLayoutTestscryptosubtlewrapKeycheckusagehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/wrapKey-check-usage.html (0 => 160534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/wrapKey-check-usage.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/wrapKey-check-usage.html        2013-12-13 08:56:06 UTC (rev 160534)
</span><span class="lines">@@ -0,0 +1,46 @@
</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("Verify that usage is respected in wrapKey operation.");
+
+jsTestIsAsync = true;
+
+var publicKeyJSON = {
+ kty: "RSA",
+ alg: "RSA-OAEP",
+ n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+ e: "AQAB"
+};
+
+var wrapAlgorithm = {name: "RSA-OAEP", hash: "sha-1"};
+var extractable = true;
+var nonExtractable = false;
+
+debug("Importing an RSA key...");
+crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(publicKeyJSON)), null, extractable, ["encrypt", "decrypt", "unwrapKey"]).then(function(result) {
+ publicKey = result;
+
+ debug("Importing an AES key...");
+ aesKeyData = hexStringToUint8Array("603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4");
+ return crypto.subtle.importKey("raw", aesKeyData, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"])
+}).then(function(result) {
+ aesKey = result;
+
+ debug("Wrapping it...");
+ // publicKey lacks wrapKey usage.
+ shouldThrow('crypto.subtle.wrapKey("raw", aesKey, publicKey, wrapAlgorithm)');
+ finishJSTest();
+});
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/wrapKey-check-usage.html
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (160533 => 160534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-12-13 08:35:21 UTC (rev 160533)
+++ trunk/Source/WebCore/ChangeLog        2013-12-13 08:56:06 UTC (rev 160534)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2013-12-12 Alexey Proskuryakov <ap@apple.com>
+
+ WebCrypto wrapKey operation doesn't check key usage
+ https://bugs.webkit.org/show_bug.cgi?id=125675
+
+ Reviewed by Darin Adler.
+
+ Tests: crypto/subtle/unwrapKey-check-usage.html
+ crypto/subtle/wrapKey-check-usage.html
+
+ * bindings/js/JSSubtleCryptoCustom.cpp: (WebCore::JSSubtleCrypto::wrapKey):
+ Added accidentally omitted code. Other operations are fine.
+
</ins><span class="cx"> 2013-12-12 Darin Adler <darin@apple.com>
</span><span class="cx">
</span><span class="cx"> Make some improvements in CSSImageGeneratorValue code
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (160533 => 160534)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2013-12-13 08:35:21 UTC (rev 160533)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2013-12-13 08:56:06 UTC (rev 160534)
</span><span class="lines">@@ -646,6 +646,11 @@
</span><span class="cx"> if (!key)
</span><span class="cx"> return throwTypeError(exec);
</span><span class="cx">
</span><ins>+ if (!wrappingKey->allows(CryptoKeyUsageWrapKey)) {
+ m_impl->document()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Key usages do not include 'wrapKey'");
+ setDOMException(exec, NOT_SUPPORTED_ERR);
+ return jsUndefined();
+ }
</ins><span class="cx">
</span><span class="cx"> auto algorithm = createAlgorithmFromJSValue(exec, exec->uncheckedArgument(3));
</span><span class="cx"> if (!algorithm) {
</span></span></pre>
</div>
</div>
</body>
</html>