<!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>[159944] 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/159944">159944</a></dd>
<dt>Author</dt> <dd>ap@apple.com</dd>
<dt>Date</dt> <dd>2013-12-02 11:50:51 -0800 (Mon, 02 Dec 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add support for WebCrypto RSA-OAEP
https://bugs.webkit.org/show_bug.cgi?id=125084
Reviewed by Sam Weinig.
Source/WebCore:
Tests: crypto/subtle/rsa-oaep-key-manipulation.html
crypto/subtle/rsa-oaep-plaintext-length.html
crypto/subtle/rsa-oaep-wrap-unwrap-aes.html
* WebCore.xcodeproj/project.pbxproj: Added new files.
* bindings/js/JSCryptoAlgorithmDictionary.cpp:
(WebCore::createRsaOaepParams):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForEncrypt):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForDecrypt):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForImportKey):
Added RSA-OAEP parameters.
* bindings/js/JSCryptoKeySerializationJWK.cpp:
(WebCore::JSCryptoKeySerializationJWK::reconcileAlgorithm):
(WebCore::JSCryptoKeySerializationJWK::keySizeIsValid):
(WebCore::JSCryptoKeySerializationJWK::addJWKAlgorithmToJSON):
Support RSA-OAEP in JWK. It is more limited than general WebCrypto, as JWK only
allows SHA-1 as hash.
* crypto/CommonCryptoUtilities.cpp: Added. (WebCore::getCommonCryptoDigestAlgorithm):
* crypto/CommonCryptoUtilities.h: Added.
Extracted some shared code and forward declarations for CommonCrypto.
* crypto/CryptoAlgorithmParameters.h: (WebCore::CryptoAlgorithmParameters::Class):
* crypto/parameters/CryptoAlgorithmRsaOaepParams.h: Added.
Added RsaOaepParams.
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp: Added.
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.h: Added.
* crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp: Added.
* crypto/mac/CryptoAlgorithmHMACMac.cpp:
(WebCore::getCommonCryptoHMACAlgorithm):
(WebCore::CryptoAlgorithmHMAC::platformSign):
(WebCore::CryptoAlgorithmHMAC::platformVerify):
* crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp:
* crypto/mac/CryptoKeyMac.cpp:
* crypto/mac/CryptoKeyRSAMac.cpp:
Use CommonCryptoUtilities.
* crypto/mac/CryptoAlgorithmRegistryMac.cpp:
(WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms): Register RSA-OAEP.
LayoutTests:
* crypto/subtle/rsa-oaep-key-manipulation-expected.txt: Added.
* crypto/subtle/rsa-oaep-key-manipulation.html: Added.
* crypto/subtle/rsa-oaep-plaintext-length-expected.txt: Added.
* crypto/subtle/rsa-oaep-plaintext-length.html: Added.
* crypto/subtle/rsa-oaep-wrap-unwrap-aes-expected.txt: Added.
* crypto/subtle/rsa-oaep-wrap-unwrap-aes.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="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCryptoAlgorithmDictionarycpp">trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCryptoKeySerializationJWKcpp">trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoAlgorithmParametersh">trunk/Source/WebCore/crypto/CryptoAlgorithmParameters.h</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoAlgorithmHMACMaccpp">trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoAlgorithmRSASSA_PKCS1_v1_5Maccpp">trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoAlgorithmRegistryMaccpp">trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoKeyMaccpp">trunk/Source/WebCore/crypto/mac/CryptoKeyMac.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoKeyRSAMaccpp">trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepkeymanipulationexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepkeymanipulationhtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepplaintextlengthexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-plaintext-length-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepplaintextlengthhtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-plaintext-length.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepwrapunwrapaesexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-wrap-unwrap-aes-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepwrapunwrapaeshtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-wrap-unwrap-aes.html</a></li>
<li><a href="#trunkSourceWebCorecryptoCommonCryptoUtilitiescpp">trunk/Source/WebCore/crypto/CommonCryptoUtilities.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCommonCryptoUtilitiesh">trunk/Source/WebCore/crypto/CommonCryptoUtilities.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoAlgorithmRSA_OAEPMaccpp">trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoparametersCryptoAlgorithmRsaOaepParamsh">trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaOaepParams.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (159943 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2013-12-02 19:49:43 UTC (rev 159943)
+++ trunk/LayoutTests/ChangeLog        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2013-12-02 Alexey Proskuryakov <ap@apple.com>
+
+ Add support for WebCrypto RSA-OAEP
+ https://bugs.webkit.org/show_bug.cgi?id=125084
+
+ Reviewed by Sam Weinig.
+
+ * crypto/subtle/rsa-oaep-key-manipulation-expected.txt: Added.
+ * crypto/subtle/rsa-oaep-key-manipulation.html: Added.
+ * crypto/subtle/rsa-oaep-plaintext-length-expected.txt: Added.
+ * crypto/subtle/rsa-oaep-plaintext-length.html: Added.
+ * crypto/subtle/rsa-oaep-wrap-unwrap-aes-expected.txt: Added.
+ * crypto/subtle/rsa-oaep-wrap-unwrap-aes.html: Added.
+
</ins><span class="cx"> 2013-12-01 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><span class="cx"> Stores to local captured variables should be intercepted
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepkeymanipulationexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation-expected.txt (0 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation-expected.txt        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+Test generating, importing and exporting RSA keys for RSA-OAEP. Test that they can't be used with another algorithm.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating a key pair...
+PASS keyPair.toString() is '[object KeyPair]'
+PASS keyPair.publicKey.type is 'public'
+PASS keyPair.publicKey.algorithm.name is 'rsa-oaep'
+PASS keyPair.publicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(keyPair.publicKey.algorithm.publicExponent) is '010001'
+PASS keyPair.publicKey.algorithm.hash is undefined.
+PASS keyPair.privateKey.type is 'private'
+PASS keyPair.privateKey.algorithm.name is 'rsa-oaep'
+PASS keyPair.privateKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(keyPair.privateKey.algorithm.publicExponent) is '010001'
+PASS keyPair.privateKey.algorithm.hash is undefined.
+
+Testing that the keys can't be used with different algorithms...
+PASS crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, keyPair.privateKey, hexStringToUint8Array("00")) threw exception Error: NotSupportedError: DOM Exception 9.
+PASS crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, keyPair.publicKey, hexStringToUint8Array("00")) threw exception Error: NotSupportedError: DOM Exception 9.
+
+Trying to export keys to raw...
+PASS Promise rejected for exporting public key
+PASS Promise rejected for exporting private key
+
+Exporting public key to JWK...
+PASS jwkPublicKey.alg is 'RSA-OAEP'
+PASS jwkPublicKey.extractable is true
+PASS jwkPublicKey.use is 'enc'
+PASS jwkPublicKey.kty is 'RSA'
+PASS bytesToHexString(Base64URL.parse(jwkPublicKey.e)) is '010001'
+
+Importing it back...
+PASS exportedPublicKey.type is 'public'
+PASS exportedPublicKey.algorithm.name is 'rsa-oaep'
+PASS exportedPublicKey.algorithm.modulusLength is 2048
+PASS bytesToHexString(exportedPublicKey.algorithm.publicExponent) is '010001'
+PASS exportedPublicKey.algorithm.hash.name is 'sha-1'
+PASS exportedPublicKey.extractable is true
+PASS exportedPublicKey.usages is ['encrypt','decrypt','wrapKey','unwrapKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation-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="trunkLayoutTestscryptosubtlersaoaepkeymanipulationhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation.html (0 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation.html        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -0,0 +1,81 @@
</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 generating, importing and exporting RSA keys for RSA-OAEP. Test that they can't be used with another algorithm.");
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+ name: "RSA-OAEP",
+ // RsaKeyGenParams
+ modulusLength: 2048,
+ publicExponent: new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537
+};
+var extractable = true;
+
+debug("Generating a key pair...");
+crypto.subtle.generateKey(algorithmKeyGen, extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(result) {
+ keyPair = result;
+ shouldBe("keyPair.toString()", "'[object KeyPair]'");
+ shouldBe("keyPair.publicKey.type", "'public'");
+ shouldBe("keyPair.publicKey.algorithm.name", "'rsa-oaep'");
+ shouldBe("keyPair.publicKey.algorithm.modulusLength", "2048");
+ shouldBe("bytesToHexString(keyPair.publicKey.algorithm.publicExponent)", "'010001'");
+ shouldBeUndefined("keyPair.publicKey.algorithm.hash");
+ shouldBe("keyPair.privateKey.type", "'private'");
+ shouldBe("keyPair.privateKey.algorithm.name", "'rsa-oaep'");
+ shouldBe("keyPair.privateKey.algorithm.modulusLength", "2048");
+ shouldBe("bytesToHexString(keyPair.privateKey.algorithm.publicExponent)", "'010001'");
+ shouldBeUndefined("keyPair.privateKey.algorithm.hash");
+
+ debug("\nTesting that the keys can't be used with different algorithms...");
+ iv = hexStringToUint8Array("000102030405060708090a0b0c0d0e0f");
+ shouldThrow('crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, keyPair.privateKey, hexStringToUint8Array("00"))');
+ shouldThrow('crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, keyPair.publicKey, hexStringToUint8Array("00"))');
+
+ debug("\nTrying to export keys to raw...");
+ return crypto.subtle.exportKey('raw', keyPair.publicKey);
+}).then(undefined, function(result) {
+ testPassed("Promise rejected for exporting public key");
+ return crypto.subtle.exportKey('raw', keyPair.privateKey);
+}).then(undefined, function(result) {
+ testPassed("Promise rejected for exporting private key");
+
+ debug("\nExporting public key to JWK...");
+ return crypto.subtle.exportKey("jwk", keyPair.publicKey);
+}).then(function(result) {
+ jwkPublicKeyArray = result;
+ jwkPublicKey = JSON.parse(bytesToASCIIString(jwkPublicKeyArray));
+ shouldBe("jwkPublicKey.alg", "'RSA-OAEP'");
+ shouldBe("jwkPublicKey.extractable", "true");
+ shouldBe("jwkPublicKey.use", "'enc'");
+ shouldBe("jwkPublicKey.kty", "'RSA'");
+ shouldBe("bytesToHexString(Base64URL.parse(jwkPublicKey.e))", "'010001'");
+
+ debug("\nImporting it back...");
+ return crypto.subtle.importKey("jwk", jwkPublicKeyArray, null, extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]);
+}).then(function(result) {
+ exportedPublicKey = result;
+ shouldBe("exportedPublicKey.type", "'public'");
+ shouldBe("exportedPublicKey.algorithm.name", "'rsa-oaep'");
+ shouldBe("exportedPublicKey.algorithm.modulusLength", "2048");
+ shouldBe("bytesToHexString(exportedPublicKey.algorithm.publicExponent)", "'010001'");
+ shouldBe("exportedPublicKey.algorithm.hash.name", "'sha-1'");
+ shouldBe("exportedPublicKey.extractable", "true");
+ shouldBe("exportedPublicKey.usages", "['encrypt','decrypt','wrapKey','unwrapKey']");
+
+ finishJSTest();
+});
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/rsa-oaep-key-manipulation.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="trunkLayoutTestscryptosubtlersaoaepplaintextlengthexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-plaintext-length-expected.txt (0 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-plaintext-length-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-plaintext-length-expected.txt        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+Test what happens when trying to encrypt a too large plain text with RSA-OAEP.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing RSA keys...
+Encrypting a 214 byte buffer with RSA-OAEP SHA-1, 2048 bit key...
+PASS Succeeded
+Encrypting a 215 byte buffer...
+PASS Rejected
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/rsa-oaep-plaintext-length-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="trunkLayoutTestscryptosubtlersaoaepplaintextlengthhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-plaintext-length.html (0 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-plaintext-length.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-plaintext-length.html        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -0,0 +1,63 @@
</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 what happens when trying to encrypt a too large plain text with RSA-OAEP.");
+
+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-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+ e: "AQAB",
+ d: "eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ",
+ p: "4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0",
+ q: "xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc",
+ dp: "fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk",
+ dq: "jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_zE",
+ qi: "YCX_pLwbMBA1ThVH0WcwmnytqNcrMCEwTm7ByA2eU6nWbQrULvf7m9_kzfLUcjsnpAVlBQG5JMXMy0Sq4ptwbywsa5-G8KAOOOR2L3v4hC-Eys9ftgFM_3i0o40eeQH4b3haPbntrIeMg8IzlOuVYKf9-2QuKDoWeRdd7NsdxTk"
+};
+var encryptAlgorithm = {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, ["encrypt", "decrypt"]).then(function(result) {
+ publicKey = result;
+ return crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(privateKeyJSON)), null, extractable, ["encrypt", "decrypt"]);
+}).then(function(result) {
+ privateKey = result;
+
+ debug("Encrypting a 214 byte buffer with RSA-OAEP SHA-1, 2048 bit key...");
+ return crypto.subtle.encrypt({name: "RSA-OAEP", hash: "SHA-1"}, publicKey, new Uint8Array(214));
+}).then(function(result) {
+ testPassed("Succeeded");
+ debug("Encrypting a 215 byte buffer...");
+ return crypto.subtle.encrypt({name: "RSA-OAEP", hash: "SHA-1"}, publicKey, new Uint8Array(215));
+}).then(function(result) {
+ testFailed("Succeeded");
+ finishJSTest();
+}, function(result) {
+ testPassed("Rejected");
+ finishJSTest();
+});
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/rsa-oaep-plaintext-length.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="trunkLayoutTestscryptosubtlersaoaepwrapunwrapaesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-wrap-unwrap-aes-expected.txt (0 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-wrap-unwrap-aes-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-wrap-unwrap-aes-expected.txt        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -0,0 +1,34 @@
</span><ins>+Test wrapping and unwrapping AES keys with RSA-OAEP.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Importing RSA keys...
+Importing an AES key...
+Wrapping it...
+PASS wrappedKey.toString() is '[object ArrayBuffer]'
+Unwrapping it...
+PASS unwrappedKey.toString() is '[object Key]'
+PASS unwrappedKey.type is 'secret'
+PASS unwrappedKey.extractable is true
+PASS unwrappedKey.algorithm.name is 'aes-cbc'
+PASS unwrappedKey.algorithm.length is 256
+PASS unwrappedKey.usages is ['encrypt', 'decrypt']
+Exporting it...
+PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData)
+
+Wrapping the same key as JWK...
+PASS wrappedKey.toString() is '[object ArrayBuffer]'
+Unwrapping it...
+PASS unwrappedKey.toString() is '[object Key]'
+PASS unwrappedKey.type is 'secret'
+PASS unwrappedKey.extractable is true
+PASS unwrappedKey.algorithm.name is 'aes-cbc'
+PASS unwrappedKey.algorithm.length is 256
+PASS unwrappedKey.usages is ['encrypt', 'decrypt']
+Exporting it...
+PASS bytesToHexString(unwrappedKeyData) is bytesToHexString(aesKeyData)
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/rsa-oaep-wrap-unwrap-aes-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="trunkLayoutTestscryptosubtlersaoaepwrapunwrapaeshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsa-oaep-wrap-unwrap-aes.html (0 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-wrap-unwrap-aes.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-wrap-unwrap-aes.html        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -0,0 +1,103 @@
</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 wrapping and unwrapping AES keys with RSA-OAEP.");
+
+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-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+ e: "AQAB",
+ d: "eNLS37aCz7RXSNPD_DtLBJ6j5T8cSxdzRBCjPaI6WcGqJp16lq3UTwuoDLAqlA9oGYm238dsIWpuucP_lQtbWe-7SpxoI6_vmYGf7YVUHv1-DF9qiOmSrMmdxMnVOzYXY8RaT6thPjn_J5cfLV2xI_LwsrMtmpdSyNlgX0zTUhwtuahgAKMEChYjH2EnjHdHw6sY2-wApdcQI7ULE0oo5RzbQZpmuhcN9hiBc0L3hhF0qo50mbl02_65_GQ7DpVkXBxNgRBLzlPabmzzG2oAhfefLgYmSC1opaCkXE6vRWQNWNL45RZNZFYM3uoJghOMqGeocM0BpjdChHrPOlFvSQ",
+ p: "4miTuAjKMeH5uJ5KB397QUwhbkYEgSbcA2mifmSkvE2018gb55qkBHK1eVryf1_m43LNlc6O_ak6gfzdZIZvS5NCGjPl0q09plUpu8qFOSspBwA67qGH76lFlZLn_d4yglS7wfLru4_5Ys8qLLs-DqVLviwposOnyyWqwM5AXp0",
+ q: "xHYrzkivtmnz_sGchnWGc0q-pDOkKicptRpv2pMFIIXxnFX5aMeEXIZjVujXtwUy1UlFIN2GZJSvy5KJ79mu_XyNnFHMzedH-A3ee3u8h1UUrZF-vUu1_e4U_x67NN1dedzUSKynN7pFl3OkuShMBWGV-cwzOPdcVAfVuZlxUMc",
+ dp: "fBzDzYDUBmBQGop7Hn0dvf_T27V6RqpctWo074CQZcFbP2atFVtKSj3viWT3xid2VHzcgiDHdfpM3nEVlEO1wwIonGCSvdjGEOZiiFVOjrZAOVxA8guOjyyFvqbXke06VwPIIVvfKeSU2zuhbP__1tt6F_fxow4Kb2xonGT0GGk",
+ dq: "jmE2DiIPdhwDgLXAQpIaBqQ81bO3XfVT_LRULAwwwwlPuQV148H04zlh9TJ6Y2GZHYokV1U0eOBpJxfkb7dLYtpJpuiBjRf4yIUEoGlkkI_QlJnFSFr-YjGRdfNHqWBkxlSMZL770R9mIATndGkH7z5x-r9KwBZFC4FCG2hg_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", "unwrapKey"]).then(function(result) {
+ publicKey = result;
+ return crypto.subtle.importKey("jwk", asciiToUint8Array(JSON.stringify(privateKeyJSON)), null, extractable, ["wrapKey", "unwrapKey"]);
+}).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;
+ shouldBe("wrappedKey.toString()", "'[object ArrayBuffer]'");
+
+ debug("Unwrapping it...");
+ return crypto.subtle.unwrapKey("raw", wrappedKey, privateKey, wrapAlgorithm, "aes-cbc", extractable, ["encrypt", "decrypt"]);
+}).then(function(result) {
+ unwrappedKey = result;
+ shouldBe("unwrappedKey.toString()", "'[object Key]'");
+ shouldBe("unwrappedKey.type", "'secret'");
+ shouldBe("unwrappedKey.extractable", "true");
+ shouldBe("unwrappedKey.algorithm.name", "'aes-cbc'");
+ shouldBe("unwrappedKey.algorithm.length", "256");
+ shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt']");
+
+ debug("Exporting it...");
+ return crypto.subtle.exportKey("raw", unwrappedKey);
+}).then(function(result) {
+ unwrappedKeyData = result;
+ shouldBe("bytesToHexString(unwrappedKeyData)", "bytesToHexString(aesKeyData)");
+
+ debug("\nWrapping the same key as JWK...");
+ return crypto.subtle.wrapKey("jwk", aesKey, publicKey, wrapAlgorithm);
+}).then(function(result) {
+ wrappedKey = result;
+ shouldBe("wrappedKey.toString()", "'[object ArrayBuffer]'");
+
+ debug("Unwrapping it...");
+ return crypto.subtle.unwrapKey("jwk", wrappedKey, privateKey, wrapAlgorithm, "aes-cbc", extractable, ["encrypt", "decrypt"]);
+}).then(function(result) {
+ unwrappedKey = result;
+ shouldBe("unwrappedKey.toString()", "'[object Key]'");
+ shouldBe("unwrappedKey.type", "'secret'");
+ shouldBe("unwrappedKey.extractable", "true");
+ shouldBe("unwrappedKey.algorithm.name", "'aes-cbc'");
+ shouldBe("unwrappedKey.algorithm.length", "256");
+ shouldBe("unwrappedKey.usages", "['encrypt', 'decrypt']");
+
+ debug("Exporting it...");
+ return crypto.subtle.exportKey("raw", unwrappedKey);
+}).then(function(result) {
+ unwrappedKeyData = result;
+ shouldBe("bytesToHexString(unwrappedKeyData)", "bytesToHexString(aesKeyData)");
+ finishJSTest();
+});
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins><span class="cx">Property changes on: trunk/LayoutTests/crypto/subtle/rsa-oaep-wrap-unwrap-aes.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 (159943 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-12-02 19:49:43 UTC (rev 159943)
+++ trunk/Source/WebCore/ChangeLog        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -1,3 +1,54 @@
</span><ins>+2013-12-02 Alexey Proskuryakov <ap@apple.com>
+
+ Add support for WebCrypto RSA-OAEP
+ https://bugs.webkit.org/show_bug.cgi?id=125084
+
+ Reviewed by Sam Weinig.
+
+ Tests: crypto/subtle/rsa-oaep-key-manipulation.html
+ crypto/subtle/rsa-oaep-plaintext-length.html
+ crypto/subtle/rsa-oaep-wrap-unwrap-aes.html
+
+ * WebCore.xcodeproj/project.pbxproj: Added new files.
+
+ * bindings/js/JSCryptoAlgorithmDictionary.cpp:
+ (WebCore::createRsaOaepParams):
+ (WebCore::JSCryptoAlgorithmDictionary::createParametersForEncrypt):
+ (WebCore::JSCryptoAlgorithmDictionary::createParametersForDecrypt):
+ (WebCore::JSCryptoAlgorithmDictionary::createParametersForImportKey):
+ Added RSA-OAEP parameters.
+
+ * bindings/js/JSCryptoKeySerializationJWK.cpp:
+ (WebCore::JSCryptoKeySerializationJWK::reconcileAlgorithm):
+ (WebCore::JSCryptoKeySerializationJWK::keySizeIsValid):
+ (WebCore::JSCryptoKeySerializationJWK::addJWKAlgorithmToJSON):
+ Support RSA-OAEP in JWK. It is more limited than general WebCrypto, as JWK only
+ allows SHA-1 as hash.
+
+ * crypto/CommonCryptoUtilities.cpp: Added. (WebCore::getCommonCryptoDigestAlgorithm):
+ * crypto/CommonCryptoUtilities.h: Added.
+ Extracted some shared code and forward declarations for CommonCrypto.
+
+ * crypto/CryptoAlgorithmParameters.h: (WebCore::CryptoAlgorithmParameters::Class):
+ * crypto/parameters/CryptoAlgorithmRsaOaepParams.h: Added.
+ Added RsaOaepParams.
+
+ * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp: Added.
+ * crypto/algorithms/CryptoAlgorithmRSA_OAEP.h: Added.
+ * crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp: Added.
+
+ * crypto/mac/CryptoAlgorithmHMACMac.cpp:
+ (WebCore::getCommonCryptoHMACAlgorithm):
+ (WebCore::CryptoAlgorithmHMAC::platformSign):
+ (WebCore::CryptoAlgorithmHMAC::platformVerify):
+ * crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp:
+ * crypto/mac/CryptoKeyMac.cpp:
+ * crypto/mac/CryptoKeyRSAMac.cpp:
+ Use CommonCryptoUtilities.
+
+ * crypto/mac/CryptoAlgorithmRegistryMac.cpp:
+ (WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms): Register RSA-OAEP.
+
</ins><span class="cx"> 2013-12-02 Andres Gomez <agomez@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK] Fails to build with freetype 2.5.1
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (159943 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2013-12-02 19:49:43 UTC (rev 159943)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -5728,6 +5728,12 @@
</span><span class="cx">                 E1F80B8E183172B5007885C3 /* JSCryptoKeyPair.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */; };
</span><span class="cx">                 E1FE13641834351100892F13 /* CryptoDigestMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE13621834351100892F13 /* CryptoDigestMac.cpp */; };
</span><span class="cx">                 E1FE136718343A1000892F13 /* CryptoDigest.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE136618343A1000892F13 /* CryptoDigest.h */; };
</span><ins>+                E1FE136A183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE1368183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp */; };
+                E1FE136B183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE1369183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h */; };
+                E1FE136D183FE21D00892F13 /* CryptoAlgorithmRsaOaepParams.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE136C183FE21D00892F13 /* CryptoAlgorithmRsaOaepParams.h */; };
+                E1FE1370183FECF000892F13 /* CryptoAlgorithmRSA_OAEPMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE136E183FECF000892F13 /* CryptoAlgorithmRSA_OAEPMac.cpp */; };
+                E1FE137418402A6700892F13 /* CommonCryptoUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE137218402A6700892F13 /* CommonCryptoUtilities.cpp */; };
+                E1FE137518402A6700892F13 /* CommonCryptoUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FE137318402A6700892F13 /* CommonCryptoUtilities.h */; };
</ins><span class="cx">                 E1FF57A30F01255B00891EBB /* ThreadGlobalData.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */; };
</span><span class="cx">                 E1FF8F5F1807442100132674 /* SubtleCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F5D1807442100132674 /* SubtleCrypto.cpp */; };
</span><span class="lines">@@ -12848,6 +12854,12 @@
</span><span class="cx">                 E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoKeyPair.h; sourceTree = "<group>"; };
</span><span class="cx">                 E1FE13621834351100892F13 /* CryptoDigestMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoDigestMac.cpp; path = mac/CryptoDigestMac.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 E1FE136618343A1000892F13 /* CryptoDigest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoDigest.h; sourceTree = "<group>"; };
</span><ins>+                E1FE1368183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRSA_OAEP.cpp; sourceTree = "<group>"; };
+                E1FE1369183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRSA_OAEP.h; sourceTree = "<group>"; };
+                E1FE136C183FE21D00892F13 /* CryptoAlgorithmRsaOaepParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoAlgorithmRsaOaepParams.h; path = parameters/CryptoAlgorithmRsaOaepParams.h; sourceTree = "<group>"; };
+                E1FE136E183FECF000892F13 /* CryptoAlgorithmRSA_OAEPMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoAlgorithmRSA_OAEPMac.cpp; path = mac/CryptoAlgorithmRSA_OAEPMac.cpp; sourceTree = "<group>"; };
+                E1FE137218402A6700892F13 /* CommonCryptoUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommonCryptoUtilities.cpp; sourceTree = "<group>"; };
+                E1FE137318402A6700892F13 /* CommonCryptoUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptoUtilities.h; sourceTree = "<group>"; };
</ins><span class="cx">                 E1FF57A20F01255B00891EBB /* ThreadGlobalData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadGlobalData.h; sourceTree = "<group>"; };
</span><span class="cx">                 E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadGlobalData.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 E1FF8F5C1807364B00132674 /* SubtleCrypto.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = SubtleCrypto.idl; sourceTree = "<group>"; };
</span><span class="lines">@@ -20406,10 +20418,13 @@
</span><span class="cx">                 E172AF71180F343400FBADB9 /* mac */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                E1FE137218402A6700892F13 /* CommonCryptoUtilities.cpp */,
+                                E1FE137318402A6700892F13 /* CommonCryptoUtilities.h */,
</ins><span class="cx">                                 E125F843182425C900D84CD9 /* CryptoAlgorithmAES_CBCMac.cpp */,
</span><span class="cx">                                 E125F8371822F1EB00D84CD9 /* CryptoAlgorithmHMACMac.cpp */,
</span><span class="cx">                                 E1BB84AC1822CA7400525043 /* CryptoAlgorithmRegistryMac.cpp */,
</span><span class="cx">                                 E1C266D618317AB4003F8B33 /* CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp */,
</span><ins>+                                E1FE136E183FECF000892F13 /* CryptoAlgorithmRSA_OAEPMac.cpp */,
</ins><span class="cx">                                 E19AC3F8182566F700349426 /* CryptoKeyMac.cpp */,
</span><span class="cx">                                 E164FAA418315E1A00DB4E61 /* CryptoKeyRSAMac.cpp */,
</span><span class="cx">                                 E1FE13621834351100892F13 /* CryptoDigestMac.cpp */,
</span><span class="lines">@@ -20424,6 +20439,8 @@
</span><span class="cx">                                 E125F8401824253A00D84CD9 /* CryptoAlgorithmAES_CBC.h */,
</span><span class="cx">                                 E125F82F1822F11B00D84CD9 /* CryptoAlgorithmHMAC.cpp */,
</span><span class="cx">                                 E125F8301822F11B00D84CD9 /* CryptoAlgorithmHMAC.h */,
</span><ins>+                                E1FE1368183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp */,
+                                E1FE1369183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h */,
</ins><span class="cx">                                 E1BD3317182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp */,
</span><span class="cx">                                 E1BD3318182D8DDD00C05D9F /* CryptoAlgorithmRSASSA_PKCS1_v1_5.h */,
</span><span class="cx">                                 E125F8291822CFEC00D84CD9 /* CryptoAlgorithmSHA1.cpp */,
</span><span class="lines">@@ -22437,6 +22454,7 @@
</span><span class="cx">                                 1C4C8F020AD85D87009475CE /* DeleteButtonController.h in Headers */,
</span><span class="cx">                                 93309DDF099E64920056E581 /* DeleteFromTextNodeCommand.h in Headers */,
</span><span class="cx">                                 07C59B6417F4D1C4000FBCBB /* MockMediaStreamCenter.h in Headers */,
</span><ins>+                                E1FE136B183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.h in Headers */,
</ins><span class="cx">                                 93309DE1099E64920056E581 /* DeleteSelectionCommand.h in Headers */,
</span><span class="cx">                                 FD1660A513787C6D001FFA7B /* DenormalDisabler.h in Headers */,
</span><span class="cx">                                 E100EE761546EAC100BA11D1 /* DeprecatedStyleBuilder.h in Headers */,
</span><span class="lines">@@ -22586,6 +22604,7 @@
</span><span class="cx">                                 BC00F0090E0A185500FD04E3 /* DOMFileListInternal.h in Headers */,
</span><span class="cx">                                 2ED609BD1145B07100C8684E /* DOMFormData.h in Headers */,
</span><span class="cx">                                 BC1A37B6097C715F0019F3D8 /* DOMHTML.h in Headers */,
</span><ins>+                                E1FE137518402A6700892F13 /* CommonCryptoUtilities.h in Headers */,
</ins><span class="cx">                                 85DF81270AA7787200486AD7 /* DOMHTMLAnchorElement.h in Headers */,
</span><span class="cx">                                 B595FF471824CEE300FF51CD /* RenderIterator.h in Headers */,
</span><span class="cx">                                 85E7119B0AC5D5350053270F /* DOMHTMLAnchorElementInternal.h in Headers */,
</span><span class="lines">@@ -23706,6 +23725,7 @@
</span><span class="cx">                                 E19AC3EF1824DC7900349426 /* CryptoAlgorithmSHA224.h in Headers */,
</span><span class="cx">                                 078E092B17D14D1C00420AA1 /* RTCStatsRequestImpl.h in Headers */,
</span><span class="cx">                                 B266CD4E0C3AEC6500EB08D2 /* JSSVGException.h in Headers */,
</span><ins>+                                E1FE136D183FE21D00892F13 /* CryptoAlgorithmRsaOaepParams.h in Headers */,
</ins><span class="cx">                                 B2FA3D6B0AB75A6F000E5AC4 /* JSSVGFEBlendElement.h in Headers */,
</span><span class="cx">                                 B2FA3D6D0AB75A6F000E5AC4 /* JSSVGFEColorMatrixElement.h in Headers */,
</span><span class="cx">                                 B2FA3D6F0AB75A6F000E5AC4 /* JSSVGFEComponentTransferElement.h in Headers */,
</span><span class="lines">@@ -26712,6 +26732,7 @@
</span><span class="cx">                                 1403BA0C09EB18C700797C7F /* JSDOMWindow.cpp in Sources */,
</span><span class="cx">                                 BC6932730D7E293900AE44D1 /* JSDOMWindowBase.cpp in Sources */,
</span><span class="cx">                                 BCD9C2620C17AA67005C90A2 /* JSDOMWindowCustom.cpp in Sources */,
</span><ins>+                                E1FE136A183FE1AB00892F13 /* CryptoAlgorithmRSA_OAEP.cpp in Sources */,
</ins><span class="cx">                                 BCBFB53C0DCD29CF0019B3E5 /* JSDOMWindowShell.cpp in Sources */,
</span><span class="cx">                                 FD7868B9136B999200D403DF /* JSDynamicsCompressorNode.cpp in Sources */,
</span><span class="cx">                                 65DF31F909D1CC60000BE325 /* JSElement.cpp in Sources */,
</span><span class="lines">@@ -28159,6 +28180,7 @@
</span><span class="cx">                                 1FAFBF1815A5FA6E00083A20 /* UTIUtilities.mm in Sources */,
</span><span class="cx">                                 2E3BBF071162DA1100B9409A /* UUID.cpp in Sources */,
</span><span class="cx">                                 50D32857163B313F0016111E /* ValidatedCustomFilterOperation.cpp in Sources */,
</span><ins>+                                E1FE137418402A6700892F13 /* CommonCryptoUtilities.cpp in Sources */,
</ins><span class="cx">                                 F5A154271279534D00D0B0C0 /* ValidationMessage.cpp in Sources */,
</span><span class="cx">                                 FD3160AE12B026F700C1A359 /* VectorMath.cpp in Sources */,
</span><span class="cx">                                 BE88E0DE1715D2A200658D98 /* VideoTrack.cpp in Sources */,
</span><span class="lines">@@ -28202,6 +28224,7 @@
</span><span class="cx">                                 01D3CF8414BD0A3000FE9970 /* WebGLContextObject.cpp in Sources */,
</span><span class="cx">                                 A0EE0DF5144F825500F80B0D /* WebGLDebugRendererInfo.cpp in Sources */,
</span><span class="cx">                                 A0EE0DF7144F825500F80B0D /* WebGLDebugShaders.cpp in Sources */,
</span><ins>+                                E1FE1370183FECF000892F13 /* CryptoAlgorithmRSA_OAEPMac.cpp in Sources */,
</ins><span class="cx">                                 6E3FAE8E14733FDB00E42307 /* WebGLDepthTexture.cpp in Sources */,
</span><span class="cx">                                 6EBF0E5412A8929800DB1709 /* WebGLExtension.cpp in Sources */,
</span><span class="cx">                                 49C7B9CE1042D32F0009D447 /* WebGLFramebuffer.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCryptoAlgorithmDictionarycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp (159943 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp        2013-12-02 19:49:43 UTC (rev 159943)
+++ trunk/Source/WebCore/bindings/js/JSCryptoAlgorithmDictionary.cpp        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include "CryptoAlgorithmRegistry.h"
</span><span class="cx"> #include "CryptoAlgorithmRsaKeyGenParams.h"
</span><span class="cx"> #include "CryptoAlgorithmRsaKeyParamsWithHash.h"
</span><ins>+#include "CryptoAlgorithmRsaOaepParams.h"
</ins><span class="cx"> #include "CryptoAlgorithmRsaSsaParams.h"
</span><span class="cx"> #include "ExceptionCode.h"
</span><span class="cx"> #include "JSCryptoOperationData.h"
</span><span class="lines">@@ -244,6 +245,40 @@
</span><span class="cx"> return std::make_unique<CryptoAlgorithmRsaKeyParamsWithHash>();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static std::unique_ptr<CryptoAlgorithmParameters> createRsaOaepParams(ExecState* exec, JSValue value)
+{
+ if (!value.isObject()) {
+ throwTypeError(exec);
+ return nullptr;
+ }
+
+ JSDictionary jsDictionary(exec, value.getObject());
+ auto result = std::make_unique<CryptoAlgorithmRsaOaepParams>();
+
+ if (!getHashAlgorithm(jsDictionary, result->hash)) {
+ ASSERT(exec->hadException());
+ return nullptr;
+ }
+
+ JSValue labelValue = getProperty(exec, value.getObject(), "label");
+ if (exec->hadException())
+ return nullptr;
+
+ result->hasLabel = !labelValue.isUndefinedOrNull();
+ if (!result->hasLabel)
+ return std::move(result);
+
+ CryptoOperationData labelData;
+ if (!cryptoOperationDataFromJSValue(exec, labelValue, labelData)) {
+ ASSERT(exec->hadException());
+ return nullptr;
+ }
+
+ result->label.append(labelData.first, labelData.second);
+
+ return std::move(result);
+}
+
</ins><span class="cx"> static std::unique_ptr<CryptoAlgorithmParameters> createRsaSsaParams(ExecState* exec, JSValue value)
</span><span class="cx"> {
</span><span class="cx"> if (!value.isObject()) {
</span><span class="lines">@@ -268,7 +303,10 @@
</span><span class="cx"> case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
</span><span class="cx"> case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
</span><span class="cx"> case CryptoAlgorithmIdentifier::RSA_PSS:
</span><ins>+ setDOMException(exec, NOT_SUPPORTED_ERR);
+ return nullptr;
</ins><span class="cx"> case CryptoAlgorithmIdentifier::RSA_OAEP:
</span><ins>+ return createRsaOaepParams(exec, value);
</ins><span class="cx"> case CryptoAlgorithmIdentifier::ECDSA:
</span><span class="cx"> case CryptoAlgorithmIdentifier::ECDH:
</span><span class="cx"> case CryptoAlgorithmIdentifier::AES_CTR:
</span><span class="lines">@@ -300,7 +338,10 @@
</span><span class="cx"> case CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5:
</span><span class="cx"> case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
</span><span class="cx"> case CryptoAlgorithmIdentifier::RSA_PSS:
</span><ins>+ setDOMException(exec, NOT_SUPPORTED_ERR);
+ return nullptr;
</ins><span class="cx"> case CryptoAlgorithmIdentifier::RSA_OAEP:
</span><ins>+ return createRsaOaepParams(exec, value);
</ins><span class="cx"> case CryptoAlgorithmIdentifier::ECDSA:
</span><span class="cx"> case CryptoAlgorithmIdentifier::ECDH:
</span><span class="cx"> case CryptoAlgorithmIdentifier::AES_CTR:
</span><span class="lines">@@ -528,7 +569,9 @@
</span><span class="cx"> case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
</span><span class="cx"> return createRsaKeyParamsWithHash(exec, value);
</span><span class="cx"> case CryptoAlgorithmIdentifier::RSA_PSS:
</span><ins>+ return std::make_unique<CryptoAlgorithmParameters>();
</ins><span class="cx"> case CryptoAlgorithmIdentifier::RSA_OAEP:
</span><ins>+ return createRsaKeyParamsWithHash(exec, value);
</ins><span class="cx"> case CryptoAlgorithmIdentifier::ECDSA:
</span><span class="cx"> case CryptoAlgorithmIdentifier::ECDH:
</span><span class="cx"> case CryptoAlgorithmIdentifier::AES_CTR:
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCryptoKeySerializationJWKcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp (159943 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp        2013-12-02 19:49:43 UTC (rev 159943)
+++ trunk/Source/WebCore/bindings/js/JSCryptoKeySerializationJWK.cpp        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -190,6 +190,9 @@
</span><span class="cx"> } else if (m_jwkAlgorithmName == "RS512") {
</span><span class="cx"> algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5);
</span><span class="cx"> parameters = createRSAKeyParametersWithHash(CryptoAlgorithmIdentifier::SHA_512);
</span><ins>+ } else if (m_jwkAlgorithmName == "RSA-OAEP") {
+ algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::RSA_OAEP);
+ parameters = createRSAKeyParametersWithHash(CryptoAlgorithmIdentifier::SHA_1);
</ins><span class="cx"> } else if (m_jwkAlgorithmName == "A128CBC") {
</span><span class="cx"> algorithm = CryptoAlgorithmRegistry::shared().create(CryptoAlgorithmIdentifier::AES_CBC);
</span><span class="cx"> parameters = std::make_unique<CryptoAlgorithmParameters>();
</span><span class="lines">@@ -218,7 +221,8 @@
</span><span class="cx">
</span><span class="cx"> if (algorithm->identifier() == CryptoAlgorithmIdentifier::HMAC)
</span><span class="cx"> return toCryptoAlgorithmHmacParams(*parameters).hash == toCryptoAlgorithmHmacParams(*suggestedParameters).hash;
</span><del>- if (algorithm->identifier() == CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5) {
</del><ins>+ if (algorithm->identifier() == CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5
+ || algorithm->identifier() == CryptoAlgorithmIdentifier::RSA_OAEP) {
</ins><span class="cx"> CryptoAlgorithmRsaKeyParamsWithHash& rsaKeyParameters = toCryptoAlgorithmRsaKeyParamsWithHash(*parameters);
</span><span class="cx"> CryptoAlgorithmRsaKeyParamsWithHash& suggestedRSAKeyParameters = toCryptoAlgorithmRsaKeyParamsWithHash(*suggestedParameters);
</span><span class="cx"> ASSERT(rsaKeyParameters.hasHash);
</span><span class="lines">@@ -283,6 +287,8 @@
</span><span class="cx"> return sizeInBits >= 2048;
</span><span class="cx"> if (m_jwkAlgorithmName == "RS512")
</span><span class="cx"> return sizeInBits >= 2048;
</span><ins>+ if (m_jwkAlgorithmName == "RSA_OAEP")
+ return sizeInBits >= 2048;
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -538,6 +544,17 @@
</span><span class="cx"> }
</span><span class="cx"> break;
</span><span class="cx"> }
</span><ins>+ case CryptoAlgorithmIdentifier::RSA_OAEP: {
+ const CryptoKeyRSA& rsaKey = toCryptoKeyRSA(key);
+ CryptoAlgorithmIdentifier hash;
+ // WebCrypto RSA-OAEP keys are not tied to any particular hash, unless previously imported from JWK, which only supports SHA-1.
+ if (rsaKey.isRestrictedToHash(hash) && hash != CryptoAlgorithmIdentifier::SHA_1)
+ break;
+ if (rsaKey.keySizeInBits() < 2048)
+ break;
+ jwkAlgorithm = "RSA-OAEP";
+ break;
+ }
</ins><span class="cx"> default:
</span><span class="cx"> break;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCommonCryptoUtilitiescpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/crypto/CommonCryptoUtilities.cpp (0 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CommonCryptoUtilities.cpp         (rev 0)
+++ trunk/Source/WebCore/crypto/CommonCryptoUtilities.cpp        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+/*
+ * Copyright (C) 2013 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.
+ */
+
+#include "config.h"
+#include "CommonCryptoUtilities.h"
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+bool getCommonCryptoDigestAlgorithm(CryptoAlgorithmIdentifier hashFunction, CCDigestAlgorithm& algorithm)
+{
+ switch (hashFunction) {
+ case CryptoAlgorithmIdentifier::SHA_1:
+ algorithm = kCCDigestSHA1;
+ return true;
+ case CryptoAlgorithmIdentifier::SHA_224:
+ algorithm = kCCDigestSHA224;
+ return true;
+ case CryptoAlgorithmIdentifier::SHA_256:
+ algorithm = kCCDigestSHA256;
+ return true;
+ case CryptoAlgorithmIdentifier::SHA_384:
+ algorithm = kCCDigestSHA384;
+ return true;
+ case CryptoAlgorithmIdentifier::SHA_512:
+ algorithm = kCCDigestSHA512;
+ return true;
+ default:
+ return false;
+ }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SUBTLE_CRYPTO)
</ins><span class="cx">Property changes on: trunk/Source/WebCore/crypto/CommonCryptoUtilities.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkSourceWebCorecryptoCommonCryptoUtilitiesh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/crypto/CommonCryptoUtilities.h (0 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CommonCryptoUtilities.h         (rev 0)
+++ trunk/Source/WebCore/crypto/CommonCryptoUtilities.h        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -0,0 +1,94 @@
</span><ins>+/*
+ * Copyright (C) 2013 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.
+ */
+
+#ifndef CommonCryptoUtilities_h
+#define CommonCryptoUtilities_h
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+#include "CryptoAlgorithmIdentifier.h"
+
+#if defined(__has_include)
+#if __has_include(<CommonCrypto/CommonRSACryptor.h>)
+#include <CommonCrypto/CommonRSACryptor.h>
+#endif
+#endif
+
+#if defined(__has_include) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
+#if __has_include(<CommonCrypto/CommonRandomSPI.h>)
+#include <CommonCrypto/CommonRandomSPI.h>
+#endif
+#endif
+
+#ifndef _CC_RSACRYPTOR_H_
+enum {
+ kCCDigestSHA1 = 8,
+ kCCDigestSHA224 = 9,
+ kCCDigestSHA256 = 10,
+ kCCDigestSHA384 = 11,
+ kCCDigestSHA512 = 12,
+};
+typedef uint32_t CCDigestAlgorithm;
+
+enum {
+ ccRSAKeyPublic = 0,
+ ccRSAKeyPrivate = 1
+};
+typedef uint32_t CCRSAKeyType;
+
+enum {
+ ccPKCS1Padding = 1001,
+ ccOAEPPadding = 1002
+};
+typedef uint32_t CCAsymmetricPadding;
+
+enum {
+ kCCNotVerified = -4306
+};
+#endif
+
+typedef struct __CCRandom *CCRandomRef;
+extern const CCRandomRef kCCRandomDefault;
+extern "C" int CCRandomCopyBytes(CCRandomRef rnd, void *bytes, size_t count);
+
+extern "C" CCCryptorStatus CCRSACryptorEncrypt(CCRSACryptorRef publicKey, CCAsymmetricPadding padding, const void *plainText, size_t plainTextLen, void *cipherText, size_t *cipherTextLen, const void *tagData, size_t tagDataLen, CCDigestAlgorithm digestType);
+extern "C" CCCryptorStatus CCRSACryptorDecrypt(CCRSACryptorRef privateKey, CCAsymmetricPadding padding, const void *cipherText, size_t cipherTextLen, void *plainText, size_t *plainTextLen, const void *tagData, size_t tagDataLen, CCDigestAlgorithm digestType);
+extern "C" CCCryptorStatus CCRSACryptorSign(CCRSACryptorRef privateKey, CCAsymmetricPadding padding, const void *hashToSign, size_t hashSignLen, CCDigestAlgorithm digestType, size_t saltLen, void *signedData, size_t *signedDataLen);
+extern "C" CCCryptorStatus CCRSACryptorVerify(CCRSACryptorRef publicKey, CCAsymmetricPadding padding, const void *hash, size_t hashLen, CCDigestAlgorithm digestType, size_t saltLen, const void *signedData, size_t signedDataLen);
+extern "C" CCCryptorStatus CCRSACryptorCreateFromData(CCRSAKeyType keyType, uint8_t *modulus, size_t modulusLength, uint8_t *exponent, size_t exponentLength, uint8_t *p, size_t pLength, uint8_t *q, size_t qLength, CCRSACryptorRef *ref);
+extern "C" CCCryptorStatus CCRSACryptorGeneratePair(size_t keysize, uint32_t e, CCRSACryptorRef *publicKey, CCRSACryptorRef *privateKey);
+extern "C" CCRSACryptorRef CCRSACryptorGetPublicKeyFromPrivateKey(CCRSACryptorRef privkey);
+extern "C" void CCRSACryptorRelease(CCRSACryptorRef key);
+extern "C" CCCryptorStatus CCRSAGetKeyComponents(CCRSACryptorRef rsaKey, uint8_t *modulus, size_t *modulusLength, uint8_t *exponent, size_t *exponentLength, uint8_t *p, size_t *pLength, uint8_t *q, size_t *qLength);
+extern "C" CCRSAKeyType CCRSAGetKeyType(CCRSACryptorRef key);
+
+namespace WebCore {
+
+bool getCommonCryptoDigestAlgorithm(CryptoAlgorithmIdentifier, CCDigestAlgorithm&);
+
+} // namespace WebCore
+
+#endif // ENABLE(SUBTLE_CRYPTO)
+#endif // CommonCryptoUtilities_h
</ins><span class="cx">Property changes on: trunk/Source/WebCore/crypto/CommonCryptoUtilities.h
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkSourceWebCorecryptoCryptoAlgorithmParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoAlgorithmParameters.h (159943 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithmParameters.h        2013-12-02 19:49:43 UTC (rev 159943)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithmParameters.h        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> HmacParams,
</span><span class="cx"> RsaKeyGenParams,
</span><span class="cx"> RsaKeyParamsWithHash,
</span><ins>+ RsaOaepParams,
</ins><span class="cx"> RsaSsaParams
</span><span class="cx"> };
</span><span class="cx"> virtual Class parametersClass() const { return Class::None; }
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp (0 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp         (rev 0)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -0,0 +1,127 @@
</span><ins>+/*
+ * Copyright (C) 2013 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.
+ */
+
+#include "config.h"
+#include "CryptoAlgorithmRSA_OAEP.h"
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+#include "CryptoAlgorithmRsaKeyGenParams.h"
+#include "CryptoAlgorithmRsaKeyParamsWithHash.h"
+#include "CryptoAlgorithmRsaOaepParams.h"
+#include "CryptoKeyDataRSAComponents.h"
+#include "CryptoKeyRSA.h"
+#include "ExceptionCode.h"
+
+namespace WebCore {
+
+const char* const CryptoAlgorithmRSA_OAEP::s_name = "rsa-oaep";
+
+CryptoAlgorithmRSA_OAEP::CryptoAlgorithmRSA_OAEP()
+{
+}
+
+CryptoAlgorithmRSA_OAEP::~CryptoAlgorithmRSA_OAEP()
+{
+}
+
+std::unique_ptr<CryptoAlgorithm> CryptoAlgorithmRSA_OAEP::create()
+{
+ return std::unique_ptr<CryptoAlgorithm>(new CryptoAlgorithmRSA_OAEP);
+}
+
+CryptoAlgorithmIdentifier CryptoAlgorithmRSA_OAEP::identifier() const
+{
+ return s_identifier;
+}
+
+bool CryptoAlgorithmRSA_OAEP::keyAlgorithmMatches(const CryptoAlgorithmRsaOaepParams& algorithmParameters, const CryptoKey& key) const
+{
+ if (key.algorithmIdentifier() != s_identifier)
+ return false;
+ ASSERT(isCryptoKeyRSA(key));
+
+ CryptoAlgorithmIdentifier keyHash;
+ if (toCryptoKeyRSA(key).isRestrictedToHash(keyHash) && keyHash != algorithmParameters.hash)
+ return false;
+
+ return true;
+}
+
+void CryptoAlgorithmRSA_OAEP::encrypt(const CryptoAlgorithmParameters& parameters, const CryptoKey& key, const CryptoOperationData& data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode& ec)
+{
+ const CryptoAlgorithmRsaOaepParams& rsaOAEPParameters = toCryptoAlgorithmRsaOaepParams(parameters);
+
+ if (!keyAlgorithmMatches(rsaOAEPParameters, key)) {
+ ec = NOT_SUPPORTED_ERR;
+ return;
+ }
+
+ platformEncrypt(rsaOAEPParameters, toCryptoKeyRSA(key), data, std::move(callback), std::move(failureCallback), ec);
+}
+
+void CryptoAlgorithmRSA_OAEP::decrypt(const CryptoAlgorithmParameters& parameters, const CryptoKey& key, const CryptoOperationData& data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode& ec)
+{
+ const CryptoAlgorithmRsaOaepParams& rsaOAEPParameters = toCryptoAlgorithmRsaOaepParams(parameters);
+
+ if (!keyAlgorithmMatches(rsaOAEPParameters, key)) {
+ ec = NOT_SUPPORTED_ERR;
+ return;
+ }
+
+ platformDecrypt(rsaOAEPParameters, toCryptoKeyRSA(key), data, std::move(callback), std::move(failureCallback), ec);
+}
+
+void CryptoAlgorithmRSA_OAEP::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsage usages, KeyOrKeyPairCallback callback, VoidCallback failureCallback, ExceptionCode&)
+{
+ const CryptoAlgorithmRsaKeyGenParams& rsaParameters = toCryptoAlgorithmRsaKeyGenParams(parameters);
+
+ auto keyPairCallback = [callback](CryptoKeyPair& pair) {
+ callback(nullptr, &pair);
+ };
+
+ CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier::RSA_OAEP, rsaParameters.modulusLength, rsaParameters.publicExponent, extractable, usages, std::move(keyPairCallback), std::move(failureCallback));
+}
+
+void CryptoAlgorithmRSA_OAEP::importKey(const CryptoAlgorithmParameters& parameters, const CryptoKeyData& keyData, bool extractable, CryptoKeyUsage usage, KeyCallback callback, VoidCallback failureCallback, ExceptionCode&)
+{
+ const CryptoAlgorithmRsaKeyParamsWithHash& rsaKeyParameters = toCryptoAlgorithmRsaKeyParamsWithHash(parameters);
+ const CryptoKeyDataRSAComponents& rsaComponents = toCryptoKeyDataRSAComponents(keyData);
+
+ RefPtr<CryptoKeyRSA> result = CryptoKeyRSA::create(CryptoAlgorithmIdentifier::RSA_OAEP, rsaComponents, extractable, usage);
+ if (!result) {
+ failureCallback();
+ return;
+ }
+
+ if (rsaKeyParameters.hasHash)
+ result->restrictToHash(rsaKeyParameters.hash);
+
+ callback(*result);
+}
+
+}
+
+#endif // ENABLE(SUBTLE_CRYPTO)
</ins><span class="cx">Property changes on: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSA_OAEPh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h (0 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h         (rev 0)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+/*
+ * Copyright (C) 2013 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.
+ */
+
+#ifndef CryptoAlgorithmRSA_OAEP_h
+#define CryptoAlgorithmRSA_OAEP_h
+
+#include "CryptoAlgorithm.h"
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+class CryptoAlgorithmRsaOaepParams;
+class CryptoKeyRSA;
+
+class CryptoAlgorithmRSA_OAEP FINAL : public CryptoAlgorithm {
+public:
+ static const char* const s_name;
+ static const CryptoAlgorithmIdentifier s_identifier = CryptoAlgorithmIdentifier::RSA_OAEP;
+
+ static std::unique_ptr<CryptoAlgorithm> create();
+
+ virtual CryptoAlgorithmIdentifier identifier() const OVERRIDE;
+
+ virtual void encrypt(const CryptoAlgorithmParameters&, const CryptoKey&, const CryptoOperationData&, VectorCallback, VoidCallback failureCallback, ExceptionCode&) OVERRIDE;
+ virtual void decrypt(const CryptoAlgorithmParameters&, const CryptoKey&, const CryptoOperationData&, VectorCallback, VoidCallback failureCallback, ExceptionCode&) OVERRIDE;
+ virtual void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsage, KeyOrKeyPairCallback, VoidCallback failureCallback, ExceptionCode&) OVERRIDE;
+ virtual void importKey(const CryptoAlgorithmParameters&, const CryptoKeyData&, bool extractable, CryptoKeyUsage, KeyCallback, VoidCallback failureCallback, ExceptionCode&) OVERRIDE;
+
+private:
+ CryptoAlgorithmRSA_OAEP();
+ virtual ~CryptoAlgorithmRSA_OAEP();
+
+ bool keyAlgorithmMatches(const CryptoAlgorithmRsaOaepParams& algorithmParameters, const CryptoKey&) const;
+ void platformEncrypt(const CryptoAlgorithmRsaOaepParams&, const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback, VoidCallback failureCallback, ExceptionCode&);
+ void platformDecrypt(const CryptoAlgorithmRsaOaepParams&, const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback, VoidCallback failureCallback, ExceptionCode&);
+};
+
+}
+
+#endif // ENABLE(SUBTLE_CRYPTO)
+#endif // CryptoAlgorithmRSA_OAEP_h
</ins><span class="cx">Property changes on: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.h
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkSourceWebCorecryptomacCryptoAlgorithmHMACMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp (159943 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp        2013-12-02 19:49:43 UTC (rev 159943)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-static bool getCommonCryptoAlgorithm(CryptoAlgorithmIdentifier hashFunction, CCHmacAlgorithm& algorithm)
</del><ins>+static bool getCommonCryptoHMACAlgorithm(CryptoAlgorithmIdentifier hashFunction, CCHmacAlgorithm& algorithm)
</ins><span class="cx"> {
</span><span class="cx"> switch (hashFunction) {
</span><span class="cx"> case CryptoAlgorithmIdentifier::SHA_1:
</span><span class="lines">@@ -91,7 +91,7 @@
</span><span class="cx"> void CryptoAlgorithmHMAC::platformSign(const CryptoAlgorithmHmacParams& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& data, VectorCallback callback, VoidCallback, ExceptionCode& ec)
</span><span class="cx"> {
</span><span class="cx"> CCHmacAlgorithm algorithm;
</span><del>- if (!getCommonCryptoAlgorithm(parameters.hash, algorithm)) {
</del><ins>+ if (!getCommonCryptoHMACAlgorithm(parameters.hash, algorithm)) {
</ins><span class="cx"> ec = NOT_SUPPORTED_ERR;
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="lines">@@ -104,7 +104,7 @@
</span><span class="cx"> void CryptoAlgorithmHMAC::platformVerify(const CryptoAlgorithmHmacParams& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& expectedSignature, const CryptoOperationData& data, BoolCallback callback, VoidCallback, ExceptionCode& ec)
</span><span class="cx"> {
</span><span class="cx"> CCHmacAlgorithm algorithm;
</span><del>- if (!getCommonCryptoAlgorithm(parameters.hash, algorithm)) {
</del><ins>+ if (!getCommonCryptoHMACAlgorithm(parameters.hash, algorithm)) {
</ins><span class="cx"> ec = NOT_SUPPORTED_ERR;
</span><span class="cx"> return;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoAlgorithmRSASSA_PKCS1_v1_5Maccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp (159943 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp        2013-12-02 19:49:43 UTC (rev 159943)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -28,66 +28,15 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx">
</span><ins>+#include "CommonCryptoUtilities.h"
</ins><span class="cx"> #include "CryptoAlgorithmRsaSsaParams.h"
</span><span class="cx"> #include "CryptoDigest.h"
</span><span class="cx"> #include "CryptoKeyRSA.h"
</span><span class="cx"> #include "ExceptionCode.h"
</span><span class="cx"> #include <CommonCrypto/CommonCryptor.h>
</span><span class="cx">
</span><del>-#if defined(__has_include)
-#if __has_include(<CommonCrypto/CommonRSACryptor.h>)
-#include <CommonCrypto/CommonRSACryptor.h>
-#endif
-#endif
-
-#ifndef _CC_RSACRYPTOR_H_
-enum {
- ccPKCS1Padding = 1001
-};
-typedef uint32_t CCAsymmetricPadding;
-
-enum {
- kCCDigestSHA1 = 8,
- kCCDigestSHA224 = 9,
- kCCDigestSHA256 = 10,
- kCCDigestSHA384 = 11,
- kCCDigestSHA512 = 12,
-};
-typedef uint32_t CCDigestAlgorithm;
-
-enum {
- kCCNotVerified = -4306
-};
-#endif
-
-extern "C" CCCryptorStatus CCRSACryptorSign(CCRSACryptorRef privateKey, CCAsymmetricPadding padding, const void *hashToSign, size_t hashSignLen, CCDigestAlgorithm digestType, size_t saltLen, void *signedData, size_t *signedDataLen);
-extern "C" CCCryptorStatus CCRSACryptorVerify(CCRSACryptorRef publicKey, CCAsymmetricPadding padding, const void *hash, size_t hashLen, CCDigestAlgorithm digestType, size_t saltLen, const void *signedData, size_t signedDataLen);
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-static bool getCommonCryptoDigestAlgorithm(CryptoAlgorithmIdentifier hashFunction, CCDigestAlgorithm& algorithm)
-{
- switch (hashFunction) {
- case CryptoAlgorithmIdentifier::SHA_1:
- algorithm = kCCDigestSHA1;
- return true;
- case CryptoAlgorithmIdentifier::SHA_224:
- algorithm = kCCDigestSHA224;
- return true;
- case CryptoAlgorithmIdentifier::SHA_256:
- algorithm = kCCDigestSHA256;
- return true;
- case CryptoAlgorithmIdentifier::SHA_384:
- algorithm = kCCDigestSHA384;
- return true;
- case CryptoAlgorithmIdentifier::SHA_512:
- algorithm = kCCDigestSHA512;
- return true;
- default:
- return false;
- }
-}
-
</del><span class="cx"> void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoAlgorithmRsaSsaParams& parameters, const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode& ec)
</span><span class="cx"> {
</span><span class="cx"> CCDigestAlgorithm digestAlgorithm;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoAlgorithmRSA_OAEPMaccpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp (0 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp         (rev 0)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -0,0 +1,81 @@
</span><ins>+/*
+ * Copyright (C) 2013 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.
+ */
+
+#include "config.h"
+#include "CryptoAlgorithmRSA_OAEP.h"
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+#include "CommonCryptoUtilities.h"
+#include "CryptoAlgorithmRsaOaepParams.h"
+#include "CryptoKeyRSA.h"
+#include "ExceptionCode.h"
+
+namespace WebCore {
+
+void CryptoAlgorithmRSA_OAEP::platformEncrypt(const CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode& ec)
+{
+ CCDigestAlgorithm digestAlgorithm;
+ if (!getCommonCryptoDigestAlgorithm(parameters.hash, digestAlgorithm)) {
+ ec = NOT_SUPPORTED_ERR;
+ return;
+ }
+
+ Vector<uint8_t> cipherText(1024);
+ size_t cipherTextLength = cipherText.size();
+ ASSERT(parameters.hasLabel || parameters.label.isEmpty());
+ CCCryptorStatus status = CCRSACryptorEncrypt(key.platformKey(), ccOAEPPadding, data.first, data.second, cipherText.data(), &cipherTextLength, parameters.label.data(), parameters.label.size(), digestAlgorithm);
+ if (status) {
+ failureCallback();
+ return;
+ }
+
+ cipherText.resize(cipherTextLength);
+ callback(cipherText);
+}
+
+void CryptoAlgorithmRSA_OAEP::platformDecrypt(const CryptoAlgorithmRsaOaepParams& parameters, const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback callback, VoidCallback failureCallback, ExceptionCode& ec)
+{
+ CCDigestAlgorithm digestAlgorithm;
+ if (!getCommonCryptoDigestAlgorithm(parameters.hash, digestAlgorithm)) {
+ ec = NOT_SUPPORTED_ERR;
+ return;
+ }
+
+ Vector<uint8_t> plainText(1024);
+ size_t plainTextLength = plainText.size();
+ CCCryptorStatus status = CCRSACryptorDecrypt(key.platformKey(), ccOAEPPadding, data.first, data.second, plainText.data(), &plainTextLength, parameters.label.data(), parameters.label.size(), digestAlgorithm);
+ if (status) {
+ failureCallback();
+ return;
+ }
+
+ plainText.resize(plainTextLength);
+ callback(plainText);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SUBTLE_CRYPTO)
</ins><span class="cx">Property changes on: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSA_OAEPMac.cpp
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
<a id="trunkSourceWebCorecryptomacCryptoAlgorithmRegistryMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp (159943 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp        2013-12-02 19:49:43 UTC (rev 159943)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include "CryptoAlgorithmAES_CBC.h"
</span><span class="cx"> #include "CryptoAlgorithmHMAC.h"
</span><span class="cx"> #include "CryptoAlgorithmRSASSA_PKCS1_v1_5.h"
</span><ins>+#include "CryptoAlgorithmRSA_OAEP.h"
</ins><span class="cx"> #include "CryptoAlgorithmSHA1.h"
</span><span class="cx"> #include "CryptoAlgorithmSHA224.h"
</span><span class="cx"> #include "CryptoAlgorithmSHA256.h"
</span><span class="lines">@@ -44,6 +45,7 @@
</span><span class="cx"> registerAlgorithm<CryptoAlgorithmAES_CBC>();
</span><span class="cx"> registerAlgorithm<CryptoAlgorithmHMAC>();
</span><span class="cx"> registerAlgorithm<CryptoAlgorithmRSASSA_PKCS1_v1_5>();
</span><ins>+ registerAlgorithm<CryptoAlgorithmRSA_OAEP>();
</ins><span class="cx"> registerAlgorithm<CryptoAlgorithmSHA1>();
</span><span class="cx"> registerAlgorithm<CryptoAlgorithmSHA224>();
</span><span class="cx"> registerAlgorithm<CryptoAlgorithmSHA256>();
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoKeyMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoKeyMac.cpp (159943 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoKeyMac.cpp        2013-12-02 19:49:43 UTC (rev 159943)
+++ trunk/Source/WebCore/crypto/mac/CryptoKeyMac.cpp        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -28,16 +28,8 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx">
</span><del>-#if defined(__has_include) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
-#if __has_include(<CommonCrypto/CommonRandomSPI.h>)
-#include <CommonCrypto/CommonRandomSPI.h>
-#endif
-#endif
</del><ins>+#include "CommonCryptoUtilities.h"
</ins><span class="cx">
</span><del>-typedef struct __CCRandom *CCRandomRef;
-extern const CCRandomRef kCCRandomDefault;
-extern "C" int CCRandomCopyBytes(CCRandomRef rnd, void *bytes, size_t count);
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> Vector<uint8_t> CryptoKey::randomData(size_t size)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoKeyRSAMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp (159943 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp        2013-12-02 19:49:43 UTC (rev 159943)
+++ trunk/Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -28,33 +28,13 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx">
</span><ins>+#include "CommonCryptoUtilities.h"
</ins><span class="cx"> #include "CryptoAlgorithmDescriptionBuilder.h"
</span><span class="cx"> #include "CryptoAlgorithmRegistry.h"
</span><span class="cx"> #include "CryptoKeyDataRSAComponents.h"
</span><span class="cx"> #include "CryptoKeyPair.h"
</span><span class="cx"> #include <CommonCrypto/CommonCryptor.h>
</span><span class="cx">
</span><del>-#if defined(__has_include)
-#if __has_include(<CommonCrypto/CommonRSACryptor.h>)
-#include <CommonCrypto/CommonRSACryptor.h>
-#endif
-#endif
-
-#ifndef _CC_RSACRYPTOR_H_
-enum {
- ccRSAKeyPublic = 0,
- ccRSAKeyPrivate = 1
-};
-typedef uint32_t CCRSAKeyType;
-#endif
-
-extern "C" CCCryptorStatus CCRSACryptorCreateFromData(CCRSAKeyType keyType, uint8_t *modulus, size_t modulusLength, uint8_t *exponent, size_t exponentLength, uint8_t *p, size_t pLength, uint8_t *q, size_t qLength, CCRSACryptorRef *ref);
-extern "C" CCCryptorStatus CCRSACryptorGeneratePair(size_t keysize, uint32_t e, CCRSACryptorRef *publicKey, CCRSACryptorRef *privateKey);
-extern "C" CCRSACryptorRef CCRSACryptorGetPublicKeyFromPrivateKey(CCRSACryptorRef privkey);
-extern "C" void CCRSACryptorRelease(CCRSACryptorRef key);
-extern "C" CCCryptorStatus CCRSAGetKeyComponents(CCRSACryptorRef rsaKey, uint8_t *modulus, size_t *modulusLength, uint8_t *exponent, size_t *exponentLength, uint8_t *p, size_t *pLength, uint8_t *q, size_t *qLength);
-extern "C" CCRSAKeyType CCRSAGetKeyType(CCRSACryptorRef key);
-
</del><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> static CCCryptorStatus getPublicKeyComponents(CCRSACryptorRef rsaKey, Vector<uint8_t>& modulus, Vector<uint8_t>& publicExponent)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoparametersCryptoAlgorithmRsaOaepParamsh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaOaepParams.h (0 => 159944)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaOaepParams.h         (rev 0)
+++ trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaOaepParams.h        2013-12-02 19:50:51 UTC (rev 159944)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+/*
+ * Copyright (C) 2013 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.
+ */
+
+#ifndef CryptoAlgorithmRsaOaepParams_h
+#define CryptoAlgorithmRsaOaepParams_h
+
+#include "CryptoAlgorithmIdentifier.h"
+#include "CryptoAlgorithmParameters.h"
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+namespace WebCore {
+
+class CryptoAlgorithmRsaOaepParams FINAL : public CryptoAlgorithmParameters {
+public:
+ CryptoAlgorithmRsaOaepParams()
+ : hasLabel(false)
+ {
+ }
+
+ // The hash function to apply to the message.
+ CryptoAlgorithmIdentifier hash;
+
+ // The optional label/application data to associate with the message.
+ // FIXME: Is there a difference between a missing label and an empty one? Perhaps we don't need the hasLabel member.
+ bool hasLabel;
+ Vector<uint8_t> label;
+
+ virtual Class parametersClass() const OVERRIDE { return Class::RsaOaepParams; }
+};
+
+CRYPTO_ALGORITHM_PARAMETERS_CASTS(RsaOaepParams)
+
+}
+
+#endif // ENABLE(SUBTLE_CRYPTO)
+#endif // CryptoAlgorithmRsaOaepParams_h
</ins><span class="cx">Property changes on: trunk/Source/WebCore/crypto/parameters/CryptoAlgorithmRsaOaepParams.h
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
</div>
</body>
</html>