<!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>[213560] 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/213560">213560</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2017-03-07 18:09:38 -0800 (Tue, 07 Mar 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WebCrypto] Implement ECDH ImportKey/ExportKey operations
https://bugs.webkit.org/show_bug.cgi?id=169257
&lt;rdar://problem/23789585&gt;

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

* web-platform-tests/WebCryptoAPI/import_export/ec_importKey.worker-expected.txt:
* web-platform-tests/WebCryptoAPI/import_export/test_ec_importKey-expected.txt:

Source/WebCore:

This patch implements ECDH ImportKey/ExportKey operations according to:
https://www.w3.org/TR/WebCryptoAPI/#ecdh-operations. Sad that we can't
support SPKI/PKCS8 formats at this moment due to lack of necessary
support in the underlying crypto library. Bug 169318 is tracking the
issue. Also, this patch fixes minor bugs while importing JWK keys for
HMAC/RSA.

Tests: crypto/subtle/ec-export-key-malformed-parameters.html
       crypto/subtle/ec-import-jwk-key-export-jwk-key-private.html
       crypto/subtle/ec-import-jwk-key-export-jwk-key-public.html
       crypto/subtle/ec-import-jwk-key-export-raw-key.html
       crypto/subtle/ec-import-key-malformed-parameters.html
       crypto/subtle/ec-import-raw-key-export-jwk-key.html
       crypto/subtle/ec-import-raw-key-export-raw-key.html
       crypto/subtle/ecdh-generate-export-jwk-key-p256.html
       crypto/subtle/ecdh-generate-export-jwk-key-p384.html
       crypto/subtle/ecdh-generate-export-key-raw-p256.html
       crypto/subtle/ecdh-generate-export-key-raw-p384.html
       crypto/subtle/ecdh-import-jwk-key-minimum.html
       crypto/subtle/ecdh-import-jwk-private-key-p256.html
       crypto/subtle/ecdh-import-jwk-private-key-p384.html
       crypto/subtle/ecdh-import-jwk-public-key-p256.html
       crypto/subtle/ecdh-import-jwk-public-key-p384.html
       crypto/subtle/ecdh-import-raw-key-p256.html
       crypto/subtle/ecdh-import-raw-key-p384.html
       crypto/workers/subtle/ec-generate-export-jwk-key.html
       crypto/workers/subtle/ec-generate-export-raw-key.html
       crypto/workers/subtle/ec-import-jwk-key-private.html
       crypto/workers/subtle/ec-import-jwk-key-public.html
       crypto/workers/subtle/ec-import-raw-key.html

* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::normalizeCryptoAlgorithmParameters):
(WebCore::supportExportKeyThrow):
Added EC family support.
* crypto/CommonCryptoUtilities.h:
Added needed CommonCrypto SPIs.
* crypto/CryptoAlgorithm.h:
* crypto/algorithms/CryptoAlgorithmECDH.cpp:
(WebCore::CryptoAlgorithmECDH::importKey):
(WebCore::CryptoAlgorithmECDH::exportKey):
* crypto/algorithms/CryptoAlgorithmECDH.h:
* crypto/gnutls/CryptoKeyECGnuTLS.cpp:
(WebCore::CryptoKeyEC::keySizeInBits):
(WebCore::CryptoKeyEC::exportRaw):
(WebCore::CryptoKeyEC::platformImportRaw):
(WebCore::CryptoKeyEC::platformImportJWKPublic):
(WebCore::CryptoKeyEC::platformImportJWKPrivate):
(WebCore::CryptoKeyEC::platformAddFieldElements):
Faked implementations for GTK+.
* crypto/keys/CryptoKeyEC.cpp:
(WebCore::toNamedCurve):
(WebCore::CryptoKeyEC::generatePair):
(WebCore::CryptoKeyEC::importRaw):
(WebCore::CryptoKeyEC::importJwk):
(WebCore::CryptoKeyEC::exportJwk):
* crypto/keys/CryptoKeyEC.h:
* crypto/keys/CryptoKeyHMAC.cpp:
(WebCore::CryptoKeyHMAC::importJwk):
Fixed a bug.
* crypto/keys/CryptoKeyRSA.cpp:
(WebCore::CryptoKeyRSA::importJwk):
Fixed a bug.
* crypto/mac/CryptoKeyECMac.cpp:
(WebCore::doesUncompressedPointMatchNamedCurve):
(WebCore::doesFieldElementMatchNamedCurve):
(WebCore::getKeySizeFromNamedCurve):
(WebCore::CryptoKeyEC::~CryptoKeyEC):
(WebCore::CryptoKeyEC::keySizeInBits):
(WebCore::CryptoKeyEC::exportRaw):
(WebCore::CryptoKeyEC::platformGeneratePair):
(WebCore::CryptoKeyEC::platformImportRaw):
(WebCore::CryptoKeyEC::platformImportJWKPublic):
(WebCore::CryptoKeyEC::platformImportJWKPrivate):
(WebCore::CryptoKeyEC::platformAddFieldElements):

LayoutTests:

