Changeset 253398 in webkit


Ignore:
Timestamp:
Dec 11, 2019 3:19:08 PM (4 years ago)
Author:
jiewen_tan@apple.com
Message:

[WebAuthn] Combine AuthenticatorResponse and PublicKeyCredentialData
https://bugs.webkit.org/show_bug.cgi?id=190783
<rdar://problem/57781183>

Reviewed by Brent Fulgham.

Source/WebCore:

This patch combines AuthenticatorResponse and PublicKeyCredentialData, and therefore renames
PublicKeyCredentialData to AuthenticatorResponseData as well. The complexity of WebKit's CTAP
implementation has reached the point that PublicKeyCredentialData is not appropriate to represent
all the different type of responses from authenticators anymore. For example, authenticatorGetNextAssertion
depends on the numberOfCredentials member from authenticatorGetAssertion response to function, but
numberOfCredentials is not used anywhere else. Therefore, a polymorphic type is needed to
represent different responses from authenticators instead of an uniform one, i.e., PublicKeyCredentialData.

AuthenticatorResponse seems to be the best fit. However, there are some limitations:
1) it is a WebIDL interface, and therefore is RefCounted. RefCounted objects cannot be serialized through
IPC. To solve this, AuthenticatorResponseData (PublicKeyCredentialData) is kept as an intermediate type
that is only used during IPC.
2) it doesn't contain all the information from an actual authenticator response. To solve this, it
has been enlarged to include all members from PublicKeyCredential. After this patch, PublicKeyCredential
will be a thin wrapper on top of AuthenticatorResponse.

Covered by existing tests.

  • CMakeLists.txt:
  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • Headers.cmake:
  • Modules/webauthn/AuthenticationExtensionsClientOutputs.h: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredential.idl.
  • Modules/webauthn/AuthenticationExtensionsClientOutputs.idl: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredential.idl.

This is separated from PublicKeyCredential such that AuthenticatorResponse can include it.

  • Modules/webauthn/AuthenticatorAssertionResponse.cpp: Added.

(WebCore::AuthenticatorAssertionResponse::create):
(WebCore::AuthenticatorAssertionResponse::AuthenticatorAssertionResponse):
(WebCore::AuthenticatorAssertionResponse::data const):

  • Modules/webauthn/AuthenticatorAssertionResponse.h:

(WebCore::AuthenticatorAssertionResponse::create): Deleted.
(WebCore::AuthenticatorAssertionResponse::AuthenticatorAssertionResponse): Deleted.

  • Modules/webauthn/AuthenticatorAttestationResponse.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.h.

(WebCore::AuthenticatorAttestationResponse::create):
(WebCore::AuthenticatorAttestationResponse::AuthenticatorAttestationResponse):
(WebCore::AuthenticatorAttestationResponse::data const):

  • Modules/webauthn/AuthenticatorAttestationResponse.h:

(WebCore::AuthenticatorAttestationResponse::create): Deleted.
(WebCore::AuthenticatorAttestationResponse::AuthenticatorAttestationResponse): Deleted.

  • Modules/webauthn/AuthenticatorCoordinator.cpp:

(WebCore::AuthenticatorCoordinator::create const):
(WebCore::AuthenticatorCoordinator::discoverFromExternalSource const):

  • Modules/webauthn/AuthenticatorCoordinatorClient.h:
  • Modules/webauthn/AuthenticatorResponse.cpp: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp.

(WebCore::AuthenticatorResponse::tryCreate):
(WebCore::AuthenticatorResponse::data const):
(WebCore::AuthenticatorResponse::extensions const):
(WebCore::AuthenticatorResponse::setClientDataJSON):
(WebCore::AuthenticatorResponse::clientDataJSON const):
(WebCore::AuthenticatorResponse::AuthenticatorResponse):

  • Modules/webauthn/AuthenticatorResponse.h:

(WebCore::AuthenticatorResponse::rawId const):
(WebCore::AuthenticatorResponse::setExtensions):
(WebCore::AuthenticatorResponse::AuthenticatorResponse): Deleted.
(WebCore::AuthenticatorResponse::clientDataJSON const): Deleted.

  • Modules/webauthn/AuthenticatorResponseData.h: Renamed from Source/WebCore/Modules/webauthn/PublicKeyCredentialData.h.

(WebCore::AuthenticatorResponseData::encode const):
(WebCore::AuthenticatorResponseData::decode):

  • Modules/webauthn/PublicKeyCredential.cpp:

(WebCore::PublicKeyCredential::create):
(WebCore::PublicKeyCredential::rawId const):
(WebCore::PublicKeyCredential::getClientExtensionResults const):
(WebCore::PublicKeyCredential::PublicKeyCredential):
(WebCore::PublicKeyCredential::tryCreate): Deleted.

  • Modules/webauthn/PublicKeyCredential.h:
  • Modules/webauthn/PublicKeyCredential.idl:
  • Modules/webauthn/fido/DeviceResponseConverter.cpp:

(fido::readCTAPMakeCredentialResponse):
(fido::readCTAPGetAssertionResponse):

  • Modules/webauthn/fido/DeviceResponseConverter.h:

A more appropriate derived type of AuthenticatorResponse is used to replace PublicKeyCredentialData.

  • Modules/webauthn/fido/U2fResponseConverter.cpp:

(fido::readU2fRegisterResponse):
(fido::readU2fSignResponse):

  • Modules/webauthn/fido/U2fResponseConverter.h:

A more appropriate derived type of AuthenticatorResponse is used to replace PublicKeyCredentialData.

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:

Source/WebKit:

Code in WebKit are changed to use AuthenticatorResponse and its subtypes.

  • UIProcess/WebAuthentication/Authenticator.h:
  • UIProcess/WebAuthentication/AuthenticatorManager.cpp:

(WebKit::AuthenticatorManager::respondReceived):
(WebKit::AuthenticatorManager::invokePendingCompletionHandler):

  • UIProcess/WebAuthentication/AuthenticatorManager.h:
  • UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:

(WebKit::LocalAuthenticator::continueMakeCredentialAfterAttested):
(WebKit::LocalAuthenticator::continueGetAssertionAfterUserConsented):

  • UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp:

(WebKit::WebAuthenticatorCoordinatorProxy::handleRequest):

  • UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h:
  • UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in:
  • UIProcess/WebAuthentication/fido/CtapAuthenticator.cpp:

(WebKit::CtapAuthenticator::continueMakeCredentialAfterResponseReceived const):
(WebKit::CtapAuthenticator::continueGetAssertionAfterResponseReceived):

  • UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp:

(WebKit::U2fAuthenticator::continueRegisterCommandAfterResponseReceived):
(WebKit::U2fAuthenticator::continueSignCommandAfterResponseReceived):

  • WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp:

Tools:

  • TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp:

(TestWebKitAPI::TEST):
Updates tests accordingly.

