<!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>[209150] 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/209150">209150</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2016-11-30 13:19:20 -0800 (Wed, 30 Nov 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Update SubtleCrypto::verify to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=164741
<rdar://problem/29257935>
Reviewed by Brent Fulgham.
LayoutTests/imported/w3c:
* WebCryptoAPI/idlharness-expected.txt:
Source/WebCore:
This patch does following few things:
1. It updates the SubtleCrypto::verify method to match the latest spec:
https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-verify.
It also refers to the latest Editor's Draft to a certain degree:
https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-verify.
2. It implements verify operations of the following algorithms: HMAC, and
RSASSA-PKCS1-V1_5.
Tests: crypto/subtle/hmac-generate-key-sign-verify.html
crypto/subtle/hmac-import-key-verify-sha1.html
crypto/subtle/hmac-import-key-verify-sha224.html
crypto/subtle/hmac-import-key-verify-sha256.html
crypto/subtle/hmac-import-key-verify-sha384.html
crypto/subtle/hmac-import-key-verify-sha512.html
crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify.html
crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1.html
crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224.html
crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256.html
crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384.html
crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512.html
crypto/subtle/verify-malformed-parameters.html
crypto/workers/subtle/hmac-import-key-verify.html
crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify.html
* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::normalizeCryptoAlgorithmParameters):
(WebCore::jsSubtleCryptoFunctionVerifyPromise):
(WebCore::JSSubtleCrypto::verify):
* crypto/CryptoAlgorithm.cpp:
(WebCore::CryptoAlgorithm::verify):
* crypto/CryptoAlgorithm.h:
* crypto/SubtleCrypto.idl:
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
(WebCore::CryptoAlgorithmHMAC::verify):
* crypto/algorithms/CryptoAlgorithmHMAC.h:
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
* crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:
(WebCore::CryptoAlgorithmHMAC::platformVerify):
* crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp:
(WebCore::CryptoAlgorithmHMAC::platformVerify):
* crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify):
* crypto/mac/CryptoAlgorithmHMACMac.cpp:
(WebCore::CryptoAlgorithmHMAC::platformVerify):
* crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp:
(WebCore::verifyRSASSA_PKCS1_v1_5):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify):
LayoutTests:
Besides adding tests for SubtleCrypto::verify, it also enhances
*generate-key-encrypt-decrypt tests.
* crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt:
* crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html:
* crypto/subtle/hmac-generate-key-sign-verify-expected.txt: Added.
* crypto/subtle/hmac-generate-key-sign-verify.html: Added.
* crypto/subtle/hmac-import-key-verify-sha1-expected.txt: Added.
* crypto/subtle/hmac-import-key-verify-sha1.html: Added.
* crypto/subtle/hmac-import-key-verify-sha224-expected.txt: Added.
* crypto/subtle/hmac-import-key-verify-sha224.html: Added.
* crypto/subtle/hmac-import-key-verify-sha256-expected.txt: Added.
* crypto/subtle/hmac-import-key-verify-sha256.html: Added.
* crypto/subtle/hmac-import-key-verify-sha384-expected.txt: Added.
* crypto/subtle/hmac-import-key-verify-sha384.html: Added.
* crypto/subtle/hmac-import-key-verify-sha512-expected.txt: Added.
* crypto/subtle/hmac-import-key-verify-sha512.html: Added.
* crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt:
* crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt:
* crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html:
* crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html:
* crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt:
* crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html:
* crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384.html: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512-expected.txt: Added.
* crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512.html: Added.
* crypto/subtle/verify-malformed-parameters-expected.txt: Added.
* crypto/subtle/verify-malformed-parameters.html: Added.
* crypto/workers/subtle/hmac-import-key-verify-expected.txt: Added.
* crypto/workers/subtle/hmac-import-key-verify.html: Added.
* crypto/workers/subtle/resources/hmac-import-key-verify.js: Added.
* crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-verify.js: Added.
* crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify-expected.txt: Added.
* crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcgeneratekeyencryptdecryptexpectedtxt">trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleaescbcgeneratekeyencryptdecrypthtml">trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecryptexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecryptlabelexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecryptlabelhtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecrypthtml">trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5generatekeyencryptdecryptexpectedtxt">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaespkcs1v1_5generatekeyencryptdecrypthtml">trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cWebCryptoAPIidlharnessexpectedtxt">trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt</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>
<li><a href="#trunkSourceWebCorecryptoCryptoAlgorithmcpp">trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoAlgorithmh">trunk/Source/WebCore/crypto/CryptoAlgorithm.h</a></li>
<li><a href="#trunkSourceWebCorecryptoSubtleCryptoidl">trunk/Source/WebCore/crypto/SubtleCrypto.idl</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5cpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5h">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h</a></li>
<li><a href="#trunkSourceWebCorecryptogcryptCryptoAlgorithmHMACGCryptcpp">trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptognutlsCryptoAlgorithmHMACGnuTLScpp">trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptognutlsCryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLScpp">trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp</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>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtlehmacgeneratekeysignverifyexpectedtxt">trunk/LayoutTests/crypto/subtle/hmac-generate-key-sign-verify-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacgeneratekeysignverifyhtml">trunk/LayoutTests/crypto/subtle/hmac-generate-key-sign-verify.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeyverifysha1expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha1-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeyverifysha1html">trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha1.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeyverifysha224expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha224-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeyverifysha224html">trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha224.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeyverifysha256expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeyverifysha256html">trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeyverifysha384expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha384-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeyverifysha384html">trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha384.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeyverifysha512expectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha512-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeyverifysha512html">trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha512.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generatekeysignverifyexpectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5generatekeysignverifyhtml">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha1expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha1html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha224expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha224html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha256expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha256html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha384expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha384html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha512expectedtxt">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha512html">trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleverifymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/verify-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleverifymalformedparametershtml">trunk/LayoutTests/crypto/subtle/verify-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlehmacimportkeyverifyexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-verify-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlehmacimportkeyverifyhtml">trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-verify.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourceshmacimportkeyverifyjs">trunk/LayoutTests/crypto/workers/subtle/resources/hmac-import-key-verify.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesrsassapkcs1v1_5importkeyverifyjs">trunk/LayoutTests/crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-verify.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersassapkcs1v1_5importkeyverifyexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtlersassapkcs1v1_5importkeyverifyhtml">trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/LayoutTests/ChangeLog        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -1,3 +1,55 @@
</span><ins>+2016-11-30 Jiewen Tan <jiewen_tan@apple.com>
+
+ Update SubtleCrypto::verify to match the latest spec
+ https://bugs.webkit.org/show_bug.cgi?id=164741
+ <rdar://problem/29257935>
+
+ Reviewed by Brent Fulgham.
+
+ Besides adding tests for SubtleCrypto::verify, it also enhances
+ *generate-key-encrypt-decrypt tests.
+
+ * crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt:
+ * crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html:
+ * crypto/subtle/hmac-generate-key-sign-verify-expected.txt: Added.
+ * crypto/subtle/hmac-generate-key-sign-verify.html: Added.
+ * crypto/subtle/hmac-import-key-verify-sha1-expected.txt: Added.
+ * crypto/subtle/hmac-import-key-verify-sha1.html: Added.
+ * crypto/subtle/hmac-import-key-verify-sha224-expected.txt: Added.
+ * crypto/subtle/hmac-import-key-verify-sha224.html: Added.
+ * crypto/subtle/hmac-import-key-verify-sha256-expected.txt: Added.
+ * crypto/subtle/hmac-import-key-verify-sha256.html: Added.
+ * crypto/subtle/hmac-import-key-verify-sha384-expected.txt: Added.
+ * crypto/subtle/hmac-import-key-verify-sha384.html: Added.
+ * crypto/subtle/hmac-import-key-verify-sha512-expected.txt: Added.
+ * crypto/subtle/hmac-import-key-verify-sha512.html: Added.
+ * crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt:
+ * crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt:
+ * crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html:
+ * crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html:
+ * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt:
+ * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html:
+ * crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify-expected.txt: Added.
+ * crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify.html: Added.
+ * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1-expected.txt: Added.
+ * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1.html: Added.
+ * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224-expected.txt: Added.
+ * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224.html: Added.
+ * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256-expected.txt: Added.
+ * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256.html: Added.
+ * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384-expected.txt: Added.
+ * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384.html: Added.
+ * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512-expected.txt: Added.
+ * crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512.html: Added.
+ * crypto/subtle/verify-malformed-parameters-expected.txt: Added.
+ * crypto/subtle/verify-malformed-parameters.html: Added.
+ * crypto/workers/subtle/hmac-import-key-verify-expected.txt: Added.
+ * crypto/workers/subtle/hmac-import-key-verify.html: Added.
+ * crypto/workers/subtle/resources/hmac-import-key-verify.js: Added.
+ * crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-verify.js: Added.
+ * crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify-expected.txt: Added.
+ * crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify.html: Added.
+
</ins><span class="cx"> 2016-11-30 Mark Lam <mark.lam@apple.com>
</span><span class="cx">
</span><span class="cx"> Proxy is not allowed in the global prototype chain.
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcgeneratekeyencryptdecryptexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -5,6 +5,7 @@
</span><span class="cx">
</span><span class="cx"> Generating a key...
</span><span class="cx"> Encrypting...
</span><ins>+PASS bytesToASCIIString(cipherText) is not "Hello, World!"
</ins><span class="cx"> Decrypting...
</span><span class="cx"> PASS bytesToASCIIString(decryptedText) is plainText
</span><span class="cx"> PASS successfullyParsed is true
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleaescbcgeneratekeyencryptdecrypthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/LayoutTests/crypto/subtle/aes-cbc-generate-key-encrypt-decrypt.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -23,7 +23,9 @@
</span><span class="cx"> key = result;
</span><span class="cx"> debug("Encrypting...");
</span><span class="cx"> return crypto.subtle.encrypt(aesCbcParams, key, asciiToUint8Array(plainText));
</span><del>-}).then(function(cipherText) {
</del><ins>+}).then(function(result) {
+ cipherText = result;
+ shouldNotBeEqualToString("bytesToASCIIString(cipherText)", plainText);
</ins><span class="cx"> debug("Decrypting...");
</span><span class="cx"> return crypto.subtle.decrypt(aesCbcParams, key, cipherText);
</span><span class="cx"> }).then(function(result) {
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacgeneratekeysignverifyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-key-sign-verify-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-key-sign-verify-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-key-sign-verify-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+Test sign/verify with HMAC SHA-1 using a generated key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating key...
+Signing...
+PASS signature.byteLength is 20
+Verifying...
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacgeneratekeysignverifyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-generate-key-sign-verify.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-generate-key-sign-verify.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-generate-key-sign-verify.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,43 @@
</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 sign/verify with HMAC SHA-1 using a generated key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var hmacParams = {
+ name: "hmac",
+ hash: "sha-1",
+}
+
+debug("Generating key...");
+crypto.subtle.generateKey(hmacParams, extractable, ["sign", "verify"]).then(function(result) {
+ key = result;
+ debug("Signing...");
+ return crypto.subtle.sign("hmac", key, text);
+}).then(function(result) {
+ signature = result;
+ shouldBe("signature.byteLength", "20");
+ debug("Verifying...");
+ return crypto.subtle.verify("hmac", key, signature, text);
+}).then(function(result) {
+ verified = result;
+ shouldBeTrue("verified");
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeyverifysha1expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha1-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha1-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha1-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test verification with HMAC SHA-1 using an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeyverifysha1html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha1.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha1.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha1.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,39 @@
</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 verification with HMAC SHA-1 using an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var hmacImportParams = {
+ name: "hmac",
+ hash: "sha-1",
+}
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var signature = hexStringToUint8Array("6e8e66ff128606f52b8c589196ef5e0f7ca04816");
+
+crypto.subtle.importKey("raw", rawKey, hmacImportParams, extractable, ["sign", "verify"]).then(function(key) {
+ return crypto.subtle.verify("hmac", key, signature, text);
+}).then(function(result) {
+ verified = result;
+
+ shouldBeTrue("verified");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeyverifysha224expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha224-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha224-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha224-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test verification with HMAC SHA-224 using an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeyverifysha224html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha224.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha224.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha224.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,39 @@
</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 verification with HMAC SHA-224 using an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var hmacImportParams = {
+ name: "hmac",
+ hash: "sha-224",
+}
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var signature = hexStringToUint8Array("70b638e082fabc3bf391a1935c4b6a74168401214f4fb5c31e0cebf4");
+
+crypto.subtle.importKey("raw", rawKey, hmacImportParams, extractable, ["sign", "verify"]).then(function(key) {
+ return crypto.subtle.verify("hmac", key, signature, text);
+}).then(function(result) {
+ verified = result;
+
+ shouldBeTrue("verified");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeyverifysha256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha256-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha256-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha256-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test verification with HMAC SHA-256 using an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeyverifysha256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha256.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha256.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha256.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,39 @@
</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 verification with HMAC SHA-256 using an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var hmacImportParams = {
+ name: "hmac",
+ hash: "sha-256",
+}
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var signature = hexStringToUint8Array("d6b92f34723a8de7ba53dceea8c821f5d21757ddb478c27d564b356c38f583db");
+
+crypto.subtle.importKey("raw", rawKey, hmacImportParams, extractable, ["sign", "verify"]).then(function(key) {
+ return crypto.subtle.verify("hmac", key, signature, text);
+}).then(function(result) {
+ verified = result;
+
+ shouldBeTrue("verified");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeyverifysha384expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha384-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha384-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha384-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test verification with HMAC SHA-384 using an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeyverifysha384html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha384.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha384.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha384.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,39 @@
</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 verification with HMAC SHA-384 using an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var hmacImportParams = {
+ name: "hmac",
+ hash: "sha-384",
+}
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var signature = hexStringToUint8Array("5cfc6cba3135c99cb426d5d59bd33c5e212aac082f5ba57a1f70def2b3e987e3f3078be80f142221b6a8e23768dd994f");
+
+crypto.subtle.importKey("raw", rawKey, hmacImportParams, extractable, ["sign", "verify"]).then(function(key) {
+ return crypto.subtle.verify("hmac", key, signature, text);
+}).then(function(result) {
+ verified = result;
+
+ shouldBeTrue("verified");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeyverifysha512expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha512-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha512-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha512-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test verification with HMAC SHA-512 using an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeyverifysha512html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha512.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha512.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-verify-sha512.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,39 @@
</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 verification with HMAC SHA-512 using an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var hmacImportParams = {
+ name: "hmac",
+ hash: "sha-512",
+}
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var signature = hexStringToUint8Array("74b22e7422bd3d8562294040b8e9ff08849cf694d3f7729e02a111647b290058af5e1ca8321e5d0f512b5a55a287b39762fae85bef73611d0bddd0b3ddf252ec");
+
+crypto.subtle.importKey("raw", rawKey, hmacImportParams, extractable, ["sign", "verify"]).then(function(key) {
+ return crypto.subtle.verify("hmac", key, signature, text);
+}).then(function(result) {
+ verified = result;
+
+ shouldBeTrue("verified");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecryptexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -5,6 +5,7 @@
</span><span class="cx">
</span><span class="cx"> Generating a key...
</span><span class="cx"> Encrypting...
</span><ins>+PASS bytesToASCIIString(cipherText) is not "Hello, World!"
</ins><span class="cx"> Decrypting...
</span><span class="cx"> PASS bytesToASCIIString(decryptedText) is plainText
</span><span class="cx"> PASS successfullyParsed is true
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecryptlabelexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -5,6 +5,7 @@
</span><span class="cx">
</span><span class="cx"> Generating a key...
</span><span class="cx"> Encrypting...
</span><ins>+PASS bytesToASCIIString(cipherText) is not "Hello, World!"
</ins><span class="cx"> Decrypting...
</span><span class="cx"> PASS bytesToASCIIString(decryptedText) is plainText
</span><span class="cx"> PASS successfullyParsed is true
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecryptlabelhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt-label.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -30,7 +30,9 @@
</span><span class="cx"> keyPair = result;
</span><span class="cx"> debug("Encrypting...");
</span><span class="cx"> return crypto.subtle.encrypt(rsaOaepParams, keyPair.publicKey, asciiToUint8Array(plainText));
</span><del>-}).then(function(cipherText) {
</del><ins>+}).then(function(result) {
+ cipherText = result;
+ shouldNotBeEqualToString("bytesToASCIIString(cipherText)", plainText);
</ins><span class="cx"> debug("Decrypting...");
</span><span class="cx"> return crypto.subtle.decrypt(rsaOaepParams, keyPair.privateKey, cipherText);
</span><span class="cx"> }).then(function(result) {
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaoaepgeneratekeyencryptdecrypthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/LayoutTests/crypto/subtle/rsa-oaep-generate-key-encrypt-decrypt.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -29,7 +29,9 @@
</span><span class="cx"> keyPair = result;
</span><span class="cx"> debug("Encrypting...");
</span><span class="cx"> return crypto.subtle.encrypt(rsaOaepParams, keyPair.publicKey, asciiToUint8Array(plainText));
</span><del>-}).then(function(cipherText) {
</del><ins>+}).then(function(result) {
+ cipherText = result;
+ shouldNotBeEqualToString("bytesToASCIIString(cipherText)", plainText);
</ins><span class="cx"> debug("Decrypting...");
</span><span class="cx"> return crypto.subtle.decrypt(rsaOaepParams, keyPair.privateKey, cipherText);
</span><span class="cx"> }).then(function(result) {
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaespkcs1v1_5generatekeyencryptdecryptexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -5,6 +5,7 @@
</span><span class="cx">
</span><span class="cx"> Generating a key...
</span><span class="cx"> Encrypting...
</span><ins>+PASS bytesToASCIIString(cipherText) is not "Hello, World!"
</ins><span class="cx"> Decrypting...
</span><span class="cx"> PASS bytesToASCIIString(decryptedText) is plainText
</span><span class="cx"> PASS successfullyParsed is true
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaespkcs1v1_5generatekeyencryptdecrypthtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-encrypt-decrypt.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -25,7 +25,9 @@
</span><span class="cx"> keyPair = result;
</span><span class="cx"> debug("Encrypting...");
</span><span class="cx"> return crypto.subtle.encrypt("RSAES-PKCS1-v1_5", keyPair.publicKey, asciiToUint8Array(plainText));
</span><del>-}).then(function(cipherText) {
</del><ins>+}).then(function(result) {
+ cipherText = result;
+ shouldNotBeEqualToString("bytesToASCIIString(cipherText)", plainText);
</ins><span class="cx"> debug("Decrypting...");
</span><span class="cx"> return crypto.subtle.decrypt("RSAES-PKCS1-v1_5", keyPair.privateKey, cipherText);
</span><span class="cx"> }).then(function(result) {
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5generatekeysignverifyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+Test sign/verify with RSASSA-PKCS1-v1_5 SHA-1 using a generated key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Generating key...
+Signing...
+PASS signature.byteLength is 256
+Verifying...
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5generatekeysignverifyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,45 @@
</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 sign/verify with RSASSA-PKCS1-v1_5 SHA-1 using a generated key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var rsatParams = {
+ name: "RSASSA-PKCS1-v1_5",
+ hash: "SHA-1",
+ modulusLength: 2048,
+ publicExponent: new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537
+}
+
+debug("Generating key...");
+crypto.subtle.generateKey(rsatParams, extractable, ["sign", "verify"]).then(function(result) {
+ keyPair = result;
+ debug("Signing...");
+ return crypto.subtle.sign("RSASSA-PKCS1-v1_5", keyPair.privateKey, text);
+}).then(function(result) {
+ signature = result;
+ shouldBe("signature.byteLength", "256");
+ debug("Verifying...");
+ return crypto.subtle.verify("RSASSA-PKCS1-v1_5", keyPair.publicKey, signature, text);
+}).then(function(result) {
+ verified = result;
+ shouldBeTrue("verified");
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha1expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test verification with RSASSA-PKCS1-v1_5 SHA-1 using an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha1html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,47 @@
</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 verification with RSASSA-PKCS1-v1_5 SHA-1 using an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var rsaImportParams = {
+ name: "RSASSA-PKCS1-v1_5",
+ hash: "SHA-1",
+}
+var jwkKey = {
+ kty: "RSA",
+ alg: "RS1",
+ use: "sig",
+ key_ops: ["verify"],
+ ext: true,
+ n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+ e: "AQAB",
+};
+var signature = hexStringToUint8Array("08b83a4a58aff1db76529fe97f6dc2b58914a56f08ebc73aebf740680fc524e721c30842759acacab8acdf6e31e7cc83dbe8a48ace80b6a6558a9df892e4c2a9276c154cd605e632c8b857855a064aea68550b660a15044a0917026e494a71e4fee99fa57941268545f338c8601baa9c4f2116f0eb5432cfee5e3ed9978876fed201647921e599101930a99a2b645a9a879bce8c24592729f1f62a3b83fe21475871273cdbbe8efa7be314cabd087fbe1931ddf3fb86cbff5176a27554726b54c43208200725c6ad71d335ee5e09f3bbff7164ddf5bc857a41c5961e6f9581459db0fd0f09ee251d63b7a01bd716f6f72632b5c0f9a2c4dc2257d1e342138c13");
+
+crypto.subtle.importKey("jwk", jwkKey, rsaImportParams, extractable, ["verify"]).then(function(key) {
+ return crypto.subtle.verify("RSASSA-PKCS1-v1_5", key, signature, text);
+}).then(function(result) {
+ verified = result;
+
+ shouldBeTrue("verified");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha224expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test verification with RSASSA-PKCS1-v1_5 SHA-224 using an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha224html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,47 @@
</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 verification with RSASSA-PKCS1-v1_5 SHA-224 using an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var rsaImportParams = {
+ name: "RSASSA-PKCS1-v1_5",
+ hash: "SHA-224",
+}
+var jwkKey = {
+ kty: "RSA",
+ alg: "RS224",
+ use: "sig",
+ key_ops: ["verify"],
+ ext: true,
+ n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+ e: "AQAB",
+};
+var signature = hexStringToUint8Array("3cb10634bbb4022b64e0af31d0c0533837e14c8a9a4d7b9ef8c6816133843ef58603887fb05f7215bf39e803326367d95ea8894dda321b753a62dcc3214c7e85a134bf741c883f1ee0037dde6334d62b8efe54dcb59c8510e4d733b35466ad5a064686616898d73e25138cc6fd572d52df5e80f70d3d803ae9100516b4bde58cafc068c655f0cdbd2249ae61eb1a952d49df493b3c3c4a15ffb900d4f489df797498a0e7333c58cb953c2f3b169290ae7dd51e3c53bdb0bdf4311ae3fd5d7a1c3de038f696c05190db1c60056f664c6421580385b9fe54e1b2f41eef9eb83d18c6d28745d9c0eb2c15b45f5949b78762558488ae09877f4305f8c9068576e6e5");
+
+crypto.subtle.importKey("jwk", jwkKey, rsaImportParams, extractable, ["verify"]).then(function(key) {
+ return crypto.subtle.verify("RSASSA-PKCS1-v1_5", key, signature, text);
+}).then(function(result) {
+ verified = result;
+
+ shouldBeTrue("verified");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test verification with RSASSA-PKCS1-v1_5 SHA-256 using an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,47 @@
</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 verification with RSASSA-PKCS1-v1_5 SHA-256 using an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var rsaImportParams = {
+ name: "RSASSA-PKCS1-v1_5",
+ hash: "SHA-256",
+}
+var jwkKey = {
+ kty: "RSA",
+ alg: "RS256",
+ use: "sig",
+ key_ops: ["verify"],
+ ext: true,
+ n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+ e: "AQAB",
+};
+var signature = hexStringToUint8Array("6dd6df5884c84e8494794f5104559fd2966b266b7d6f3f9b8080adfb36e7c63d8f9b3b1d26084028735030749e829da0d22e3ba39454c07db7c104a19b9f509f0e4c0908c16cd604b5771bdf06507dec95d6545b896f56684016777675c16d852bb6d6ff98e1dbfc27a11d06fa028d4b8c8d2ac6790406f89283674e3f3d200aa17feb4332cbd6a6dca6b73008f5996297ac572f943037950da37b25420b24c51e76918f3e4aedeb70a0d026c75f6ae20f7fa3185f34914fc0ffd682e514d84fb73c1ce33bd1c19e4ec4b96536004af0a6206d0114196863a11d0ea575e14aedaceac6e08f1d1f9e2fab1f0cd49a0c840a8c94f9c30a2483d770cb8f9867ba6d");
+
+crypto.subtle.importKey("jwk", jwkKey, rsaImportParams, extractable, ["verify"]).then(function(key) {
+ return crypto.subtle.verify("RSASSA-PKCS1-v1_5", key, signature, text);
+}).then(function(result) {
+ verified = result;
+
+ shouldBeTrue("verified");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha384expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test verification with RSASSA-PKCS1-v1_5 SHA-384 using an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha384html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,47 @@
</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 verification with RSASSA-PKCS1-v1_5 SHA-384 using an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var rsaImportParams = {
+ name: "RSASSA-PKCS1-v1_5",
+ hash: "SHA-384",
+}
+var jwkKey = {
+ kty: "RSA",
+ alg: "RS384",
+ use: "sig",
+ key_ops: ["verify"],
+ ext: true,
+ n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+ e: "AQAB",
+};
+var signature = hexStringToUint8Array("8517104ae42b39e958e01a78158f90077b7711a60634873c3ae62565900dc1c7a3e75626b30e1281fa396594bbab742a5fc3be39dee3d981b9e4e83248bf69ed3671dee86a8f03c6a9b4465bf7b3dcd1dd04c3446e77aa340f20f9bd203966dd3dec2d4d135ea1c916f218a711ccaa167332f021ed7163ba61ffed6c0c48c4097ff979eea349011febf10398c3abcec9b4540ff0767fa9a29e7b119b8fdb8eb55786d311058dc509ce58da8abf50fe0ab2f1b092a24d3f8ae2f1f533a1ef0b7e191a43bb710acb376f4f5e620ffff602d9865a93e90f5d264309559a6acd4071058abb3ce0935a06df59b6c7c273cb033bc6d6a18b32559a8d4b14da2bfa2b15");
+
+crypto.subtle.importKey("jwk", jwkKey, rsaImportParams, extractable, ["verify"]).then(function(key) {
+ return crypto.subtle.verify("RSASSA-PKCS1-v1_5", key, signature, text);
+}).then(function(result) {
+ verified = result;
+
+ shouldBeTrue("verified");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha512expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test verification with RSASSA-PKCS1-v1_5 SHA-512 using an imported key
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersassapkcs1v1_5importkeyverifysha512html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,47 @@
</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 verification with RSASSA-PKCS1-v1_5 SHA-512 using an imported key");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var rsaImportParams = {
+ name: "RSASSA-PKCS1-v1_5",
+ hash: "SHA-512",
+}
+var jwkKey = {
+ kty: "RSA",
+ alg: "RS512",
+ use: "sig",
+ key_ops: ["verify"],
+ ext: true,
+ n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+ e: "AQAB",
+};
+var signature = hexStringToUint8Array("04dfcced9635d2208ea05c73ce76745678db57b7575a7ffa9770615a9ef9c68455bb49e9c70a99d053eb91c9dd2ecf09dba2a1334325318a2e75b78f4c4eb63c0d05a2a9418d6aefc5cb97ffbfb8cd06b39f8adaa545ea6b95e09934b0e2ef8e05734dcb1f1a72877f891637a99cd80b2f8a5ad419aebe18fa354bff95141b207f986e60ae16f192011b7f9c97137820a7af77be59d771ad35f51a895a2c5e0aafc96ba8f1f2dfcfbe5257b7b603d37e25670996c6c05f3db940c973f561bac8582659701fad4b4c84faa56af2dfeab450c40714f46bdd1bc6e24a3efc10bf3767ad452a79fb7de5fff282b2302e3f3f98bfdbb4037780e793343358b51cead1");
+
+crypto.subtle.importKey("jwk", jwkKey, rsaImportParams, extractable, ["verify"]).then(function(key) {
+ return crypto.subtle.verify("RSASSA-PKCS1-v1_5", key, signature, text);
+}).then(function(result) {
+ verified = result;
+
+ shouldBeTrue("verified");
+
+ finishJSTest();
+});
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleverifymalformedparametersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/verify-malformed-parameters-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/verify-malformed-parameters-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/verify-malformed-parameters-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+Test verification with malformed parameters
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS crypto.subtle.verify() rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.verify(1) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.verify(1, 2) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.verify(1, 2, 3) rejected promise with TypeError: Not enough arguments.
+PASS crypto.subtle.verify("rsassa-pkcs1-v1_5", wrongKey, signature, text) rejected promise with InvalidAccessError (DOM Exception 15): CryptoKey doesn't match AlgorithmIdentifier.
+PASS crypto.subtle.verify("hmac", wrongKey, signature, text) rejected promise with InvalidAccessError (DOM Exception 15): CryptoKey doesn't support verification.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleverifymalformedparametershtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/verify-malformed-parameters.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/verify-malformed-parameters.html         (rev 0)
+++ trunk/LayoutTests/crypto/subtle/verify-malformed-parameters.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,47 @@
</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 verification with malformed parameters");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var signature = hexStringToUint8Array("6e8e66ff128606f52b8c589196ef5e0f7ca04816");
+var hmacImportParams = {
+ name: "hmac",
+ hash: "sha-1",
+}
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+
+// Not enough arguments.
+shouldReject('crypto.subtle.verify()');
+shouldReject('crypto.subtle.verify(1)');
+shouldReject('crypto.subtle.verify(1, 2)');
+shouldReject('crypto.subtle.verify(1, 2, 3)');
+
+crypto.subtle.importKey("raw", rawKey, hmacImportParams, extractable, ["sign", "verify"]).then(function(result) {
+ wrongKey = result;
+ // Wrong algorithm identifier.
+ shouldReject('crypto.subtle.verify("rsassa-pkcs1-v1_5", wrongKey, signature, text)');
+
+ return crypto.subtle.importKey("raw", rawKey, hmacImportParams, extractable, ["sign"]);
+}).then(function(result) {
+ wrongKey = result;
+ // Wrong usage.
+ return shouldReject('crypto.subtle.verify("hmac", wrongKey, signature, text)');
+}).then(finishJSTest);
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlehmacimportkeyverifyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-verify-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-verify-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-verify-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[Worker] Test verification with HMAC SHA-1 using an imported key in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/hmac-import-key-verify.js
+PASS [Worker] verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlehmacimportkeyverifyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-verify.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-verify.html         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/hmac-import-key-verify.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+ <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/hmac-import-key-verify.js');
+ </script>
+ <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourceshmacimportkeyverifyjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/hmac-import-key-verify.js (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/hmac-import-key-verify.js         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/hmac-import-key-verify.js        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description("Test verification with HMAC SHA-1 using an imported key in workers");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var hmacImportParams = {
+ name: "hmac",
+ hash: "sha-1",
+}
+var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
+var signature = hexStringToUint8Array("6e8e66ff128606f52b8c589196ef5e0f7ca04816");
+
+crypto.subtle.importKey("raw", rawKey, hmacImportParams, extractable, ["sign", "verify"]).then(function(key) {
+ return crypto.subtle.verify("hmac", key, signature, text);
+}).then(function(result) {
+ verified = result;
+
+ shouldBeTrue("verified");
+
+ finishJSTest();
+});
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesrsassapkcs1v1_5importkeyverifyjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-verify.js (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-verify.js         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/rsassa-pkcs1-v1_5-import-key-verify.js        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts('../../../resources/common.js');
+
+description("Test verification with RSASSA-PKCS1-v1_5 SHA-1 using an imported key in workers");
+
+jsTestIsAsync = true;
+
+var extractable = false;
+var text = asciiToUint8Array("Hello, World!");
+var rsaImportParams = {
+ name: "RSASSA-PKCS1-v1_5",
+ hash: "SHA-1",
+}
+var jwkKey = {
+ kty: "RSA",
+ alg: "RS1",
+ use: "sig",
+ key_ops: ["verify"],
+ ext: true,
+ n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
+ e: "AQAB",
+};
+var signature = hexStringToUint8Array("08b83a4a58aff1db76529fe97f6dc2b58914a56f08ebc73aebf740680fc524e721c30842759acacab8acdf6e31e7cc83dbe8a48ace80b6a6558a9df892e4c2a9276c154cd605e632c8b857855a064aea68550b660a15044a0917026e494a71e4fee99fa57941268545f338c8601baa9c4f2116f0eb5432cfee5e3ed9978876fed201647921e599101930a99a2b645a9a879bce8c24592729f1f62a3b83fe21475871273cdbbe8efa7be314cabd087fbe1931ddf3fb86cbff5176a27554726b54c43208200725c6ad71d335ee5e09f3bbff7164ddf5bc857a41c5961e6f9581459db0fd0f09ee251d63b7a01bd716f6f72632b5c0f9a2c4dc2257d1e342138c13");
+
+crypto.subtle.importKey("jwk", jwkKey, rsaImportParams, extractable, ["verify"]).then(function(key) {
+ return crypto.subtle.verify("RSASSA-PKCS1-v1_5", key, signature, text);
+}).then(function(result) {
+ verified = result;
+
+ shouldBeTrue("verified");
+
+ finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersassapkcs1v1_5importkeyverifyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify-expected.txt (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify-expected.txt         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+[Worker] Test verification with RSASSA-PKCS1-v1_5 SHA-1 using an imported key in workers
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/rsassa-pkcs1-v1_5-import-key-verify.js
+PASS [Worker] verified is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtlersassapkcs1v1_5importkeyverifyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify.html (0 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify.html         (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify.html        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+ <script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+ <script>
+ worker = startWorker('resources/rsassa-pkcs1-v1_5-import-key-verify.js');
+ </script>
+ <script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-11-30 Jiewen Tan <jiewen_tan@apple.com>
+
+ Update SubtleCrypto::verify to match the latest spec
+ https://bugs.webkit.org/show_bug.cgi?id=164741
+ <rdar://problem/29257935>
+
+ Reviewed by Brent Fulgham.
+
+ * WebCryptoAPI/idlharness-expected.txt:
+
</ins><span class="cx"> 2016-11-22 Jiewen Tan <jiewen_tan@apple.com>
</span><span class="cx">
</span><span class="cx"> Update SubtleCrypto::sign to match the latest spec
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cWebCryptoAPIidlharnessexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/LayoutTests/imported/w3c/WebCryptoAPI/idlharness-expected.txt        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -49,8 +49,8 @@
</span><span class="cx"> PASS SubtleCrypto interface: calling decrypt(AlgorithmIdentifier,CryptoKey,BufferSource) on crypto.subtle with too few arguments must throw TypeError
</span><span class="cx"> PASS SubtleCrypto interface: crypto.subtle must inherit property "sign" with the proper type (2)
</span><span class="cx"> PASS SubtleCrypto interface: calling sign(AlgorithmIdentifier,CryptoKey,BufferSource) on crypto.subtle with too few arguments must throw TypeError
</span><del>-FAIL SubtleCrypto interface: crypto.subtle must inherit property "verify" with the proper type (3) assert_inherits: property "verify" not found in prototype chain
-FAIL SubtleCrypto interface: calling verify(AlgorithmIdentifier,CryptoKey,BufferSource,BufferSource) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "verify" not found in prototype chain
</del><ins>+PASS SubtleCrypto interface: crypto.subtle must inherit property "verify" with the proper type (3)
+PASS SubtleCrypto interface: calling verify(AlgorithmIdentifier,CryptoKey,BufferSource,BufferSource) on crypto.subtle with too few arguments must throw TypeError
</ins><span class="cx"> FAIL SubtleCrypto interface: crypto.subtle must inherit property "digest" with the proper type (4) assert_inherits: property "digest" not found in prototype chain
</span><span class="cx"> FAIL SubtleCrypto interface: calling digest(AlgorithmIdentifier,BufferSource) on crypto.subtle with too few arguments must throw TypeError assert_inherits: property "digest" not found in prototype chain
</span><span class="cx"> PASS SubtleCrypto interface: crypto.subtle must inherit property "generateKey" with the proper type (5)
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/ChangeLog        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -1,3 +1,61 @@
</span><ins>+2016-11-30 Jiewen Tan <jiewen_tan@apple.com>
+
+ Update SubtleCrypto::verify to match the latest spec
+ https://bugs.webkit.org/show_bug.cgi?id=164741
+ <rdar://problem/29257935>
+
+ Reviewed by Brent Fulgham.
+
+ This patch does following few things:
+ 1. It updates the SubtleCrypto::verify method to match the latest spec:
+ https://www.w3.org/TR/WebCryptoAPI/#SubtleCrypto-method-verify.
+ It also refers to the latest Editor's Draft to a certain degree:
+ https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-verify.
+ 2. It implements verify operations of the following algorithms: HMAC, and
+ RSASSA-PKCS1-V1_5.
+
+ Tests: crypto/subtle/hmac-generate-key-sign-verify.html
+ crypto/subtle/hmac-import-key-verify-sha1.html
+ crypto/subtle/hmac-import-key-verify-sha224.html
+ crypto/subtle/hmac-import-key-verify-sha256.html
+ crypto/subtle/hmac-import-key-verify-sha384.html
+ crypto/subtle/hmac-import-key-verify-sha512.html
+ crypto/subtle/rsassa-pkcs1-v1_5-generate-key-sign-verify.html
+ crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha1.html
+ crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha224.html
+ crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha256.html
+ crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha384.html
+ crypto/subtle/rsassa-pkcs1-v1_5-import-key-verify-sha512.html
+ crypto/subtle/verify-malformed-parameters.html
+ crypto/workers/subtle/hmac-import-key-verify.html
+ crypto/workers/subtle/rsassa-pkcs1-v1_5-import-key-verify.html
+
+ * bindings/js/JSSubtleCryptoCustom.cpp:
+ (WebCore::normalizeCryptoAlgorithmParameters):
+ (WebCore::jsSubtleCryptoFunctionVerifyPromise):
+ (WebCore::JSSubtleCrypto::verify):
+ * crypto/CryptoAlgorithm.cpp:
+ (WebCore::CryptoAlgorithm::verify):
+ * crypto/CryptoAlgorithm.h:
+ * crypto/SubtleCrypto.idl:
+ * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
+ (WebCore::CryptoAlgorithmHMAC::verify):
+ * crypto/algorithms/CryptoAlgorithmHMAC.h:
+ * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
+ (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
+ * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h:
+ * crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:
+ (WebCore::CryptoAlgorithmHMAC::platformVerify):
+ * crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp:
+ (WebCore::CryptoAlgorithmHMAC::platformVerify):
+ * crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp:
+ (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify):
+ * crypto/mac/CryptoAlgorithmHMACMac.cpp:
+ (WebCore::CryptoAlgorithmHMAC::platformVerify):
+ * crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp:
+ (WebCore::verifyRSASSA_PKCS1_v1_5):
+ (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify):
+
</ins><span class="cx"> 2016-11-30 Dave Hyatt <hyatt@apple.com>
</span><span class="cx">
</span><span class="cx"> [CSS Parser] Fix columns shorthand parsing
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> Encrypt,
</span><span class="cx"> Decrypt,
</span><span class="cx"> Sign,
</span><ins>+ Verify,
</ins><span class="cx"> Digest,
</span><span class="cx"> GenerateKey,
</span><span class="cx"> ImportKey,
</span><span class="lines">@@ -119,6 +120,7 @@
</span><span class="cx"> }
</span><span class="cx"> break;
</span><span class="cx"> case Operations::Sign:
</span><ins>+ case Operations::Verify:
</ins><span class="cx"> switch (*identifier) {
</span><span class="cx"> case CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5:
</span><span class="cx"> case CryptoAlgorithmIdentifier::HMAC:
</span><span class="lines">@@ -563,6 +565,54 @@
</span><span class="cx"> algorithm->sign(key.releaseNonNull(), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state), subtle->wrapped().workQueue());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static void jsSubtleCryptoFunctionVerifyPromise(ExecState& state, Ref<DeferredPromise>&& promise)
+{
+ VM& vm = state.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ if (UNLIKELY(state.argumentCount() < 4)) {
+ promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+ return;
+ }
+
+ auto params = normalizeCryptoAlgorithmParameters(state, state.uncheckedArgument(0), Operations::Verify);
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto key = toCryptoKey(state, state.uncheckedArgument(1));
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto signature = toVector(state, state.uncheckedArgument(2));
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto data = toVector(state, state.uncheckedArgument(3));
+ RETURN_IF_EXCEPTION(scope, void());
+
+ if (params->identifier != key->algorithmIdentifier()) {
+ promise->reject(INVALID_ACCESS_ERR, ASCIILiteral("CryptoKey doesn't match AlgorithmIdentifier"));
+ return;
+ }
+
+ if (!key->allows(CryptoKeyUsageVerify)) {
+ promise->reject(INVALID_ACCESS_ERR, ASCIILiteral("CryptoKey doesn't support verification"));
+ return;
+ }
+
+ auto algorithm = createAlgorithm(state, key->algorithmIdentifier());
+ RETURN_IF_EXCEPTION(scope, void());
+
+ auto callback = [capturedPromise = promise.copyRef()](bool result) mutable {
+ capturedPromise->resolve(result);
+ return;
+ };
+ auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
+ rejectWithException(WTFMove(capturedPromise), ec);
+ };
+
+ auto subtle = jsDynamicDowncast<JSSubtleCrypto*>(state.thisValue());
+ ASSERT(subtle);
+ algorithm->verify(key.releaseNonNull(), WTFMove(signature), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), *scriptExecutionContextFromExecState(&state), subtle->wrapped().workQueue());
+}
+
</ins><span class="cx"> static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<DeferredPromise>&& promise)
</span><span class="cx"> {
</span><span class="cx"> VM& vm = state.vm();
</span><span class="lines">@@ -739,6 +789,11 @@
</span><span class="cx"> return callPromiseFunction<jsSubtleCryptoFunctionSignPromise, PromiseExecutionScope::WindowOrWorker>(state);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+JSValue JSSubtleCrypto::verify(ExecState& state)
+{
+ return callPromiseFunction<jsSubtleCryptoFunctionVerifyPromise, PromiseExecutionScope::WindowOrWorker>(state);
+}
+
</ins><span class="cx"> JSValue JSSubtleCrypto::generateKey(ExecState& state)
</span><span class="cx"> {
</span><span class="cx"> return callPromiseFunction<jsSubtleCryptoFunctionGenerateKeyPromise, PromiseExecutionScope::WindowOrWorker>(state);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoAlgorithmcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.cpp        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -47,6 +47,11 @@
</span><span class="cx"> exceptionCallback(NOT_SUPPORTED_ERR);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithm::verify(Ref<CryptoKey>&&, Vector<uint8_t>&&, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&, WorkQueue&)
+{
+ exceptionCallback(NOT_SUPPORTED_ERR);
+}
+
</ins><span class="cx"> void CryptoAlgorithm::generateKey(const CryptoAlgorithmParameters&, bool, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)
</span><span class="cx"> {
</span><span class="cx"> exceptionCallback(NOT_SUPPORTED_ERR);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoAlgorithmh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoAlgorithm.h (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithm.h        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.h        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -67,6 +67,7 @@
</span><span class="cx"> virtual void encrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span><span class="cx"> virtual void decrypt(std::unique_ptr<CryptoAlgorithmParameters>&&, Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span><span class="cx"> virtual void sign(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span><ins>+ virtual void verify(Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</ins><span class="cx"> virtual void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&);
</span><span class="cx"> virtual void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&);
</span><span class="cx"> virtual void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoSubtleCryptoidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/SubtleCrypto.idl (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/SubtleCrypto.idl        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/crypto/SubtleCrypto.idl        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> [Custom] Promise<any> encrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
</span><span class="cx"> [Custom] Promise<any> decrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
</span><span class="cx"> [Custom] Promise<any> sign(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data);
</span><ins>+ [Custom] Promise<any> verify(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource signature, BufferSource data);
</ins><span class="cx"> // FIXME: Should this return a Promise<(CryptoKey or CryptoKeyPair)>?
</span><span class="cx"> [Custom] Promise<any> generateKey(AlgorithmIdentifier algorithm, boolean extractable, sequence<CryptoKeyUsage> keyUsages);
</span><span class="cx"> [Custom] Promise<CryptoKey> importKey(KeyFormat format, (BufferSource or JsonWebKey) keyData, AlgorithmIdentifier algorithm, boolen extractable, sequence<CryptoKeyUsage> keyUsages);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -74,6 +74,11 @@
</span><span class="cx"> platformSign(WTFMove(key), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmHMAC::verify(Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ platformVerify(WTFMove(key), WTFMove(signature), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
+}
+
</ins><span class="cx"> void CryptoAlgorithmHMAC::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext&)
</span><span class="cx"> {
</span><span class="cx"> const auto& hmacParameters = downcast<CryptoAlgorithmHmacKeyParams>(parameters);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmHMACh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.h        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> CryptoAlgorithmIdentifier identifier() const final;
</span><span class="cx">
</span><span class="cx"> void sign(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
</span><ins>+ void verify(Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
</ins><span class="cx"> void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
</span><span class="cx"> void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
</span><span class="cx"> void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
</span><span class="lines">@@ -57,6 +58,7 @@
</span><span class="cx">
</span><span class="cx"> bool keyAlgorithmMatches(const CryptoAlgorithmHmacParamsDeprecated& algorithmParameters, const CryptoKey&) const;
</span><span class="cx"> void platformSign(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span><ins>+ void platformVerify(Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</ins><span class="cx"> ExceptionOr<void> platformSign(const CryptoAlgorithmHmacParamsDeprecated&, const CryptoKeyHMAC&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
</span><span class="cx"> ExceptionOr<void> platformVerify(const CryptoAlgorithmHmacParamsDeprecated&, const CryptoKeyHMAC&, const CryptoOperationData& signature, const CryptoOperationData&, BoolCallback&&, VoidCallback&& failureCallback);
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5cpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -77,6 +77,15 @@
</span><span class="cx"> platformSign(WTFMove(key), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmRSASSA_PKCS1_v1_5::verify(Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ if (key->type() != CryptoKeyType::Public) {
+ exceptionCallback(INVALID_ACCESS_ERR);
+ return;
+ }
+ platformVerify(WTFMove(key), WTFMove(signature), WTFMove(data), WTFMove(callback), WTFMove(exceptionCallback), context, workQueue);
+}
+
</ins><span class="cx"> void CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey(const CryptoAlgorithmParameters& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context)
</span><span class="cx"> {
</span><span class="cx"> const auto& rsaParameters = downcast<CryptoAlgorithmRsaHashedKeyGenParams>(parameters);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmRSASSA_PKCS1_v1_5h"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.h        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> CryptoAlgorithmIdentifier identifier() const final;
</span><span class="cx">
</span><span class="cx"> void sign(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
</span><ins>+ void verify(Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&) final;
</ins><span class="cx"> void generateKey(const CryptoAlgorithmParameters&, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&&, ExceptionCallback&&, ScriptExecutionContext&) final;
</span><span class="cx"> void importKey(SubtleCrypto::KeyFormat, KeyData&&, const std::unique_ptr<CryptoAlgorithmParameters>&&, bool extractable, CryptoKeyUsageBitmap, KeyCallback&&, ExceptionCallback&&) final;
</span><span class="cx"> void exportKey(SubtleCrypto::KeyFormat, Ref<CryptoKey>&&, KeyDataCallback&&, ExceptionCallback&&) final;
</span><span class="lines">@@ -56,6 +57,7 @@
</span><span class="cx">
</span><span class="cx"> bool keyAlgorithmMatches(const CryptoAlgorithmRsaSsaParamsDeprecated& algorithmParameters, const CryptoKey&) const;
</span><span class="cx"> void platformSign(Ref<CryptoKey>&&, Vector<uint8_t>&&, VectorCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</span><ins>+ void platformVerify(Ref<CryptoKey>&&, Vector<uint8_t>&& signature, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&);
</ins><span class="cx"> ExceptionOr<void> platformSign(const CryptoAlgorithmRsaSsaParamsDeprecated&, const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&& failureCallback);
</span><span class="cx"> ExceptionOr<void> platformVerify(const CryptoAlgorithmRsaSsaParamsDeprecated&, const CryptoKeyRSA&, const CryptoOperationData& signature, const CryptoOperationData&, BoolCallback&&, VoidCallback&& failureCallback);
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCorecryptogcryptCryptoAlgorithmHMACGCryptcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -102,6 +102,11 @@
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmHMAC::platformVerify(Ref<CryptoKey>&&, Vector<uint8_t>&&, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&)
+{
+ notImplemented();
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmHMAC::platformSign(const CryptoAlgorithmHmacParamsDeprecated& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
</span><span class="cx"> {
</span><span class="cx"> int algorithm = getGCryptDigestAlgorithm(parameters.hash);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptognutlsCryptoAlgorithmHMACGnuTLScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -74,6 +74,11 @@
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmHMAC::platformVerify(Ref<CryptoKey>&&, Vector<uint8_t>&&, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&)
+{
+ notImplemented();
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmHMAC::platformSign(const CryptoAlgorithmHmacParamsDeprecated& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&&)
</span><span class="cx"> {
</span><span class="cx"> gnutls_mac_algorithm_t algorithm = getGnutlsDigestAlgorithm(parameters.hash);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptognutlsCryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -40,6 +40,11 @@
</span><span class="cx"> notImplemented();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(Ref<CryptoKey>&&, Vector<uint8_t>&&, Vector<uint8_t>&&, BoolCallback&&, ExceptionCallback&&, ScriptExecutionContext&, WorkQueue&)
+{
+ notImplemented();
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoAlgorithmRsaSsaParamsDeprecated&, const CryptoKeyRSA&, const CryptoOperationData&, VectorCallback&&, VoidCallback&&)
</span><span class="cx"> {
</span><span class="cx"> notImplemented();
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoAlgorithmHMACMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHMACMac.cpp        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -110,6 +110,31 @@
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmHMAC::platformVerify(Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ context.ref();
+ workQueue.dispatch([key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable {
+ auto& hmacKey = downcast<CryptoKeyHMAC>(key.get());
+ auto algorithm = commonCryptoHMACAlgorithm(hmacKey.hashAlgorithmIdentifier());
+ if (!algorithm) {
+ // We should only dereference callbacks after being back to the Document/Worker threads.
+ context.postTask([exceptionCallback = WTFMove(exceptionCallback), callback = WTFMove(callback)](ScriptExecutionContext& context) {
+ exceptionCallback(OperationError);
+ context.deref();
+ });
+ return;
+ }
+ auto expectedSignature = calculateSignature(*algorithm, hmacKey.key(), data.data(), data.size());
+ // Using a constant time comparison to prevent timing attacks.
+ bool result = signature.size() == expectedSignature.size() && !constantTimeMemcmp(expectedSignature.data(), signature.data(), expectedSignature.size());
+ // We should only dereference callbacks after being back to the Document/Worker threads.
+ context.postTask([callback = WTFMove(callback), result, exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) {
+ callback(result);
+ context.deref();
+ });
+ });
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmHMAC::platformSign(const CryptoAlgorithmHmacParamsDeprecated& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&&)
</span><span class="cx"> {
</span><span class="cx"> auto algorithm = commonCryptoHMACAlgorithm(parameters.hash);
</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 (209149 => 209150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp        2016-11-30 21:13:42 UTC (rev 209149)
+++ trunk/Source/WebCore/crypto/mac/CryptoAlgorithmRSASSA_PKCS1_v1_5Mac.cpp        2016-11-30 21:19:20 UTC (rev 209150)
</span><span class="lines">@@ -82,6 +82,32 @@
</span><span class="cx"> return WTFMove(signature);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+// FIXME: We should change signature, data to Vector<uint8_t> type once WebKitSubtleCrypto is deprecated.
+// https://bugs.webkit.org/show_bug.cgi?id=164939
+static ExceptionOr<bool> verifyRSASSA_PKCS1_v1_5(CryptoAlgorithmIdentifier hash, const PlatformRSAKey key, const uint8_t* signature, size_t signatureLength, const uint8_t* data, size_t dataLength)
+{
+ CCDigestAlgorithm digestAlgorithm;
+ if (!getCommonCryptoDigestAlgorithm(hash, digestAlgorithm))
+ return Exception { OperationError };
+
+ auto cryptoDigestAlgorithm = WebCore::cryptoDigestAlgorithm(hash);
+ if (!cryptoDigestAlgorithm)
+ return Exception { OperationError };
+ auto digest = CryptoDigest::create(*cryptoDigestAlgorithm);
+ if (!digest)
+ return Exception { OperationError };
+ digest->addBytes(data, dataLength);
+ auto digestData = digest->computeHash();
+
+ auto status = CCRSACryptorVerify(key, ccPKCS1Padding, digestData.data(), digestData.size(), digestAlgorithm, 0, signature, signatureLength);
+ if (!status)
+ return true;
+ if (status == kCCNotVerified || status == kCCDecodeError) // <rdar://problem/15464982> CCRSACryptorVerify returns kCCDecodeError instead of kCCNotVerified sometimes
+ return false;
+
+ return Exception { OperationError };
+}
+
</ins><span class="cx"> void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(Ref<CryptoKey>&& key, Vector<uint8_t>&& data, VectorCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
</span><span class="cx"> {
</span><span class="cx"> context.ref();
</span><span class="lines">@@ -104,6 +130,28 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(Ref<CryptoKey>&& key, Vector<uint8_t>&& signature, Vector<uint8_t>&& data, BoolCallback&& callback, ExceptionCallback&& exceptionCallback, ScriptExecutionContext& context, WorkQueue& workQueue)
+{
+ context.ref();
+ workQueue.dispatch([key = WTFMove(key), signature = WTFMove(signature), data = WTFMove(data), callback = WTFMove(callback), exceptionCallback = WTFMove(exceptionCallback), &context]() mutable {
+ auto& rsaKey = downcast<CryptoKeyRSA>(key.get());
+ auto result = verifyRSASSA_PKCS1_v1_5(rsaKey.hashAlgorithmIdentifier(), rsaKey.platformKey(), signature.data(), signature.size(), data.data(), data.size());
+ if (result.hasException()) {
+ // We should only dereference callbacks after being back to the Document/Worker threads.
+ context.postTask([exceptionCallback = WTFMove(exceptionCallback), ec = result.releaseException().code(), callback = WTFMove(callback)](ScriptExecutionContext& context) {
+ exceptionCallback(ec);
+ context.deref();
+ });
+ return;
+ }
+ // We should only dereference callbacks after being back to the Document/Worker threads.
+ context.postTask([callback = WTFMove(callback), result = result.releaseReturnValue(), exceptionCallback = WTFMove(exceptionCallback)](ScriptExecutionContext& context) {
+ callback(result);
+ context.deref();
+ });
+ });
+}
+
</ins><span class="cx"> ExceptionOr<void> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformSign(const CryptoAlgorithmRsaSsaParamsDeprecated& parameters, const CryptoKeyRSA& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback)
</span><span class="cx"> {
</span><span class="cx"> auto result = signRSASSA_PKCS1_v1_5(parameters.hash, key.platformKey(), key.keySizeInBits(), data.first, data.second);
</span><span class="lines">@@ -117,29 +165,12 @@
</span><span class="cx">
</span><span class="cx"> ExceptionOr<void> CryptoAlgorithmRSASSA_PKCS1_v1_5::platformVerify(const CryptoAlgorithmRsaSsaParamsDeprecated& parameters, const CryptoKeyRSA& key, const CryptoOperationData& signature, const CryptoOperationData& data, BoolCallback&& callback, VoidCallback&& failureCallback)
</span><span class="cx"> {
</span><del>- CCDigestAlgorithm digestAlgorithm;
- if (!getCommonCryptoDigestAlgorithm(parameters.hash, digestAlgorithm))
- return Exception { NOT_SUPPORTED_ERR };
-
- auto cryptoDigestAlgorithm = WebCore::cryptoDigestAlgorithm(parameters.hash);
- if (!cryptoDigestAlgorithm)
- return Exception { NOT_SUPPORTED_ERR };
-
- auto digest = CryptoDigest::create(*cryptoDigestAlgorithm);
- if (!digest)
- return Exception { NOT_SUPPORTED_ERR };
-
- digest->addBytes(data.first, data.second);
-
- auto digestData = digest->computeHash();
-
- auto status = CCRSACryptorVerify(key.platformKey(), ccPKCS1Padding, digestData.data(), digestData.size(), digestAlgorithm, 0, signature.first, signature.second);
- if (!status)
- callback(true);
- else if (status == kCCNotVerified || status == kCCDecodeError) // <rdar://problem/15464982> CCRSACryptorVerify returns kCCDecodeError instead of kCCNotVerified sometimes
- callback(false);
- else
</del><ins>+ auto result = verifyRSASSA_PKCS1_v1_5(parameters.hash, key.platformKey(), signature.first, signature.second, data.first, data.second);
+ if (result.hasException()) {
</ins><span class="cx"> failureCallback();
</span><ins>+ return { };
+ }
+ callback(result.releaseReturnValue());
</ins><span class="cx"> return { };
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>