<!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>[237993] trunk/Tools</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/237993">237993</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2018-11-08 11:41:42 -0800 (Thu, 08 Nov 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>Unreviewed, a quick build fix for <a href="http://trac.webkit.org/projects/webkit/changeset/237983">r237983</a>

Temporarily make CtapRequestTest.cpp/CtapResponseTest.cpp to mac only to avoid iOS build failures.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
* TestWebKitAPI/Tests/WebCore/mac/CtapRequestTest.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp.
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebCore/mac/CtapResponseTest.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp.
(TestWebKitAPI::getTestCorruptedSignResponse):
(TestWebKitAPI::getTestCredentialRawIdBytes):
(TestWebKitAPI::convertToVector):
(TestWebKitAPI::TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoremacCtapRequestTestcpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/CtapRequestTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoremacCtapResponseTestcpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/CtapResponseTest.cpp</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreCtapRequestTestcpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreCtapResponseTestcpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (237992 => 237993)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2018-11-08 19:40:29 UTC (rev 237992)
+++ trunk/Tools/ChangeLog       2018-11-08 19:41:42 UTC (rev 237993)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2018-11-08  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Unreviewed, a quick build fix for r237983
+
+        Temporarily make CtapRequestTest.cpp/CtapResponseTest.cpp to mac only to avoid iOS build failures.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
+        * TestWebKitAPI/Tests/WebCore/mac/CtapRequestTest.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp.
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebCore/mac/CtapResponseTest.cpp: Renamed from Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp.
+        (TestWebKitAPI::getTestCorruptedSignResponse):
+        (TestWebKitAPI::getTestCredentialRawIdBytes):
+        (TestWebKitAPI::convertToVector):
+        (TestWebKitAPI::TEST):
+
</ins><span class="cx"> 2018-11-05  Ryan Haddad  <ryanhaddad@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Fix steps_unittest.py failures related to recent Win10/Win7 changes
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (237992 => 237993)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2018-11-08 19:40:29 UTC (rev 237992)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj   2018-11-08 19:41:42 UTC (rev 237993)
</span><span class="lines">@@ -2530,6 +2530,8 @@
</span><span class="cx">          3162AE9A1E6F2F8F000E4DBC /* mac */ = {
</span><span class="cx">                  isa = PBXGroup;
</span><span class="cx">                  children = (
</span><ins>+                               572B403321769A88000AD43E /* CtapRequestTest.cpp */,
+                               572B404321781B42000AD43E /* CtapResponseTest.cpp */,
</ins><span class="cx">                           316BDBAB1E7207F100DE0D5A /* GPULegacyBuffer.mm */,
</span><span class="cx">                          315231C91EB3B3C700A22A16 /* GPULegacyCommandQueue.mm */,
</span><span class="cx">                          3162AE9B1E6F2FCE000E4DBC /* GPULegacyDevice.mm */,
</span><span class="lines">@@ -2557,8 +2559,6 @@
</span><span class="cx">                          1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */,
</span><span class="cx">                          7CB184C41AA3F2100066EDFD /* ContentExtensions.cpp */,
</span><span class="cx">                          CD5451E919E41F9D0016936F /* CSSParser.cpp */,
</span><del>-                               572B403321769A88000AD43E /* CtapRequestTest.cpp */,
-                               572B404321781B42000AD43E /* CtapResponseTest.cpp */,
</del><span class="cx">                           260BA5781B1D2E7B004FA07C /* DFACombiner.cpp */,
</span><span class="cx">                          260BA57A1B1D2EE2004FA07C /* DFAHelpers.h */,
</span><span class="cx">                          26F6E1EF1ADC749B00DE696B /* DFAMinimizer.cpp */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreCtapRequestTestcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp (237992 => 237993)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp      2018-11-08 19:40:29 UTC (rev 237992)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp 2018-11-08 19:41:42 UTC (rev 237993)
</span><span class="lines">@@ -1,128 +0,0 @@
</span><del>-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Copyright (C) 2018 Apple Inc. All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//    * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//    * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//    * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include "config.h"
-
-#if ENABLE(WEB_AUTHN)
-
-#include "FidoTestData.h"
-#include <WebCore/DeviceRequestConverter.h>
-#include <WebCore/FidoConstants.h>
-#include <WebCore/PublicKeyCredentialCreationOptions.h>
-#include <WebCore/PublicKeyCredentialRequestOptions.h>
-#include <wtf/text/Base64.h>
-
-namespace TestWebKitAPI {
-using namespace WebCore;
-using namespace fido;
-
-// Leveraging example 2 of section 6.1 of the spec
-// https://fidoalliance.org/specs/fido-v2.0-ps-20170927/fido-client-to-authenticator-protocol-v2.0-ps-20170927.html
-TEST(CTAPRequestTest, TestConstructMakeCredentialRequestParam)
-{
-    PublicKeyCredentialCreationOptions::RpEntity rp;
-    rp.name = "Acme";
-    rp.id = "acme.com";
-
-    PublicKeyCredentialCreationOptions::UserEntity user;
-    user.name = "johnpsmith@example.com";
-    user.icon = "https://pics.acme.com/00/p/aBjjjpqPb.png";
-    user.idVector.append(TestData::kUserId, sizeof(TestData::kUserId));
-    user.displayName = "John P. Smith";
-
-    Vector<PublicKeyCredentialCreationOptions::Parameters> params { { PublicKeyCredentialType::PublicKey, 7 }, { PublicKeyCredentialType::PublicKey, 257 } };
-    PublicKeyCredentialCreationOptions::AuthenticatorSelectionCriteria selection { PublicKeyCredentialCreationOptions::AuthenticatorAttachment::Platform, true, UserVerificationRequirement::Preferred };
-
-    PublicKeyCredentialCreationOptions options { rp, user, { }, params, std::nullopt, { }, selection };
-    Vector<uint8_t> hash;
-    hash.append(TestData::kClientDataHash, sizeof(TestData::kClientDataHash));
-    auto serializedData = encodeMakeCredenitalRequestAsCBOR(hash, options, AuthenticatorSupportedOptions::UserVerificationAvailability::kSupportedButNotConfigured);
-    EXPECT_EQ(serializedData.size(), sizeof(TestData::kCtapMakeCredentialRequest));
-    EXPECT_EQ(memcmp(serializedData.data(), TestData::kCtapMakeCredentialRequest, serializedData.size()), 0);
-}
-
-TEST(CTAPRequestTest, TestConstructGetAssertionRequest)
-{
-    PublicKeyCredentialRequestOptions options;
-    options.rpId = "acme.com";
-
-    PublicKeyCredentialDescriptor descriptor1;
-    descriptor1.type = PublicKeyCredentialType::PublicKey;
-    const uint8_t id1[] = {
-        0xf2, 0x20, 0x06, 0xde, 0x4f, 0x90, 0x5a, 0xf6, 0x8a, 0x43, 0x94,
-        0x2f, 0x02, 0x4f, 0x2a, 0x5e, 0xce, 0x60, 0x3d, 0x9c, 0x6d, 0x4b,
-        0x3d, 0xf8, 0xbe, 0x08, 0xed, 0x01, 0xfc, 0x44, 0x26, 0x46, 0xd0,
-        0x34, 0x85, 0x8a, 0xc7, 0x5b, 0xed, 0x3f, 0xd5, 0x80, 0xbf, 0x98,
-        0x08, 0xd9, 0x4f, 0xcb, 0xee, 0x82, 0xb9, 0xb2, 0xef, 0x66, 0x77,
-        0xaf, 0x0a, 0xdc, 0xc3, 0x58, 0x52, 0xea, 0x6b, 0x9e };
-    descriptor1.idVector.append(id1, sizeof(id1));
-    options.allowCredentials.append(descriptor1);
-
-    PublicKeyCredentialDescriptor descriptor2;
-    descriptor2.type = PublicKeyCredentialType::PublicKey;
-    const uint8_t id2[] = {
-        0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
-        0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
-        0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
-        0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
-        0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 };
-    descriptor2.idVector.append(id2, sizeof(id2));
-    options.allowCredentials.append(descriptor2);
-
-    options.userVerification = UserVerificationRequirement::Required;
-
-    Vector<uint8_t> hash;
-    hash.append(TestData::kClientDataHash, sizeof(TestData::kClientDataHash));
-    auto serializedData = encodeGetAssertionRequestAsCBOR(hash, options, AuthenticatorSupportedOptions::UserVerificationAvailability::kSupportedButNotConfigured);
-    EXPECT_EQ(serializedData.size(), sizeof(TestData::kTestComplexCtapGetAssertionRequest));
-    EXPECT_EQ(memcmp(serializedData.data(), TestData::kTestComplexCtapGetAssertionRequest, serializedData.size()), 0);
-}
-
-TEST(CTAPRequestTest, TestConstructCtapAuthenticatorRequestParam)
-{
-    static constexpr uint8_t kSerializedGetInfoCmd = 0x04;
-    static constexpr uint8_t kSerializedGetNextAssertionCmd = 0x08;
-    static constexpr uint8_t kSerializedResetCmd = 0x07;
-
-    auto serializedData1 = encodeEmptyAuthenticatorRequest(CtapRequestCommand::kAuthenticatorGetInfo);
-    EXPECT_EQ(serializedData1.size(), 1u);
-    EXPECT_EQ(memcmp(serializedData1.data(), &kSerializedGetInfoCmd, 1), 0);
-
-    auto serializedData2 = encodeEmptyAuthenticatorRequest(CtapRequestCommand::kAuthenticatorGetNextAssertion);
-    EXPECT_EQ(serializedData2.size(), 1u);
-    EXPECT_EQ(memcmp(serializedData2.data(), &kSerializedGetNextAssertionCmd, 1), 0);
-
-    auto serializedData3 = encodeEmptyAuthenticatorRequest(CtapRequestCommand::kAuthenticatorReset);
-    EXPECT_EQ(serializedData3.size(), 1u);
-    EXPECT_EQ(memcmp(serializedData3.data(), &kSerializedResetCmd, 1), 0);
-}
-
-} // namespace TestWebKitAPI
-
-#endif // ENABLE(WEB_AUTHN)
</del></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreCtapResponseTestcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp (237992 => 237993)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp     2018-11-08 19:40:29 UTC (rev 237992)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp        2018-11-08 19:41:42 UTC (rev 237993)
</span><span class="lines">@@ -1,354 +0,0 @@
</span><del>-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Copyright (C) 2018 Apple Inc. All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-//    * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//    * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//    * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#include "config.h"
-
-#if ENABLE(WEB_AUTHN)
-
-#include "FidoTestData.h"
-#include <WebCore/CBORReader.h>
-#include <WebCore/CBORValue.h>
-#include <WebCore/CBORWriter.h>
-#include <WebCore/DeviceResponseConverter.h>
-#include <WebCore/FidoConstants.h>
-#include <WebCore/PublicKeyCredential.h>
-
-namespace TestWebKitAPI {
-using namespace fido;
-
-constexpr uint8_t kTestAuthenticatorGetInfoResponseWithNoVersion[] = {
-    // Success status byte
-    0x00,
-    // Map of 6 elements
-    0xA6,
-    // Key(01) - versions
-    0x01,
-    // Array(0)
-    0x80,
-    // Key(02) - extensions
-    0x02,
-    // Array(2)
-    0x82,
-    // "uvm"
-    0x63, 0x75, 0x76, 0x6D,
-    // "hmac-secret"
-    0x6B, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74,
-    // Key(03) - AAGUID
-    0x03,
-    // Bytes(16)
-    0x50, 0xF8, 0xA0, 0x11, 0xF3, 0x8C, 0x0A, 0x4D, 0x15, 0x80, 0x06, 0x17,
-    0x11, 0x1F, 0x9E, 0xDC, 0x7D,
-    // Key(04) - options
-    0x04,
-    // Map(05)
-    0xA5,
-    // Key - "rk"
-    0x62, 0x72, 0x6B,
-    // true
-    0xF5,
-    // Key - "up"
-    0x62, 0x75, 0x70,
-    // true
-    0xF5,
-    // Key - "uv"
-    0x62, 0x75, 0x76,
-    // true
-    0xF5,
-    // Key - "plat"
-    0x64, 0x70, 0x6C, 0x61, 0x74,
-    // true
-    0xF5,
-    // Key - "clientPin"
-    0x69, 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x50, 0x69, 0x6E,
-    // false
-    0xF4,
-    // Key(05) - Max message size
-    0x05,
-    // 1200
-    0x19, 0x04, 0xB0,
-    // Key(06) - Pin protocols
-    0x06,
-    // Array[1]
-    0x81, 0x01,
-};
-
-constexpr uint8_t kTestAuthenticatorGetInfoResponseWithDuplicateVersion[] = {
-    // Success status byte
-    0x00,
-    // Map of 6 elements
-    0xA6,
-    // Key(01) - versions
-    0x01,
-    // Array(02)
-    0x82,
-    // "U2F_V2"
-    0x66, 0x55, 0x32, 0x46, 0x5F, 0x56, 0x32,
-    // "U2F_V2"
-    0x66, 0x55, 0x32, 0x46, 0x5F, 0x56, 0x32,
-    // Key(02) - extensions
-    0x02,
-    // Array(2)
-    0x82,
-    // "uvm"
-    0x63, 0x75, 0x76, 0x6D,
-    // "hmac-secret"
-    0x6B, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74,
-    // Key(03) - AAGUID
-    0x03,
-    // Bytes(16)
-    0x50, 0xF8, 0xA0, 0x11, 0xF3, 0x8C, 0x0A, 0x4D, 0x15, 0x80, 0x06, 0x17,
-    0x11, 0x1F, 0x9E, 0xDC, 0x7D,
-    // Key(04) - options
-    0x04,
-    // Map(05)
-    0xA5,
-    // Key - "rk"
-    0x62, 0x72, 0x6B,
-    // true
-    0xF5,
-    // Key - "up"
-    0x62, 0x75, 0x70,
-    // true
-    0xF5,
-    // Key - "uv"
-    0x62, 0x75, 0x76,
-    // true
-    0xF5,
-    // Key - "plat"
-    0x64, 0x70, 0x6C, 0x61, 0x74,
-    // true
-    0xF5,
-    // Key - "clientPin"
-    0x69, 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x50, 0x69, 0x6E,
-    // false
-    0xF4,
-    // Key(05) - Max message size
-    0x05,
-    // 1200
-    0x19, 0x04, 0xB0,
-    // Key(06) - Pin protocols
-    0x06,
-    // Array[1]
-    0x81, 0x01,
-};
-
-constexpr uint8_t kTestAuthenticatorGetInfoResponseWithIncorrectAaguid[] = {
-    // Success status byte
-    0x00,
-    // Map of 6 elements
-    0xA6,
-    // Key(01) - versions
-    0x01,
-    // Array(01)
-    0x81,
-    // "U2F_V2"
-    0x66, 0x55, 0x32, 0x46, 0x5F, 0x56, 0x32,
-    // Key(02) - extensions
-    0x02,
-    // Array(2)
-    0x82,
-    // "uvm"
-    0x63, 0x75, 0x76, 0x6D,
-    // "hmac-secret"
-    0x6B, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74,
-    // Key(03) - AAGUID
-    0x03,
-    // Bytes(17) - FIDO2 device AAGUID must be 16 bytes long in order to be
-    // correct.
-    0x51, 0xF8, 0xA0, 0x11, 0xF3, 0x8C, 0x0A, 0x4D, 0x15, 0x80, 0x06, 0x17,
-    0x11, 0x1F, 0x9E, 0xDC, 0x7D, 0x00,
-    // Key(04) - options
-    0x04,
-    // Map(05)
-    0xA5,
-    // Key - "rk"
-    0x62, 0x72, 0x6B,
-    // true
-    0xF5,
-    // Key - "up"
-    0x62, 0x75, 0x70,
-    // true
-    0xF5,
-    // Key - "uv"
-    0x62, 0x75, 0x76,
-    // true
-    0xF5,
-    // Key - "plat"
-    0x64, 0x70, 0x6C, 0x61, 0x74,
-    // true
-    0xF5,
-    // Key - "clientPin"
-    0x69, 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x50, 0x69, 0x6E,
-    // false
-    0xF4,
-    // Key(05) - Max message size
-    0x05,
-    // 1200
-    0x19, 0x04, 0xB0,
-    // Key(06) - Pin protocols
-    0x06,
-    // Array[1]
-    0x81, 0x01,
-};
-
-constexpr uint8_t kTestDeviceAaguid[] = {
-    0xF8, 0xA0, 0x11, 0xF3, 0x8C, 0x0A, 0x4D, 0x15, 0x80, 0x06, 0x17, 0x11, 0x1F, 0x9E, 0xDC, 0x7D
-};
-
-// Get a subset of the response for testing error handling.
-Vector<uint8_t> getTestCorruptedSignResponse(size_t length)
-{
-    ASSERT(length < sizeof(TestData::kTestU2fSignResponse));
-    Vector<uint8_t> testCorruptedSignResponse;
-    testCorruptedSignResponse.reserveInitialCapacity(length);
-    testCorruptedSignResponse.append(TestData::kTestU2fSignResponse, length);
-    return testCorruptedSignResponse;
-}
-
-// Return a key handle used for GetAssertion request.
-Vector<uint8_t> getTestCredentialRawIdBytes()
-{
-    Vector<uint8_t> testCredentialRawIdBytes;
-    testCredentialRawIdBytes.reserveInitialCapacity(sizeof(TestData::kU2fSignKeyHandle));
-    testCredentialRawIdBytes.append(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle));
-    return testCredentialRawIdBytes;
-}
-
-Vector<uint8_t> convertToVector(const uint8_t byteArray[], const size_t length)
-{
-    Vector<uint8_t> result;
-    result.reserveInitialCapacity(length);
-    result.append(byteArray, length);
-    return result;
-}
-
-// Leveraging example 4 of section 6.1 of the spec
-// https://fidoalliance.org/specs/fido-v2.0-ps-20170927/fido-client-to-authenticator-protocol-v2.0-ps-20170927.html#commands
-TEST(CTAPResponseTest, TestReadMakeCredentialResponse)
-{
-    auto makeCredentialResponse = readCTAPMakeCredentialResponse(convertToVector(TestData::kTestMakeCredentialResponse, sizeof(TestData::kTestMakeCredentialResponse)));
-    ASSERT_TRUE(makeCredentialResponse);
-    auto cborAttestationObject = cbor::CBORReader::read(convertToVector(reinterpret_cast<uint8_t*>(makeCredentialResponse->attestationObject->data()), makeCredentialResponse->attestationObject->byteLength()));
-    ASSERT_TRUE(cborAttestationObject);
-    ASSERT_TRUE(cborAttestationObject->isMap());
-
-    const auto& attestationObjectMap = cborAttestationObject->getMap();
-    auto it = attestationObjectMap.find(cbor::CBORValue(kFormatKey));
-    ASSERT_TRUE(it != attestationObjectMap.end());
-    ASSERT_TRUE(it->second.isString());
-    EXPECT_STREQ(it->second.getString().utf8().data(), "packed");
-
-    it = attestationObjectMap.find(cbor::CBORValue(kAuthDataKey));
-    ASSERT_TRUE(it != attestationObjectMap.end());
-    ASSERT_TRUE(it->second.isByteString());
-    EXPECT_EQ(it->second.getByteString(), convertToVector(TestData::kCtap2MakeCredentialAuthData, sizeof(TestData::kCtap2MakeCredentialAuthData)));
-
-    it = attestationObjectMap.find(cbor::CBORValue(kAttestationStatementKey));
-    ASSERT_TRUE(it != attestationObjectMap.end());
-    ASSERT_TRUE(it->second.isMap());
-
-    const auto& attestationStatementMap = it->second.getMap();
-    auto attStmtIt = attestationStatementMap.find(cbor::CBORValue("alg"));
-
-    ASSERT_TRUE(attStmtIt != attestationStatementMap.end());
-    ASSERT_TRUE(attStmtIt->second.isInteger());
-    EXPECT_EQ(attStmtIt->second.getInteger(), -7);
-
-    attStmtIt = attestationStatementMap.find(cbor::CBORValue("sig"));
-    ASSERT_TRUE(attStmtIt != attestationStatementMap.end());
-    ASSERT_TRUE(attStmtIt->second.isByteString());
-    EXPECT_EQ(attStmtIt->second.getByteString(), convertToVector(TestData::kCtap2MakeCredentialSignature, sizeof(TestData::kCtap2MakeCredentialSignature)));
-
-    attStmtIt = attestationStatementMap.find(cbor::CBORValue("x5c"));
-    ASSERT_TRUE(attStmtIt != attestationStatementMap.end());
-    const auto& certificate = attStmtIt->second;
-    ASSERT_TRUE(certificate.isArray());
-    ASSERT_EQ(certificate.getArray().size(), 1u);
-    ASSERT_TRUE(certificate.getArray()[0].isByteString());
-    EXPECT_EQ(certificate.getArray()[0].getByteString(), convertToVector(TestData::kCtap2MakeCredentialCertificate, sizeof(TestData::kCtap2MakeCredentialCertificate)));
-    EXPECT_EQ(makeCredentialResponse->rawId->byteLength(), sizeof(TestData::kCtap2MakeCredentialCredentialId));
-    EXPECT_EQ(memcmp(makeCredentialResponse->rawId->data(), TestData::kCtap2MakeCredentialCredentialId, sizeof(TestData::kCtap2MakeCredentialCredentialId)), 0);
-}
-
-// Leveraging example 5 of section 6.1 of the CTAP spec.
-// https://fidoalliance.org/specs/fido-v2.0-ps-20170927/fido-client-to-authenticator-protocol-v2.0-ps-20170927.html
-TEST(CTAPResponseTest, TestReadGetAssertionResponse)
-{
-    auto getAssertionResponse = readCTAPGetAssertionResponse(convertToVector(TestData::kDeviceGetAssertionResponse, sizeof(TestData::kDeviceGetAssertionResponse)));
-    ASSERT_TRUE(getAssertionResponse);
-
-    EXPECT_EQ(getAssertionResponse->authenticatorData->byteLength(), sizeof(TestData::kCtap2GetAssertionAuthData));
-    EXPECT_EQ(memcmp(getAssertionResponse->authenticatorData->data(), TestData::kCtap2GetAssertionAuthData, sizeof(TestData::kCtap2GetAssertionAuthData)), 0);
-    EXPECT_EQ(getAssertionResponse->signature->byteLength(), sizeof(TestData::kCtap2GetAssertionSignature));
-    EXPECT_EQ(memcmp(getAssertionResponse->signature->data(), TestData::kCtap2GetAssertionSignature, sizeof(TestData::kCtap2GetAssertionSignature)), 0);
-}
-
-TEST(CTAPResponseTest, TestReadGetInfoResponse)
-{
-    auto getInfoResponse = readCTAPGetInfoResponse(convertToVector(TestData::kTestGetInfoResponsePlatformDevice, sizeof(TestData::kTestGetInfoResponsePlatformDevice)));
-    ASSERT_TRUE(getInfoResponse);
-    ASSERT_TRUE(getInfoResponse->maxMsgSize());
-    EXPECT_EQ(*getInfoResponse->maxMsgSize(), 1200u);
-    EXPECT_NE(getInfoResponse->versions().find(ProtocolVersion::kCtap), getInfoResponse->versions().end());
-    EXPECT_NE(getInfoResponse->versions().find(ProtocolVersion::kU2f), getInfoResponse->versions().end());
-    EXPECT_TRUE(getInfoResponse->options().isPlatformDevice());
-    EXPECT_TRUE(getInfoResponse->options().supportsResidentKey());
-    EXPECT_TRUE(getInfoResponse->options().userPresenceRequired());
-    EXPECT_EQ(AuthenticatorSupportedOptions::UserVerificationAvailability::kSupportedAndConfigured, getInfoResponse->options().userVerificationAvailability());
-    EXPECT_EQ(AuthenticatorSupportedOptions::ClientPinAvailability::kSupportedButPinNotSet, getInfoResponse->options().clientPinAvailability());
-}
-
-TEST(CTAPResponseTest, TestReadGetInfoResponseWithIncorrectFormat)
-{
-    EXPECT_FALSE(readCTAPGetInfoResponse(convertToVector(kTestAuthenticatorGetInfoResponseWithNoVersion, sizeof(kTestAuthenticatorGetInfoResponseWithNoVersion))));
-    EXPECT_FALSE(readCTAPGetInfoResponse(convertToVector(kTestAuthenticatorGetInfoResponseWithDuplicateVersion, sizeof(kTestAuthenticatorGetInfoResponseWithDuplicateVersion))));
-    EXPECT_FALSE(readCTAPGetInfoResponse(convertToVector(kTestAuthenticatorGetInfoResponseWithIncorrectAaguid, sizeof(kTestAuthenticatorGetInfoResponseWithIncorrectAaguid))));
-}
-
-TEST(CTAPResponseTest, TestSerializeGetInfoResponse)
-{
-    AuthenticatorGetInfoResponse response({ ProtocolVersion::kCtap, ProtocolVersion::kU2f }, convertToVector(kTestDeviceAaguid, sizeof(kTestDeviceAaguid)));
-    response.setExtensions({ "uvm", "hmac-secret" });
-    AuthenticatorSupportedOptions options;
-    options.setSupportsResidentKey(true);
-    options.setIsPlatformDevice(true);
-    options.setClientPinAvailability(AuthenticatorSupportedOptions::ClientPinAvailability::kSupportedButPinNotSet);
-    options.setUserVerificationAvailability(AuthenticatorSupportedOptions::UserVerificationAvailability::kSupportedAndConfigured);
-    response.setOptions(WTFMove(options));
-    response.setMaxMsgSize(1200);
-    response.setPinProtocols({ 1 });
-
-    auto responseAsCBOR = encodeAsCBOR(response);
-    EXPECT_EQ(responseAsCBOR.size(), sizeof(TestData::kTestGetInfoResponsePlatformDevice) - 1);
-    EXPECT_EQ(memcmp(responseAsCBOR.data(), TestData::kTestGetInfoResponsePlatformDevice + 1, responseAsCBOR.size()), 0);
-}
-
-} // namespace TestWebKitAPI
-
-#endif // ENABLE(WEB_AUTHN)
</del></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoremacCtapRequestTestcppfromrev237992trunkToolsTestWebKitAPITestsWebCoreCtapRequestTestcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/CtapRequestTest.cpp (from rev 237992, trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp) (0 => 237993)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/CtapRequestTest.cpp                          (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/CtapRequestTest.cpp     2018-11-08 19:41:42 UTC (rev 237993)
</span><span class="lines">@@ -0,0 +1,128 @@
</span><ins>+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Copyright (C) 2018 Apple Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//    * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//    * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//    * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "config.h"
+
+#if ENABLE(WEB_AUTHN)
+
+#include "FidoTestData.h"
+#include <WebCore/DeviceRequestConverter.h>
+#include <WebCore/FidoConstants.h>
+#include <WebCore/PublicKeyCredentialCreationOptions.h>
+#include <WebCore/PublicKeyCredentialRequestOptions.h>
+#include <wtf/text/Base64.h>
+
+namespace TestWebKitAPI {
+using namespace WebCore;
+using namespace fido;
+
+// Leveraging example 2 of section 6.1 of the spec
+// https://fidoalliance.org/specs/fido-v2.0-ps-20170927/fido-client-to-authenticator-protocol-v2.0-ps-20170927.html
+TEST(CTAPRequestTest, TestConstructMakeCredentialRequestParam)
+{
+    PublicKeyCredentialCreationOptions::RpEntity rp;
+    rp.name = "Acme";
+    rp.id = "acme.com";
+
+    PublicKeyCredentialCreationOptions::UserEntity user;
+    user.name = "johnpsmith@example.com";
+    user.icon = "https://pics.acme.com/00/p/aBjjjpqPb.png";
+    user.idVector.append(TestData::kUserId, sizeof(TestData::kUserId));
+    user.displayName = "John P. Smith";
+
+    Vector<PublicKeyCredentialCreationOptions::Parameters> params { { PublicKeyCredentialType::PublicKey, 7 }, { PublicKeyCredentialType::PublicKey, 257 } };
+    PublicKeyCredentialCreationOptions::AuthenticatorSelectionCriteria selection { PublicKeyCredentialCreationOptions::AuthenticatorAttachment::Platform, true, UserVerificationRequirement::Preferred };
+
+    PublicKeyCredentialCreationOptions options { rp, user, { }, params, std::nullopt, { }, selection };
+    Vector<uint8_t> hash;
+    hash.append(TestData::kClientDataHash, sizeof(TestData::kClientDataHash));
+    auto serializedData = encodeMakeCredenitalRequestAsCBOR(hash, options, AuthenticatorSupportedOptions::UserVerificationAvailability::kSupportedButNotConfigured);
+    EXPECT_EQ(serializedData.size(), sizeof(TestData::kCtapMakeCredentialRequest));
+    EXPECT_EQ(memcmp(serializedData.data(), TestData::kCtapMakeCredentialRequest, serializedData.size()), 0);
+}
+
+TEST(CTAPRequestTest, TestConstructGetAssertionRequest)
+{
+    PublicKeyCredentialRequestOptions options;
+    options.rpId = "acme.com";
+
+    PublicKeyCredentialDescriptor descriptor1;
+    descriptor1.type = PublicKeyCredentialType::PublicKey;
+    const uint8_t id1[] = {
+        0xf2, 0x20, 0x06, 0xde, 0x4f, 0x90, 0x5a, 0xf6, 0x8a, 0x43, 0x94,
+        0x2f, 0x02, 0x4f, 0x2a, 0x5e, 0xce, 0x60, 0x3d, 0x9c, 0x6d, 0x4b,
+        0x3d, 0xf8, 0xbe, 0x08, 0xed, 0x01, 0xfc, 0x44, 0x26, 0x46, 0xd0,
+        0x34, 0x85, 0x8a, 0xc7, 0x5b, 0xed, 0x3f, 0xd5, 0x80, 0xbf, 0x98,
+        0x08, 0xd9, 0x4f, 0xcb, 0xee, 0x82, 0xb9, 0xb2, 0xef, 0x66, 0x77,
+        0xaf, 0x0a, 0xdc, 0xc3, 0x58, 0x52, 0xea, 0x6b, 0x9e };
+    descriptor1.idVector.append(id1, sizeof(id1));
+    options.allowCredentials.append(descriptor1);
+
+    PublicKeyCredentialDescriptor descriptor2;
+    descriptor2.type = PublicKeyCredentialType::PublicKey;
+    const uint8_t id2[] = {
+        0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+        0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+        0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+        0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+        0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 };
+    descriptor2.idVector.append(id2, sizeof(id2));
+    options.allowCredentials.append(descriptor2);
+
+    options.userVerification = UserVerificationRequirement::Required;
+
+    Vector<uint8_t> hash;
+    hash.append(TestData::kClientDataHash, sizeof(TestData::kClientDataHash));
+    auto serializedData = encodeGetAssertionRequestAsCBOR(hash, options, AuthenticatorSupportedOptions::UserVerificationAvailability::kSupportedButNotConfigured);
+    EXPECT_EQ(serializedData.size(), sizeof(TestData::kTestComplexCtapGetAssertionRequest));
+    EXPECT_EQ(memcmp(serializedData.data(), TestData::kTestComplexCtapGetAssertionRequest, serializedData.size()), 0);
+}
+
+TEST(CTAPRequestTest, TestConstructCtapAuthenticatorRequestParam)
+{
+    static constexpr uint8_t kSerializedGetInfoCmd = 0x04;
+    static constexpr uint8_t kSerializedGetNextAssertionCmd = 0x08;
+    static constexpr uint8_t kSerializedResetCmd = 0x07;
+
+    auto serializedData1 = encodeEmptyAuthenticatorRequest(CtapRequestCommand::kAuthenticatorGetInfo);
+    EXPECT_EQ(serializedData1.size(), 1u);
+    EXPECT_EQ(memcmp(serializedData1.data(), &kSerializedGetInfoCmd, 1), 0);
+
+    auto serializedData2 = encodeEmptyAuthenticatorRequest(CtapRequestCommand::kAuthenticatorGetNextAssertion);
+    EXPECT_EQ(serializedData2.size(), 1u);
+    EXPECT_EQ(memcmp(serializedData2.data(), &kSerializedGetNextAssertionCmd, 1), 0);
+
+    auto serializedData3 = encodeEmptyAuthenticatorRequest(CtapRequestCommand::kAuthenticatorReset);
+    EXPECT_EQ(serializedData3.size(), 1u);
+    EXPECT_EQ(memcmp(serializedData3.data(), &kSerializedResetCmd, 1), 0);
+}
+
+} // namespace TestWebKitAPI
+
+#endif // ENABLE(WEB_AUTHN)
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoremacCtapResponseTestcppfromrev237992trunkToolsTestWebKitAPITestsWebCoreCtapResponseTestcpp"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/CtapResponseTest.cpp (from rev 237992, trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp) (0 => 237993)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/CtapResponseTest.cpp                         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/CtapResponseTest.cpp    2018-11-08 19:41:42 UTC (rev 237993)
</span><span class="lines">@@ -0,0 +1,354 @@
</span><ins>+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Copyright (C) 2018 Apple Inc. All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+//    * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//    * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+//    * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "config.h"
+
+#if ENABLE(WEB_AUTHN)
+
+#include "FidoTestData.h"
+#include <WebCore/CBORReader.h>
+#include <WebCore/CBORValue.h>
+#include <WebCore/CBORWriter.h>
+#include <WebCore/DeviceResponseConverter.h>
+#include <WebCore/FidoConstants.h>
+#include <WebCore/PublicKeyCredential.h>
+
+namespace TestWebKitAPI {
+using namespace fido;
+
+constexpr uint8_t kTestAuthenticatorGetInfoResponseWithNoVersion[] = {
+    // Success status byte
+    0x00,
+    // Map of 6 elements
+    0xA6,
+    // Key(01) - versions
+    0x01,
+    // Array(0)
+    0x80,
+    // Key(02) - extensions
+    0x02,
+    // Array(2)
+    0x82,
+    // "uvm"
+    0x63, 0x75, 0x76, 0x6D,
+    // "hmac-secret"
+    0x6B, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74,
+    // Key(03) - AAGUID
+    0x03,
+    // Bytes(16)
+    0x50, 0xF8, 0xA0, 0x11, 0xF3, 0x8C, 0x0A, 0x4D, 0x15, 0x80, 0x06, 0x17,
+    0x11, 0x1F, 0x9E, 0xDC, 0x7D,
+    // Key(04) - options
+    0x04,
+    // Map(05)
+    0xA5,
+    // Key - "rk"
+    0x62, 0x72, 0x6B,
+    // true
+    0xF5,
+    // Key - "up"
+    0x62, 0x75, 0x70,
+    // true
+    0xF5,
+    // Key - "uv"
+    0x62, 0x75, 0x76,
+    // true
+    0xF5,
+    // Key - "plat"
+    0x64, 0x70, 0x6C, 0x61, 0x74,
+    // true
+    0xF5,
+    // Key - "clientPin"
+    0x69, 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x50, 0x69, 0x6E,
+    // false
+    0xF4,
+    // Key(05) - Max message size
+    0x05,
+    // 1200
+    0x19, 0x04, 0xB0,
+    // Key(06) - Pin protocols
+    0x06,
+    // Array[1]
+    0x81, 0x01,
+};
+
+constexpr uint8_t kTestAuthenticatorGetInfoResponseWithDuplicateVersion[] = {
+    // Success status byte
+    0x00,
+    // Map of 6 elements
+    0xA6,
+    // Key(01) - versions
+    0x01,
+    // Array(02)
+    0x82,
+    // "U2F_V2"
+    0x66, 0x55, 0x32, 0x46, 0x5F, 0x56, 0x32,
+    // "U2F_V2"
+    0x66, 0x55, 0x32, 0x46, 0x5F, 0x56, 0x32,
+    // Key(02) - extensions
+    0x02,
+    // Array(2)
+    0x82,
+    // "uvm"
+    0x63, 0x75, 0x76, 0x6D,
+    // "hmac-secret"
+    0x6B, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74,
+    // Key(03) - AAGUID
+    0x03,
+    // Bytes(16)
+    0x50, 0xF8, 0xA0, 0x11, 0xF3, 0x8C, 0x0A, 0x4D, 0x15, 0x80, 0x06, 0x17,
+    0x11, 0x1F, 0x9E, 0xDC, 0x7D,
+    // Key(04) - options
+    0x04,
+    // Map(05)
+    0xA5,
+    // Key - "rk"
+    0x62, 0x72, 0x6B,
+    // true
+    0xF5,
+    // Key - "up"
+    0x62, 0x75, 0x70,
+    // true
+    0xF5,
+    // Key - "uv"
+    0x62, 0x75, 0x76,
+    // true
+    0xF5,
+    // Key - "plat"
+    0x64, 0x70, 0x6C, 0x61, 0x74,
+    // true
+    0xF5,
+    // Key - "clientPin"
+    0x69, 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x50, 0x69, 0x6E,
+    // false
+    0xF4,
+    // Key(05) - Max message size
+    0x05,
+    // 1200
+    0x19, 0x04, 0xB0,
+    // Key(06) - Pin protocols
+    0x06,
+    // Array[1]
+    0x81, 0x01,
+};
+
+constexpr uint8_t kTestAuthenticatorGetInfoResponseWithIncorrectAaguid[] = {
+    // Success status byte
+    0x00,
+    // Map of 6 elements
+    0xA6,
+    // Key(01) - versions
+    0x01,
+    // Array(01)
+    0x81,
+    // "U2F_V2"
+    0x66, 0x55, 0x32, 0x46, 0x5F, 0x56, 0x32,
+    // Key(02) - extensions
+    0x02,
+    // Array(2)
+    0x82,
+    // "uvm"
+    0x63, 0x75, 0x76, 0x6D,
+    // "hmac-secret"
+    0x6B, 0x68, 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74,
+    // Key(03) - AAGUID
+    0x03,
+    // Bytes(17) - FIDO2 device AAGUID must be 16 bytes long in order to be
+    // correct.
+    0x51, 0xF8, 0xA0, 0x11, 0xF3, 0x8C, 0x0A, 0x4D, 0x15, 0x80, 0x06, 0x17,
+    0x11, 0x1F, 0x9E, 0xDC, 0x7D, 0x00,
+    // Key(04) - options
+    0x04,
+    // Map(05)
+    0xA5,
+    // Key - "rk"
+    0x62, 0x72, 0x6B,
+    // true
+    0xF5,
+    // Key - "up"
+    0x62, 0x75, 0x70,
+    // true
+    0xF5,
+    // Key - "uv"
+    0x62, 0x75, 0x76,
+    // true
+    0xF5,
+    // Key - "plat"
+    0x64, 0x70, 0x6C, 0x61, 0x74,
+    // true
+    0xF5,
+    // Key - "clientPin"
+    0x69, 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x50, 0x69, 0x6E,
+    // false
+    0xF4,
+    // Key(05) - Max message size
+    0x05,
+    // 1200
+    0x19, 0x04, 0xB0,
+    // Key(06) - Pin protocols
+    0x06,
+    // Array[1]
+    0x81, 0x01,
+};
+
+constexpr uint8_t kTestDeviceAaguid[] = {
+    0xF8, 0xA0, 0x11, 0xF3, 0x8C, 0x0A, 0x4D, 0x15, 0x80, 0x06, 0x17, 0x11, 0x1F, 0x9E, 0xDC, 0x7D
+};
+
+// Get a subset of the response for testing error handling.
+Vector<uint8_t> getTestCorruptedSignResponse(size_t length)
+{
+    ASSERT(length < sizeof(TestData::kTestU2fSignResponse));
+    Vector<uint8_t> testCorruptedSignResponse;
+    testCorruptedSignResponse.reserveInitialCapacity(length);
+    testCorruptedSignResponse.append(TestData::kTestU2fSignResponse, length);
+    return testCorruptedSignResponse;
+}
+
+// Return a key handle used for GetAssertion request.
+Vector<uint8_t> getTestCredentialRawIdBytes()
+{
+    Vector<uint8_t> testCredentialRawIdBytes;
+    testCredentialRawIdBytes.reserveInitialCapacity(sizeof(TestData::kU2fSignKeyHandle));
+    testCredentialRawIdBytes.append(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle));
+    return testCredentialRawIdBytes;
+}
+
+Vector<uint8_t> convertToVector(const uint8_t byteArray[], const size_t length)
+{
+    Vector<uint8_t> result;
+    result.reserveInitialCapacity(length);
+    result.append(byteArray, length);
+    return result;
+}
+
+// Leveraging example 4 of section 6.1 of the spec
+// https://fidoalliance.org/specs/fido-v2.0-ps-20170927/fido-client-to-authenticator-protocol-v2.0-ps-20170927.html#commands
+TEST(CTAPResponseTest, TestReadMakeCredentialResponse)
+{
+    auto makeCredentialResponse = readCTAPMakeCredentialResponse(convertToVector(TestData::kTestMakeCredentialResponse, sizeof(TestData::kTestMakeCredentialResponse)));
+    ASSERT_TRUE(makeCredentialResponse);
+    auto cborAttestationObject = cbor::CBORReader::read(convertToVector(reinterpret_cast<uint8_t*>(makeCredentialResponse->attestationObject->data()), makeCredentialResponse->attestationObject->byteLength()));
+    ASSERT_TRUE(cborAttestationObject);
+    ASSERT_TRUE(cborAttestationObject->isMap());
+
+    const auto& attestationObjectMap = cborAttestationObject->getMap();
+    auto it = attestationObjectMap.find(cbor::CBORValue(kFormatKey));
+    ASSERT_TRUE(it != attestationObjectMap.end());
+    ASSERT_TRUE(it->second.isString());
+    EXPECT_STREQ(it->second.getString().utf8().data(), "packed");
+
+    it = attestationObjectMap.find(cbor::CBORValue(kAuthDataKey));
+    ASSERT_TRUE(it != attestationObjectMap.end());
+    ASSERT_TRUE(it->second.isByteString());
+    EXPECT_EQ(it->second.getByteString(), convertToVector(TestData::kCtap2MakeCredentialAuthData, sizeof(TestData::kCtap2MakeCredentialAuthData)));
+
+    it = attestationObjectMap.find(cbor::CBORValue(kAttestationStatementKey));
+    ASSERT_TRUE(it != attestationObjectMap.end());
+    ASSERT_TRUE(it->second.isMap());
+
+    const auto& attestationStatementMap = it->second.getMap();
+    auto attStmtIt = attestationStatementMap.find(cbor::CBORValue("alg"));
+
+    ASSERT_TRUE(attStmtIt != attestationStatementMap.end());
+    ASSERT_TRUE(attStmtIt->second.isInteger());
+    EXPECT_EQ(attStmtIt->second.getInteger(), -7);
+
+    attStmtIt = attestationStatementMap.find(cbor::CBORValue("sig"));
+    ASSERT_TRUE(attStmtIt != attestationStatementMap.end());
+    ASSERT_TRUE(attStmtIt->second.isByteString());
+    EXPECT_EQ(attStmtIt->second.getByteString(), convertToVector(TestData::kCtap2MakeCredentialSignature, sizeof(TestData::kCtap2MakeCredentialSignature)));
+
+    attStmtIt = attestationStatementMap.find(cbor::CBORValue("x5c"));
+    ASSERT_TRUE(attStmtIt != attestationStatementMap.end());
+    const auto& certificate = attStmtIt->second;
+    ASSERT_TRUE(certificate.isArray());
+    ASSERT_EQ(certificate.getArray().size(), 1u);
+    ASSERT_TRUE(certificate.getArray()[0].isByteString());
+    EXPECT_EQ(certificate.getArray()[0].getByteString(), convertToVector(TestData::kCtap2MakeCredentialCertificate, sizeof(TestData::kCtap2MakeCredentialCertificate)));
+    EXPECT_EQ(makeCredentialResponse->rawId->byteLength(), sizeof(TestData::kCtap2MakeCredentialCredentialId));
+    EXPECT_EQ(memcmp(makeCredentialResponse->rawId->data(), TestData::kCtap2MakeCredentialCredentialId, sizeof(TestData::kCtap2MakeCredentialCredentialId)), 0);
+}
+
+// Leveraging example 5 of section 6.1 of the CTAP spec.
+// https://fidoalliance.org/specs/fido-v2.0-ps-20170927/fido-client-to-authenticator-protocol-v2.0-ps-20170927.html
+TEST(CTAPResponseTest, TestReadGetAssertionResponse)
+{
+    auto getAssertionResponse = readCTAPGetAssertionResponse(convertToVector(TestData::kDeviceGetAssertionResponse, sizeof(TestData::kDeviceGetAssertionResponse)));
+    ASSERT_TRUE(getAssertionResponse);
+
+    EXPECT_EQ(getAssertionResponse->authenticatorData->byteLength(), sizeof(TestData::kCtap2GetAssertionAuthData));
+    EXPECT_EQ(memcmp(getAssertionResponse->authenticatorData->data(), TestData::kCtap2GetAssertionAuthData, sizeof(TestData::kCtap2GetAssertionAuthData)), 0);
+    EXPECT_EQ(getAssertionResponse->signature->byteLength(), sizeof(TestData::kCtap2GetAssertionSignature));
+    EXPECT_EQ(memcmp(getAssertionResponse->signature->data(), TestData::kCtap2GetAssertionSignature, sizeof(TestData::kCtap2GetAssertionSignature)), 0);
+}
+
+TEST(CTAPResponseTest, TestReadGetInfoResponse)
+{
+    auto getInfoResponse = readCTAPGetInfoResponse(convertToVector(TestData::kTestGetInfoResponsePlatformDevice, sizeof(TestData::kTestGetInfoResponsePlatformDevice)));
+    ASSERT_TRUE(getInfoResponse);
+    ASSERT_TRUE(getInfoResponse->maxMsgSize());
+    EXPECT_EQ(*getInfoResponse->maxMsgSize(), 1200u);
+    EXPECT_NE(getInfoResponse->versions().find(ProtocolVersion::kCtap), getInfoResponse->versions().end());
+    EXPECT_NE(getInfoResponse->versions().find(ProtocolVersion::kU2f), getInfoResponse->versions().end());
+    EXPECT_TRUE(getInfoResponse->options().isPlatformDevice());
+    EXPECT_TRUE(getInfoResponse->options().supportsResidentKey());
+    EXPECT_TRUE(getInfoResponse->options().userPresenceRequired());
+    EXPECT_EQ(AuthenticatorSupportedOptions::UserVerificationAvailability::kSupportedAndConfigured, getInfoResponse->options().userVerificationAvailability());
+    EXPECT_EQ(AuthenticatorSupportedOptions::ClientPinAvailability::kSupportedButPinNotSet, getInfoResponse->options().clientPinAvailability());
+}
+
+TEST(CTAPResponseTest, TestReadGetInfoResponseWithIncorrectFormat)
+{
+    EXPECT_FALSE(readCTAPGetInfoResponse(convertToVector(kTestAuthenticatorGetInfoResponseWithNoVersion, sizeof(kTestAuthenticatorGetInfoResponseWithNoVersion))));
+    EXPECT_FALSE(readCTAPGetInfoResponse(convertToVector(kTestAuthenticatorGetInfoResponseWithDuplicateVersion, sizeof(kTestAuthenticatorGetInfoResponseWithDuplicateVersion))));
+    EXPECT_FALSE(readCTAPGetInfoResponse(convertToVector(kTestAuthenticatorGetInfoResponseWithIncorrectAaguid, sizeof(kTestAuthenticatorGetInfoResponseWithIncorrectAaguid))));
+}
+
+TEST(CTAPResponseTest, TestSerializeGetInfoResponse)
+{
+    AuthenticatorGetInfoResponse response({ ProtocolVersion::kCtap, ProtocolVersion::kU2f }, convertToVector(kTestDeviceAaguid, sizeof(kTestDeviceAaguid)));
+    response.setExtensions({ "uvm", "hmac-secret" });
+    AuthenticatorSupportedOptions options;
+    options.setSupportsResidentKey(true);
+    options.setIsPlatformDevice(true);
+    options.setClientPinAvailability(AuthenticatorSupportedOptions::ClientPinAvailability::kSupportedButPinNotSet);
+    options.setUserVerificationAvailability(AuthenticatorSupportedOptions::UserVerificationAvailability::kSupportedAndConfigured);
+    response.setOptions(WTFMove(options));
+    response.setMaxMsgSize(1200);
+    response.setPinProtocols({ 1 });
+
+    auto responseAsCBOR = encodeAsCBOR(response);
+    EXPECT_EQ(responseAsCBOR.size(), sizeof(TestData::kTestGetInfoResponsePlatformDevice) - 1);
+    EXPECT_EQ(memcmp(responseAsCBOR.data(), TestData::kTestGetInfoResponsePlatformDevice + 1, responseAsCBOR.size()), 0);
+}
+
+} // namespace TestWebKitAPI
+
+#endif // ENABLE(WEB_AUTHN)
</ins></span></pre>
</div>
</div>

</body>
</html>