Location:
trunk
Files:
1 added
33 edited
4 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r253153 r253398  
    462462    Modules/webauthn/AttestationConveyancePreference.idl
    463463    Modules/webauthn/AuthenticationExtensionsClientInputs.idl
     464    Modules/webauthn/AuthenticationExtensionsClientOutputs.idl
    464465    Modules/webauthn/AuthenticatorAssertionResponse.idl
    465466    Modules/webauthn/AuthenticatorAttestationResponse.idl
  • trunk/Source/WebCore/ChangeLog

    r253397 r253398  
     12019-12-11  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthn] Combine AuthenticatorResponse and PublicKeyCredentialData
     4        https://bugs.webkit.org/show_bug.cgi?id=190783
     5        <rdar://problem/57781183>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        This patch combines AuthenticatorResponse and PublicKeyCredentialData, and therefore renames
     10        PublicKeyCredentialData to AuthenticatorResponseData as well. The complexity of WebKit's CTAP
     11        implementation has reached the point that PublicKeyCredentialData is not appropriate to represent
     12        all the different type of responses from authenticators anymore. For example, authenticatorGetNextAssertion
     13        depends on the numberOfCredentials member from authenticatorGetAssertion response to function, but
     14        numberOfCredentials is not used anywhere else. Therefore, a polymorphic type is needed to
     15        represent different responses from authenticators instead of an uniform one, i.e., PublicKeyCredentialData.
     16
     17        AuthenticatorResponse seems to be the best fit. However, there are some limitations:
     18        1) it is a WebIDL interface, and therefore is RefCounted. RefCounted objects cannot be serialized through
     19        IPC. To solve this, AuthenticatorResponseData (PublicKeyCredentialData) is kept as an intermediate type
     20        that is only used during IPC.
     21        2) it doesn't contain all the information from an actual authenticator response. To solve this, it
     22        has been enlarged to include all members from PublicKeyCredential. After this patch, PublicKeyCredential
     23        will be a thin wrapper on top of AuthenticatorResponse.
     24
     25        Covered by existing tests.
     26
     27        * CMakeLists.txt:
     28        * DerivedSources-input.xcfilelist:
     29        * DerivedSources-output.xcfilelist:
     30        * DerivedSources.make:
     31        * Headers.cmake:
     32        * Modules/webauthn/AuthenticationExtensionsClientOutputs.h: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredential.idl.
     33        * Modules/webauthn/AuthenticationExtensionsClientOutputs.idl: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredential.idl.
     34        This is separated from PublicKeyCredential such that AuthenticatorResponse can include it.
     35        * Modules/webauthn/AuthenticatorAssertionResponse.cpp: Added.
     36        (WebCore::AuthenticatorAssertionResponse::create):
     37        (WebCore::AuthenticatorAssertionResponse::AuthenticatorAssertionResponse):
     38        (WebCore::AuthenticatorAssertionResponse::data const):
     39        * Modules/webauthn/AuthenticatorAssertionResponse.h:
     40        (WebCore::AuthenticatorAssertionResponse::create): Deleted.
     41        (WebCore::AuthenticatorAssertionResponse::AuthenticatorAssertionResponse): Deleted.
     42        * Modules/webauthn/AuthenticatorAttestationResponse.cpp: Copied from Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.h.
     43        (WebCore::AuthenticatorAttestationResponse::create):
     44        (WebCore::AuthenticatorAttestationResponse::AuthenticatorAttestationResponse):
     45        (WebCore::AuthenticatorAttestationResponse::data const):
     46        * Modules/webauthn/AuthenticatorAttestationResponse.h:
     47        (WebCore::AuthenticatorAttestationResponse::create): Deleted.
     48        (WebCore::AuthenticatorAttestationResponse::AuthenticatorAttestationResponse): Deleted.
     49        * Modules/webauthn/AuthenticatorCoordinator.cpp:
     50        (WebCore::AuthenticatorCoordinator::create const):
     51        (WebCore::AuthenticatorCoordinator::discoverFromExternalSource const):
     52        * Modules/webauthn/AuthenticatorCoordinatorClient.h:
     53        * Modules/webauthn/AuthenticatorResponse.cpp: Copied from Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp.
     54        (WebCore::AuthenticatorResponse::tryCreate):
     55        (WebCore::AuthenticatorResponse::data const):
     56        (WebCore::AuthenticatorResponse::extensions const):
     57        (WebCore::AuthenticatorResponse::setClientDataJSON):
     58        (WebCore::AuthenticatorResponse::clientDataJSON const):
     59        (WebCore::AuthenticatorResponse::AuthenticatorResponse):
     60        * Modules/webauthn/AuthenticatorResponse.h:
     61        (WebCore::AuthenticatorResponse::rawId const):
     62        (WebCore::AuthenticatorResponse::setExtensions):
     63        (WebCore::AuthenticatorResponse::AuthenticatorResponse): Deleted.
     64        (WebCore::AuthenticatorResponse::clientDataJSON const): Deleted.
     65        * Modules/webauthn/AuthenticatorResponseData.h: Renamed from Source/WebCore/Modules/webauthn/PublicKeyCredentialData.h.
     66        (WebCore::AuthenticatorResponseData::encode const):
     67        (WebCore::AuthenticatorResponseData::decode):
     68        * Modules/webauthn/PublicKeyCredential.cpp:
     69        (WebCore::PublicKeyCredential::create):
     70        (WebCore::PublicKeyCredential::rawId const):
     71        (WebCore::PublicKeyCredential::getClientExtensionResults const):
     72        (WebCore::PublicKeyCredential::PublicKeyCredential):
     73        (WebCore::PublicKeyCredential::tryCreate): Deleted.
     74        * Modules/webauthn/PublicKeyCredential.h:
     75        * Modules/webauthn/PublicKeyCredential.idl:
     76        * Modules/webauthn/fido/DeviceResponseConverter.cpp:
     77        (fido::readCTAPMakeCredentialResponse):
     78        (fido::readCTAPGetAssertionResponse):
     79        * Modules/webauthn/fido/DeviceResponseConverter.h:
     80        A more appropriate derived type of AuthenticatorResponse is used to replace PublicKeyCredentialData.
     81        * Modules/webauthn/fido/U2fResponseConverter.cpp:
     82        (fido::readU2fRegisterResponse):
     83        (fido::readU2fSignResponse):
     84        * Modules/webauthn/fido/U2fResponseConverter.h:
     85        A more appropriate derived type of AuthenticatorResponse is used to replace PublicKeyCredentialData.
     86        * Sources.txt:
     87        * WebCore.xcodeproj/project.pbxproj:
     88
    1892019-12-11  Eric Carlson  <eric.carlson@apple.com>
    290
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r253153 r253398  
    315315$(PROJECT_DIR)/Modules/webauthn/AttestationConveyancePreference.idl
    316316$(PROJECT_DIR)/Modules/webauthn/AuthenticationExtensionsClientInputs.idl
     317$(PROJECT_DIR)/Modules/webauthn/AuthenticationExtensionsClientOutputs.idl
    317318$(PROJECT_DIR)/Modules/webauthn/AuthenticatorAssertionResponse.idl
    318319$(PROJECT_DIR)/Modules/webauthn/AuthenticatorAttestationResponse.idl
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r253153 r253398  
    161161$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticationExtensionsClientInputs.cpp
    162162$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticationExtensionsClientInputs.h
     163$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticationExtensionsClientOutputs.cpp
     164$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticationExtensionsClientOutputs.h
    163165$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticatorAssertionResponse.cpp
    164166$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAuthenticatorAssertionResponse.h
  • trunk/Source/WebCore/DerivedSources.make

    r253153 r253398  
    374374    $(WebCore)/Modules/webauthn/AttestationConveyancePreference.idl \
    375375    $(WebCore)/Modules/webauthn/AuthenticationExtensionsClientInputs.idl \
     376    $(WebCore)/Modules/webauthn/AuthenticationExtensionsClientOutputs.idl \
    376377    $(WebCore)/Modules/webauthn/AuthenticatorAssertionResponse.idl \
    377378    $(WebCore)/Modules/webauthn/AuthenticatorAttestationResponse.idl \
  • trunk/Source/WebCore/Headers.cmake

    r253380 r253398  
    113113    Modules/webauthn/AttestationConveyancePreference.h
    114114    Modules/webauthn/AuthenticationExtensionsClientInputs.h
     115    Modules/webauthn/AuthenticationExtensionsClientOutputs.h
    115116    Modules/webauthn/AuthenticatorCoordinator.h
    116117    Modules/webauthn/AuthenticatorCoordinatorClient.h
     118    Modules/webauthn/AuthenticatorResponseData.h
    117119    Modules/webauthn/AuthenticatorTransport.h
    118120    Modules/webauthn/PublicKeyCredentialCreationOptions.h
    119     Modules/webauthn/PublicKeyCredentialData.h
    120121    Modules/webauthn/PublicKeyCredentialDescriptor.h
    121122    Modules/webauthn/PublicKeyCredentialRequestOptions.h
  • trunk/Source/WebCore/Modules/webauthn/AuthenticationExtensionsClientOutputs.h

    r253397 r253398  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 [
    27     Conditional=WEB_AUTHN,
    28     EnabledAtRuntime=WebAuthentication,
    29     Exposed=Window,
    30     SecureContext,
    31 ] interface PublicKeyCredential : BasicCredential {
    32     [SameObject] readonly attribute ArrayBuffer rawId;
    33     [SameObject] readonly attribute AuthenticatorResponse response;
    34     AuthenticationExtensionsClientOutputs getClientExtensionResults();
     26#pragma once
    3527
    36     [CallWith=Document] static Promise<boolean> isUserVerifyingPlatformAuthenticatorAvailable();
     28#if ENABLE(WEB_AUTHN)
     29
     30namespace WebCore {
     31
     32struct AuthenticationExtensionsClientOutputs {
     33    Optional<bool> appid;
    3734};
    3835
    39 [
    40     Conditional=WEB_AUTHN,
    41     JSGenerateToJSObject,
    42 ] dictionary AuthenticationExtensionsClientOutputs {
    43     boolean appid;
    44 };
     36} // namespace WebCore
     37
     38#endif // ENABLE(WEB_AUTHN)
  • trunk/Source/WebCore/Modules/webauthn/AuthenticationExtensionsClientOutputs.idl

    r253397 r253398  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626[
    2727    Conditional=WEB_AUTHN,
    28     EnabledAtRuntime=WebAuthentication,
    29     Exposed=Window,
    30     SecureContext,
    31 ] interface PublicKeyCredential : BasicCredential {
    32     [SameObject] readonly attribute ArrayBuffer rawId;
    33     [SameObject] readonly attribute AuthenticatorResponse response;
    34     AuthenticationExtensionsClientOutputs getClientExtensionResults();
    35 
    36     [CallWith=Document] static Promise<boolean> isUserVerifyingPlatformAuthenticatorAvailable();
    37 };
    38 
    39 [
    40     Conditional=WEB_AUTHN,
    4128    JSGenerateToJSObject,
    4229] dictionary AuthenticationExtensionsClientOutputs {
  • trunk/Source/WebCore/Modules/webauthn/AuthenticatorAssertionResponse.h

    r238238 r253398  
    3434class AuthenticatorAssertionResponse : public AuthenticatorResponse {
    3535public:
    36     static Ref<AuthenticatorAssertionResponse> create(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& authenticatorData, Ref<ArrayBuffer>&& signature, RefPtr<ArrayBuffer>&& userHandle)
    37     {
    38         return adoptRef(*new AuthenticatorAssertionResponse(WTFMove(clientDataJSON), WTFMove(authenticatorData), WTFMove(signature), WTFMove(userHandle)));
    39     }
    40 
     36    static Ref<AuthenticatorAssertionResponse> create(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& authenticatorData, Ref<ArrayBuffer>&& signature, RefPtr<ArrayBuffer>&& userHandle, Optional<AuthenticationExtensionsClientOutputs>&&);
     37    WEBCORE_EXPORT static Ref<AuthenticatorAssertionResponse> create(const Vector<uint8_t>& rawId, const Vector<uint8_t>& authenticatorData, const Vector<uint8_t>& signature,  const Vector<uint8_t>& userHandle);
    4138    virtual ~AuthenticatorAssertionResponse() = default;
    4239
     
    4643
    4744private:
    48     AuthenticatorAssertionResponse(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& authenticatorData, Ref<ArrayBuffer>&& signature, RefPtr<ArrayBuffer>&& userHandle)
    49         : AuthenticatorResponse(WTFMove(clientDataJSON))
    50         , m_authenticatorData(WTFMove(authenticatorData))
    51         , m_signature(WTFMove(signature))
    52         , m_userHandle(WTFMove(userHandle))
    53     {
    54     }
     45    AuthenticatorAssertionResponse(Ref<ArrayBuffer>&&, Ref<ArrayBuffer>&&, Ref<ArrayBuffer>&&, RefPtr<ArrayBuffer>&&);
    5546
    5647    Type type() const final { return Type::Assertion; }
     48    AuthenticatorResponseData data() const final;
    5749
    5850    Ref<ArrayBuffer> m_authenticatorData;
  • trunk/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.cpp

    r253397 r253398  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "AuthenticatorAttestationResponse.h"
    2728
    2829#if ENABLE(WEB_AUTHN)
    2930
    30 #include "AuthenticatorResponse.h"
     31#include "AuthenticatorResponseData.h"
    3132
    3233namespace WebCore {
    3334
    34 class AuthenticatorAttestationResponse : public AuthenticatorResponse {
    35 public:
    36     static Ref<AuthenticatorAttestationResponse> create(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& attestationObject)
    37     {
    38         return adoptRef(*new AuthenticatorAttestationResponse(WTFMove(clientDataJSON), WTFMove(attestationObject)));
    39     }
     35Ref<AuthenticatorAttestationResponse> AuthenticatorAttestationResponse::create(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& attestationObject)
     36{
     37    return adoptRef(*new AuthenticatorAttestationResponse(WTFMove(rawId), WTFMove(attestationObject)));
     38}
    4039
    41     virtual ~AuthenticatorAttestationResponse() = default;
     40Ref<AuthenticatorAttestationResponse> AuthenticatorAttestationResponse::create(const Vector<uint8_t>& rawId, const Vector<uint8_t>& attestationObject)
     41{
     42    return create(ArrayBuffer::create(rawId.data(), rawId.size()), ArrayBuffer::create(attestationObject.data(), attestationObject.size()));
     43}
    4244
    43     ArrayBuffer* attestationObject() const { return m_attestationObject.ptr(); }
     45AuthenticatorAttestationResponse::AuthenticatorAttestationResponse(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& attestationObject)
     46    : AuthenticatorResponse(WTFMove(rawId))
     47    , m_attestationObject(WTFMove(attestationObject))
     48{
     49}
    4450
    45 private:
    46     AuthenticatorAttestationResponse(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& attestationObject)
    47         : AuthenticatorResponse(WTFMove(clientDataJSON))
    48         , m_attestationObject(WTFMove(attestationObject))
    49     {
    50     }
    51 
    52     Type type() const final { return Type::Attestation; }
    53 
    54     Ref<ArrayBuffer> m_attestationObject;
    55 };
     51AuthenticatorResponseData AuthenticatorAttestationResponse::data() const
     52{
     53    auto data = AuthenticatorResponse::data();
     54    data.isAuthenticatorAttestationResponse = true;
     55    data.attestationObject = m_attestationObject.copyRef();
     56    return data;
     57}
    5658
    5759} // namespace WebCore
    5860
    59 SPECIALIZE_TYPE_TRAITS_AUTHENTICATOR_RESPONSE(AuthenticatorAttestationResponse, AuthenticatorResponse::Type::Attestation)
    60 
    6161#endif // ENABLE(WEB_AUTHN)
  • trunk/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.h

    r235888 r253398  
    3434class AuthenticatorAttestationResponse : public AuthenticatorResponse {
    3535public:
    36     static Ref<AuthenticatorAttestationResponse> create(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& attestationObject)
    37     {
    38         return adoptRef(*new AuthenticatorAttestationResponse(WTFMove(clientDataJSON), WTFMove(attestationObject)));
    39     }
     36    static Ref<AuthenticatorAttestationResponse> create(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& attestationObject);
     37    WEBCORE_EXPORT static Ref<AuthenticatorAttestationResponse> create(const Vector<uint8_t>& rawId, const Vector<uint8_t>& attestationObject);
    4038
    4139    virtual ~AuthenticatorAttestationResponse() = default;
     
    4442
    4543private:
    46     AuthenticatorAttestationResponse(Ref<ArrayBuffer>&& clientDataJSON, Ref<ArrayBuffer>&& attestationObject)
    47         : AuthenticatorResponse(WTFMove(clientDataJSON))
    48         , m_attestationObject(WTFMove(attestationObject))
    49     {
    50     }
     44    AuthenticatorAttestationResponse(Ref<ArrayBuffer>&&, Ref<ArrayBuffer>&&);
    5145
    5246    Type type() const final { return Type::Attestation; }
     47    AuthenticatorResponseData data() const final;
    5348
    5449    Ref<ArrayBuffer> m_attestationObject;
  • trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinator.cpp

    r251762 r253398  
    3333#include "AuthenticatorAttestationResponse.h"
    3434#include "AuthenticatorCoordinatorClient.h"
     35#include "AuthenticatorResponseData.h"
    3536#include "Document.h"
    3637#include "JSBasicCredential.h"
     
    3839#include "PublicKeyCredential.h"
    3940#include "PublicKeyCredentialCreationOptions.h"
    40 #include "PublicKeyCredentialData.h"
    4141#include "PublicKeyCredentialRequestOptions.h"
    4242#include "RegistrableDomain.h"
     
    186186    }
    187187
    188     auto callback = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), abortSignal = WTFMove(abortSignal)] (PublicKeyCredentialData&& data, ExceptionData&& exception) mutable {
     188    auto callback = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), abortSignal = WTFMove(abortSignal)] (AuthenticatorResponseData&& data, ExceptionData&& exception) mutable {
    189189        if (abortSignal && abortSignal->aborted()) {
    190190            promise.reject(Exception { AbortError, "Aborted by AbortSignal."_s });
     
    192192        }
    193193
    194         data.clientDataJSON = WTFMove(clientDataJson);
    195         if (auto publicKeyCredential = PublicKeyCredential::tryCreate(WTFMove(data))) {
    196             promise.resolve(publicKeyCredential.get());
     194        if (auto response = AuthenticatorResponse::tryCreate(WTFMove(data))) {
     195            response->setClientDataJSON(WTFMove(clientDataJson));
     196            promise.resolve(PublicKeyCredential::create(response.releaseNonNull()).ptr());
    197197            return;
    198198        }
     
    257257    }
    258258
    259     auto callback = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), abortSignal = WTFMove(abortSignal)] (PublicKeyCredentialData&& data, ExceptionData&& exception) mutable {
     259    auto callback = [clientDataJson = WTFMove(clientDataJson), promise = WTFMove(promise), abortSignal = WTFMove(abortSignal)] (AuthenticatorResponseData&& data, ExceptionData&& exception) mutable {
    260260        if (abortSignal && abortSignal->aborted()) {
    261261            promise.reject(Exception { AbortError, "Aborted by AbortSignal."_s });
     
    263263        }
    264264
    265         data.clientDataJSON = WTFMove(clientDataJson);
    266         if (auto publicKeyCredential = PublicKeyCredential::tryCreate(WTFMove(data))) {
    267             promise.resolve(publicKeyCredential.get());
     265        if (auto response = AuthenticatorResponse::tryCreate(WTFMove(data))) {
     266            response->setClientDataJSON(WTFMove(clientDataJson));
     267            promise.resolve(PublicKeyCredential::create(response.releaseNonNull()).ptr());
    268268            return;
    269269        }
  • trunk/Source/WebCore/Modules/webauthn/AuthenticatorCoordinatorClient.h

    r251489 r253398  
    3939class SecurityOrigin;
    4040
     41struct AuthenticatorResponseData;
    4142struct PublicKeyCredentialCreationOptions;
    42 struct PublicKeyCredentialData;
    4343struct PublicKeyCredentialRequestOptions;
    4444
    45 using RequestCompletionHandler = CompletionHandler<void(WebCore::PublicKeyCredentialData&&, WebCore::ExceptionData&&)>;
     45using RequestCompletionHandler = CompletionHandler<void(WebCore::AuthenticatorResponseData&&, WebCore::ExceptionData&&)>;
    4646using QueryCompletionHandler = CompletionHandler<void(bool)>;
    4747
  • trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponse.cpp

    r253397 r253398  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#include "config.h"
    27 #include "PublicKeyCredential.h"
     27#include "AuthenticatorResponse.h"
    2828
    2929#if ENABLE(WEB_AUTHN)
     
    3131#include "AuthenticatorAssertionResponse.h"
    3232#include "AuthenticatorAttestationResponse.h"
    33 #include "AuthenticatorCoordinator.h"
    34 #include "AuthenticatorResponse.h"
    35 #include "Document.h"
    36 #include "JSDOMPromiseDeferred.h"
    37 #include "Page.h"
    38 #include "PublicKeyCredentialData.h"
    39 #include "RuntimeEnabledFeatures.h"
    40 #include <wtf/text/Base64.h>
     33#include "AuthenticatorResponseData.h"
    4134
    4235namespace WebCore {
    4336
    44 RefPtr<PublicKeyCredential> PublicKeyCredential::tryCreate(PublicKeyCredentialData&& data)
     37RefPtr<AuthenticatorResponse> AuthenticatorResponse::tryCreate(AuthenticatorResponseData&& data)
    4538{
    46     if (!data.rawId || !data.clientDataJSON)
     39    if (!data.rawId)
    4740        return nullptr;
    4841
     
    5144            return nullptr;
    5245
    53         return adoptRef(*new PublicKeyCredential(data.rawId.releaseNonNull(), AuthenticatorAttestationResponse::create(data.clientDataJSON.releaseNonNull(), data.attestationObject.releaseNonNull()), { data.appid }));
     46        return AuthenticatorAttestationResponse::create(data.rawId.releaseNonNull(), data.attestationObject.releaseNonNull());
    5447    }
    5548
     
    5750        return nullptr;
    5851
    59     return adoptRef(*new PublicKeyCredential(data.rawId.releaseNonNull(), AuthenticatorAssertionResponse::create(data.clientDataJSON.releaseNonNull(), data.authenticatorData.releaseNonNull(), data.signature.releaseNonNull(), WTFMove(data.userHandle)), { data.appid }));
     52    return AuthenticatorAssertionResponse::create(data.rawId.releaseNonNull(), data.authenticatorData.releaseNonNull(), data.signature.releaseNonNull(), WTFMove(data.userHandle), AuthenticationExtensionsClientOutputs { data.appid });
    6053}
    6154
    62 PublicKeyCredential::PublicKeyCredential(Ref<ArrayBuffer>&& id, Ref<AuthenticatorResponse>&& response, AuthenticationExtensionsClientOutputs&& extensions)
    63     : BasicCredential(WTF::base64URLEncode(id->data(), id->byteLength()), Type::PublicKey, Discovery::Remote)
    64     , m_rawId(WTFMove(id))
    65     , m_response(WTFMove(response))
    66     , m_extensions(WTFMove(extensions))
     55AuthenticatorResponseData AuthenticatorResponse::data() const
    6756{
     57    AuthenticatorResponseData data;
     58    data.rawId = m_rawId.copyRef();
     59    data.appid = m_extensions.appid;
     60    return data;
    6861}
    6962
    70 PublicKeyCredential::AuthenticationExtensionsClientOutputs PublicKeyCredential::getClientExtensionResults() const
     63ArrayBuffer* AuthenticatorResponse::rawId() const
     64{
     65    return m_rawId.ptr();
     66}
     67
     68void AuthenticatorResponse::setExtensions(AuthenticationExtensionsClientOutputs&& extensions)
     69{
     70    m_extensions = WTFMove(extensions);
     71}
     72
     73AuthenticationExtensionsClientOutputs AuthenticatorResponse::extensions() const
    7174{
    7275    return m_extensions;
    7376}
    7477
    75 void PublicKeyCredential::isUserVerifyingPlatformAuthenticatorAvailable(Document& document, DOMPromiseDeferred<IDLBoolean>&& promise)
     78void AuthenticatorResponse::setClientDataJSON(Ref<ArrayBuffer>&& clientDataJSON)
    7679{
    77     if (!RuntimeEnabledFeatures::sharedFeatures().webAuthenticationLocalAuthenticatorEnabled()) {
    78         promise.resolve(false);
    79         return;
    80     }
    81     document.page()->authenticatorCoordinator().isUserVerifyingPlatformAuthenticatorAvailable(WTFMove(promise));
     80    m_clientDataJSON = WTFMove(clientDataJSON);
     81}
     82
     83ArrayBuffer* AuthenticatorResponse::clientDataJSON() const
     84{
     85    return m_clientDataJSON.get();
     86}
     87
     88AuthenticatorResponse::AuthenticatorResponse(Ref<ArrayBuffer>&& rawId)
     89    : m_rawId(WTFMove(rawId))
     90{
    8291}
    8392
  • trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponse.h

    r235888 r253398  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828#if ENABLE(WEB_AUTHN)
    2929
    30 #include <JavaScriptCore/ArrayBuffer.h>
     30#include "AuthenticationExtensionsClientOutputs.h"
     31#include "IDLTypes.h"
    3132#include <wtf/RefCounted.h>
    3233#include <wtf/TypeCasts.h>
    3334
    3435namespace WebCore {
     36
     37struct AuthenticatorResponseData;
    3538
    3639class AuthenticatorResponse : public RefCounted<AuthenticatorResponse> {
     
    4144    };
    4245
    43     explicit AuthenticatorResponse(Ref<ArrayBuffer>&& clientDataJSON)
    44         : m_clientDataJSON(WTFMove(clientDataJSON))
    45     {
    46     }
     46    static RefPtr<AuthenticatorResponse> tryCreate(AuthenticatorResponseData&&);
    4747    virtual ~AuthenticatorResponse() = default;
    4848
    4949    virtual Type type() const = 0;
     50    virtual AuthenticatorResponseData data() const;
    5051
    51     ArrayBuffer* clientDataJSON() const { return m_clientDataJSON.ptr(); }
     52    WEBCORE_EXPORT ArrayBuffer* rawId() const;
     53    WEBCORE_EXPORT void setExtensions(AuthenticationExtensionsClientOutputs&&);
     54    AuthenticationExtensionsClientOutputs extensions() const;
     55    void setClientDataJSON(Ref<ArrayBuffer>&&);
     56    ArrayBuffer* clientDataJSON() const;
     57
     58protected:
     59    AuthenticatorResponse(Ref<ArrayBuffer>&&);
    5260
    5361private:
    54     Ref<ArrayBuffer> m_clientDataJSON;
     62    Ref<ArrayBuffer> m_rawId;
     63    AuthenticationExtensionsClientOutputs m_extensions;
     64    RefPtr<ArrayBuffer> m_clientDataJSON;
    5565};
    5666
  • trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponseData.h

    r253397 r253398  
    3535class AuthenticatorResponse;
    3636
    37 struct PublicKeyCredentialData {
     37struct AuthenticatorResponseData {
     38    bool isAuthenticatorAttestationResponse;
     39
     40    // AuthenticatorResponse
    3841    RefPtr<ArrayBuffer> rawId;
    3942
    40     // AuthenticatorResponse
    41     bool isAuthenticatorAttestationResponse;
    42     RefPtr<ArrayBuffer> clientDataJSON;
     43    // Extensions
     44    Optional<bool> appid;
    4345
    4446    // AuthenticatorAttestationResponse
     
    5052    RefPtr<ArrayBuffer> userHandle;
    5153
    52     // Extensions
    53     Optional<bool> appid;
    54 
    5554    template<class Encoder> void encode(Encoder&) const;
    56     template<class Decoder> static Optional<PublicKeyCredentialData> decode(Decoder&);
     55    template<class Decoder> static Optional<AuthenticatorResponseData> decode(Decoder&);
    5756};
    5857
    59 // Noted: clientDataJSON is never encoded or decoded as it is never sent across different processes.
    6058template<class Encoder>
    61 void PublicKeyCredentialData::encode(Encoder& encoder) const
     59void AuthenticatorResponseData::encode(Encoder& encoder) const
    6260{
    6361    if (!rawId) {
     
    9896
    9997template<class Decoder>
    100 Optional<PublicKeyCredentialData> PublicKeyCredentialData::decode(Decoder& decoder)
     98Optional<AuthenticatorResponseData> AuthenticatorResponseData::decode(Decoder& decoder)
    10199{
    102     PublicKeyCredentialData result;
     100    AuthenticatorResponseData result;
    103101
    104102    Optional<bool> isEmpty;
  • trunk/Source/WebCore/Modules/webauthn/PublicKeyCredential.cpp

    r251295 r253398  
    2929#if ENABLE(WEB_AUTHN)
    3030
    31 #include "AuthenticatorAssertionResponse.h"
    32 #include "AuthenticatorAttestationResponse.h"
    3331#include "AuthenticatorCoordinator.h"
    3432#include "AuthenticatorResponse.h"
     
    3634#include "JSDOMPromiseDeferred.h"
    3735#include "Page.h"
    38 #include "PublicKeyCredentialData.h"
    3936#include "RuntimeEnabledFeatures.h"
    4037#include <wtf/text/Base64.h>
     
    4239namespace WebCore {
    4340
    44 RefPtr<PublicKeyCredential> PublicKeyCredential::tryCreate(PublicKeyCredentialData&& data)
     41Ref<PublicKeyCredential> PublicKeyCredential::create(Ref<AuthenticatorResponse>&& response)
    4542{
    46     if (!data.rawId || !data.clientDataJSON)
    47         return nullptr;
    48 
    49     if (data.isAuthenticatorAttestationResponse) {
    50         if (!data.attestationObject)
    51             return nullptr;
    52 
    53         return adoptRef(*new PublicKeyCredential(data.rawId.releaseNonNull(), AuthenticatorAttestationResponse::create(data.clientDataJSON.releaseNonNull(), data.attestationObject.releaseNonNull()), { data.appid }));
    54     }
    55 
    56     if (!data.authenticatorData || !data.signature)
    57         return nullptr;
    58 
    59     return adoptRef(*new PublicKeyCredential(data.rawId.releaseNonNull(), AuthenticatorAssertionResponse::create(data.clientDataJSON.releaseNonNull(), data.authenticatorData.releaseNonNull(), data.signature.releaseNonNull(), WTFMove(data.userHandle)), { data.appid }));
     43    return adoptRef(*new PublicKeyCredential(WTFMove(response)));
    6044}
    6145
    62 PublicKeyCredential::PublicKeyCredential(Ref<ArrayBuffer>&& id, Ref<AuthenticatorResponse>&& response, AuthenticationExtensionsClientOutputs&& extensions)
    63     : BasicCredential(WTF::base64URLEncode(id->data(), id->byteLength()), Type::PublicKey, Discovery::Remote)
    64     , m_rawId(WTFMove(id))
    65     , m_response(WTFMove(response))
    66     , m_extensions(WTFMove(extensions))
     46ArrayBuffer* PublicKeyCredential::rawId() const
    6747{
     48    return m_response->rawId();
    6849}
    6950
    70 PublicKeyCredential::AuthenticationExtensionsClientOutputs PublicKeyCredential::getClientExtensionResults() const
     51AuthenticationExtensionsClientOutputs PublicKeyCredential::getClientExtensionResults() const
    7152{
    72     return m_extensions;
     53    return m_response->extensions();
     54}
     55
     56PublicKeyCredential::PublicKeyCredential(Ref<AuthenticatorResponse>&& response)
     57    : BasicCredential(WTF::base64URLEncode(response->rawId()->data(), response->rawId()->byteLength()), Type::PublicKey, Discovery::Remote)
     58    , m_response(WTFMove(response))
     59{
    7360}
    7461
  • trunk/Source/WebCore/Modules/webauthn/PublicKeyCredential.h

    r251295 r253398  
    2929
    3030#include "BasicCredential.h"
    31 #include "ExceptionOr.h"
    3231#include "IDLTypes.h"
    33 #include <JavaScriptCore/ArrayBuffer.h>
    3432#include <wtf/Forward.h>
    3533
     
    3937class Document;
    4038
    41 struct PublicKeyCredentialData;
     39struct AuthenticationExtensionsClientOutputs;
    4240
    4341template<typename IDLType> class DOMPromiseDeferred;
     
    4543class PublicKeyCredential final : public BasicCredential {
    4644public:
    47     struct AuthenticationExtensionsClientOutputs {
    48         Optional<bool> appid;
    49     };
     45    static Ref<PublicKeyCredential> create(Ref<AuthenticatorResponse>&&);
    5046
    51     static RefPtr<PublicKeyCredential> tryCreate(PublicKeyCredentialData&&);
    52 
    53     ArrayBuffer* rawId() const { return m_rawId.ptr(); }
     47    ArrayBuffer* rawId() const;
    5448    AuthenticatorResponse* response() const { return m_response.ptr(); }
    5549    AuthenticationExtensionsClientOutputs getClientExtensionResults() const;
     
    5852
    5953private:
    60     PublicKeyCredential(Ref<ArrayBuffer>&& id, Ref<AuthenticatorResponse>&&, AuthenticationExtensionsClientOutputs&&);
     54    PublicKeyCredential(Ref<AuthenticatorResponse>&&);
    6155
    6256    Type credentialType() const final { return Type::PublicKey; }
    6357
    64     Ref<ArrayBuffer> m_rawId;
    6558    Ref<AuthenticatorResponse> m_response;
    66     AuthenticationExtensionsClientOutputs m_extensions;
    6759};
    6860
  • trunk/Source/WebCore/Modules/webauthn/PublicKeyCredential.idl

    r243193 r253398  
    3636    [CallWith=Document] static Promise<boolean> isUserVerifyingPlatformAuthenticatorAvailable();
    3737};
    38 
    39 [
    40     Conditional=WEB_AUTHN,
    41     JSGenerateToJSObject,
    42 ] dictionary AuthenticationExtensionsClientOutputs {
    43     boolean appid;
    44 };
  • trunk/Source/WebCore/Modules/webauthn/fido/DeviceResponseConverter.cpp

    r249927 r253398  
    8686// Decodes byte array response from authenticator to CBOR value object and
    8787// checks for correct encoding format.
    88 Optional<PublicKeyCredentialData> readCTAPMakeCredentialResponse(const Vector<uint8_t>& inBuffer, const WebCore::AttestationConveyancePreference& attestation)
     88RefPtr<AuthenticatorAttestationResponse> readCTAPMakeCredentialResponse(const Vector<uint8_t>& inBuffer, const AttestationConveyancePreference& attestation)
    8989{
    9090    if (inBuffer.size() <= kResponseCodeLength)
    91         return WTF::nullopt;
     91        return nullptr;
    9292
    9393    Vector<uint8_t> buffer;
     
    9595    Optional<CBOR> decodedResponse = cbor::CBORReader::read(buffer);
    9696    if (!decodedResponse || !decodedResponse->isMap())
    97         return WTF::nullopt;
     97        return nullptr;
    9898    const auto& decodedMap = decodedResponse->getMap();
    9999
    100100    auto it = decodedMap.find(CBOR(1));
    101101    if (it == decodedMap.end() || !it->second.isString())
    102         return WTF::nullopt;
     102        return nullptr;
    103103    auto format = it->second.clone();
    104104
    105105    it = decodedMap.find(CBOR(2));
    106106    if (it == decodedMap.end() || !it->second.isByteString())
    107         return WTF::nullopt;
     107        return nullptr;
    108108    auto authenticatorData = it->second.clone();
    109109
    110110    auto credentialId = getCredentialId(authenticatorData.getByteString());
    111111    if (credentialId.isEmpty())
    112         return WTF::nullopt;
     112        return nullptr;
    113113
    114114    it = decodedMap.find(CBOR(3));
    115115    if (it == decodedMap.end() || !it->second.isMap())
    116         return WTF::nullopt;
     116        return nullptr;
    117117    auto attStmt = it->second.clone();
    118118
     
    131131    }
    132132
    133     return PublicKeyCredentialData { ArrayBuffer::create(credentialId.data(), credentialId.size()), true, nullptr, ArrayBuffer::create(attestationObject.value().data(), attestationObject.value().size()), nullptr, nullptr, nullptr, WTF::nullopt };
    134 }
    135 
    136 Optional<PublicKeyCredentialData> readCTAPGetAssertionResponse(const Vector<uint8_t>& inBuffer)
     133    return AuthenticatorAttestationResponse::create(credentialId, *attestationObject);
     134}
     135
     136RefPtr<AuthenticatorAssertionResponse> readCTAPGetAssertionResponse(const Vector<uint8_t>& inBuffer)
    137137{
    138138    if (inBuffer.size() <= kResponseCodeLength)
    139         return WTF::nullopt;
     139        return nullptr;
    140140
    141141    Vector<uint8_t> buffer;
     
    144144
    145145    if (!decodedResponse || !decodedResponse->isMap())
    146         return WTF::nullopt;
     146        return nullptr;
    147147
    148148    auto& responseMap = decodedResponse->getMap();
    149149
    150     RefPtr<ArrayBuffer> credentialId;
    151150    auto it = responseMap.find(CBOR(1));
    152     if (it != responseMap.end() && it->second.isMap()) {
    153         auto& credential = it->second.getMap();
    154         auto itr = credential.find(CBOR(kCredentialIdKey));
    155         if (itr == credential.end() || !itr->second.isByteString())
    156             return WTF::nullopt;
    157         auto& id = itr->second.getByteString();
    158         credentialId = ArrayBuffer::create(id.data(), id.size());
    159     }
     151    if (it == responseMap.end() || !it->second.isMap())
     152        return nullptr;
     153    auto& credential = it->second.getMap();
     154    auto itr = credential.find(CBOR(kCredentialIdKey));
     155    if (itr == credential.end() || !itr->second.isByteString())
     156        return nullptr;
     157    auto& credentialId = itr->second.getByteString();
    160158
    161159    it = responseMap.find(CBOR(2));
    162160    if (it == responseMap.end() || !it->second.isByteString())
    163         return WTF::nullopt;
     161        return nullptr;
    164162    auto& authData = it->second.getByteString();
    165163
    166164    it = responseMap.find(CBOR(3));
    167165    if (it == responseMap.end() || !it->second.isByteString())
    168         return WTF::nullopt;
     166        return nullptr;
    169167    auto& signature = it->second.getByteString();
    170168
    171     RefPtr<ArrayBuffer> userHandle;
    172169    it = responseMap.find(CBOR(4));
    173170    if (it != responseMap.end() && it->second.isMap()) {
     
    175172        auto itr = user.find(CBOR(kEntityIdMapKey));
    176173        if (itr == user.end() || !itr->second.isByteString())
    177             return WTF::nullopt;
    178         auto& id = itr->second.getByteString();
    179         userHandle = ArrayBuffer::create(id.data(), id.size());
    180     }
    181 
    182     return PublicKeyCredentialData { WTFMove(credentialId), false, nullptr, nullptr, ArrayBuffer::create(authData.data(), authData.size()), ArrayBuffer::create(signature.data(), signature.size()), WTFMove(userHandle), WTF::nullopt };
     174            return nullptr;
     175        auto& userHandle = itr->second.getByteString();
     176        return AuthenticatorAssertionResponse::create(credentialId, authData, signature, userHandle);
     177    }
     178
     179    return AuthenticatorAssertionResponse::create(credentialId, authData, signature, { });
    183180}
    184181
  • trunk/Source/WebCore/Modules/webauthn/fido/DeviceResponseConverter.h

    r245638 r253398  
    3333
    3434#include "AttestationConveyancePreference.h"
     35#include "AuthenticatorAssertionResponse.h"
     36#include "AuthenticatorAttestationResponse.h"
    3537#include "AuthenticatorGetInfoResponse.h"
    3638#include "FidoConstants.h"
    37 #include "PublicKeyCredentialData.h"
    3839
    3940// Converts response from authenticators to CTAPResponse objects. If the
     
    5051// CBOR map keys that conform to format of attestation object defined by the
    5152// WebAuthN spec : https://w3c.github.io/webauthn/#fig-attStructs
    52 WEBCORE_EXPORT Optional<WebCore::PublicKeyCredentialData> readCTAPMakeCredentialResponse(const Vector<uint8_t>&, const WebCore::AttestationConveyancePreference& attestation = WebCore::AttestationConveyancePreference::Direct);
     53WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAttestationResponse> readCTAPMakeCredentialResponse(const Vector<uint8_t>&, const WebCore::AttestationConveyancePreference& attestation = WebCore::AttestationConveyancePreference::Direct);
    5354
    5455// De-serializes CBOR encoded response to AuthenticatorGetAssertion /
    5556// AuthenticatorGetNextAssertion request to AuthenticatorGetAssertionResponse
    5657// object.
    57 // FIXME(190783): Probably need to remake AuthenticatorResponse to include more fields like numberOfCredentials,
    58 // and use it here instead of PublicKeyCredentialData.
    59 WEBCORE_EXPORT Optional<WebCore::PublicKeyCredentialData> readCTAPGetAssertionResponse(const Vector<uint8_t>&);
     58WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAssertionResponse> readCTAPGetAssertionResponse(const Vector<uint8_t>&);
    6059
    6160// De-serializes CBOR encoded response to AuthenticatorGetInfo request to
  • trunk/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.cpp

    r251089 r253398  
    148148} // namespace
    149149
    150 Optional<PublicKeyCredentialData> readU2fRegisterResponse(const String& rpId, const Vector<uint8_t>& u2fData, const AttestationConveyancePreference& attestation)
     150RefPtr<AuthenticatorAttestationResponse> readU2fRegisterResponse(const String& rpId, const Vector<uint8_t>& u2fData, const AttestationConveyancePreference& attestation)
    151151{
    152152    auto publicKey = extractECPublicKeyFromU2fRegistrationResponse(u2fData);
    153153    if (publicKey.isEmpty())
    154         return WTF::nullopt;
     154        return nullptr;
    155155
    156156    auto attestedCredentialData = createAttestedCredentialDataFromU2fRegisterResponse(u2fData, publicKey);
    157157    if (attestedCredentialData.isEmpty())
    158         return WTF::nullopt;
     158        return nullptr;
    159159
    160160    // Extract the credentialId for packing into the response data.
     
    167167    auto fidoAttestationStatement = createFidoAttestationStatementFromU2fRegisterResponse(u2fData, kU2fKeyHandleOffset + credentialId.size());
    168168    if (fidoAttestationStatement.empty())
    169         return WTF::nullopt;
     169        return nullptr;
    170170
    171171    auto attestationObject = buildAttestationObject(WTFMove(authData), "fido-u2f", WTFMove(fidoAttestationStatement), attestation);
    172172
    173     return PublicKeyCredentialData { ArrayBuffer::create(credentialId.data(), credentialId.size()), true, nullptr, ArrayBuffer::create(attestationObject.data(), attestationObject.size()), nullptr, nullptr, nullptr, WTF::nullopt };
     173    return AuthenticatorAttestationResponse::create(credentialId, attestationObject);
    174174}
    175175
    176 Optional<PublicKeyCredentialData> readU2fSignResponse(const String& rpId, const Vector<uint8_t>& keyHandle, const Vector<uint8_t>& u2fData)
     176RefPtr<AuthenticatorAssertionResponse> readU2fSignResponse(const String& rpId, const Vector<uint8_t>& keyHandle, const Vector<uint8_t>& u2fData)
    177177{
    178178    if (keyHandle.isEmpty() || u2fData.size() <= signatureIndex)
    179         return WTF::nullopt;
     179        return nullptr;
    180180
    181181    // 1 byte flags, 4 bytes counter
     
    187187    auto authData = buildAuthData(rpId, flags, counter, { });
    188188
    189     return PublicKeyCredentialData { ArrayBuffer::create(keyHandle.data(), keyHandle.size()), false, nullptr, nullptr, ArrayBuffer::create(authData.data(), authData.size()), ArrayBuffer::create(u2fData.data() + signatureIndex, u2fData.size() - signatureIndex), nullptr, WTF::nullopt };
     189    // FIXME: Find a way to remove the need of constructing a vector here.
     190    Vector<uint8_t> signature;
     191    signature.append(u2fData.data() + signatureIndex, u2fData.size() - signatureIndex);
     192
     193    return AuthenticatorAssertionResponse::create(keyHandle, authData, signature, { });
    190194}
    191195
  • trunk/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.h

    r245638 r253398  
    3333
    3434#include "AttestationConveyancePreference.h"
    35 #include "PublicKeyCredentialData.h"
     35#include "AuthenticatorAssertionResponse.h"
     36#include "AuthenticatorAttestationResponse.h"
    3637#include <wtf/Forward.h>
    3738
     
    4041// Converts a U2F register response to WebAuthN makeCredential response.
    4142// https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-client-to-authenticator-protocol-v2.0-id-20180227.html#u2f-authenticatorMakeCredential-interoperability
    42 WEBCORE_EXPORT Optional<WebCore::PublicKeyCredentialData> readU2fRegisterResponse(const String& rpId, const Vector<uint8_t>& u2fData, const WebCore::AttestationConveyancePreference& attestation = WebCore::AttestationConveyancePreference::Direct);
     43WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAttestationResponse> readU2fRegisterResponse(const String& rpId, const Vector<uint8_t>& u2fData, const WebCore::AttestationConveyancePreference& attestation = WebCore::AttestationConveyancePreference::Direct);
    4344
    4445// Converts a U2F authentication response to WebAuthN getAssertion response.
    4546// https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-client-to-authenticator-protocol-v2.0-id-20180227.html#u2f-authenticatorGetAssertion-interoperability
    46 WEBCORE_EXPORT Optional<WebCore::PublicKeyCredentialData> readU2fSignResponse(const String& rpId, const Vector<uint8_t>& keyHandle, const Vector<uint8_t>& u2fData);
     47WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAssertionResponse> readU2fSignResponse(const String& rpId, const Vector<uint8_t>& keyHandle, const Vector<uint8_t>& u2fData);
    4748
    4849} // namespace fido
  • trunk/Source/WebCore/Sources.txt

    r253254 r253398  
    269269
    270270Modules/webauthn/AuthenticatorCoordinator.cpp
     271Modules/webauthn/AuthenticatorAssertionResponse.cpp
     272Modules/webauthn/AuthenticatorAttestationResponse.cpp
     273Modules/webauthn/AuthenticatorResponse.cpp
    271274Modules/webauthn/PublicKeyCredential.cpp
    272275Modules/webauthn/WebAuthenticationUtils.cpp
     
    26542657JSAttestationConveyancePreference.cpp
    26552658JSAuthenticationExtensionsClientInputs.cpp
     2659JSAuthenticationExtensionsClientOutputs.cpp
    26562660JSAuthenticatorAssertionResponse.cpp
    26572661JSAuthenticatorAttestationResponse.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r253351 r253398  
    17741774                57303BBB2006C6EE00355965 /* CBORBinary.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BB62006C6ED00355965 /* CBORBinary.h */; };
    17751775                57303BC12006E00C00355965 /* CBORReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BBF2006E00C00355965 /* CBORReader.h */; settings = {ATTRIBUTES = (Private, ); }; };
    1776                 57303BD220087A8300355965 /* AuthenticatorResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BCF20087A8300355965 /* AuthenticatorResponse.h */; };
     1776                57303BD220087A8300355965 /* AuthenticatorResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BCF20087A8300355965 /* AuthenticatorResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17771777                57303BE120095D6100355965 /* JSAuthenticatorResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BDD20095B2600355965 /* JSAuthenticatorResponse.h */; };
    17781778                57303BE92009748D00355965 /* PublicKeyCredentialCreationOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303BE62009747A00355965 /* PublicKeyCredentialCreationOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    17841784                57303C1120099CB100355965 /* JSPublicKeyCredentialRequestOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C0C20099C7500355965 /* JSPublicKeyCredentialRequestOptions.h */; };
    17851785                57303C192009A2F300355965 /* JSPublicKeyCredentialCreationOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C132009A25700355965 /* JSPublicKeyCredentialCreationOptions.h */; };
    1786                 57303C1F2009AB4200355965 /* AuthenticatorAttestationResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */; };
     1786                57303C1F2009AB4200355965 /* AuthenticatorAttestationResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17871787                57303C222009AF0300355965 /* JSAuthenticatorAttestationResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C212009AEF600355965 /* JSAuthenticatorAttestationResponse.h */; };
    1788                 57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */; };
     1788                57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17891789                57303C2F2009B7E100355965 /* JSAuthenticatorAssertionResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */; };
    17901790                57303C4620105D2F00355965 /* AuthenticatorCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 57303C4320105B3D00355965 /* AuthenticatorCoordinator.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    17991799                5750A9871E6A216800705C4A /* CryptoAlgorithmECDH.h in Headers */ = {isa = PBXBuildFile; fileRef = 5750A9851E6A216800705C4A /* CryptoAlgorithmECDH.h */; };
    18001800                5754719F1ECE628300DD63B2 /* JSRsaPssParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 575471991ECE5D2A00DD63B2 /* JSRsaPssParams.h */; };
     1801                57585961239F124D00C74572 /* JSAuthenticationExtensionsClientOutputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 5758595E239F117300C74572 /* JSAuthenticationExtensionsClientOutputs.h */; };
     1802                5758596C239F321C00C74572 /* AuthenticationExtensionsClientOutputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 57585965239F14CC00C74572 /* AuthenticationExtensionsClientOutputs.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18011803                5760827220215A5500116678 /* AuthenticatorCoordinatorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18021804                5768142A1E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */; };
     
    18261828                57D846351FEAFCD300CA3682 /* JSPublicKeyCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D846301FEAFC2F00CA3682 /* JSPublicKeyCredential.h */; };
    18271829                57DA47B0224034E4002A4612 /* AuthenticationExtensionsClientInputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DA47A522401E0F002A4612 /* AuthenticationExtensionsClientInputs.h */; settings = {ATTRIBUTES = (Private, ); }; };
    1828                 57DCED74214305F00016B847 /* PublicKeyCredentialData.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED72214305F00016B847 /* PublicKeyCredentialData.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1830                57DCED74214305F00016B847 /* AuthenticatorResponseData.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED72214305F00016B847 /* AuthenticatorResponseData.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18291831                57DCED9021487FF70016B847 /* AuthenticatorTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED8C21487EDB0016B847 /* AuthenticatorTransport.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18301832                57DCED98214882160016B847 /* JSAuthenticatorTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED92214880C60016B847 /* JSAuthenticatorTransport.h */; };
     
    87838785                575471991ECE5D2A00DD63B2 /* JSRsaPssParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRsaPssParams.h; sourceTree = "<group>"; };
    87848786                5754719A1ECE5D2A00DD63B2 /* JSRsaPssParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRsaPssParams.cpp; sourceTree = "<group>"; };
     8787                5758595C239F113000C74572 /* JSAuthenticationExtensionsClientOutputs.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticationExtensionsClientOutputs.cpp; sourceTree = "<group>"; };
     8788                5758595E239F117300C74572 /* JSAuthenticationExtensionsClientOutputs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSAuthenticationExtensionsClientOutputs.h; sourceTree = "<group>"; };
     8789                57585965239F14CC00C74572 /* AuthenticationExtensionsClientOutputs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticationExtensionsClientOutputs.h; sourceTree = "<group>"; };
     8790                57585967239F14CD00C74572 /* AuthenticationExtensionsClientOutputs.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AuthenticationExtensionsClientOutputs.idl; sourceTree = "<group>"; };
     8791                57585969239F1EC700C74572 /* AuthenticatorResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorResponse.cpp; sourceTree = "<group>"; };
     8792                5758596B239F284B00C74572 /* AuthenticatorAttestationResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorAttestationResponse.cpp; sourceTree = "<group>"; };
     8793                5758596E239F397900C74572 /* AuthenticatorAssertionResponse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorAssertionResponse.cpp; sourceTree = "<group>"; };
    87858794                5760824F20118D8D00116678 /* JSBasicCredentialCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSBasicCredentialCustom.cpp; sourceTree = "<group>"; };
    87868795                576082562011BE0200116678 /* JSAuthenticatorResponseCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorResponseCustom.cpp; sourceTree = "<group>"; };
     
    88538862                57DA47AC224032DC002A4612 /* JSAuthenticationExtensionsClientInputs.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticationExtensionsClientInputs.cpp; sourceTree = "<group>"; };
    88548863                57DA47AD224032DD002A4612 /* JSAuthenticationExtensionsClientInputs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSAuthenticationExtensionsClientInputs.h; sourceTree = "<group>"; };
    8855                 57DCED72214305F00016B847 /* PublicKeyCredentialData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PublicKeyCredentialData.h; sourceTree = "<group>"; };
     8864                57DCED72214305F00016B847 /* AuthenticatorResponseData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorResponseData.h; sourceTree = "<group>"; };
    88568865                57DCED8C21487EDB0016B847 /* AuthenticatorTransport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorTransport.h; sourceTree = "<group>"; };
    88578866                57DCED8E21487EDB0016B847 /* AuthenticatorTransport.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = AuthenticatorTransport.idl; sourceTree = "<group>"; };
     
    2002920038                                57DA47A522401E0F002A4612 /* AuthenticationExtensionsClientInputs.h */,
    2003020039                                57DA47A722401E0F002A4612 /* AuthenticationExtensionsClientInputs.idl */,
     20040                                57585965239F14CC00C74572 /* AuthenticationExtensionsClientOutputs.h */,
     20041                                57585967239F14CD00C74572 /* AuthenticationExtensionsClientOutputs.idl */,
     20042                                5758596E239F397900C74572 /* AuthenticatorAssertionResponse.cpp */,
    2003120043                                57303C272009B2FC00355965 /* AuthenticatorAssertionResponse.h */,
    2003220044                                57303C292009B2FC00355965 /* AuthenticatorAssertionResponse.idl */,
     20045                                5758596B239F284B00C74572 /* AuthenticatorAttestationResponse.cpp */,
    2003320046                                57303C1B2009A98600355965 /* AuthenticatorAttestationResponse.h */,
    2003420047                                57303C1D2009A98600355965 /* AuthenticatorAttestationResponse.idl */,
     
    2003620049                                57303C4320105B3D00355965 /* AuthenticatorCoordinator.h */,
    2003720050                                576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */,
     20051                                57585969239F1EC700C74572 /* AuthenticatorResponse.cpp */,
    2003820052                                57303BCF20087A8300355965 /* AuthenticatorResponse.h */,
    2003920053                                57303BD120087A8300355965 /* AuthenticatorResponse.idl */,
     20054                                57DCED72214305F00016B847 /* AuthenticatorResponseData.h */,
    2004020055                                57DCED8C21487EDB0016B847 /* AuthenticatorTransport.h */,
    2004120056                                57DCED8E21487EDB0016B847 /* AuthenticatorTransport.idl */,
     
    2004520060                                57303BE62009747A00355965 /* PublicKeyCredentialCreationOptions.h */,
    2004620061                                57303BE82009747A00355965 /* PublicKeyCredentialCreationOptions.idl */,
    20047                                 57DCED72214305F00016B847 /* PublicKeyCredentialData.h */,
    2004820062                                57303BEC200980BF00355965 /* PublicKeyCredentialDescriptor.h */,
    2004920063                                57303BEE200980BF00355965 /* PublicKeyCredentialDescriptor.idl */,
     
    2006820082                                57DA47AC224032DC002A4612 /* JSAuthenticationExtensionsClientInputs.cpp */,
    2006920083                                57DA47AD224032DD002A4612 /* JSAuthenticationExtensionsClientInputs.h */,
     20084                                5758595C239F113000C74572 /* JSAuthenticationExtensionsClientOutputs.cpp */,
     20085                                5758595E239F117300C74572 /* JSAuthenticationExtensionsClientOutputs.h */,
    2007020086                                57303C2E2009B7DA00355965 /* JSAuthenticatorAssertionResponse.cpp */,
    2007120087                                57303C2D2009B7D900355965 /* JSAuthenticatorAssertionResponse.h */,
     
    2904329059                                E124748410AA161D00B79493 /* AuthenticationClient.h in Headers */,
    2904429060                                57DA47B0224034E4002A4612 /* AuthenticationExtensionsClientInputs.h in Headers */,
     29061                                5758596C239F321C00C74572 /* AuthenticationExtensionsClientOutputs.h in Headers */,
    2904529062                                514C764C0CE9234E007EF3CD /* AuthenticationMac.h in Headers */,
    2904629063                                57303C2C2009B4A800355965 /* AuthenticatorAssertionResponse.h in Headers */,
     
    2905029067                                572B40422178114A000AD43E /* AuthenticatorGetInfoResponse.h in Headers */,
    2905129068                                57303BD220087A8300355965 /* AuthenticatorResponse.h in Headers */,
     29069                                57DCED74214305F00016B847 /* AuthenticatorResponseData.h in Headers */,
    2905229070                                572B404021780171000AD43E /* AuthenticatorSupportedOptions.h in Headers */,
    2905329071                                57DCED9021487FF70016B847 /* AuthenticatorTransport.h in Headers */,
     
    3040130419                                BE8EF045171C8FF9009B48C3 /* JSAudioTrackList.h in Headers */,
    3040230420                                57D1352A2294AA3900827401 /* JSAuthenticationExtensionsClientInputs.h in Headers */,
     30421                                57585961239F124D00C74572 /* JSAuthenticationExtensionsClientOutputs.h in Headers */,
    3040330422                                57303C2F2009B7E100355965 /* JSAuthenticatorAssertionResponse.h in Headers */,
    3040430423                                57303C222009AF0300355965 /* JSAuthenticatorAttestationResponse.h in Headers */,
     
    3177631795                                57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */,
    3177731796                                57303BE92009748D00355965 /* PublicKeyCredentialCreationOptions.h in Headers */,
    31778                                 57DCED74214305F00016B847 /* PublicKeyCredentialData.h in Headers */,
    3177931797                                57303BEF200980C600355965 /* PublicKeyCredentialDescriptor.h in Headers */,
    3178031798                                57303C0A20099BAD00355965 /* PublicKeyCredentialRequestOptions.h in Headers */,
  • trunk/Source/WebKit/ChangeLog

    r253396 r253398  
     12019-12-11  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthn] Combine AuthenticatorResponse and PublicKeyCredentialData
     4        https://bugs.webkit.org/show_bug.cgi?id=190783
     5        <rdar://problem/57781183>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Code in WebKit are changed to use AuthenticatorResponse and its subtypes.
     10
     11        * UIProcess/WebAuthentication/Authenticator.h:
     12        * UIProcess/WebAuthentication/AuthenticatorManager.cpp:
     13        (WebKit::AuthenticatorManager::respondReceived):
     14        (WebKit::AuthenticatorManager::invokePendingCompletionHandler):
     15        * UIProcess/WebAuthentication/AuthenticatorManager.h:
     16        * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
     17        (WebKit::LocalAuthenticator::continueMakeCredentialAfterAttested):
     18        (WebKit::LocalAuthenticator::continueGetAssertionAfterUserConsented):
     19        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp:
     20        (WebKit::WebAuthenticatorCoordinatorProxy::handleRequest):
     21        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h:
     22        * UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in:
     23        * UIProcess/WebAuthentication/fido/CtapAuthenticator.cpp:
     24        (WebKit::CtapAuthenticator::continueMakeCredentialAfterResponseReceived const):
     25        (WebKit::CtapAuthenticator::continueGetAssertionAfterResponseReceived):
     26        * UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp:
     27        (WebKit::U2fAuthenticator::continueRegisterCommandAfterResponseReceived):
     28        (WebKit::U2fAuthenticator::continueSignCommandAfterResponseReceived):
     29        * WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp:
     30
    1312019-12-11  Truitt Savell  <tsavell@apple.com>
    232
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Authenticator.h

    r251317 r253398  
    3030#include "WebAuthenticationFlags.h"
    3131#include "WebAuthenticationRequestData.h"
     32#include <WebCore/AuthenticatorResponse.h>
    3233#include <WebCore/ExceptionData.h>
    33 #include <WebCore/PublicKeyCredentialData.h>
    3434#include <wtf/Forward.h>
    3535#include <wtf/RefCounted.h>
     
    4040class Authenticator : public RefCounted<Authenticator>, public CanMakeWeakPtr<Authenticator> {
    4141public:
    42     using Respond = Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>;
     42    using Respond = Variant<Ref<WebCore::AuthenticatorResponse>, WebCore::ExceptionData>;
    4343
    4444    class Observer : public CanMakeWeakPtr<Observer> {
  • trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.cpp

    r252492 r253398  
    244244    ASSERT(m_pendingCompletionHandler);
    245245
    246     auto shouldComplete = WTF::holds_alternative<PublicKeyCredentialData>(respond);
     246    auto shouldComplete = WTF::holds_alternative<Ref<AuthenticatorResponse>>(respond);
    247247    if (!shouldComplete)
    248248        shouldComplete = WTF::get<ExceptionData>(respond).code == InvalidStateError;
     
    350350{
    351351    if (auto *panel = m_pendingRequestData.panel.get()) {
    352         WTF::switchOn(respond, [&](const PublicKeyCredentialData&) {
     352        WTF::switchOn(respond, [&](const Ref<AuthenticatorResponse>&) {
    353353            panel->client().dismissPanel(WebAuthenticationResult::Succeeded);
    354354        }, [&](const ExceptionData&) {
  • trunk/Source/WebKit/UIProcess/WebAuthentication/AuthenticatorManager.h

    r252248 r253398  
    3131#include "AuthenticatorTransportService.h"
    3232#include "WebAuthenticationRequestData.h"
     33#include <WebCore/AuthenticatorResponse.h>
    3334#include <WebCore/ExceptionData.h>
    34 #include <WebCore/PublicKeyCredentialData.h>
    3535#include <wtf/CompletionHandler.h>
    3636#include <wtf/HashSet.h>
     
    4949    WTF_MAKE_NONCOPYABLE(AuthenticatorManager);
    5050public:
    51     using Respond = Variant<WebCore::PublicKeyCredentialData, WebCore::ExceptionData>;
     51    using Respond = Variant<Ref<WebCore::AuthenticatorResponse>, WebCore::ExceptionData>;
    5252    using Callback = CompletionHandler<void(Respond&&)>;
    5353    using TransportSet = HashSet<WebCore::AuthenticatorTransport, WTF::IntHash<WebCore::AuthenticatorTransport>, WTF::StrongEnumHashTraits<WebCore::AuthenticatorTransport>>;
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm

    r250249 r253398  
    3030
    3131#import <Security/SecItem.h>
     32#import <WebCore/AuthenticatorAssertionResponse.h>
     33#import <WebCore/AuthenticatorAttestationResponse.h>
    3234#import <WebCore/CBORWriter.h>
    3335#import <WebCore/ExceptionData.h>
    3436#import <WebCore/PublicKeyCredentialCreationOptions.h>
    35 #import <WebCore/PublicKeyCredentialData.h>
    3637#import <WebCore/PublicKeyCredentialRequestOptions.h>
    3738#import <WebCore/WebAuthenticationConstants.h>
     
    341342    auto attestationObject = buildAttestationObject(WTFMove(authData), "Apple", WTFMove(attestationStatementMap), creationOptions.attestation);
    342343
    343     receiveRespond(PublicKeyCredentialData { ArrayBuffer::create(credentialId.data(), credentialId.size()), true, nullptr, ArrayBuffer::create(attestationObject.data(), attestationObject.size()), nullptr, nullptr, nullptr, WTF::nullopt });
     344    receiveRespond(AuthenticatorAttestationResponse::create(credentialId, attestationObject));
    344345}
    345346
     
    482483
    483484    // Step 13.
    484     receiveRespond(PublicKeyCredentialData { ArrayBuffer::create(credentialId.data(), credentialId.size()), false, nullptr, nullptr, ArrayBuffer::create(authData.data(), authData.size()), ArrayBuffer::create(signature.data(), signature.size()), ArrayBuffer::create(userhandle.data(), userhandle.size()), WTF::nullopt });
     485    receiveRespond(AuthenticatorAssertionResponse::create(credentialId, authData, signature, userhandle));
    485486}
    486487
  • trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.cpp

    r251489 r253398  
    3636#include "WebProcessProxy.h"
    3737#include "WebsiteDataStore.h"
     38#include <WebCore/AuthenticatorResponseData.h>
    3839#include <WebCore/ExceptionData.h>
    39 #include <WebCore/PublicKeyCredentialData.h>
    4040#include <WebCore/SecurityOriginData.h>
    4141#include <wtf/MainThread.h>
     
    6868void WebAuthenticatorCoordinatorProxy::handleRequest(WebAuthenticationRequestData&& data, RequestCompletionHandler&& handler)
    6969{
    70     auto callback = [handler = WTFMove(handler)] (Variant<PublicKeyCredentialData, ExceptionData>&& result) mutable {
     70    auto callback = [handler = WTFMove(handler)] (Variant<Ref<AuthenticatorResponse>, ExceptionData>&& result) mutable {
    7171        ASSERT(RunLoop::isMain());
    72         WTF::switchOn(result, [&](const PublicKeyCredentialData& data) {
    73             handler(data, { });
     72        WTF::switchOn(result, [&](const Ref<AuthenticatorResponse>& response) {
     73            handler(response->data(), { });
    7474        }, [&](const ExceptionData& exception) {
    7575            handler({ }, exception);
  • trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.h

    r251489 r253398  
    3636struct ExceptionData;
    3737struct PublicKeyCredentialCreationOptions;
    38 struct PublicKeyCredentialData;
     38struct AuthenticatorResponseData;
    3939struct PublicKeyCredentialRequestOptions;
    4040struct SecurityOriginData;
     
    5555
    5656private:
    57     using RequestCompletionHandler = CompletionHandler<void(const WebCore::PublicKeyCredentialData&, const WebCore::ExceptionData&)>;
     57    using RequestCompletionHandler = CompletionHandler<void(const WebCore::AuthenticatorResponseData&, const WebCore::ExceptionData&)>;
    5858    using QueryCompletionHandler = CompletionHandler<void(bool)>;
    5959
  • trunk/Source/WebKit/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in

    r252655 r253398  
    2727messages -> WebAuthenticatorCoordinatorProxy NotRefCounted {
    2828
    29     MakeCredential(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData origin, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialCreationOptions options) -> (struct WebCore::PublicKeyCredentialData data, struct WebCore::ExceptionData exception) Async
    30     GetAssertion(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData origin, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialRequestOptions options) -> (struct WebCore::PublicKeyCredentialData data, struct WebCore::ExceptionData exception) Async
     29    MakeCredential(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData origin, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialCreationOptions options) -> (struct WebCore::AuthenticatorResponseData data, struct WebCore::ExceptionData exception) Async
     30    GetAssertion(WebCore::FrameIdentifier frameID, struct WebCore::SecurityOriginData origin, Vector<uint8_t> hash, struct WebCore::PublicKeyCredentialRequestOptions options) -> (struct WebCore::AuthenticatorResponseData data, struct WebCore::ExceptionData exception) Async
    3131    IsUserVerifyingPlatformAuthenticatorAvailable() -> (bool result) Async
    3232}
  • trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapAuthenticator.cpp

    r251979 r253398  
    7474        return;
    7575    }
    76     receiveRespond(WTFMove(*response));
     76    receiveRespond(response.releaseNonNull());
    7777}
    7878
     
    101101        return;
    102102    }
    103     receiveRespond(WTFMove(*response));
     103    receiveRespond(response.releaseNonNull());
    104104}
    105105
  • trunk/Source/WebKit/UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp

    r251645 r253398  
    162162            return;
    163163        }
    164         receiveRespond(WTFMove(*response));
     164        receiveRespond(response.releaseNonNull());
    165165        return;
    166166    }
     
    206206    switch (apduResponse.status()) {
    207207    case ApduResponse::Status::SW_NO_ERROR: {
    208         Optional<PublicKeyCredentialData> response;
     208        RefPtr<AuthenticatorAssertionResponse> response;
    209209        if (m_isAppId) {
    210210            ASSERT(requestOptions.extensions && !requestOptions.extensions->appid.isNull());
     
    217217        }
    218218        if (m_isAppId)
    219             response->appid = m_isAppId;
    220 
    221         receiveRespond(WTFMove(*response));
     219            response->setExtensions({ m_isAppId });
     220
     221        receiveRespond(response.releaseNonNull());
    222222        return;
    223223    }
  • trunk/Source/WebKit/WebProcess/WebAuthentication/WebAuthenticatorCoordinator.cpp

    r251489 r253398  
    3232#include "WebFrame.h"
    3333#include "WebPage.h"
     34#include <WebCore/AuthenticatorResponseData.h>
    3435#include <WebCore/PublicKeyCredentialCreationOptions.h>
    35 #include <WebCore/PublicKeyCredentialData.h>
    3636#include <WebCore/PublicKeyCredentialRequestOptions.h>
    3737#include <WebCore/SecurityOrigin.h>
  • trunk/Tools/ChangeLog

    r253396 r253398  
     12019-12-11  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthn] Combine AuthenticatorResponse and PublicKeyCredentialData
     4        https://bugs.webkit.org/show_bug.cgi?id=190783
     5        <rdar://problem/57781183>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp:
     10        (TestWebKitAPI::TEST):
     11        Updates tests accordingly.
     12
    1132019-12-11  Truitt Savell  <tsavell@apple.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp

    r249927 r253398  
    356356    auto makeCredentialResponse = readCTAPMakeCredentialResponse(convertBytesToVector(TestData::kTestMakeCredentialResponse, sizeof(TestData::kTestMakeCredentialResponse)));
    357357    ASSERT_TRUE(makeCredentialResponse);
    358     auto cborAttestationObject = cbor::CBORReader::read(convertBytesToVector(reinterpret_cast<uint8_t*>(makeCredentialResponse->attestationObject->data()), makeCredentialResponse->attestationObject->byteLength()));
     358    auto cborAttestationObject = cbor::CBORReader::read(convertBytesToVector(reinterpret_cast<uint8_t*>(makeCredentialResponse->attestationObject()->data()), makeCredentialResponse->attestationObject()->byteLength()));
    359359    ASSERT_TRUE(cborAttestationObject);
    360360    ASSERT_TRUE(cborAttestationObject->isMap());
     
    394394    ASSERT_TRUE(certificate.getArray()[0].isByteString());
    395395    EXPECT_EQ(certificate.getArray()[0].getByteString(), convertBytesToVector(TestData::kCtap2MakeCredentialCertificate, sizeof(TestData::kCtap2MakeCredentialCertificate)));
    396     EXPECT_EQ(makeCredentialResponse->rawId->byteLength(), sizeof(TestData::kCtap2MakeCredentialCredentialId));
    397     EXPECT_EQ(memcmp(makeCredentialResponse->rawId->data(), TestData::kCtap2MakeCredentialCredentialId, sizeof(TestData::kCtap2MakeCredentialCredentialId)), 0);
     396    EXPECT_EQ(makeCredentialResponse->rawId()->byteLength(), sizeof(TestData::kCtap2MakeCredentialCredentialId));
     397    EXPECT_EQ(memcmp(makeCredentialResponse->rawId()->data(), TestData::kCtap2MakeCredentialCredentialId, sizeof(TestData::kCtap2MakeCredentialCredentialId)), 0);
    398398}
    399399
     
    405405    ASSERT_TRUE(getAssertionResponse);
    406406
    407     EXPECT_EQ(getAssertionResponse->authenticatorData->byteLength(), sizeof(TestData::kCtap2GetAssertionAuthData));
    408     EXPECT_EQ(memcmp(getAssertionResponse->authenticatorData->data(), TestData::kCtap2GetAssertionAuthData, sizeof(TestData::kCtap2GetAssertionAuthData)), 0);
    409     EXPECT_EQ(getAssertionResponse->signature->byteLength(), sizeof(TestData::kCtap2GetAssertionSignature));
    410     EXPECT_EQ(memcmp(getAssertionResponse->signature->data(), TestData::kCtap2GetAssertionSignature, sizeof(TestData::kCtap2GetAssertionSignature)), 0);
     407    EXPECT_EQ(getAssertionResponse->authenticatorData()->byteLength(), sizeof(TestData::kCtap2GetAssertionAuthData));
     408    EXPECT_EQ(memcmp(getAssertionResponse->authenticatorData()->data(), TestData::kCtap2GetAssertionAuthData, sizeof(TestData::kCtap2GetAssertionAuthData)), 0);
     409    EXPECT_EQ(getAssertionResponse->signature()->byteLength(), sizeof(TestData::kCtap2GetAssertionSignature));
     410    EXPECT_EQ(memcmp(getAssertionResponse->signature()->data(), TestData::kCtap2GetAssertionSignature, sizeof(TestData::kCtap2GetAssertionSignature)), 0);
    411411}
    412412
     
    416416    auto response = readU2fRegisterResponse(TestData::kRelyingPartyId, convertBytesToVector(TestData::kTestU2fRegisterResponse, sizeof(TestData::kTestU2fRegisterResponse)));
    417417    ASSERT_TRUE(response);
    418     EXPECT_EQ(response->rawId->byteLength(), sizeof(TestData::kU2fSignKeyHandle));
    419     EXPECT_EQ(memcmp(response->rawId->data(), TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)), 0);
    420     EXPECT_TRUE(response->isAuthenticatorAttestationResponse);
     418    EXPECT_EQ(response->rawId()->byteLength(), sizeof(TestData::kU2fSignKeyHandle));
     419    EXPECT_EQ(memcmp(response->rawId()->data(), TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)), 0);
    421420    auto expectedAttestationObject = getTestAttestationObjectBytes();
    422     EXPECT_EQ(response->attestationObject->byteLength(), expectedAttestationObject.size());
    423     EXPECT_EQ(memcmp(response->attestationObject->data(), expectedAttestationObject.data(), expectedAttestationObject.size()), 0);
     421    EXPECT_EQ(response->attestationObject()->byteLength(), expectedAttestationObject.size());
     422    EXPECT_EQ(memcmp(response->attestationObject()->data(), expectedAttestationObject.data(), expectedAttestationObject.size()), 0);
    424423}
    425424
     
    523522    auto response = readU2fSignResponse(TestData::kRelyingPartyId, getTestCredentialRawIdBytes(), getTestSignResponse());
    524523    ASSERT_TRUE(response);
    525     EXPECT_EQ(response->rawId->byteLength(), sizeof(TestData::kU2fSignKeyHandle));
    526     EXPECT_EQ(memcmp(response->rawId->data(), TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)), 0);
    527     EXPECT_FALSE(response->isAuthenticatorAttestationResponse);
    528     EXPECT_EQ(response->authenticatorData->byteLength(), sizeof(TestData::kTestSignAuthenticatorData));
    529     EXPECT_EQ(memcmp(response->authenticatorData->data(), TestData::kTestSignAuthenticatorData, sizeof(TestData::kTestSignAuthenticatorData)), 0);
    530     EXPECT_EQ(response->signature->byteLength(), sizeof(TestData::kU2fSignature));
    531     EXPECT_EQ(memcmp(response->signature->data(), TestData::kU2fSignature, sizeof(TestData::kU2fSignature)), 0);
     524    EXPECT_EQ(response->rawId()->byteLength(), sizeof(TestData::kU2fSignKeyHandle));
     525    EXPECT_EQ(memcmp(response->rawId()->data(), TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)), 0);
     526    EXPECT_EQ(response->authenticatorData()->byteLength(), sizeof(TestData::kTestSignAuthenticatorData));
     527    EXPECT_EQ(memcmp(response->authenticatorData()->data(), TestData::kTestSignAuthenticatorData, sizeof(TestData::kTestSignAuthenticatorData)), 0);
     528    EXPECT_EQ(response->signature()->byteLength(), sizeof(TestData::kU2fSignature));
     529    EXPECT_EQ(memcmp(response->signature()->data(), TestData::kU2fSignature, sizeof(TestData::kU2fSignature)), 0);
    532530}
    533531
Note: See TracChangeset for help on using the changeset viewer.