* crypto/subtle/ec-export-key-malformed-parameters-expected.txt: Added.
* crypto/subtle/ec-export-key-malformed-parameters.html: Added.
* crypto/subtle/ec-import-jwk-key-export-jwk-key-private-expected.txt: Added.
* crypto/subtle/ec-import-jwk-key-export-jwk-key-private.html: Added.
* crypto/subtle/ec-import-jwk-key-export-jwk-key-public-expected.txt: Added.
* crypto/subtle/ec-import-jwk-key-export-jwk-key-public.html: Added.
* crypto/subtle/ec-import-jwk-key-export-raw-key-expected.txt: Added.
* crypto/subtle/ec-import-jwk-key-export-raw-key.html: Added.
* crypto/subtle/ec-import-key-malformed-parameters-expected.txt: Added.
* crypto/subtle/ec-import-key-malformed-parameters.html: Added.
* crypto/subtle/ec-import-raw-key-export-jwk-key-expected.txt: Added.
* crypto/subtle/ec-import-raw-key-export-jwk-key.html: Added.
* crypto/subtle/ec-import-raw-key-export-raw-key-expected.txt: Added.
* crypto/subtle/ec-import-raw-key-export-raw-key.html: Added.
* crypto/subtle/ecdh-generate-export-jwk-key-p256-expected.txt: Added.
* crypto/subtle/ecdh-generate-export-jwk-key-p256.html: Added.
* crypto/subtle/ecdh-generate-export-jwk-key-p384-expected.txt: Added.
* crypto/subtle/ecdh-generate-export-jwk-key-p384.html: Added.
* crypto/subtle/ecdh-generate-export-key-raw-p256-expected.txt: Added.
* crypto/subtle/ecdh-generate-export-key-raw-p256.html: Added.
* crypto/subtle/ecdh-generate-export-key-raw-p384-expected.txt: Added.
* crypto/subtle/ecdh-generate-export-key-raw-p384.html: Added.
* crypto/subtle/ecdh-import-jwk-key-minimum-expected.txt: Added.
* crypto/subtle/ecdh-import-jwk-key-minimum.html: Added.
* crypto/subtle/ecdh-import-jwk-private-key-p256-expected.txt: Added.
* crypto/subtle/ecdh-import-jwk-private-key-p256.html: Added.
* crypto/subtle/ecdh-import-jwk-private-key-p384-expected.txt: Added.
* crypto/subtle/ecdh-import-jwk-private-key-p384.html: Added.
* crypto/subtle/ecdh-import-jwk-public-key-p256-expected.txt: Added.
* crypto/subtle/ecdh-import-jwk-public-key-p256.html: Added.
* crypto/subtle/ecdh-import-jwk-public-key-p384-expected.txt: Added.
* crypto/subtle/ecdh-import-jwk-public-key-p384.html: Added.
* crypto/subtle/ecdh-import-raw-key-p256-expected.txt: Added.
* crypto/subtle/ecdh-import-raw-key-p256.html: Added.
* crypto/subtle/ecdh-import-raw-key-p384-expected.txt: Added.
* crypto/subtle/ecdh-import-raw-key-p384.html: Added.
* crypto/subtle/hmac-import-key-malformed-parameters-expected.txt:
* crypto/subtle/hmac-import-key-malformed-parameters.html:
* crypto/subtle/rsa-import-key-malformed-parameters-expected.txt:
* crypto/subtle/rsa-import-key-malformed-parameters.html:
Fixed some minor bugs.
* crypto/workers/subtle/ec-generate-export-jwk-key-expected.txt: Added.
* crypto/workers/subtle/ec-generate-export-jwk-key.html: Added.
* crypto/workers/subtle/ec-generate-export-raw-key-expected.txt: Added.
* crypto/workers/subtle/ec-generate-export-raw-key.html: Added.
* crypto/workers/subtle/ec-import-jwk-key-private-expected.txt: Added.
* crypto/workers/subtle/ec-import-jwk-key-private.html: Added.
* crypto/workers/subtle/ec-import-jwk-key-public-expected.txt: Added.
* crypto/workers/subtle/ec-import-jwk-key-public.html: Added.
* crypto/workers/subtle/ec-import-raw-key-expected.txt: Added.
* crypto/workers/subtle/ec-import-raw-key.html: Added.
* crypto/workers/subtle/resources/ec-generate-export-jwk-key.js: Added.
* crypto/workers/subtle/resources/ec-generate-export-raw-key.js: Added.
* crypto/workers/subtle/resources/ec-import-jwk-key-private.js: Added.
* crypto/workers/subtle/resources/ec-import-jwk-key-public.js: Added.
* crypto/workers/subtle/resources/ec-import-raw-key.js: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlehmacimportkeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportkeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtlersaimportkeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsWebCryptoAPIimport_exportec_importKeyworkerexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/ec_importKey.worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsWebCryptoAPIimport_exporttest_ec_importKeyexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/test_ec_importKey-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="#trunkSourceWebCorecryptoCommonCryptoUtilitiesh">trunk/Source/WebCore/crypto/CommonCryptoUtilities.h</a></li>
<li><a href="#trunkSourceWebCorecryptoCryptoAlgorithmh">trunk/Source/WebCore/crypto/CryptoAlgorithm.h</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmECDHcpp">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmECDHh">trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h</a></li>
<li><a href="#trunkSourceWebCorecryptognutlsCryptoKeyECGnuTLScpp">trunk/Source/WebCore/crypto/gnutls/CryptoKeyECGnuTLS.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyECcpp">trunk/Source/WebCore/crypto/keys/CryptoKeyEC.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyECh">trunk/Source/WebCore/crypto/keys/CryptoKeyEC.h</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyHMACcpp">trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptokeysCryptoKeyRSAcpp">trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.cpp</a></li>
<li><a href="#trunkSourceWebCorecryptomacCryptoKeyECMaccpp">trunk/Source/WebCore/crypto/mac/CryptoKeyECMac.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestscryptosubtleecexportkeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/ec-export-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecexportkeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/ec-export-key-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecimportjwkkeyexportjwkkeyprivateexpectedtxt">trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-private-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecimportjwkkeyexportjwkkeyprivatehtml">trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-private.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecimportjwkkeyexportjwkkeypublicexpectedtxt">trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-public-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecimportjwkkeyexportjwkkeypublichtml">trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-public.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecimportjwkkeyexportrawkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-raw-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecimportjwkkeyexportrawkeyhtml">trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-raw-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecimportkeymalformedparametersexpectedtxt">trunk/LayoutTests/crypto/subtle/ec-import-key-malformed-parameters-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecimportkeymalformedparametershtml">trunk/LayoutTests/crypto/subtle/ec-import-key-malformed-parameters.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecimportrawkeyexportjwkkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-jwk-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecimportrawkeyexportjwkkeyhtml">trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-jwk-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecimportrawkeyexportrawkeyexpectedtxt">trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-raw-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecimportrawkeyexportrawkeyhtml">trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-raw-key.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhgenerateexportjwkkeyp256expectedtxt">trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhgenerateexportjwkkeyp256html">trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhgenerateexportjwkkeyp384expectedtxt">trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p384-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhgenerateexportjwkkeyp384html">trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p384.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhgenerateexportkeyrawp256expectedtxt">trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhgenerateexportkeyrawp256html">trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhgenerateexportkeyrawp384expectedtxt">trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p384-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhgenerateexportkeyrawp384html">trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p384.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportjwkkeyminimumexpectedtxt">trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-key-minimum-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportjwkkeyminimumhtml">trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-key-minimum.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportjwkprivatekeyp256expectedtxt">trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportjwkprivatekeyp256html">trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportjwkprivatekeyp384expectedtxt">trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p384-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportjwkprivatekeyp384html">trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p384.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportjwkpublickeyp256expectedtxt">trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportjwkpublickeyp256html">trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportjwkpublickeyp384expectedtxt">trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p384-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportjwkpublickeyp384html">trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p384.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportrawkeyp256expectedtxt">trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p256-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportrawkeyp256html">trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p256.html</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportrawkeyp384expectedtxt">trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p384-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptosubtleecdhimportrawkeyp384html">trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p384.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleecgenerateexportjwkkeyexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-jwk-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleecgenerateexportjwkkeyhtml">trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-jwk-key.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleecgenerateexportrawkeyexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-raw-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleecgenerateexportrawkeyhtml">trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-raw-key.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleecimportjwkkeyprivateexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-private-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleecimportjwkkeyprivatehtml">trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-private.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleecimportjwkkeypublicexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-public-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleecimportjwkkeypublichtml">trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-public.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleecimportrawkeyexpectedtxt">trunk/LayoutTests/crypto/workers/subtle/ec-import-raw-key-expected.txt</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleecimportrawkeyhtml">trunk/LayoutTests/crypto/workers/subtle/ec-import-raw-key.html</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesecgenerateexportjwkkeyjs">trunk/LayoutTests/crypto/workers/subtle/resources/ec-generate-export-jwk-key.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesecgenerateexportrawkeyjs">trunk/LayoutTests/crypto/workers/subtle/resources/ec-generate-export-raw-key.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesecimportjwkkeyprivatejs">trunk/LayoutTests/crypto/workers/subtle/resources/ec-import-jwk-key-private.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesecimportjwkkeypublicjs">trunk/LayoutTests/crypto/workers/subtle/resources/ec-import-jwk-key-public.js</a></li>
<li><a href="#trunkLayoutTestscryptoworkerssubtleresourcesecimportrawkeyjs">trunk/LayoutTests/crypto/workers/subtle/resources/ec-import-raw-key.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/LayoutTests/ChangeLog        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -1,3 +1,68 @@
</span><ins>+2017-03-07  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        [WebCrypto] Implement ECDH ImportKey/ExportKey operations
+        https://bugs.webkit.org/show_bug.cgi?id=169257
+        &lt;rdar://problem/23789585&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * crypto/subtle/ec-export-key-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/ec-export-key-malformed-parameters.html: Added.
+        * crypto/subtle/ec-import-jwk-key-export-jwk-key-private-expected.txt: Added.
+        * crypto/subtle/ec-import-jwk-key-export-jwk-key-private.html: Added.
+        * crypto/subtle/ec-import-jwk-key-export-jwk-key-public-expected.txt: Added.
+        * crypto/subtle/ec-import-jwk-key-export-jwk-key-public.html: Added.
+        * crypto/subtle/ec-import-jwk-key-export-raw-key-expected.txt: Added.
+        * crypto/subtle/ec-import-jwk-key-export-raw-key.html: Added.
+        * crypto/subtle/ec-import-key-malformed-parameters-expected.txt: Added.
+        * crypto/subtle/ec-import-key-malformed-parameters.html: Added.
+        * crypto/subtle/ec-import-raw-key-export-jwk-key-expected.txt: Added.
+        * crypto/subtle/ec-import-raw-key-export-jwk-key.html: Added.
+        * crypto/subtle/ec-import-raw-key-export-raw-key-expected.txt: Added.
+        * crypto/subtle/ec-import-raw-key-export-raw-key.html: Added.
+        * crypto/subtle/ecdh-generate-export-jwk-key-p256-expected.txt: Added.
+        * crypto/subtle/ecdh-generate-export-jwk-key-p256.html: Added.
+        * crypto/subtle/ecdh-generate-export-jwk-key-p384-expected.txt: Added.
+        * crypto/subtle/ecdh-generate-export-jwk-key-p384.html: Added.
+        * crypto/subtle/ecdh-generate-export-key-raw-p256-expected.txt: Added.
+        * crypto/subtle/ecdh-generate-export-key-raw-p256.html: Added.
+        * crypto/subtle/ecdh-generate-export-key-raw-p384-expected.txt: Added.
+        * crypto/subtle/ecdh-generate-export-key-raw-p384.html: Added.
+        * crypto/subtle/ecdh-import-jwk-key-minimum-expected.txt: Added.
+        * crypto/subtle/ecdh-import-jwk-key-minimum.html: Added.
+        * crypto/subtle/ecdh-import-jwk-private-key-p256-expected.txt: Added.
+        * crypto/subtle/ecdh-import-jwk-private-key-p256.html: Added.
+        * crypto/subtle/ecdh-import-jwk-private-key-p384-expected.txt: Added.
+        * crypto/subtle/ecdh-import-jwk-private-key-p384.html: Added.
+        * crypto/subtle/ecdh-import-jwk-public-key-p256-expected.txt: Added.
+        * crypto/subtle/ecdh-import-jwk-public-key-p256.html: Added.
+        * crypto/subtle/ecdh-import-jwk-public-key-p384-expected.txt: Added.
+        * crypto/subtle/ecdh-import-jwk-public-key-p384.html: Added.
+        * crypto/subtle/ecdh-import-raw-key-p256-expected.txt: Added.
+        * crypto/subtle/ecdh-import-raw-key-p256.html: Added.
+        * crypto/subtle/ecdh-import-raw-key-p384-expected.txt: Added.
+        * crypto/subtle/ecdh-import-raw-key-p384.html: Added.
+        * crypto/subtle/hmac-import-key-malformed-parameters-expected.txt:
+        * crypto/subtle/hmac-import-key-malformed-parameters.html:
+        * crypto/subtle/rsa-import-key-malformed-parameters-expected.txt:
+        * crypto/subtle/rsa-import-key-malformed-parameters.html:
+        Fixed some minor bugs.
+        * crypto/workers/subtle/ec-generate-export-jwk-key-expected.txt: Added.
+        * crypto/workers/subtle/ec-generate-export-jwk-key.html: Added.
+        * crypto/workers/subtle/ec-generate-export-raw-key-expected.txt: Added.
+        * crypto/workers/subtle/ec-generate-export-raw-key.html: Added.
+        * crypto/workers/subtle/ec-import-jwk-key-private-expected.txt: Added.
+        * crypto/workers/subtle/ec-import-jwk-key-private.html: Added.
+        * crypto/workers/subtle/ec-import-jwk-key-public-expected.txt: Added.
+        * crypto/workers/subtle/ec-import-jwk-key-public.html: Added.
+        * crypto/workers/subtle/ec-import-raw-key-expected.txt: Added.
+        * crypto/workers/subtle/ec-import-raw-key.html: Added.
+        * crypto/workers/subtle/resources/ec-generate-export-jwk-key.js: Added.
+        * crypto/workers/subtle/resources/ec-generate-export-raw-key.js: Added.
+        * crypto/workers/subtle/resources/ec-import-jwk-key-private.js: Added.
+        * crypto/workers/subtle/resources/ec-import-jwk-key-public.js: Added.
+        * crypto/workers/subtle/resources/ec-import-raw-key.js: Added.
+
</ins><span class="cx"> 2017-03-07  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add Debug flag to TestExpectation for webrtc/libwebrtc/descriptionGetters.html.
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecexportkeymalformedparametersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-export-key-malformed-parameters-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-export-key-malformed-parameters-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-export-key-malformed-parameters-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Test exporting an EC key with malformed parameters
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS crypto.subtle.exportKey(&quot;raw&quot;, privateKey) rejected promise  with InvalidAccessError (DOM Exception 15): The requested operation is not valid for the provided key.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecexportkeymalformedparametershtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-export-key-malformed-parameters.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-export-key-malformed-parameters.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-export-key-malformed-parameters.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test exporting an EC key with malformed parameters&quot;);
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: &quot;ECDH&quot;,
+    namedCurve: &quot;P-256&quot;
+};
+var extractable = true;
+
+crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;deriveKey&quot;, &quot;deriveBits&quot;]).then(function(result) {
+    privateKey = result.privateKey;
+
+    // Wrong key and format.
+    return shouldReject('crypto.subtle.exportKey(&quot;raw&quot;, privateKey)');
+}).then(finishJSTest, finishJSTest);
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecimportjwkkeyexportjwkkeyprivateexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-private-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-private-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-private-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+Test importing a jwk private ECDH key and then export it in jwk format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.kty is jwkKey.kty
+PASS publicKey.crv is jwkKey.crv
+PASS publicKey.x is jwkKey.x
+PASS publicKey.y is jwkKey.y
+PASS publicKey.d is jwkKey.d
+PASS publicKey.key_ops is jwkKey.key_ops
+PASS publicKey.ext is jwkKey.ext
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecimportjwkkeyexportjwkkeyprivatehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-private.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-private.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-private.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a jwk private ECDH key and then export it in jwk format&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;EC&quot;,
+    ext: true,
+    key_ops: [&quot;deriveBits&quot;, &quot;deriveKey&quot;],
+    crv: &quot;P-256&quot;,
+    x: &quot;1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA&quot;,
+    y: &quot;9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI&quot;,
+    d: &quot;ppxBSov3N8_AUcisAuvmLV4yE8e_L_BLE8bZb9Z1Xjg&quot;,
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;deriveKey&quot;, &quot;deriveBits&quot;]).then(function(result) {
+    return crypto.subtle.exportKey(&quot;jwk&quot;, result);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;jwkKey.kty&quot;);
+    shouldBe(&quot;publicKey.crv&quot;, &quot;jwkKey.crv&quot;);
+    shouldBe(&quot;publicKey.x&quot;, &quot;jwkKey.x&quot;);
+    shouldBe(&quot;publicKey.y&quot;, &quot;jwkKey.y&quot;);
+    shouldBe(&quot;publicKey.d&quot;, &quot;jwkKey.d&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;jwkKey.key_ops&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;jwkKey.ext&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecimportjwkkeyexportjwkkeypublicexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-public-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-public-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-public-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test importing a jwk public ECDH key and then export it in jwk format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.kty is jwkKey.kty
+PASS publicKey.crv is jwkKey.crv
+PASS publicKey.x is jwkKey.x
+PASS publicKey.y is jwkKey.y
+PASS publicKey.key_ops is [ ]
+PASS publicKey.ext is jwkKey.ext
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecimportjwkkeyexportjwkkeypublichtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-public.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-public.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-jwk-key-public.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a jwk public ECDH key and then export it in jwk format&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;EC&quot;,
+    use: &quot;enc&quot;,
+    ext: true,
+    crv: &quot;P-256&quot;,
+    x: &quot;1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA&quot;,
+    y: &quot;9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI&quot;,
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]).then(function(result) {
+    return crypto.subtle.exportKey(&quot;jwk&quot;, result);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;jwkKey.kty&quot;);
+    shouldBe(&quot;publicKey.crv&quot;, &quot;jwkKey.crv&quot;);
+    shouldBe(&quot;publicKey.x&quot;, &quot;jwkKey.x&quot;);
+    shouldBe(&quot;publicKey.y&quot;, &quot;jwkKey.y&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;[ ]&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;jwkKey.ext&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecimportjwkkeyexportrawkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-raw-key-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-raw-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-raw-key-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Test importing a jwk ECDH key and then export it in raw format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS bytesToHexString(publicKey) is expectedRawKey
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecimportjwkkeyexportrawkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-raw-key.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-raw-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-jwk-key-export-raw-key.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a jwk ECDH key and then export it in raw format&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;EC&quot;,
+    use: &quot;enc&quot;,
+    ext: true,
+    crv: &quot;P-256&quot;,
+    x: &quot;1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA&quot;,
+    y: &quot;9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI&quot;,
+};
+var expectedRawKey = &quot;04d454955a2793be2905906d4d3b286450268c6dd421c701fa682bb8133fac46d0f6398d4cba8ce1c8c185d0271dc348f58415dcef0b166a3e11d65693c9ed01a2&quot;;
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]).then(function(result) {
+    return crypto.subtle.exportKey(&quot;raw&quot;, result);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;bytesToHexString(publicKey)&quot;, &quot;expectedRawKey&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecimportkeymalformedparametersexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-import-key-malformed-parameters-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-import-key-malformed-parameters-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-key-malformed-parameters-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+Test importing a EC key with malformed parameters
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS crypto.subtle.importKey(&quot;raw&quot;, rawP256Key, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;raw&quot;, rawP384Key, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;raw&quot;, rawP256Key, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;deriveBits&quot;]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey(&quot;raw&quot;, rawP256Key, { name: &quot;ECDH&quot;, namedCurve: &quot;P-521&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;deriveKey&quot;]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;encrypt&quot;]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;decrypt&quot;]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;sign&quot;]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;verify&quot;]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;wrapKey&quot;]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;unwrapKey&quot;]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d, use: &quot;sig&quot;}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;deriveKey&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, crv: &quot;P-256&quot;, x:x, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d, key_ops: [&quot;sign&quot;, &quot;verify&quot;]}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;deriveKey&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, ext: false}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, x:x, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-384&quot;, x:x, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-521&quot;, x:x, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-521&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-384&quot;, x:x, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-384&quot;, x:x384, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-384&quot;, x:x, y:y384}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-384&quot;, x:x384, y:y384, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, extractable, [ ]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecimportkeymalformedparametershtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-import-key-malformed-parameters.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-import-key-malformed-parameters.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-key-malformed-parameters.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a EC key with malformed parameters&quot;);
+
+var extractable = true;
+var rawP256Key = hexStringToUint8Array(&quot;04dc08d9bf603333eab1ad29cef41a6203ab6ecce03c5a4a9bf5771a3fb9f971d89a09664bfb87c61199b3453220eadec714c49ad1e24bf5d7ec5bddeca6420893&quot;);
+var rawP384Key = hexStringToUint8Array(&quot;048ba3e0a0ac5c9bb25476323570fa11dff30745a13da751a5eb1dacb5e9b439df0f77979077ee9ac97c02ca1e3cd72677cbbc256a69b99fd83a519ca9a9a26c62d45b51659274b1cea3c9858543abf5c64bfcfcd1948b7075c0409da4494f9060&quot;);
+var x = &quot;1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA&quot;; // P-256
+var y = &quot;9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI&quot;; // P-256
+var d = &quot;ppxBSov3N8_AUcisAuvmLV4yE8e_L_BLE8bZb9Z1Xjg&quot;; // P-256
+var x384 = &quot;1bHwFrsaPRjYq-zFOyLXK8Ugv3EqbVF075ct7ouTl_pwyhjeBu03JHjKTsyVbNWK&quot;;
+var y384 = &quot;1bHwFrsaPRjYq-zFOyLXK8Ugv3EqbVF075ct7ouTl_pwyhjeBu03JHjKTsyVbNWK&quot;;
+
+// Named curves mismatch raw keys
+shouldReject('crypto.subtle.importKey(&quot;raw&quot;, rawP256Key, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, extractable, [ ])');
+shouldReject('crypto.subtle.importKey(&quot;raw&quot;, rawP384Key, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ])');
+// Raw: Non-empty usages
+shouldReject('crypto.subtle.importKey(&quot;raw&quot;, rawP256Key, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;deriveBits&quot;])');
+// Raw: Not support named curve
+shouldReject('crypto.subtle.importKey(&quot;raw&quot;, rawP256Key, { name: &quot;ECDH&quot;, namedCurve: &quot;P-521&quot; }, extractable, [ ])');
+// Jwk: Wrong usages
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;deriveKey&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;encrypt&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;decrypt&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;sign&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;verify&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;wrapKey&quot;])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;unwrapKey&quot;])');
+// Jwk: Wrong use
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d, use: &quot;sig&quot;}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;deriveKey&quot;])');
+// Jwk: Wrong kty
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, crv: &quot;P-256&quot;, x:x, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ])');
+// Jwk: Wrong key_ops
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, d:d, key_ops: [&quot;sign&quot;, &quot;verify&quot;]}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [&quot;deriveKey&quot;])');
+// Jwk: Wrong ext
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x, y:y, ext: false}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ])');
+// Jwk: Missing crv
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, x:x, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ])');
+// Jwk: Mismatched crv
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-384&quot;, x:x, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ])');
+// Jwk: Not supported crv
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-521&quot;, x:x, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-521&quot; }, extractable, [ ])');
+// Jwk: Missing x, y
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-256&quot;, x:x}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ])');
+// Jwk: Mismatched x, y, d
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-384&quot;, x:x, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, extractable, [ ])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-384&quot;, x:x384, y:y}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, extractable, [ ])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-384&quot;, x:x, y:y384}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, extractable, [ ])');
+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;EC&quot;, crv: &quot;P-384&quot;, x:x384, y:y384, d:d}, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, extractable, [ ])');
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecimportrawkeyexportjwkkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-jwk-key-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-jwk-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-jwk-key-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test importing a raw ECDH key and then export it in jwk format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.kty is expectedJwkKey.kty
+PASS publicKey.crv is expectedJwkKey.crv
+PASS publicKey.x is expectedJwkKey.x
+PASS publicKey.y is expectedJwkKey.y
+PASS publicKey.key_ops is [ ]
+PASS publicKey.ext is expectedJwkKey.ext
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecimportrawkeyexportjwkkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-jwk-key.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-jwk-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-jwk-key.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a raw ECDH key and then export it in jwk format&quot;);
+
+jsTestIsAsync = true;
+
+var expectedJwkKey = {
+    kty: &quot;EC&quot;,
+    use: &quot;enc&quot;,
+    ext: true,
+    crv: &quot;P-256&quot;,
+    x: &quot;1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA&quot;,
+    y: &quot;9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI&quot;,
+};
+var rawKey = hexStringToUint8Array(&quot;04d454955a2793be2905906d4d3b286450268c6dd421c701fa682bb8133fac46d0f6398d4cba8ce1c8c185d0271dc348f58415dcef0b166a3e11d65693c9ed01a2&quot;);
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]).then(function(result) {
+    return crypto.subtle.exportKey(&quot;jwk&quot;, result);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;expectedJwkKey.kty&quot;);
+    shouldBe(&quot;publicKey.crv&quot;, &quot;expectedJwkKey.crv&quot;);
+    shouldBe(&quot;publicKey.x&quot;, &quot;expectedJwkKey.x&quot;);
+    shouldBe(&quot;publicKey.y&quot;, &quot;expectedJwkKey.y&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;[ ]&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;expectedJwkKey.ext&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecimportrawkeyexportrawkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-raw-key-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-raw-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-raw-key-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Test importing a raw ECDH key and then export it in raw format
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS bytesToHexString(publicKey) is rawKeyHex
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecimportrawkeyexportrawkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-raw-key.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-raw-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ec-import-raw-key-export-raw-key.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a raw ECDH key and then export it in raw format&quot;);
+
+jsTestIsAsync = true;
+
+var rawKeyHex = &quot;04dc08d9bf603333eab1ad29cef41a6203ab6ecce03c5a4a9bf5771a3fb9f971d89a09664bfb87c61199b3453220eadec714c49ad1e24bf5d7ec5bddeca6420893&quot;;
+var rawKey = hexStringToUint8Array(rawKeyHex);
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, {name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot;}, extractable, [ ]).then(function(publicKey) {
+    return crypto.subtle.exportKey(&quot;raw&quot;, publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;bytesToHexString(publicKey)&quot;, &quot;rawKeyHex&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhgenerateexportjwkkeyp256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p256-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p256-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p256-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+Test exporting a P-256 ECDH key pair with JWK format.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key pair...
+Exporting the public key...
+PASS publicKey.kty is 'EC'
+PASS publicKey.crv is 'P-256'
+PASS Base64URL.parse(publicKey.x).byteLength is 32
+PASS Base64URL.parse(publicKey.y).byteLength is 32
+PASS publicKey.d is undefined.
+PASS publicKey.key_ops is [ ]
+PASS publicKey.ext is true
+Exporting the private key...
+PASS privateKey.kty is 'EC'
+PASS privateKey.crv is 'P-256'
+PASS Base64URL.parse(privateKey.x).byteLength is 32
+PASS Base64URL.parse(privateKey.y).byteLength is 32
+PASS Base64URL.parse(privateKey.d).byteLength is 32
+PASS privateKey.key_ops is ['deriveBits', 'deriveKey']
+PASS privateKey.ext is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhgenerateexportjwkkeyp256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p256.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p256.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p256.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test exporting a P-256 ECDH key pair with JWK format.&quot;);
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: &quot;ECDH&quot;,
+    namedCurve: &quot;P-256&quot;
+};
+var extractable = true;
+
+var keyPair;
+debug(&quot;Generating a key pair...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;deriveKey&quot;, &quot;deriveBits&quot;]).then(function(result) {
+    keyPair = result;
+    debug(&quot;Exporting the public key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'EC'&quot;);
+    shouldBe(&quot;publicKey.crv&quot;, &quot;'P-256'&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.x).byteLength&quot;, &quot;32&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.y).byteLength&quot;, &quot;32&quot;);
+    shouldBeUndefined(&quot;publicKey.d&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;[ ]&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'EC'&quot;);
+    shouldBe(&quot;privateKey.crv&quot;, &quot;'P-256'&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.x).byteLength&quot;, &quot;32&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.y).byteLength&quot;, &quot;32&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.d).byteLength&quot;, &quot;32&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['deriveBits', 'deriveKey']&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+
+    finishJSTest();
+});
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhgenerateexportjwkkeyp384expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p384-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p384-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p384-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+Test exporting a P-384 ECDH key pair with JWK format.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key pair...
+Exporting the public key...
+PASS publicKey.kty is 'EC'
+PASS publicKey.crv is 'P-384'
+PASS Base64URL.parse(publicKey.x).byteLength is 48
+PASS Base64URL.parse(publicKey.y).byteLength is 48
+PASS publicKey.d is undefined.
+PASS publicKey.key_ops is [ ]
+PASS publicKey.ext is true
+Exporting the private key...
+PASS privateKey.kty is 'EC'
+PASS privateKey.crv is 'P-384'
+PASS Base64URL.parse(privateKey.x).byteLength is 48
+PASS Base64URL.parse(privateKey.y).byteLength is 48
+PASS Base64URL.parse(privateKey.d).byteLength is 48
+PASS privateKey.key_ops is ['deriveBits', 'deriveKey']
+PASS privateKey.ext is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhgenerateexportjwkkeyp384html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p384.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p384.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-jwk-key-p384.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test exporting a P-384 ECDH key pair with JWK format.&quot;);
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: &quot;ECDH&quot;,
+    namedCurve: &quot;P-384&quot;
+};
+var extractable = true;
+
+var keyPair;
+debug(&quot;Generating a key pair...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;deriveKey&quot;, &quot;deriveBits&quot;]).then(function(result) {
+    keyPair = result;
+    debug(&quot;Exporting the public key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'EC'&quot;);
+    shouldBe(&quot;publicKey.crv&quot;, &quot;'P-384'&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.x).byteLength&quot;, &quot;48&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.y).byteLength&quot;, &quot;48&quot;);
+    shouldBeUndefined(&quot;publicKey.d&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;[ ]&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'EC'&quot;);
+    shouldBe(&quot;privateKey.crv&quot;, &quot;'P-384'&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.x).byteLength&quot;, &quot;48&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.y).byteLength&quot;, &quot;48&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.d).byteLength&quot;, &quot;48&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['deriveBits', 'deriveKey']&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+
+    finishJSTest();
+});
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhgenerateexportkeyrawp256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p256-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p256-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p256-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test exporting a P-256 ECDH public key with raw format.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key pair...
+Exporting the public key...
+PASS publicKey.byteLength is 65
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhgenerateexportkeyrawp256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p256.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p256.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p256.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test exporting a P-256 ECDH public key with raw format.&quot;);
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: &quot;ECDH&quot;,
+    namedCurve: &quot;P-256&quot;
+};
+var extractable = true;
+
+var keyPair;
+debug(&quot;Generating a key pair...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;deriveKey&quot;, &quot;deriveBits&quot;]).then(function(result) {
+    keyPair = result;
+    debug(&quot;Exporting the public key...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.byteLength&quot;, &quot;65&quot;);
+
+    finishJSTest();
+});
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhgenerateexportkeyrawp384expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p384-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p384-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p384-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+Test exporting a P-384 ECDH public key with raw format.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Generating a key pair...
+Exporting the public key...
+PASS publicKey.byteLength is 97
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhgenerateexportkeyrawp384html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p384.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p384.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-generate-export-key-raw-p384.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test exporting a P-384 ECDH public key with raw format.&quot;);
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: &quot;ECDH&quot;,
+    namedCurve: &quot;P-384&quot;
+};
+var extractable = true;
+
+var keyPair;
+debug(&quot;Generating a key pair...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;deriveKey&quot;, &quot;deriveBits&quot;]).then(function(result) {
+    keyPair = result;
+    debug(&quot;Exporting the public key...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.byteLength&quot;, &quot;97&quot;);
+
+    finishJSTest();
+});
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportjwkkeyminimumexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-key-minimum-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-key-minimum-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-key-minimum-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test importing a JWK ECDH public key with minimum JWK
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'ECDH'
+PASS publicKey.algorithm.namedCurve is 'P-256'
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportjwkkeyminimumhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-key-minimum.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-key-minimum.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-key-minimum.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a JWK ECDH public key with minimum JWK&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;EC&quot;,
+    crv: &quot;P-256&quot;,
+    x: &quot;1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA&quot;,
+    y: &quot;9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI&quot;,
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;publicKey.type&quot;, &quot;'public'&quot;);
+    shouldBe(&quot;publicKey.extractable&quot;, &quot;true&quot;);
+    shouldBe(&quot;publicKey.algorithm.name&quot;, &quot;'ECDH'&quot;);
+    shouldBe(&quot;publicKey.algorithm.namedCurve&quot;, &quot;'P-256'&quot;);
+    shouldBe(&quot;publicKey.usages&quot;, &quot;[ ]&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportjwkprivatekeyp256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p256-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p256-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p256-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test importing a JWK ECDH private key with P-256
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS privateKey.toString() is '[object CryptoKey]'
+PASS privateKey.type is 'private'
+PASS privateKey.extractable is false
+PASS privateKey.algorithm.name is 'ECDH'
+PASS privateKey.algorithm.namedCurve is 'P-256'
+PASS privateKey.usages is ['deriveBits', 'deriveKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportjwkprivatekeyp256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p256.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p256.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p256.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a JWK ECDH private key with P-256&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;EC&quot;,
+    use: &quot;enc&quot;,
+    ext: false,
+    key_ops: [&quot;deriveKey&quot;, &quot;deriveBits&quot;],
+    crv: &quot;P-256&quot;,
+    x: &quot;1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA&quot;,
+    y: &quot;9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI&quot;,
+    d: &quot;ppxBSov3N8_AUcisAuvmLV4yE8e_L_BLE8bZb9Z1Xjg&quot;,
+};
+var nonExtractable = false;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, nonExtractable, [&quot;deriveKey&quot;, &quot;deriveBits&quot;]).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;privateKey.type&quot;, &quot;'private'&quot;);
+    shouldBe(&quot;privateKey.extractable&quot;, &quot;false&quot;);
+    shouldBe(&quot;privateKey.algorithm.name&quot;, &quot;'ECDH'&quot;);
+    shouldBe(&quot;privateKey.algorithm.namedCurve&quot;, &quot;'P-256'&quot;);
+    shouldBe(&quot;privateKey.usages&quot;, &quot;['deriveBits', 'deriveKey']&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportjwkprivatekeyp384expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p384-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p384-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p384-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test importing a JWK ECDH private key with P-384
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS privateKey.toString() is '[object CryptoKey]'
+PASS privateKey.type is 'private'
+PASS privateKey.extractable is false
+PASS privateKey.algorithm.name is 'ECDH'
+PASS privateKey.algorithm.namedCurve is 'P-384'
+PASS privateKey.usages is ['deriveBits', 'deriveKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportjwkprivatekeyp384html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p384.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p384.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-private-key-p384.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a JWK ECDH private key with P-384&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;EC&quot;,
+    use: &quot;enc&quot;,
+    ext: false,
+    key_ops: [&quot;deriveKey&quot;, &quot;deriveBits&quot;],
+    crv: &quot;P-384&quot;,
+    x: &quot;1bHwFrsaPRjYq-zFOyLXK8Ugv3EqbVF075ct7ouTl_pwyhjeBu03JHjKTsyVbNWK&quot;,
+    y: &quot;1bHwFrsaPRjYq-zFOyLXK8Ugv3EqbVF075ct7ouTl_pwyhjeBu03JHjKTsyVbNWK&quot;,
+    d: &quot;ZV5MWMNl0j2wYmTS0bccCCWdp29-WH3u5-cenSSuv-aHX-GkaPFP4sYSvsrfOlLE&quot;,
+};
+var nonExtractable = false;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, nonExtractable, [&quot;deriveKey&quot;, &quot;deriveBits&quot;]).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;privateKey.type&quot;, &quot;'private'&quot;);
+    shouldBe(&quot;privateKey.extractable&quot;, &quot;false&quot;);
+    shouldBe(&quot;privateKey.algorithm.name&quot;, &quot;'ECDH'&quot;);
+    shouldBe(&quot;privateKey.algorithm.namedCurve&quot;, &quot;'P-384'&quot;);
+    shouldBe(&quot;privateKey.usages&quot;, &quot;['deriveBits', 'deriveKey']&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportjwkpublickeyp256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p256-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p256-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p256-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test importing a JWK ECDH public key with P-256
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'ECDH'
+PASS publicKey.algorithm.namedCurve is 'P-256'
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportjwkpublickeyp256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p256.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p256.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p256.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a JWK ECDH public key with P-256&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;EC&quot;,
+    use: &quot;enc&quot;,
+    ext: true,
+    crv: &quot;P-256&quot;,
+    x: &quot;1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA&quot;,
+    y: &quot;9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI&quot;,
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;publicKey.type&quot;, &quot;'public'&quot;);
+    shouldBe(&quot;publicKey.extractable&quot;, &quot;true&quot;);
+    shouldBe(&quot;publicKey.algorithm.name&quot;, &quot;'ECDH'&quot;);
+    shouldBe(&quot;publicKey.algorithm.namedCurve&quot;, &quot;'P-256'&quot;);
+    shouldBe(&quot;publicKey.usages&quot;, &quot;[ ]&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportjwkpublickeyp384expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p384-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p384-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p384-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test importing a JWK ECDH public key with P-384
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'ECDH'
+PASS publicKey.algorithm.namedCurve is 'P-384'
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportjwkpublickeyp384html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p384.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p384.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-jwk-public-key-p384.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing a JWK ECDH public key with P-384&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;EC&quot;,
+    use: &quot;enc&quot;,
+    ext: true,
+    crv: &quot;P-384&quot;,
+    x: &quot;1bHwFrsaPRjYq-zFOyLXK8Ugv3EqbVF075ct7ouTl_pwyhjeBu03JHjKTsyVbNWK&quot;,
+    y: &quot;1bHwFrsaPRjYq-zFOyLXK8Ugv3EqbVF075ct7ouTl_pwyhjeBu03JHjKTsyVbNWK&quot;,
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;publicKey.type&quot;, &quot;'public'&quot;);
+    shouldBe(&quot;publicKey.extractable&quot;, &quot;true&quot;);
+    shouldBe(&quot;publicKey.algorithm.name&quot;, &quot;'ECDH'&quot;);
+    shouldBe(&quot;publicKey.algorithm.namedCurve&quot;, &quot;'P-384'&quot;);
+    shouldBe(&quot;publicKey.usages&quot;, &quot;[ ]&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportrawkeyp256expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p256-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p256-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p256-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test importing an ECDH raw key with P-256
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'ECDH'
+PASS publicKey.algorithm.namedCurve is 'P-256'
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportrawkeyp256html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p256.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p256.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p256.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing an ECDH raw key with P-256&quot;);
+
+jsTestIsAsync = true;
+
+var rawKey = hexStringToUint8Array(&quot;04dc08d9bf603333eab1ad29cef41a6203ab6ecce03c5a4a9bf5771a3fb9f971d89a09664bfb87c61199b3453220eadec714c49ad1e24bf5d7ec5bddeca6420893&quot;);
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;publicKey.type&quot;, &quot;'public'&quot;);
+    shouldBe(&quot;publicKey.extractable&quot;, &quot;true&quot;);
+    shouldBe(&quot;publicKey.algorithm.name&quot;, &quot;'ECDH'&quot;);
+    shouldBe(&quot;publicKey.algorithm.namedCurve&quot;, &quot;'P-256'&quot;);
+    shouldBe(&quot;publicKey.usages&quot;, &quot;[ ]&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportrawkeyp384expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p384-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p384-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p384-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Test importing an ECDH raw key with P-384
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Importing a key...
+PASS publicKey.toString() is '[object CryptoKey]'
+PASS publicKey.type is 'public'
+PASS publicKey.extractable is true
+PASS publicKey.algorithm.name is 'ECDH'
+PASS publicKey.algorithm.namedCurve is 'P-384'
+PASS publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtleecdhimportrawkeyp384html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p384.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p384.html                                (rev 0)
+++ trunk/LayoutTests/crypto/subtle/ecdh-import-raw-key-p384.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/common.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;description&quot;&gt;&lt;/p&gt;
+&lt;div id=&quot;console&quot;&gt;&lt;/div&gt;
+
+&lt;script&gt;
+description(&quot;Test importing an ECDH raw key with P-384&quot;);
+
+jsTestIsAsync = true;
+
+var rawKey = hexStringToUint8Array(&quot;048ba3e0a0ac5c9bb25476323570fa11dff30745a13da751a5eb1dacb5e9b439df0f77979077ee9ac97c02ca1e3cd72677cbbc256a69b99fd83a519ca9a9a26c62d45b51659274b1cea3c9858543abf5c64bfcfcd1948b7075c0409da4494f9060&quot;);
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;publicKey.type&quot;, &quot;'public'&quot;);
+    shouldBe(&quot;publicKey.extractable&quot;, &quot;true&quot;);
+    shouldBe(&quot;publicKey.algorithm.name&quot;, &quot;'ECDH'&quot;);
+    shouldBe(&quot;publicKey.algorithm.namedCurve&quot;, &quot;'P-384'&quot;);
+    shouldBe(&quot;publicKey.usages&quot;, &quot;[ ]&quot;);
+
+    finishJSTest();
+});
+
+&lt;/script&gt;
+
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeymalformedparametersexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters-expected.txt (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters-expected.txt        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -23,6 +23,7 @@
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, use: &quot;enc&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, use: &quot;&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, key_ops: [&quot;sign&quot;]}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</span><ins>+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, key_ops: [ ]}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</ins><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, ext: false}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</span><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlehmacimportkeymalformedparametershtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters.html (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters.html        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/LayoutTests/crypto/subtle/hmac-import-key-malformed-parameters.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, use: &quot;&quot;}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
</span><span class="cx"> // Jwk: wrong key_ops
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, key_ops: [&quot;sign&quot;]}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
</span><ins>+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, key_ops: [ ]}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
</ins><span class="cx"> // Jwk: wrong ext
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, k: k, alg: &quot;HS1&quot;, ext: false}, {name: &quot;hmac&quot;, hash: &quot;sha-1&quot;}, extractable, [&quot;sign&quot;, &quot;verify&quot;])');
</span><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaimportkeymalformedparametersexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters-expected.txt (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters-expected.txt        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e, alg: &quot;&quot;}, {name: &quot;RSA-OAEP&quot;, hash: &quot;sha-512&quot;}, extractable, [&quot;encrypt&quot;, &quot;wrapKey&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, n: n, e: e}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;encrypt&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e, key_ops: [&quot;sign&quot;, &quot;verify&quot;]}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;encrypt&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</span><ins>+PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e, key_ops: [ ]}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;encrypt&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</ins><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e, ext: false}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;encrypt&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;encrypt&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</span><span class="cx"> PASS crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;encrypt&quot;]) rejected promise  with DataError (DOM Exception 30): Data provided to an operation does not meet requirements.
</span></span></pre></div>
<a id="trunkLayoutTestscryptosubtlersaimportkeymalformedparametershtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters.html (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters.html        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/LayoutTests/crypto/subtle/rsa-import-key-malformed-parameters.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -76,6 +76,7 @@
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;oct&quot;, n: n, e: e}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;encrypt&quot;])');
</span><span class="cx"> // Jwk: Wrong key_ops
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e, key_ops: [&quot;sign&quot;, &quot;verify&quot;]}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;encrypt&quot;])');
</span><ins>+shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e, key_ops: [ ]}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;encrypt&quot;])');
</ins><span class="cx"> // Jwk: Wrong ext
</span><span class="cx"> shouldReject('crypto.subtle.importKey(&quot;jwk&quot;, {kty: &quot;RSA&quot;, n: n, e: e, ext: false}, &quot;RSAES-PKCS1-v1_5&quot;, extractable, [&quot;encrypt&quot;])');
</span><span class="cx"> // Jwk: Missing n or e
</span></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleecgenerateexportjwkkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-jwk-key-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-jwk-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-jwk-key-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+[Worker] Test exporting an ECDH key pair with JWK format in workers.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Starting worker: resources/ec-generate-export-jwk-key.js
+[Worker] Generating a key pair...
+[Worker] Exporting the public key...
+PASS [Worker] publicKey.kty is 'EC'
+PASS [Worker] publicKey.crv is 'P-384'
+PASS [Worker] Base64URL.parse(publicKey.x).byteLength is 48
+PASS [Worker] Base64URL.parse(publicKey.y).byteLength is 48
+PASS [Worker] publicKey.d is undefined.
+PASS [Worker] publicKey.key_ops is [ ]
+PASS [Worker] publicKey.ext is true
+[Worker] Exporting the private key...
+PASS [Worker] privateKey.kty is 'EC'
+PASS [Worker] privateKey.crv is 'P-384'
+PASS [Worker] Base64URL.parse(privateKey.x).byteLength is 48
+PASS [Worker] Base64URL.parse(privateKey.y).byteLength is 48
+PASS [Worker] Base64URL.parse(privateKey.d).byteLength is 48
+PASS [Worker] privateKey.key_ops is ['deriveBits', 'deriveKey']
+PASS [Worker] privateKey.ext is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleecgenerateexportjwkkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-jwk-key.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-jwk-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-jwk-key.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;script&gt;
+        worker = startWorker('resources/ec-generate-export-jwk-key.js');
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleecgenerateexportrawkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-raw-key-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-raw-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-raw-key-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+[Worker] Test exporting an ECDH public key with raw format in workers.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Starting worker: resources/ec-generate-export-raw-key.js
+[Worker] Generating a key pair...
+[Worker] Exporting the public key...
+PASS [Worker] publicKey.byteLength is 65
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleecgenerateexportrawkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-raw-key.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-raw-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/ec-generate-export-raw-key.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;script&gt;
+        worker = startWorker('resources/ec-generate-export-raw-key.js');
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleecimportjwkkeyprivateexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-private-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-private-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-private-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+[Worker] Test importing a JWK ECDH private key in workers
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Starting worker: resources/ec-import-jwk-key-private.js
+[Worker] Importing a key...
+PASS [Worker] privateKey.toString() is '[object CryptoKey]'
+PASS [Worker] privateKey.type is 'private'
+PASS [Worker] privateKey.extractable is false
+PASS [Worker] privateKey.algorithm.name is 'ECDH'
+PASS [Worker] privateKey.algorithm.namedCurve is 'P-256'
+PASS [Worker] privateKey.usages is ['deriveBits', 'deriveKey']
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleecimportjwkkeyprivatehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-private.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-private.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-private.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;script&gt;
+        worker = startWorker('resources/ec-import-jwk-key-private.js');
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleecimportjwkkeypublicexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-public-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-public-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-public-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+[Worker] Test importing a JWK ECDH public key in workers
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Starting worker: resources/ec-import-jwk-key-public.js
+[Worker] Importing a key...
+PASS [Worker] publicKey.toString() is '[object CryptoKey]'
+PASS [Worker] publicKey.type is 'public'
+PASS [Worker] publicKey.extractable is true
+PASS [Worker] publicKey.algorithm.name is 'ECDH'
+PASS [Worker] publicKey.algorithm.namedCurve is 'P-384'
+PASS [Worker] publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleecimportjwkkeypublichtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-public.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-public.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/ec-import-jwk-key-public.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;script&gt;
+        worker = startWorker('resources/ec-import-jwk-key-public.js');
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleecimportrawkeyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/ec-import-raw-key-expected.txt (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/ec-import-raw-key-expected.txt                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/ec-import-raw-key-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+[Worker] Test importing an ECDH raw key in workers
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+Starting worker: resources/ec-import-raw-key.js
+[Worker] Importing a key...
+PASS [Worker] publicKey.toString() is '[object CryptoKey]'
+PASS [Worker] publicKey.type is 'public'
+PASS [Worker] publicKey.extractable is true
+PASS [Worker] publicKey.algorithm.name is 'ECDH'
+PASS [Worker] publicKey.algorithm.namedCurve is 'P-256'
+PASS [Worker] publicKey.usages is [ ]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleecimportrawkeyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/ec-import-raw-key.html (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/ec-import-raw-key.html                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/ec-import-raw-key.html        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;script&gt;
+        worker = startWorker('resources/ec-import-raw-key.js');
+    &lt;/script&gt;
+    &lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesecgenerateexportjwkkeyjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/ec-generate-export-jwk-key.js (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/ec-generate-export-jwk-key.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/ec-generate-export-jwk-key.js        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts(&quot;../../../resources/common.js&quot;);
+
+description(&quot;Test exporting an ECDH key pair with JWK format in workers.&quot;);
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: &quot;ECDH&quot;,
+    namedCurve: &quot;P-384&quot;
+};
+var extractable = true;
+
+var keyPair;
+debug(&quot;Generating a key pair...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;deriveKey&quot;, &quot;deriveBits&quot;]).then(function(result) {
+    keyPair = result;
+    debug(&quot;Exporting the public key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.kty&quot;, &quot;'EC'&quot;);
+    shouldBe(&quot;publicKey.crv&quot;, &quot;'P-384'&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.x).byteLength&quot;, &quot;48&quot;);
+    shouldBe(&quot;Base64URL.parse(publicKey.y).byteLength&quot;, &quot;48&quot;);
+    shouldBeUndefined(&quot;publicKey.d&quot;);
+    shouldBe(&quot;publicKey.key_ops&quot;, &quot;[ ]&quot;);
+    shouldBe(&quot;publicKey.ext&quot;, &quot;true&quot;);
+
+    debug(&quot;Exporting the private key...&quot;);
+    return crypto.subtle.exportKey(&quot;jwk&quot;, keyPair.privateKey);
+}).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.kty&quot;, &quot;'EC'&quot;);
+    shouldBe(&quot;privateKey.crv&quot;, &quot;'P-384'&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.x).byteLength&quot;, &quot;48&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.y).byteLength&quot;, &quot;48&quot;);
+    shouldBe(&quot;Base64URL.parse(privateKey.d).byteLength&quot;, &quot;48&quot;);
+    shouldBe(&quot;privateKey.key_ops&quot;, &quot;['deriveBits', 'deriveKey']&quot;);
+    shouldBe(&quot;privateKey.ext&quot;, &quot;true&quot;);
+
+    finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesecgenerateexportrawkeyjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/ec-generate-export-raw-key.js (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/ec-generate-export-raw-key.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/ec-generate-export-raw-key.js        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts(&quot;../../../resources/common.js&quot;);
+
+description(&quot;Test exporting an ECDH public key with raw format in workers.&quot;);
+
+jsTestIsAsync = true;
+
+var algorithmKeyGen = {
+    name: &quot;ECDH&quot;,
+    namedCurve: &quot;P-256&quot;
+};
+var extractable = true;
+
+var keyPair;
+debug(&quot;Generating a key pair...&quot;);
+crypto.subtle.generateKey(algorithmKeyGen, extractable, [&quot;deriveKey&quot;, &quot;deriveBits&quot;]).then(function(result) {
+    keyPair = result;
+    debug(&quot;Exporting the public key...&quot;);
+    return crypto.subtle.exportKey(&quot;raw&quot;, keyPair.publicKey);
+}).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.byteLength&quot;, &quot;65&quot;);
+
+    finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesecimportjwkkeyprivatejs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/ec-import-jwk-key-private.js (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/ec-import-jwk-key-private.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/ec-import-jwk-key-private.js        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts(&quot;../../../resources/common.js&quot;);
+
+description(&quot;Test importing a JWK ECDH private key in workers&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;EC&quot;,
+    use: &quot;enc&quot;,
+    ext: false,
+    key_ops: [&quot;deriveKey&quot;, &quot;deriveBits&quot;],
+    crv: &quot;P-256&quot;,
+    x: &quot;1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA&quot;,
+    y: &quot;9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI&quot;,
+    d: &quot;ppxBSov3N8_AUcisAuvmLV4yE8e_L_BLE8bZb9Z1Xjg&quot;,
+};
+var nonExtractable = false;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, nonExtractable, [&quot;deriveKey&quot;, &quot;deriveBits&quot;]).then(function(result) {
+    privateKey = result;
+
+    shouldBe(&quot;privateKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;privateKey.type&quot;, &quot;'private'&quot;);
+    shouldBe(&quot;privateKey.extractable&quot;, &quot;false&quot;);
+    shouldBe(&quot;privateKey.algorithm.name&quot;, &quot;'ECDH'&quot;);
+    shouldBe(&quot;privateKey.algorithm.namedCurve&quot;, &quot;'P-256'&quot;);
+    shouldBe(&quot;privateKey.usages&quot;, &quot;['deriveBits', 'deriveKey']&quot;);
+
+    finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesecimportjwkkeypublicjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/ec-import-jwk-key-public.js (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/ec-import-jwk-key-public.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/ec-import-jwk-key-public.js        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts(&quot;../../../resources/common.js&quot;);
+
+description(&quot;Test importing a JWK ECDH public key in workers&quot;);
+
+jsTestIsAsync = true;
+
+var jwkKey = {
+    kty: &quot;EC&quot;,
+    use: &quot;enc&quot;,
+    ext: true,
+    crv: &quot;P-384&quot;,
+    x: &quot;1bHwFrsaPRjYq-zFOyLXK8Ugv3EqbVF075ct7ouTl_pwyhjeBu03JHjKTsyVbNWK&quot;,
+    y: &quot;1bHwFrsaPRjYq-zFOyLXK8Ugv3EqbVF075ct7ouTl_pwyhjeBu03JHjKTsyVbNWK&quot;,
+};
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;jwk&quot;, jwkKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-384&quot; }, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;publicKey.type&quot;, &quot;'public'&quot;);
+    shouldBe(&quot;publicKey.extractable&quot;, &quot;true&quot;);
+    shouldBe(&quot;publicKey.algorithm.name&quot;, &quot;'ECDH'&quot;);
+    shouldBe(&quot;publicKey.algorithm.namedCurve&quot;, &quot;'P-384'&quot;);
+    shouldBe(&quot;publicKey.usages&quot;, &quot;[ ]&quot;);
+
+    finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestscryptoworkerssubtleresourcesecimportrawkeyjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/crypto/workers/subtle/resources/ec-import-raw-key.js (0 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/crypto/workers/subtle/resources/ec-import-raw-key.js                                (rev 0)
+++ trunk/LayoutTests/crypto/workers/subtle/resources/ec-import-raw-key.js        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+importScripts('../../../../resources/js-test-pre.js');
+importScripts(&quot;../../../resources/common.js&quot;);
+
+description(&quot;Test importing an ECDH raw key in workers&quot;);
+
+jsTestIsAsync = true;
+
+var rawKey = hexStringToUint8Array(&quot;04dc08d9bf603333eab1ad29cef41a6203ab6ecce03c5a4a9bf5771a3fb9f971d89a09664bfb87c61199b3453220eadec714c49ad1e24bf5d7ec5bddeca6420893&quot;);
+var extractable = true;
+
+debug(&quot;Importing a key...&quot;);
+crypto.subtle.importKey(&quot;raw&quot;, rawKey, { name: &quot;ECDH&quot;, namedCurve: &quot;P-256&quot; }, extractable, [ ]).then(function(result) {
+    publicKey = result;
+
+    shouldBe(&quot;publicKey.toString()&quot;, &quot;'[object CryptoKey]'&quot;);
+    shouldBe(&quot;publicKey.type&quot;, &quot;'public'&quot;);
+    shouldBe(&quot;publicKey.extractable&quot;, &quot;true&quot;);
+    shouldBe(&quot;publicKey.algorithm.name&quot;, &quot;'ECDH'&quot;);
+    shouldBe(&quot;publicKey.algorithm.namedCurve&quot;, &quot;'P-256'&quot;);
+    shouldBe(&quot;publicKey.usages&quot;, &quot;[ ]&quot;);
+
+    finishJSTest();
+});
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-03-07  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        [WebCrypto] Implement ECDH ImportKey/ExportKey operations
+        https://bugs.webkit.org/show_bug.cgi?id=169257
+        &lt;rdar://problem/23789585&gt;
+
+        Reviewed by Brent Fulgham.
+
+        * web-platform-tests/WebCryptoAPI/import_export/ec_importKey.worker-expected.txt:
+        * web-platform-tests/WebCryptoAPI/import_export/test_ec_importKey-expected.txt:
+
</ins><span class="cx"> 2017-03-07  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [URLParser] Fix file URLs that are just file:// and a Windows drive letter
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsWebCryptoAPIimport_exportec_importKeyworkerexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/ec_importKey.worker-expected.txt (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/ec_importKey.worker-expected.txt        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/ec_importKey.worker-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -23,52 +23,52 @@
</span><span class="cx"> FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDSA, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
</span><span class="cx"> FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDSA, namedCurve: P-521}, false, [sign]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
</span><span class="cx"> FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDSA, namedCurve: P-521}, false, [sign]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
</span><del>-FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
</del><ins>+FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, true, []) 
+FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) 
+FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) 
+FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) 
+FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, false, []) 
+FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) 
+FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) 
+FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) 
+FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, true, []) 
+FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) 
+FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) 
+FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) 
+FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, false, []) 
+FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) 
+FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) 
+FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) 
+FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsWebCryptoAPIimport_exporttest_ec_importKeyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/test_ec_importKey-expected.txt (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/test_ec_importKey-expected.txt        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/test_ec_importKey-expected.txt        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -23,52 +23,52 @@
</span><span class="cx"> FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDSA, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
</span><span class="cx"> FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDSA, namedCurve: P-521}, false, [sign]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
</span><span class="cx"> FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDSA, namedCurve: P-521}, false, [sign]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
</span><del>-FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
-FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The operation is not supported. Reached unreachable code
</del><ins>+FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, true, []) 
+FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveKey]) 
+FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits, deriveKey]) 
+FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, true, [deriveBits]) 
+FAIL Good parameters: P-256 bits (spki, buffer(91), {name: ECDH, namedCurve: P-256}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-256}, false, []) 
+FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveKey]) 
+FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits, deriveKey]) 
+FAIL Good parameters: P-256 bits (pkcs8, buffer(138), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-256 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-256}, false, [deriveBits]) 
+FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, true, []) 
+FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveKey]) 
+FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits, deriveKey]) 
+FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, true, [deriveBits]) 
+FAIL Good parameters: P-384 bits (spki, buffer(120), {name: ECDH, namedCurve: P-384}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-384}, false, []) 
+FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveKey]) 
+FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits, deriveKey]) 
+FAIL Good parameters: P-384 bits (pkcs8, buffer(185), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+PASS Good parameters: P-384 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-384}, false, [deriveBits]) 
+FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, true, []) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, true, [deriveBits]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (spki, buffer(158), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y), {name: ECDH, namedCurve: P-521}, false, []) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits, deriveKey]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
+FAIL Good parameters: P-521 bits (pkcs8, buffer(241), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: NotSupportedError (DOM Exception 9): The algorithm is not supported Reached unreachable code
+FAIL Good parameters: P-521 bits (jwk, object(kty, crv, x, y, d), {name: ECDH, namedCurve: P-521}, false, [deriveBits]) assert_unreached: Threw an unexpected error: DataError (DOM Exception 30): Data provided to an operation does not meet requirements Reached unreachable code
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/Source/WebCore/ChangeLog        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -1,3 +1,87 @@
</span><ins>+2017-03-07  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
+
+        [WebCrypto] Implement ECDH ImportKey/ExportKey operations
+        https://bugs.webkit.org/show_bug.cgi?id=169257
+        &lt;rdar://problem/23789585&gt;
+
+        Reviewed by Brent Fulgham.
+
+        This patch implements ECDH ImportKey/ExportKey operations according to:
+        https://www.w3.org/TR/WebCryptoAPI/#ecdh-operations. Sad that we can't
+        support SPKI/PKCS8 formats at this moment due to lack of necessary
+        support in the underlying crypto library. Bug 169318 is tracking the
+        issue. Also, this patch fixes minor bugs while importing JWK keys for
+        HMAC/RSA.
+
+        Tests: crypto/subtle/ec-export-key-malformed-parameters.html
+               crypto/subtle/ec-import-jwk-key-export-jwk-key-private.html
+               crypto/subtle/ec-import-jwk-key-export-jwk-key-public.html
+               crypto/subtle/ec-import-jwk-key-export-raw-key.html
+               crypto/subtle/ec-import-key-malformed-parameters.html
+               crypto/subtle/ec-import-raw-key-export-jwk-key.html
+               crypto/subtle/ec-import-raw-key-export-raw-key.html
+               crypto/subtle/ecdh-generate-export-jwk-key-p256.html
+               crypto/subtle/ecdh-generate-export-jwk-key-p384.html
+               crypto/subtle/ecdh-generate-export-key-raw-p256.html
+               crypto/subtle/ecdh-generate-export-key-raw-p384.html
+               crypto/subtle/ecdh-import-jwk-key-minimum.html
+               crypto/subtle/ecdh-import-jwk-private-key-p256.html
+               crypto/subtle/ecdh-import-jwk-private-key-p384.html
+               crypto/subtle/ecdh-import-jwk-public-key-p256.html
+               crypto/subtle/ecdh-import-jwk-public-key-p384.html
+               crypto/subtle/ecdh-import-raw-key-p256.html
+               crypto/subtle/ecdh-import-raw-key-p384.html
+               crypto/workers/subtle/ec-generate-export-jwk-key.html
+               crypto/workers/subtle/ec-generate-export-raw-key.html
+               crypto/workers/subtle/ec-import-jwk-key-private.html
+               crypto/workers/subtle/ec-import-jwk-key-public.html
+               crypto/workers/subtle/ec-import-raw-key.html
+
+        * bindings/js/JSSubtleCryptoCustom.cpp:
+        (WebCore::normalizeCryptoAlgorithmParameters):
+        (WebCore::supportExportKeyThrow):
+        Added EC family support.
+        * crypto/CommonCryptoUtilities.h:
+        Added needed CommonCrypto SPIs.
+        * crypto/CryptoAlgorithm.h:
+        * crypto/algorithms/CryptoAlgorithmECDH.cpp:
+        (WebCore::CryptoAlgorithmECDH::importKey):
+        (WebCore::CryptoAlgorithmECDH::exportKey):
+        * crypto/algorithms/CryptoAlgorithmECDH.h:
+        * crypto/gnutls/CryptoKeyECGnuTLS.cpp:
+        (WebCore::CryptoKeyEC::keySizeInBits):
+        (WebCore::CryptoKeyEC::exportRaw):
+        (WebCore::CryptoKeyEC::platformImportRaw):
+        (WebCore::CryptoKeyEC::platformImportJWKPublic):
+        (WebCore::CryptoKeyEC::platformImportJWKPrivate):
+        (WebCore::CryptoKeyEC::platformAddFieldElements):
+        Faked implementations for GTK+.
+        * crypto/keys/CryptoKeyEC.cpp:
+        (WebCore::toNamedCurve):
+        (WebCore::CryptoKeyEC::generatePair):
+        (WebCore::CryptoKeyEC::importRaw):
+        (WebCore::CryptoKeyEC::importJwk):
+        (WebCore::CryptoKeyEC::exportJwk):
+        * crypto/keys/CryptoKeyEC.h:
+        * crypto/keys/CryptoKeyHMAC.cpp:
+        (WebCore::CryptoKeyHMAC::importJwk):
+        Fixed a bug.
+        * crypto/keys/CryptoKeyRSA.cpp:
+        (WebCore::CryptoKeyRSA::importJwk):
+        Fixed a bug.
+        * crypto/mac/CryptoKeyECMac.cpp:
+        (WebCore::doesUncompressedPointMatchNamedCurve):
+        (WebCore::doesFieldElementMatchNamedCurve):
+        (WebCore::getKeySizeFromNamedCurve):
+        (WebCore::CryptoKeyEC::~CryptoKeyEC):
+        (WebCore::CryptoKeyEC::keySizeInBits):
+        (WebCore::CryptoKeyEC::exportRaw):
+        (WebCore::CryptoKeyEC::platformGeneratePair):
+        (WebCore::CryptoKeyEC::platformImportRaw):
+        (WebCore::CryptoKeyEC::platformImportJWKPublic):
+        (WebCore::CryptoKeyEC::platformImportJWKPrivate):
+        (WebCore::CryptoKeyEC::platformAddFieldElements):
+
</ins><span class="cx"> 2017-03-07  Youenn Fablet  &lt;youenn@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebRTC can be used even if getUserMedia is off
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSSubtleCryptoCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -243,6 +243,13 @@
</span><span class="cx">                 result = std::make_unique&lt;CryptoAlgorithmHmacKeyParams&gt;(params);
</span><span class="cx">                 break;
</span><span class="cx">             }
</span><ins>+            case CryptoAlgorithmIdentifier::ECDSA:
+            case CryptoAlgorithmIdentifier::ECDH: {
+                auto params = convertDictionary&lt;CryptoAlgorithmEcKeyParams&gt;(state, value);
+                RETURN_IF_EXCEPTION(scope, nullptr);
+                result = std::make_unique&lt;CryptoAlgorithmEcKeyParams&gt;(params);
+                break;
+            }
</ins><span class="cx">             default:
</span><span class="cx">                 throwNotSupportedError(state, scope);
</span><span class="cx">                 return nullptr;
</span><span class="lines">@@ -415,6 +422,8 @@
</span><span class="cx">     case CryptoAlgorithmIdentifier::AES_CFB:
</span><span class="cx">     case CryptoAlgorithmIdentifier::AES_KW:
</span><span class="cx">     case CryptoAlgorithmIdentifier::HMAC:
</span><ins>+    case CryptoAlgorithmIdentifier::ECDSA:
+    case CryptoAlgorithmIdentifier::ECDH:
</ins><span class="cx">         return;
</span><span class="cx">     default:
</span><span class="cx">         throwNotSupportedError(state, scope);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCommonCryptoUtilitiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CommonCryptoUtilities.h (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CommonCryptoUtilities.h        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/Source/WebCore/crypto/CommonCryptoUtilities.h        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -86,10 +86,29 @@
</span><span class="cx"> extern &quot;C&quot; CCCryptorStatus CCRSACryptorImport(const void *keyPackage, size_t keyPackageLen, CCRSACryptorRef *key);
</span><span class="cx"> extern &quot;C&quot; CCCryptorStatus CCRSACryptorExport(CCRSACryptorRef key, void *out, size_t *outLen);
</span><span class="cx"> 
</span><ins>+#ifndef _CC_ECCRYPTOR_H_
+enum {
+    ccECKeyPublic = 0,
+    ccECKeyPrivate = 1,
+};
+typedef uint32_t CCECKeyType;
+
+enum {
+    kCCImportKeyBinary = 0,
+};
+typedef uint32_t CCECKeyExternalFormat;
+#endif
+
</ins><span class="cx"> typedef struct _CCECCryptor *CCECCryptorRef;
</span><span class="cx"> extern &quot;C&quot; CCCryptorStatus CCECCryptorGeneratePair(size_t keysize, CCECCryptorRef *publicKey, CCECCryptorRef *privateKey);
</span><span class="cx"> extern &quot;C&quot; void CCECCryptorRelease(CCECCryptorRef key);
</span><ins>+extern &quot;C&quot; CCCryptorStatus CCECCryptorImportKey(CCECKeyExternalFormat format, void *keyPackage, size_t keyPackageLen, CCECKeyType keyType, CCECCryptorRef *key);
+extern &quot;C&quot; CCCryptorStatus CCECCryptorExportKey(CCECKeyExternalFormat format, void *keyPackage, size_t *keyPackageLen, CCECKeyType keyType, CCECCryptorRef key);
+extern &quot;C&quot; int CCECGetKeySize(CCECCryptorRef key);
+extern &quot;C&quot; CCCryptorStatus CCECCryptorCreateFromData(size_t keySize, uint8_t *qX, size_t qXLength, uint8_t *qY, size_t qYLength, CCECCryptorRef *ref);
+extern &quot;C&quot; CCCryptorStatus CCECCryptorGetKeyComponents(CCECCryptorRef ecKey, size_t *keySize, uint8_t *qX, size_t *qXLength, uint8_t *qY, size_t *qYLength, uint8_t *d, size_t *dLength);
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx"> #if !USE(APPLE_INTERNAL_SDK)
</span><span class="cx"> extern &quot;C&quot; CCCryptorStatus CCCryptorGCM(CCOperation op, CCAlgorithm alg, const void* key, size_t keyLength, const void* iv, size_t ivLen, const void* aData, size_t aDataLen, const void* dataIn, size_t dataInLength, void* dataOut, void* tag, size_t* tagLength);
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoCryptoAlgorithmh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/CryptoAlgorithm.h (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/CryptoAlgorithm.h        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/Source/WebCore/crypto/CryptoAlgorithm.h        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -72,6 +72,7 @@
</span><span class="cx">     virtual void verify(Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp; signature, Vector&lt;uint8_t&gt;&amp;&amp;, BoolCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;);
</span><span class="cx">     virtual void digest(Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;, WorkQueue&amp;);
</span><span class="cx">     virtual void generateKey(const CryptoAlgorithmParameters&amp;, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;);
</span><ins>+    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=169262
</ins><span class="cx">     virtual void importKey(SubtleCrypto::KeyFormat, KeyData&amp;&amp;, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, ExceptionCallback&amp;&amp;);
</span><span class="cx">     virtual void exportKey(SubtleCrypto::KeyFormat, Ref&lt;CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp;);
</span><span class="cx">     virtual void wrapKey(Ref&lt;CryptoKey&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, VectorCallback&amp;&amp;, ExceptionCallback&amp;&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmECDHcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -65,6 +65,86 @@
</span><span class="cx">     callback(WTFMove(pair));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void CryptoAlgorithmECDH::importKey(SubtleCrypto::KeyFormat format, KeyData&amp;&amp; data, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp; parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback)
+{
+    ASSERT(parameters);
+    const auto&amp; ecParameters = downcast&lt;CryptoAlgorithmEcKeyParams&gt;(*parameters);
+
+    RefPtr&lt;CryptoKeyEC&gt; result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Jwk: {
+        JsonWebKey key = WTFMove(WTF::get&lt;JsonWebKey&gt;(data));
+
+        bool isUsagesAllowed = false;
+        if (!key.d.isNull()) {
+            isUsagesAllowed = isUsagesAllowed || !(usages ^ CryptoKeyUsageDeriveKey);
+            isUsagesAllowed = isUsagesAllowed || !(usages ^ CryptoKeyUsageDeriveBits);
+            isUsagesAllowed = isUsagesAllowed || !(usages ^ (CryptoKeyUsageDeriveKey | CryptoKeyUsageDeriveBits));
+        }
+        isUsagesAllowed = isUsagesAllowed || !usages;
+        if (!isUsagesAllowed) {
+            exceptionCallback(SYNTAX_ERR);
+            return;
+        }
+
+        if (usages &amp;&amp; !key.use.isNull() &amp;&amp; key.use != &quot;enc&quot;) {
+            exceptionCallback(DataError);
+            return;
+        }
+
+        result = CryptoKeyEC::importJwk(ecParameters.identifier, ecParameters.namedCurve, WTFMove(key), extractable, usages);
+        break;
+    }
+    case SubtleCrypto::KeyFormat::Raw:
+        if (usages) {
+            exceptionCallback(SYNTAX_ERR);
+            return;
+        }
+        result = CryptoKeyEC::importRaw(ecParameters.identifier, ecParameters.namedCurve, WTFMove(WTF::get&lt;Vector&lt;uint8_t&gt;&gt;(data)), extractable, usages);
+        break;
+    default:
+        exceptionCallback(NOT_SUPPORTED_ERR);
+        return;
+    }
+    if (!result) {
+        exceptionCallback(DataError);
+        return;
+    }
+
+    callback(*result);
+}
+
+void CryptoAlgorithmECDH::exportKey(SubtleCrypto::KeyFormat format, Ref&lt;CryptoKey&gt;&amp;&amp; key, KeyDataCallback&amp;&amp; callback, ExceptionCallback&amp;&amp; exceptionCallback)
+{
+    const auto&amp; ecKey = downcast&lt;CryptoKeyEC&gt;(key.get());
+
+    if (!ecKey.keySizeInBits()) {
+        exceptionCallback(OperationError);
+        return;
+    }
+
+    KeyData result;
+    switch (format) {
+    case SubtleCrypto::KeyFormat::Jwk: {
+        result = ecKey.exportJwk();
+        break;
+    }
+    case SubtleCrypto::KeyFormat::Raw: {
+        if (ecKey.type() != CryptoKey::Type::Public) {
+            exceptionCallback(INVALID_ACCESS_ERR);
+            return;
+        }
+        result = ecKey.exportRaw();
+        break;
+    }
+    default:
+        exceptionCallback(NOT_SUPPORTED_ERR);
+        return;
+    }
+
+    callback(format, WTFMove(result));
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptoalgorithmsCryptoAlgorithmECDHh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -42,6 +42,8 @@
</span><span class="cx">     CryptoAlgorithmIdentifier identifier() const final;
</span><span class="cx"> 
</span><span class="cx">     void generateKey(const CryptoAlgorithmParameters&amp;, bool extractable, CryptoKeyUsageBitmap, KeyOrKeyPairCallback&amp;&amp;, ExceptionCallback&amp;&amp;, ScriptExecutionContext&amp;) final;
</span><ins>+    void importKey(SubtleCrypto::KeyFormat, KeyData&amp;&amp;, const std::unique_ptr&lt;CryptoAlgorithmParameters&gt;&amp;&amp;, bool extractable, CryptoKeyUsageBitmap, KeyCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
+    void exportKey(SubtleCrypto::KeyFormat, Ref&lt;CryptoKey&gt;&amp;&amp;, KeyDataCallback&amp;&amp;, ExceptionCallback&amp;&amp;) final;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorecryptognutlsCryptoKeyECGnuTLScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/gnutls/CryptoKeyECGnuTLS.cpp (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/gnutls/CryptoKeyECGnuTLS.cpp        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/Source/WebCore/crypto/gnutls/CryptoKeyECGnuTLS.cpp        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -41,6 +41,20 @@
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+size_t CryptoKeyEC::keySizeInBits() const
+{
+    notImplemented();
+
+    return 0;
+}
+
+Vector&lt;uint8_t&gt; CryptoKeyEC::exportRaw() const
+{
+    notImplemented();
+
+    return { };
+}
+
</ins><span class="cx"> std::optional&lt;CryptoKeyPair&gt; CryptoKeyEC::platformGeneratePair(CryptoAlgorithmIdentifier, NamedCurve, bool, CryptoKeyUsageBitmap)
</span><span class="cx"> {
</span><span class="cx">     notImplemented();
</span><span class="lines">@@ -48,6 +62,32 @@
</span><span class="cx">     return std::nullopt;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;CryptoKeyEC&gt; CryptoKeyEC::platformImportRaw(CryptoAlgorithmIdentifier, NamedCurve, Vector&lt;uint8_t&gt;&amp;&amp;, bool, CryptoKeyUsageBitmap)
+{
+    notImplemented();
+
+    return nullptr;
+}
+
+RefPtr&lt;CryptoKeyEC&gt; CryptoKeyEC::platformImportJWKPublic(CryptoAlgorithmIdentifier, NamedCurve, Vector&lt;uint8_t&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, bool, CryptoKeyUsageBitmap)
+{
+    notImplemented();
+
+    return nullptr;
+}
+
+RefPtr&lt;CryptoKeyEC&gt; CryptoKeyEC::platformImportJWKPrivate(CryptoAlgorithmIdentifier, NamedCurve, Vector&lt;uint8_t&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, Vector&lt;uint8_t&gt;&amp;&amp;, bool, CryptoKeyUsageBitmap)
+{
+    notImplemented();
+
+    return nullptr;
+}
+
+void CryptoKeyEC::platformAddFieldElements(JsonWebKey&amp;) const
+{
+    notImplemented();
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyECcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyEC.cpp (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyEC.cpp        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyEC.cpp        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -31,6 +31,8 @@
</span><span class="cx"> #include &quot;CryptoAlgorithmRegistry.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyData.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><ins>+#include &quot;JsonWebKey.h&quot;
+#include &lt;wtf/text/Base64.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -37,6 +39,16 @@
</span><span class="cx"> static const char* const P256 = &quot;P-256&quot;;
</span><span class="cx"> static const char* const P384 = &quot;P-384&quot;;
</span><span class="cx"> 
</span><ins>+static std::optional&lt;CryptoKeyEC::NamedCurve&gt; toNamedCurve(const String&amp; curve)
+{
+    if (curve == P256)
+        return CryptoKeyEC::NamedCurve::P256;
+    if (curve == P384)
+        return CryptoKeyEC::NamedCurve::P384;
+
+    return std::nullopt;
+}
+
</ins><span class="cx"> CryptoKeyEC::CryptoKeyEC(CryptoAlgorithmIdentifier identifier, NamedCurve curve, CryptoKeyType type, PlatformECKey platformKey, bool extractable, CryptoKeyUsageBitmap usages)
</span><span class="cx">     : CryptoKey(identifier, type, extractable, usages)
</span><span class="cx">     , m_platformKey(platformKey)
</span><span class="lines">@@ -44,17 +56,13 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ExceptionOr&lt;CryptoKeyPair&gt; CryptoKeyEC::generatePair(CryptoAlgorithmIdentifier identifier, const String&amp; namedCurve, bool extractable, CryptoKeyUsageBitmap usages)
</del><ins>+ExceptionOr&lt;CryptoKeyPair&gt; CryptoKeyEC::generatePair(CryptoAlgorithmIdentifier identifier, const String&amp; curve, bool extractable, CryptoKeyUsageBitmap usages)
</ins><span class="cx"> {
</span><del>-    NamedCurve curve;
-    if (namedCurve == P256)
-        curve = NamedCurve::P256;
-    else if (namedCurve == P384)
-        curve = NamedCurve::P384;
-    else
</del><ins>+    auto namedCurve = toNamedCurve(curve);
+    if (!namedCurve)
</ins><span class="cx">         return Exception { NOT_SUPPORTED_ERR };
</span><span class="cx"> 
</span><del>-    auto result = platformGeneratePair(identifier, curve, extractable, usages);
</del><ins>+    auto result = platformGeneratePair(identifier, *namedCurve, extractable, usages);
</ins><span class="cx">     if (!result)
</span><span class="cx">         return Exception { OperationError };
</span><span class="cx"> 
</span><span class="lines">@@ -61,6 +69,68 @@
</span><span class="cx">     return WTFMove(*result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;CryptoKeyEC&gt; CryptoKeyEC::importRaw(CryptoAlgorithmIdentifier identifier, const String&amp; curve, Vector&lt;uint8_t&gt;&amp;&amp; keyData, bool extractable, CryptoKeyUsageBitmap usages)
+{
+    auto namedCurve = toNamedCurve(curve);
+    if (!namedCurve)
+        return nullptr;
+
+    return platformImportRaw(identifier, *namedCurve, WTFMove(keyData), extractable, usages);
+}
+
+RefPtr&lt;CryptoKeyEC&gt; CryptoKeyEC::importJwk(CryptoAlgorithmIdentifier identifier, const String&amp; curve, JsonWebKey&amp;&amp; keyData, bool extractable, CryptoKeyUsageBitmap usages)
+{
+    if (keyData.kty != &quot;EC&quot;)
+        return nullptr;
+    if (keyData.key_ops &amp;&amp; ((keyData.usages &amp; usages) != usages))
+        return nullptr;
+    if (keyData.ext &amp;&amp; !keyData.ext.value() &amp;&amp; extractable)
+        return nullptr;
+
+    if (keyData.crv.isNull() || curve != keyData.crv)
+        return nullptr;
+    auto namedCurve = toNamedCurve(keyData.crv);
+    if (!namedCurve)
+        return nullptr;
+
+    if (keyData.x.isNull() || keyData.y.isNull())
+        return nullptr;
+    Vector&lt;uint8_t&gt; x;
+    if (!WTF::base64URLDecode(keyData.x, x))
+        return nullptr;
+    Vector&lt;uint8_t&gt; y;
+    if (!WTF::base64URLDecode(keyData.y, y))
+        return nullptr;
+    if (keyData.d.isNull()) {
+        // import public key
+        return platformImportJWKPublic(identifier, *namedCurve, WTFMove(x), WTFMove(y), extractable, usages);
+    }
+
+    Vector&lt;uint8_t&gt; d;
+    if (!WTF::base64URLDecode(keyData.d, d))
+        return nullptr;
+    // import private key
+    return platformImportJWKPrivate(identifier, *namedCurve, WTFMove(x), WTFMove(y), WTFMove(d), extractable, usages);
+}
+
+JsonWebKey CryptoKeyEC::exportJwk() const
+{
+    JsonWebKey result;
+    result.kty = &quot;EC&quot;;
+    switch (m_curve) {
+    case NamedCurve::P256:
+        result.crv = P256;
+        break;
+    case NamedCurve::P384:
+        result.crv = P384;
+        break;
+    }
+    result.key_ops = usages();
+    result.ext = extractable();
+    platformAddFieldElements(result);
+    return result;
+}
+
</ins><span class="cx"> std::unique_ptr&lt;KeyAlgorithm&gt; CryptoKeyEC::buildAlgorithm() const
</span><span class="cx"> {
</span><span class="cx">     String name = CryptoAlgorithmRegistry::singleton().name(algorithmIdentifier());
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyECh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyEC.h (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyEC.h        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyEC.h        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -44,6 +44,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+struct JsonWebKey;
+
</ins><span class="cx"> class EcKeyAlgorithm : public KeyAlgorithm {
</span><span class="cx"> public:
</span><span class="cx">     EcKeyAlgorithm(const String&amp; name, const String&amp; curve)
</span><span class="lines">@@ -74,8 +76,15 @@
</span><span class="cx">     }
</span><span class="cx">     virtual ~CryptoKeyEC();
</span><span class="cx"> 
</span><del>-    static ExceptionOr&lt;CryptoKeyPair&gt; generatePair(CryptoAlgorithmIdentifier, const String&amp;, bool extractable, CryptoKeyUsageBitmap);
</del><ins>+    static ExceptionOr&lt;CryptoKeyPair&gt; generatePair(CryptoAlgorithmIdentifier, const String&amp; curve, bool extractable, CryptoKeyUsageBitmap);
+    static RefPtr&lt;CryptoKeyEC&gt; importRaw(CryptoAlgorithmIdentifier, const String&amp; curve, Vector&lt;uint8_t&gt;&amp;&amp; keyData, bool extractable, CryptoKeyUsageBitmap);
+    static RefPtr&lt;CryptoKeyEC&gt; importJwk(CryptoAlgorithmIdentifier, const String&amp; curve, JsonWebKey&amp;&amp;, bool extractable, CryptoKeyUsageBitmap);
</ins><span class="cx"> 
</span><ins>+    Vector&lt;uint8_t&gt; exportRaw() const;
+    JsonWebKey exportJwk() const;
+
+    size_t keySizeInBits() const;
+
</ins><span class="cx"> private:
</span><span class="cx">     CryptoKeyEC(CryptoAlgorithmIdentifier, NamedCurve, CryptoKeyType, PlatformECKey, bool extractable, CryptoKeyUsageBitmap);
</span><span class="cx"> 
</span><span class="lines">@@ -85,6 +94,10 @@
</span><span class="cx">     std::unique_ptr&lt;CryptoKeyData&gt; exportData() const final;
</span><span class="cx"> 
</span><span class="cx">     static std::optional&lt;CryptoKeyPair&gt; platformGeneratePair(CryptoAlgorithmIdentifier, NamedCurve, bool extractable, CryptoKeyUsageBitmap);
</span><ins>+    static RefPtr&lt;CryptoKeyEC&gt; platformImportRaw(CryptoAlgorithmIdentifier, NamedCurve, Vector&lt;uint8_t&gt;&amp;&amp; keyData, bool extractable, CryptoKeyUsageBitmap);
+    static RefPtr&lt;CryptoKeyEC&gt; platformImportJWKPublic(CryptoAlgorithmIdentifier, NamedCurve, Vector&lt;uint8_t&gt;&amp;&amp; x, Vector&lt;uint8_t&gt;&amp;&amp; y, bool extractable, CryptoKeyUsageBitmap);
+    static RefPtr&lt;CryptoKeyEC&gt; platformImportJWKPrivate(CryptoAlgorithmIdentifier, NamedCurve, Vector&lt;uint8_t&gt;&amp;&amp; x, Vector&lt;uint8_t&gt;&amp;&amp; y, Vector&lt;uint8_t&gt;&amp;&amp; d, bool extractable, CryptoKeyUsageBitmap);
+    void platformAddFieldElements(JsonWebKey&amp;) const;
</ins><span class="cx"> 
</span><span class="cx">     PlatformECKey m_platformKey;
</span><span class="cx">     NamedCurve m_curve;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyHMACcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyHMAC.cpp        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx">         return nullptr;
</span><span class="cx">     if (usages &amp;&amp; !keyData.use.isNull() &amp;&amp; keyData.use != &quot;sig&quot;)
</span><span class="cx">         return nullptr;
</span><del>-    if (keyData.usages &amp;&amp; ((keyData.usages &amp; usages) != usages))
</del><ins>+    if (keyData.key_ops &amp;&amp; ((keyData.usages &amp; usages) != usages))
</ins><span class="cx">         return nullptr;
</span><span class="cx">     if (keyData.ext &amp;&amp; !keyData.ext.value() &amp;&amp; extractable)
</span><span class="cx">         return nullptr;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptokeysCryptoKeyRSAcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.cpp (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.cpp        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/Source/WebCore/crypto/keys/CryptoKeyRSA.cpp        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (keyData.kty != &quot;RSA&quot;)
</span><span class="cx">         return nullptr;
</span><del>-    if (keyData.usages &amp;&amp; ((keyData.usages &amp; usages) != usages))
</del><ins>+    if (keyData.key_ops &amp;&amp; ((keyData.usages &amp; usages) != usages))
</ins><span class="cx">         return nullptr;
</span><span class="cx">     if (keyData.ext &amp;&amp; !keyData.ext.value() &amp;&amp; extractable)
</span><span class="cx">         return nullptr;
</span></span></pre></div>
<a id="trunkSourceWebCorecryptomacCryptoKeyECMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/crypto/mac/CryptoKeyECMac.cpp (213559 => 213560)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/mac/CryptoKeyECMac.cpp        2017-03-08 01:50:40 UTC (rev 213559)
+++ trunk/Source/WebCore/crypto/mac/CryptoKeyECMac.cpp        2017-03-08 02:09:38 UTC (rev 213560)
</span><span class="lines">@@ -29,30 +29,80 @@
</span><span class="cx"> #if ENABLE(SUBTLE_CRYPTO)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CommonCryptoUtilities.h&quot;
</span><ins>+#include &quot;JsonWebKey.h&quot;
+#include &lt;wtf/text/Base64.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+static unsigned char InitialOctet = 0x04; // Per Section 2.3.3 of http://www.secg.org/sec1-v2.pdf
+
+// Per Section 2.3.4 of http://www.secg.org/sec1-v2.pdf
+// We only support uncompressed point format.
+static bool doesUncompressedPointMatchNamedCurve(CryptoKeyEC::NamedCurve curve, size_t size)
+{
+    switch (curve) {
+    case CryptoKeyEC::NamedCurve::P256:
+        return size == 65;
+    case CryptoKeyEC::NamedCurve::P384:
+        return size == 97;
+    }
+
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
+// Per Section 2.3.5 of http://www.secg.org/sec1-v2.pdf
+static bool doesFieldElementMatchNamedCurve(CryptoKeyEC::NamedCurve curve, size_t size)
+{
+    switch (curve) {
+    case CryptoKeyEC::NamedCurve::P256:
+        return size == 32;
+    case CryptoKeyEC::NamedCurve::P384:
+        return size == 48;
+    }
+
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
+static size_t getKeySizeFromNamedCurve(CryptoKeyEC::NamedCurve curve)
+{
+    switch (curve) {
+    case CryptoKeyEC::NamedCurve::P256:
+        return 256;
+    case CryptoKeyEC::NamedCurve::P384:
+        return 384;
+    }
+
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
</ins><span class="cx"> CryptoKeyEC::~CryptoKeyEC()
</span><span class="cx"> {
</span><span class="cx">     CCECCryptorRelease(m_platformKey);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+size_t CryptoKeyEC::keySizeInBits() const
+{
+    int result = CCECGetKeySize(m_platformKey);
+    return result ? result : 0;
+}
+
+Vector&lt;uint8_t&gt; CryptoKeyEC::exportRaw() const
+{
+    Vector&lt;uint8_t&gt; result(keySizeInBits() / 4 + 1); // Per Section 2.3.4 of http://www.secg.org/sec1-v2.pdf
+    size_t size = result.size();
+    CCECCryptorExportKey(kCCImportKeyBinary, result.data(), &amp;size, ccECKeyPublic, m_platformKey);
+    return result;
+}
+
</ins><span class="cx"> std::optional&lt;CryptoKeyPair&gt; CryptoKeyEC::platformGeneratePair(CryptoAlgorithmIdentifier identifier, NamedCurve curve, bool extractable, CryptoKeyUsageBitmap usages)
</span><span class="cx"> {
</span><del>-    size_t size;
-    switch (curve) {
-    case NamedCurve::P256:
-        size = 256;
-        break;
-    case NamedCurve::P384:
-        size = 384;
-        break;
-    }
-
</del><ins>+    size_t size = getKeySizeFromNamedCurve(curve);
</ins><span class="cx">     CCECCryptorRef ccPublicKey;
</span><span class="cx">     CCECCryptorRef ccPrivateKey;
</span><del>-    CCCryptorStatus status = CCECCryptorGeneratePair(size, &amp;ccPublicKey, &amp;ccPrivateKey);
-    if (status)
</del><ins>+    if (CCECCryptorGeneratePair(size, &amp;ccPublicKey, &amp;ccPrivateKey))
</ins><span class="cx">         return std::nullopt;
</span><span class="cx"> 
</span><span class="cx">     auto publicKey = CryptoKeyEC::create(identifier, curve, CryptoKeyType::Public, ccPublicKey, true, usages);
</span><span class="lines">@@ -60,6 +110,69 @@
</span><span class="cx">     return CryptoKeyPair { WTFMove(publicKey), WTFMove(privateKey) };
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;CryptoKeyEC&gt; CryptoKeyEC::platformImportRaw(CryptoAlgorithmIdentifier identifier, NamedCurve curve, Vector&lt;uint8_t&gt;&amp;&amp; keyData, bool extractable, CryptoKeyUsageBitmap usages)
+{
+    if (!doesUncompressedPointMatchNamedCurve(curve, keyData.size()))
+        return nullptr;
+
+    CCECCryptorRef ccPublicKey;
+    if (CCECCryptorImportKey(kCCImportKeyBinary, keyData.data(), keyData.size(), ccECKeyPublic, &amp;ccPublicKey))
+        return nullptr;
+
+    return create(identifier, curve, CryptoKeyType::Public, ccPublicKey, extractable, usages);
+}
+
+RefPtr&lt;CryptoKeyEC&gt; CryptoKeyEC::platformImportJWKPublic(CryptoAlgorithmIdentifier identifier, NamedCurve curve, Vector&lt;uint8_t&gt;&amp;&amp; x, Vector&lt;uint8_t&gt;&amp;&amp; y, bool extractable, CryptoKeyUsageBitmap usages)
+{
+    if (!doesFieldElementMatchNamedCurve(curve, x.size()) || !doesFieldElementMatchNamedCurve(curve, y.size()))
+        return nullptr;
+
+    size_t size = getKeySizeFromNamedCurve(curve);
+    CCECCryptorRef ccPublicKey;
+    if (CCECCryptorCreateFromData(size, x.data(), x.size(), y.data(), y.size(), &amp;ccPublicKey))
+        return nullptr;
+
+    return create(identifier, curve, CryptoKeyType::Public, ccPublicKey, extractable, usages);
+}
+
+RefPtr&lt;CryptoKeyEC&gt; CryptoKeyEC::platformImportJWKPrivate(CryptoAlgorithmIdentifier identifier, NamedCurve curve, Vector&lt;uint8_t&gt;&amp;&amp; x, Vector&lt;uint8_t&gt;&amp;&amp; y, Vector&lt;uint8_t&gt;&amp;&amp; d, bool extractable, CryptoKeyUsageBitmap usages)
+{
+    if (!doesFieldElementMatchNamedCurve(curve, x.size()) || !doesFieldElementMatchNamedCurve(curve, y.size()) || !doesFieldElementMatchNamedCurve(curve, d.size()))
+        return nullptr;
+
+    // A hack to CommonCrypto since it doesn't provide API for creating private keys directly from x, y, d.
+    // BinaryInput = InitialOctet + X + Y + D
+    Vector&lt;uint8_t&gt; binaryInput;
+    binaryInput.append(InitialOctet);
+    binaryInput.appendVector(x);
+    binaryInput.appendVector(y);
+    binaryInput.appendVector(d);
+
+    CCECCryptorRef ccPrivateKey;
+    if (CCECCryptorImportKey(kCCImportKeyBinary, binaryInput.data(), binaryInput.size(), ccECKeyPrivate, &amp;ccPrivateKey))
+        return nullptr;
+
+    return create(identifier, curve, CryptoKeyType::Private, ccPrivateKey, extractable, usages);
+}
+
+void CryptoKeyEC::platformAddFieldElements(JsonWebKey&amp; jwk) const
+{
+    size_t size = getKeySizeFromNamedCurve(m_curve);
+    size_t sizeInBytes = size / 8;
+    Vector&lt;uint8_t&gt; x(sizeInBytes);
+    size_t xSize = x.size();
+    Vector&lt;uint8_t&gt; y(sizeInBytes);
+    size_t ySize = y.size();
+    Vector&lt;uint8_t&gt; d(sizeInBytes);
+    size_t dSize = d.size();
+
+    CCECCryptorGetKeyComponents(m_platformKey, &amp;size, x.data(), &amp;xSize, y.data(), &amp;ySize, d.data(), &amp;dSize);
+    jwk.x = base64URLEncode(x);
+    jwk.y = base64URLEncode(y);
+    if (type() == Type::Private)
+        jwk.d = base64URLEncode(d);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(SUBTLE_CRYPTO)
</span></span></pre>
</div>
</div>

</body>
</html>