Diff
Modified: trunk/LayoutTests/ChangeLog (292912 => 292913)
--- trunk/LayoutTests/ChangeLog 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/LayoutTests/ChangeLog 2022-04-15 17:38:42 UTC (rev 292913)
@@ -1,3 +1,16 @@
+2022-04-15 J Pascoe <[email protected]>
+
+ [WebAuthn] Implement getTransports() and getAuthenticatorData() on AuthenticatorAttestationResponse
+ https://bugs.webkit.org/show_bug.cgi?id=238966
+ rdar://problem/91449906
+
+ Reviewed by Brent Fulgham.
+
+ Add getTransports() to test.
+
+ * http/wpt/webauthn/public-key-credential-create-success-hid.https.html:
+ * http/wpt/webauthn/resources/util.js:
+
2022-04-15 Karl Rackler <[email protected]>
[ Monterey wk2 ] WebGL conformance tests are a flaky time out
Modified: trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-hid.https.html (292912 => 292913)
--- trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-hid.https.html 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-success-hid.https.html 2022-04-15 17:38:42 UTC (rev 292913)
@@ -27,7 +27,7 @@
};
return navigator.credentials.create(options).then(credential => {
- checkCtapMakeCredentialResult(credential);
+ checkCtapMakeCredentialResult(credential, true, ["usb"]);
});
}, "PublicKeyCredential's [[create]] with minimum options in a mock hid authenticator.");
Modified: trunk/LayoutTests/http/wpt/webauthn/resources/util.js (292912 => 292913)
--- trunk/LayoutTests/http/wpt/webauthn/resources/util.js 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/LayoutTests/http/wpt/webauthn/resources/util.js 2022-04-15 17:38:42 UTC (rev 292913)
@@ -355,7 +355,7 @@
return true;
}
-function checkCtapMakeCredentialResult(credential, isNoneAttestation = true)
+function checkCtapMakeCredentialResult(credential, isNoneAttestation = true, transports = null)
{
// Check response
assert_array_equals(Base64URL.parse(credential.id), Base64URL.parse(testHidCredentialIdBase64));
@@ -388,6 +388,8 @@
assert_equals(attestationObject.attStmt.alg, -7);
assert_equals(attestationObject.attStmt.x5c.length, 1);
}
+ if (transports)
+ assert_array_equals(transports, credential.response.getTransports());
}
function checkU2fMakeCredentialResult(credential, isNoneAttestation = true)
Modified: trunk/Source/WebCore/ChangeLog (292912 => 292913)
--- trunk/Source/WebCore/ChangeLog 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/ChangeLog 2022-04-15 17:38:42 UTC (rev 292913)
@@ -1,3 +1,52 @@
+2022-04-15 J Pascoe <[email protected]>
+
+ [WebAuthn] Implement getTransports() and getAuthenticatorData() on AuthenticatorAttestationResponse
+ https://bugs.webkit.org/show_bug.cgi?id=238966
+ rdar://problem/91449906
+
+ This change implements the getTransports() and getAuthenticatorData() functions
+ on AuthenticatorAttestationResponse. For security keys, the supported transports of
+ the key are parsed from authenticatorGetInfo. For the local authenticator, the supported
+ transports are specified according to which features are available. getAuthenticatorData()
+ is a convenience method for RPs who want to avoid parsing CBOR.
+
+ Reviewed by Brent Fulgham.
+
+ * Modules/webauthn/AuthenticatorAttestationResponse.cpp:
+ (WebCore::AuthenticatorAttestationResponse::create):
+ (WebCore::AuthenticatorAttestationResponse::AuthenticatorAttestationResponse):
+ (WebCore::AuthenticatorAttestationResponse::data const):
+ (WebCore::AuthenticatorAttestationResponse::getTransports const):
+ (WebCore::AuthenticatorAttestationResponse::getAuthenticatorData const):
+ * Modules/webauthn/AuthenticatorAttestationResponse.h:
+ * Modules/webauthn/AuthenticatorAttestationResponse.idl:
+ * Modules/webauthn/AuthenticatorResponse.cpp:
+ (WebCore::AuthenticatorResponse::tryCreate):
+ * Modules/webauthn/AuthenticatorResponse.h:
+ * Modules/webauthn/AuthenticatorResponseData.h:
+ (WebCore::AuthenticatorResponseData::encode const):
+ (WebCore::AuthenticatorResponseData::decode):
+ * Modules/webauthn/AuthenticatorTransport.h:
+ * Modules/webauthn/AuthenticatorTransport.idl:
+ * Modules/webauthn/WebAuthenticationConstants.h:
+ * Modules/webauthn/WebAuthenticationUtils.cpp:
+ (WebCore::convertArrayBufferToVector):
+ * Modules/webauthn/WebAuthenticationUtils.h:
+ * Modules/webauthn/fido/AuthenticatorGetInfoResponse.cpp:
+ (fido::AuthenticatorGetInfoResponse::setTransports):
+ (fido::toStringVector):
+ (fido::encodeAsCBOR):
+ * Modules/webauthn/fido/AuthenticatorGetInfoResponse.h:
+ * Modules/webauthn/fido/DeviceResponseConverter.cpp:
+ (fido::convertStringToAuthenticatorTransport):
+ (fido::readCTAPMakeCredentialResponse):
+ (fido::readCTAPGetInfoResponse):
+ * Modules/webauthn/fido/DeviceResponseConverter.h:
+ * Modules/webauthn/fido/U2fResponseConverter.cpp:
+ (fido::readU2fRegisterResponse):
+ * Modules/webauthn/fido/U2fResponseConverter.h:
+ (fido::readU2fRegisterResponse):
+
2022-04-15 Brandon Stewart <[email protected]>
Parent Mismatch
Modified: trunk/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.cpp (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.cpp 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.cpp 2022-04-15 17:38:42 UTC (rev 292913)
@@ -29,22 +29,25 @@
#if ENABLE(WEB_AUTHN)
#include "AuthenticatorResponseData.h"
+#include "CBORReader.h"
+#include "WebAuthenticationUtils.h"
namespace WebCore {
-Ref<AuthenticatorAttestationResponse> AuthenticatorAttestationResponse::create(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& attestationObject, AuthenticatorAttachment attachment)
+Ref<AuthenticatorAttestationResponse> AuthenticatorAttestationResponse::create(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& attestationObject, AuthenticatorAttachment attachment, Vector<AuthenticatorTransport>&& transports)
{
- return adoptRef(*new AuthenticatorAttestationResponse(WTFMove(rawId), WTFMove(attestationObject), attachment));
+ return adoptRef(*new AuthenticatorAttestationResponse(WTFMove(rawId), WTFMove(attestationObject), attachment, WTFMove(transports)));
}
-Ref<AuthenticatorAttestationResponse> AuthenticatorAttestationResponse::create(const Vector<uint8_t>& rawId, const Vector<uint8_t>& attestationObject, AuthenticatorAttachment attachment)
+Ref<AuthenticatorAttestationResponse> AuthenticatorAttestationResponse::create(const Vector<uint8_t>& rawId, const Vector<uint8_t>& attestationObject, AuthenticatorAttachment attachment, Vector<AuthenticatorTransport>&& transports)
{
- return create(ArrayBuffer::create(rawId.data(), rawId.size()), ArrayBuffer::create(attestationObject.data(), attestationObject.size()), attachment);
+ return create(ArrayBuffer::create(rawId.data(), rawId.size()), ArrayBuffer::create(attestationObject.data(), attestationObject.size()), attachment, WTFMove(transports));
}
-AuthenticatorAttestationResponse::AuthenticatorAttestationResponse(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& attestationObject, AuthenticatorAttachment attachment)
+AuthenticatorAttestationResponse::AuthenticatorAttestationResponse(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& attestationObject, AuthenticatorAttachment attachment, Vector<AuthenticatorTransport>&& transports)
: AuthenticatorResponse(WTFMove(rawId), attachment)
, m_attestationObject(WTFMove(attestationObject))
+ , m_transports(WTFMove(transports))
{
}
@@ -53,9 +56,27 @@
auto data = ""
data.isAuthenticatorAttestationResponse = true;
data.attestationObject = m_attestationObject.copyRef();
+ data.transports = m_transports;
return data;
}
+RefPtr<ArrayBuffer> AuthenticatorAttestationResponse::getAuthenticatorData() const
+{
+ auto decodedResponse = cbor::CBORReader::read(convertArrayBufferToVector(m_attestationObject.ptr()));
+ if (!decodedResponse || !decodedResponse->isMap()) {
+ ASSERT_NOT_REACHED();
+ return nullptr;
+ }
+ const auto& attObjMap = decodedResponse->getMap();
+ auto it = attObjMap.find(cbor::CBORValue("authData"));
+ if (it == attObjMap.end() || !it->second.isByteString()) {
+ ASSERT_NOT_REACHED();
+ return nullptr;
+ }
+ auto authData = it->second.getByteString();
+ return ArrayBuffer::tryCreate(authData.data(), authData.size());
+}
+
} // namespace WebCore
#endif // ENABLE(WEB_AUTHN)
Modified: trunk/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.h (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -28,25 +28,29 @@
#if ENABLE(WEB_AUTHN)
#include "AuthenticatorResponse.h"
+#include "AuthenticatorTransport.h"
namespace WebCore {
class AuthenticatorAttestationResponse : public AuthenticatorResponse {
public:
- static Ref<AuthenticatorAttestationResponse> create(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& attestationObject, AuthenticatorAttachment);
- WEBCORE_EXPORT static Ref<AuthenticatorAttestationResponse> create(const Vector<uint8_t>& rawId, const Vector<uint8_t>& attestationObject, AuthenticatorAttachment);
+ static Ref<AuthenticatorAttestationResponse> create(Ref<ArrayBuffer>&& rawId, Ref<ArrayBuffer>&& attestationObject, AuthenticatorAttachment, Vector<AuthenticatorTransport>&&);
+ WEBCORE_EXPORT static Ref<AuthenticatorAttestationResponse> create(const Vector<uint8_t>& rawId, const Vector<uint8_t>& attestationObject, AuthenticatorAttachment, Vector<AuthenticatorTransport>&&);
virtual ~AuthenticatorAttestationResponse() = default;
ArrayBuffer* attestationObject() const { return m_attestationObject.ptr(); }
+ const Vector<AuthenticatorTransport>& getTransports() const { return m_transports; }
+ RefPtr<ArrayBuffer> getAuthenticatorData() const;
private:
- AuthenticatorAttestationResponse(Ref<ArrayBuffer>&&, Ref<ArrayBuffer>&&, AuthenticatorAttachment);
+ AuthenticatorAttestationResponse(Ref<ArrayBuffer>&&, Ref<ArrayBuffer>&&, AuthenticatorAttachment, Vector<AuthenticatorTransport>&&);
Type type() const final { return Type::Attestation; }
AuthenticatorResponseData data() const final;
Ref<ArrayBuffer> m_attestationObject;
+ Vector<AuthenticatorTransport> m_transports;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.idl (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.idl 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/AuthenticatorAttestationResponse.idl 2022-04-15 17:38:42 UTC (rev 292913)
@@ -30,4 +30,6 @@
SecureContext
] interface AuthenticatorAttestationResponse : AuthenticatorResponse {
[SameObject] readonly attribute ArrayBuffer attestationObject;
+ sequence<AuthenticatorTransport> getTransports();
+ ArrayBuffer getAuthenticatorData();
};
Modified: trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponse.cpp (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponse.cpp 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponse.cpp 2022-04-15 17:38:42 UTC (rev 292913)
@@ -43,7 +43,7 @@
if (!data.attestationObject)
return nullptr;
- return AuthenticatorAttestationResponse::create(data.rawId.releaseNonNull(), data.attestationObject.releaseNonNull(), attachment);
+ return AuthenticatorAttestationResponse::create(data.rawId.releaseNonNull(), data.attestationObject.releaseNonNull(), attachment, WTFMove(data.transports));
}
if (!data.authenticatorData || !data.signature)
Modified: trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponse.h (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponse.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponse.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -35,6 +35,7 @@
namespace WebCore {
enum class AuthenticatorAttachment;
+enum class AuthenticatorTransport;
struct AuthenticatorResponseData;
Modified: trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponseData.h (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponseData.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponseData.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -27,6 +27,7 @@
#if ENABLE(WEB_AUTHN)
+#include "AuthenticatorTransport.h"
#include <_javascript_Core/ArrayBuffer.h>
#include <wtf/Forward.h>
@@ -51,6 +52,8 @@
RefPtr<ArrayBuffer> signature;
RefPtr<ArrayBuffer> userHandle;
+ Vector<WebCore::AuthenticatorTransport> transports;
+
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static std::optional<AuthenticatorResponseData> decode(Decoder&);
};
@@ -94,6 +97,7 @@
if (isAuthenticatorAttestationResponse && attestationObject) {
encodeArrayBuffer(encoder, *attestationObject);
+ encoder << transports;
return;
}
@@ -139,6 +143,12 @@
result.attestationObject = decodeArrayBuffer(decoder);
if (!result.attestationObject)
return std::nullopt;
+
+ std::optional<Vector<AuthenticatorTransport>> transports;
+ decoder >> transports;
+ if (!transports)
+ return std::nullopt;
+ result.transports = WTFMove(*transports);
return result;
}
Modified: trunk/Source/WebCore/Modules/webauthn/AuthenticatorTransport.h (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/AuthenticatorTransport.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/AuthenticatorTransport.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -35,7 +35,8 @@
Usb,
Nfc,
Ble,
- Internal
+ Internal,
+ Cable
};
} // namespace WebCore
@@ -48,7 +49,8 @@
WebCore::AuthenticatorTransport::Usb,
WebCore::AuthenticatorTransport::Nfc,
WebCore::AuthenticatorTransport::Ble,
- WebCore::AuthenticatorTransport::Internal
+ WebCore::AuthenticatorTransport::Internal,
+ WebCore::AuthenticatorTransport::Cable
>;
};
Modified: trunk/Source/WebCore/Modules/webauthn/AuthenticatorTransport.idl (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/AuthenticatorTransport.idl 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/AuthenticatorTransport.idl 2022-04-15 17:38:42 UTC (rev 292913)
@@ -29,5 +29,6 @@
"usb",
"nfc",
"ble",
- "internal"
+ "internal",
+ "cable"
};
Modified: trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/WebAuthenticationConstants.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -93,6 +93,12 @@
constexpr const char relyingPartyKey[] = "rp";
constexpr const char applicationTagKey[] = "tag";
+constexpr auto authenticatorTransportUsb = "usb"_s;
+constexpr auto authenticatorTransportNfc = "nfc"_s;
+constexpr auto authenticatorTransportBle = "ble"_s;
+constexpr auto authenticatorTransportInternal = "internal"_s;
+constexpr auto authenticatorTransportCable = "cable"_s;
+
} // namespace WebCore
namespace WebAuthn {
Modified: trunk/Source/WebCore/Modules/webauthn/WebAuthenticationUtils.cpp (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/WebAuthenticationUtils.cpp 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/WebAuthenticationUtils.cpp 2022-04-15 17:38:42 UTC (rev 292913)
@@ -28,6 +28,7 @@
#if ENABLE(WEB_AUTHN)
+#include "CBORReader.h"
#include "CBORWriter.h"
#include "FidoConstants.h"
#include "WebAuthenticationConstants.h"
@@ -43,6 +44,11 @@
return { byteArray, length };
}
+Vector<uint8_t> convertArrayBufferToVector(ArrayBuffer* buffer)
+{
+ return convertBytesToVector(static_cast<uint8_t*>(buffer->data()), buffer->byteLength());
+}
+
Vector<uint8_t> produceRpIdHash(const String& rpId)
{
auto crypto = PAL::CryptoDigest::create(PAL::CryptoDigest::Algorithm::SHA_256);
Modified: trunk/Source/WebCore/Modules/webauthn/WebAuthenticationUtils.h (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/WebAuthenticationUtils.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/WebAuthenticationUtils.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -38,6 +38,8 @@
WEBCORE_EXPORT Vector<uint8_t> convertBytesToVector(const uint8_t byteArray[], const size_t length);
+WEBCORE_EXPORT Vector<uint8_t> convertArrayBufferToVector(ArrayBuffer*);
+
// Produce a SHA-256 hash of the given RP ID.
WEBCORE_EXPORT Vector<uint8_t> produceRpIdHash(const String& rpId);
Modified: trunk/Source/WebCore/Modules/webauthn/fido/AuthenticatorGetInfoResponse.cpp (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/fido/AuthenticatorGetInfoResponse.cpp 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/fido/AuthenticatorGetInfoResponse.cpp 2022-04-15 17:38:42 UTC (rev 292913)
@@ -34,6 +34,7 @@
#include "CBORValue.h"
#include "CBORWriter.h"
+#include "WebAuthenticationConstants.h"
namespace fido {
@@ -76,6 +77,36 @@
return *this;
}
+AuthenticatorGetInfoResponse& AuthenticatorGetInfoResponse::setTransports(Vector<WebCore::AuthenticatorTransport>&& transports)
+{
+ m_transports = WTFMove(transports);
+ return *this;
+}
+
+static String toString(WebCore::AuthenticatorTransport transport)
+{
+ switch (transport) {
+ case WebCore::AuthenticatorTransport::Usb:
+ return WebCore::authenticatorTransportUsb;
+ break;
+ case WebCore::AuthenticatorTransport::Nfc:
+ return WebCore::authenticatorTransportNfc;
+ break;
+ case WebCore::AuthenticatorTransport::Ble:
+ return WebCore::authenticatorTransportBle;
+ break;
+ case WebCore::AuthenticatorTransport::Internal:
+ return WebCore::authenticatorTransportInternal;
+ break;
+ case WebCore::AuthenticatorTransport::Cable:
+ return WebCore::authenticatorTransportCable;
+ default:
+ break;
+ }
+ ASSERT_NOT_REACHED();
+ return nullString();
+}
+
Vector<uint8_t> encodeAsCBOR(const AuthenticatorGetInfoResponse& response)
{
using namespace cbor;
@@ -98,6 +129,11 @@
if (response.pinProtocol())
deviceInfoMap.emplace(CBORValue(6), toArrayValue(*response.pinProtocol()));
+
+ if (response.transports()) {
+ auto transports = *response.transports();
+ deviceInfoMap.emplace(CBORValue(7), toArrayValue(transports.map(toString)));
+ }
auto encodedBytes = CBORWriter::write(CBORValue(WTFMove(deviceInfoMap)));
ASSERT(encodedBytes);
Modified: trunk/Source/WebCore/Modules/webauthn/fido/AuthenticatorGetInfoResponse.h (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/fido/AuthenticatorGetInfoResponse.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/fido/AuthenticatorGetInfoResponse.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -32,6 +32,7 @@
#if ENABLE(WEB_AUTHN)
#include "AuthenticatorSupportedOptions.h"
+#include "AuthenticatorTransport.h"
#include "FidoConstants.h"
#include <wtf/StdSet.h>
@@ -52,6 +53,7 @@
AuthenticatorGetInfoResponse& setPinProtocols(Vector<uint8_t>&&);
AuthenticatorGetInfoResponse& setExtensions(Vector<String>&&);
AuthenticatorGetInfoResponse& setOptions(AuthenticatorSupportedOptions&&);
+ AuthenticatorGetInfoResponse& setTransports(Vector<WebCore::AuthenticatorTransport>&&);
const StdSet<ProtocolVersion>& versions() const { return m_versions; }
const Vector<uint8_t>& aaguid() const { return m_aaguid; }
@@ -59,6 +61,7 @@
const std::optional<Vector<uint8_t>>& pinProtocol() const { return m_pinProtocols; }
const std::optional<Vector<String>>& extensions() const { return m_extensions; }
const AuthenticatorSupportedOptions& options() const { return m_options; }
+ const std::optional<Vector<WebCore::AuthenticatorTransport>>& transports() const { return m_transports; }
private:
StdSet<ProtocolVersion> m_versions;
@@ -67,6 +70,7 @@
std::optional<Vector<uint8_t>> m_pinProtocols;
std::optional<Vector<String>> m_extensions;
AuthenticatorSupportedOptions m_options;
+ std::optional<Vector<WebCore::AuthenticatorTransport>> m_transports;
};
WEBCORE_EXPORT Vector<uint8_t> encodeAsCBOR(const AuthenticatorGetInfoResponse&);
Modified: trunk/Source/WebCore/Modules/webauthn/fido/DeviceResponseConverter.cpp (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/fido/DeviceResponseConverter.cpp 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/fido/DeviceResponseConverter.cpp 2022-04-15 17:38:42 UTC (rev 292913)
@@ -54,6 +54,21 @@
return ProtocolVersion::kUnknown;
}
+static std::optional<AuthenticatorTransport> convertStringToAuthenticatorTransport(const String& transport)
+{
+ if (transport == authenticatorTransportUsb)
+ return AuthenticatorTransport::Usb;
+ if (transport == authenticatorTransportNfc)
+ return AuthenticatorTransport::Nfc;
+ if (transport == authenticatorTransportBle)
+ return AuthenticatorTransport::Ble;
+ if (transport == authenticatorTransportInternal)
+ return AuthenticatorTransport::Internal;
+ if (transport == authenticatorTransportCable)
+ return AuthenticatorTransport::Cable;
+ return std::nullopt;
+}
+
std::optional<cbor::CBORValue> decodeResponseMap(const Vector<uint8_t>& inBuffer)
{
if (inBuffer.size() <= kResponseCodeLength || getResponseCode(inBuffer) != CtapDeviceResponseCode::kSuccess)
@@ -95,7 +110,7 @@
// Decodes byte array response from authenticator to CBOR value object and
// checks for correct encoding format.
-RefPtr<AuthenticatorAttestationResponse> readCTAPMakeCredentialResponse(const Vector<uint8_t>& inBuffer, WebCore::AuthenticatorAttachment attachment, const AttestationConveyancePreference& attestation)
+RefPtr<AuthenticatorAttestationResponse> readCTAPMakeCredentialResponse(const Vector<uint8_t>& inBuffer, WebCore::AuthenticatorAttachment attachment, Vector<AuthenticatorTransport>&& transports, const AttestationConveyancePreference& attestation)
{
auto decodedMap = decodeResponseMap(inBuffer);
if (!decodedMap)
@@ -135,7 +150,7 @@
attestationObject = cbor::CBORWriter::write(CBOR(WTFMove(attestationObjectMap)));
}
- return AuthenticatorAttestationResponse::create(credentialId, *attestationObject, attachment);
+ return AuthenticatorAttestationResponse::create(credentialId, *attestationObject, attachment, WTFMove(transports));
}
RefPtr<AuthenticatorAssertionResponse> readCTAPGetAssertionResponse(const Vector<uint8_t>& inBuffer, WebCore::AuthenticatorAttachment attachment)
@@ -325,6 +340,22 @@
response.setPinProtocols(WTFMove(supportedPinProtocols));
}
+ it = responseMap.find(CBOR(9));
+ if (it != responseMap.end()) {
+ if (!it->second.isArray())
+ return std::nullopt;
+
+ Vector<AuthenticatorTransport> transports;
+ for (const auto& transportString : it->second.getArray()) {
+ if (!transportString.isString())
+ return std::nullopt;
+ auto transport = convertStringToAuthenticatorTransport(transportString.getString());
+ if (transport)
+ transports.append(*transport);
+ }
+ response.setTransports(WTFMove(transports));
+ }
+
return WTFMove(response);
}
Modified: trunk/Source/WebCore/Modules/webauthn/fido/DeviceResponseConverter.h (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/fido/DeviceResponseConverter.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/fido/DeviceResponseConverter.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -52,7 +52,7 @@
// and converts response to AuthenticatorMakeCredentialResponse object with
// CBOR map keys that conform to format of attestation object defined by the
// WebAuthN spec : https://w3c.github.io/webauthn/#fig-attStructs
-WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAttestationResponse> readCTAPMakeCredentialResponse(const Vector<uint8_t>&, WebCore::AuthenticatorAttachment, const WebCore::AttestationConveyancePreference& = WebCore::AttestationConveyancePreference::Direct);
+WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAttestationResponse> readCTAPMakeCredentialResponse(const Vector<uint8_t>&, WebCore::AuthenticatorAttachment, Vector<WebCore::AuthenticatorTransport>&&, const WebCore::AttestationConveyancePreference& = WebCore::AttestationConveyancePreference::Direct);
// De-serializes CBOR encoded response to AuthenticatorGetAssertion /
// AuthenticatorGetNextAssertion request to AuthenticatorGetAssertionResponse
Modified: trunk/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.cpp (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.cpp 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.cpp 2022-04-15 17:38:42 UTC (rev 292913)
@@ -137,7 +137,7 @@
} // namespace
-RefPtr<AuthenticatorAttestationResponse> readU2fRegisterResponse(const String& rpId, const Vector<uint8_t>& u2fData, AuthenticatorAttachment attachment, const AttestationConveyancePreference& attestation)
+RefPtr<AuthenticatorAttestationResponse> readU2fRegisterResponse(const String& rpId, const Vector<uint8_t>& u2fData, AuthenticatorAttachment attachment, Vector<AuthenticatorTransport>&& transports, const AttestationConveyancePreference& attestation)
{
auto publicKey = extractECPublicKeyFromU2fRegistrationResponse(u2fData);
if (publicKey.isEmpty())
@@ -160,7 +160,7 @@
auto attestationObject = buildAttestationObject(WTFMove(authData), "fido-u2f"_s, WTFMove(fidoAttestationStatement), attestation);
- return AuthenticatorAttestationResponse::create(credentialId, attestationObject, attachment);
+ return AuthenticatorAttestationResponse::create(credentialId, attestationObject, attachment, WTFMove(transports));
}
RefPtr<AuthenticatorAssertionResponse> readU2fSignResponse(const String& rpId, const WebCore::BufferSource& keyHandle, const Vector<uint8_t>& u2fData, AuthenticatorAttachment attachment)
Modified: trunk/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.h (292912 => 292913)
--- trunk/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -44,7 +44,7 @@
// Converts a U2F register response to WebAuthN makeCredential response.
// https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-client-to-authenticator-protocol-v2.0-id-20180227.html#u2f-authenticatorMakeCredential-interoperability
-WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAttestationResponse> readU2fRegisterResponse(const String& rpId, const Vector<uint8_t>& u2fData, WebCore::AuthenticatorAttachment, const WebCore::AttestationConveyancePreference& = WebCore::AttestationConveyancePreference::Direct);
+WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAttestationResponse> readU2fRegisterResponse(const String& rpId, const Vector<uint8_t>& u2fData, WebCore::AuthenticatorAttachment, Vector<WebCore::AuthenticatorTransport>&& transports = { }, const WebCore::AttestationConveyancePreference& = WebCore::AttestationConveyancePreference::Direct);
// Converts a U2F authentication response to WebAuthN getAssertion response.
// https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-client-to-authenticator-protocol-v2.0-id-20180227.html#u2f-authenticatorGetAssertion-interoperability
Modified: trunk/Source/WebKit/ChangeLog (292912 => 292913)
--- trunk/Source/WebKit/ChangeLog 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/ChangeLog 2022-04-15 17:38:42 UTC (rev 292913)
@@ -1,3 +1,50 @@
+2022-04-15 J Pascoe <[email protected]>
+
+ [WebAuthn] Implement getTransports() and getAuthenticatorData() on AuthenticatorAttestationResponse
+ https://bugs.webkit.org/show_bug.cgi?id=238966
+ rdar://problem/91449906
+
+ This change implements the getTransports() and getAuthenticatorData() functions
+ on AuthenticatorAttestationResponse. For security keys, the supported transports of
+ the key are parsed from authenticatorGetInfo. For the local authenticator, the supported
+ transports are specified according to which features are available. getAuthenticatorData()
+ is a convenience method for RPs who want to avoid parsing CBOR.
+
+ Reviewed by Brent Fulgham.
+
+ * Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h:
+ * UIProcess/API/Cocoa/_WKAuthenticatorAttestationResponse.h:
+ * UIProcess/API/Cocoa/_WKAuthenticatorAttestationResponse.mm:
+ (-[_WKAuthenticatorAttestationResponse initWithClientDataJSON:rawId:extensions:attestationObject:attachment:transports:]):
+ (-[_WKAuthenticatorAttestationResponse initWithClientDataJSON:rawId:extensions:attestationObject:attachment:]): Deleted.
+ * UIProcess/API/Cocoa/_WKAuthenticatorAttestationResponseInternal.h:
+ * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:
+ (wkExtensionsClientOutputs):
+ (wkAuthenticatorAttestationResponse):
+ (wkAuthenticatorAssertionResponse):
+ * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:
+ (WebKit::LocalAuthenticatorInternal::transports):
+ (WebKit::LocalAuthenticator::continueMakeCredentialAfterUserVerification):
+ (WebKit::LocalAuthenticator::continueMakeCredentialAfterAttested):
+ * UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm:
+ (WebKit::toASCDescriptor):
+ (WebKit::toAuthenticatorTransports):
+ (WebKit::continueAfterRequest):
+ * UIProcess/WebAuthentication/fido/CtapAuthenticator.cpp:
+ (WebKit::CtapAuthenticator::continueMakeCredentialAfterResponseReceived):
+ (WebKit::CtapAuthenticator::transports):
+ * UIProcess/WebAuthentication/fido/CtapAuthenticator.h:
+ * UIProcess/WebAuthentication/fido/CtapDriver.h:
+ (WebKit::CtapDriver::transport const):
+ (WebKit::CtapDriver::protocol const):
+ (WebKit::CtapDriver::CtapDriver):
+ * UIProcess/WebAuthentication/fido/CtapHidDriver.cpp:
+ (WebKit::CtapHidDriver::CtapHidDriver):
+ * UIProcess/WebAuthentication/fido/CtapNfcDriver.cpp:
+ (WebKit::CtapNfcDriver::CtapNfcDriver):
+ * UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp:
+ (WebKit::U2fAuthenticator::continueRegisterCommandAfterResponseReceived):
+
2022-04-14 Simon Fraser <[email protected]>
Use the ProcessTerminationReason enum for all the process types
Modified: trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h (292912 => 292913)
--- trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/Platform/spi/Cocoa/AuthenticationServicesCoreSPI.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -290,6 +290,7 @@
@property (nonatomic, copy, readonly) NSString *relyingPartyIdentifier;
@property (nonatomic, copy, readonly) NSData *attestationObject;
@property (nonatomic, copy, readonly) NSData *rawClientDataJSON;
+@property (nonatomic, copy) NSArray<NSNumber *> *transports;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
@@ -304,6 +305,7 @@
@property (nonatomic, copy, readonly) NSData *rawClientDataJSON;
@property (nonatomic, copy, readonly) NSString *relyingPartyIdentifier;
@property (nonatomic, copy, readonly) NSData *attestationObject;
+@property (nonatomic, copy) NSArray<NSNumber *> *transports;
@end
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAuthenticatorAttestationResponse.h (292912 => 292913)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAuthenticatorAttestationResponse.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAuthenticatorAttestationResponse.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -33,6 +33,7 @@
@interface _WKAuthenticatorAttestationResponse : _WKAuthenticatorResponse
@property (nonatomic, readonly) NSData *attestationObject;
+@property (nonatomic, copy) NSArray<NSNumber *> *transports;
@end
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAuthenticatorAttestationResponse.mm (292912 => 292913)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAuthenticatorAttestationResponse.mm 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAuthenticatorAttestationResponse.mm 2022-04-15 17:38:42 UTC (rev 292913)
@@ -32,12 +32,13 @@
@implementation _WKAuthenticatorAttestationResponse
-- (instancetype)initWithClientDataJSON:(NSData *)clientDataJSON rawId:(NSData *)rawId extensions:(RetainPtr<_WKAuthenticationExtensionsClientOutputs>&&)extensions attestationObject:(NSData *)attestationObject attachment:(_WKAuthenticatorAttachment)attachment
+- (instancetype)initWithClientDataJSON:(NSData *)clientDataJSON rawId:(NSData *)rawId extensions:(RetainPtr<_WKAuthenticationExtensionsClientOutputs>&&)extensions attestationObject:(NSData *)attestationObject attachment:(_WKAuthenticatorAttachment)attachment transports:(NSArray<NSNumber *> *)transports
{
if (!(self = [super initWithClientDataJSON:clientDataJSON rawId:rawId extensions:WTFMove(extensions) attachment:attachment]))
return nil;
_attestationObject = attestationObject;
+ _transports = transports;
return self;
}
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAuthenticatorAttestationResponseInternal.h (292912 => 292913)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAuthenticatorAttestationResponseInternal.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKAuthenticatorAttestationResponseInternal.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -34,7 +34,7 @@
@interface _WKAuthenticatorAttestationResponse ()
-- (instancetype)initWithClientDataJSON:(NSData *)clientDataJSON rawId:(NSData *)rawId extensions:(RetainPtr<_WKAuthenticationExtensionsClientOutputs>&&)extensions attestationObject:(NSData *)attestationObject attachment:(_WKAuthenticatorAttachment)attachment;
+- (instancetype)initWithClientDataJSON:(NSData *)clientDataJSON rawId:(NSData *)rawId extensions:(RetainPtr<_WKAuthenticationExtensionsClientOutputs>&&)extensions attestationObject:(NSData *)attestationObject attachment:(_WKAuthenticatorAttachment)attachment transports:(NSArray<NSNumber *> *)transports;
@end
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm (292912 => 292913)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm 2022-04-15 17:38:42 UTC (rev 292913)
@@ -848,9 +848,28 @@
}
}
+static RetainPtr<_WKAuthenticationExtensionsClientOutputs> wkExtensionsClientOutputs(const WebCore::AuthenticatorResponseData& data)
+{
+ RetainPtr<_WKAuthenticationExtensionsClientOutputs> extensions;
+ if (data.appid)
+ extensions = adoptNS([[_WKAuthenticationExtensionsClientOutputs alloc] initWithAppid:data.appid.value()]);
+ return extensions;
+}
+
+static RetainPtr<NSArray<NSNumber *>> wkTransports(const Vector<WebCore::AuthenticatorTransport>& transports)
+{
+ auto wkTransports = adoptNS([NSMutableArray<NSNumber *> new]);
+ for (auto transport : transports)
+ [wkTransports addObject:[NSNumber numberWithInt:(int)transport]];
+ return wkTransports;
+}
+
+
static RetainPtr<_WKAuthenticatorAttestationResponse> wkAuthenticatorAttestationResponse(const WebCore::AuthenticatorResponseData& data, NSData *clientDataJSON, WebCore::AuthenticatorAttachment attachment)
{
- return adoptNS([[_WKAuthenticatorAttestationResponse alloc] initWithClientDataJSON:clientDataJSON rawId:[NSData dataWithBytes:data.rawId->data() length:data.rawId->byteLength()] extensions:nil attestationObject:[NSData dataWithBytes:data.attestationObject->data() length:data.attestationObject->byteLength()] attachment: authenticatorAttachmentToWKAuthenticatorAttachment(attachment)]);
+ auto value = adoptNS([[_WKAuthenticatorAttestationResponse alloc] initWithClientDataJSON:clientDataJSON rawId:[NSData dataWithBytes:data.rawId->data() length:data.rawId->byteLength()] extensions:wkExtensionsClientOutputs(data) attestationObject:[NSData dataWithBytes:data.attestationObject->data() length:data.attestationObject->byteLength()] attachment: authenticatorAttachmentToWKAuthenticatorAttachment(attachment) transports:wkTransports(data.transports).autorelease()]);
+
+ return value;
}
#endif
@@ -911,15 +930,11 @@
#if ENABLE(WEB_AUTHN)
static RetainPtr<_WKAuthenticatorAssertionResponse> wkAuthenticatorAssertionResponse(const WebCore::AuthenticatorResponseData& data, NSData *clientDataJSON, WebCore::AuthenticatorAttachment attachment)
{
- RetainPtr<_WKAuthenticationExtensionsClientOutputs> extensions;
- if (data.appid)
- extensions = adoptNS([[_WKAuthenticationExtensionsClientOutputs alloc] initWithAppid:data.appid.value()]);
-
NSData *userHandle = nil;
if (data.userHandle)
userHandle = [NSData dataWithBytes:data.userHandle->data() length:data.userHandle->byteLength()];
- return adoptNS([[_WKAuthenticatorAssertionResponse alloc] initWithClientDataJSON:clientDataJSON rawId:[NSData dataWithBytes:data.rawId->data() length:data.rawId->byteLength()] extensions:WTFMove(extensions) authenticatorData:[NSData dataWithBytes:data.authenticatorData->data() length:data.authenticatorData->byteLength()] signature:[NSData dataWithBytes:data.signature->data() length:data.signature->byteLength()] userHandle:userHandle attachment:authenticatorAttachmentToWKAuthenticatorAttachment(attachment)]);
+ return adoptNS([[_WKAuthenticatorAssertionResponse alloc] initWithClientDataJSON:clientDataJSON rawId:[NSData dataWithBytes:data.rawId->data() length:data.rawId->byteLength()] extensions:wkExtensionsClientOutputs(data) authenticatorData:[NSData dataWithBytes:data.authenticatorData->data() length:data.authenticatorData->byteLength()] signature:[NSData dataWithBytes:data.signature->data() length:data.signature->byteLength()] userHandle:userHandle attachment:authenticatorAttachmentToWKAuthenticatorAttachment(attachment)]);
}
#endif
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm (292912 => 292913)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm 2022-04-15 17:38:42 UTC (rev 292913)
@@ -28,6 +28,7 @@
#if ENABLE(WEB_AUTHN)
+#import "AuthenticationServicesCoreSoftLink.h"
#import <Security/SecItem.h>
#import <WebCore/AuthenticatorAssertionResponse.h>
#import <WebCore/AuthenticatorAttachment.h>
@@ -60,6 +61,10 @@
{
return nullString();
}
+static bool shouldUpdateQuery()
+{
+ return false;
+}
#endif
namespace WebKit {
@@ -181,6 +186,14 @@
return result;
}
+static Vector<AuthenticatorTransport> transports()
+{
+ Vector<WebCore::AuthenticatorTransport> transports = { WebCore::AuthenticatorTransport::Internal };
+ if (shouldUpdateQuery())
+ transports.append(WebCore::AuthenticatorTransport::Cable);
+ return transports;
+}
+
} // LocalAuthenticatorInternal
void LocalAuthenticator::clearAllCredentials()
@@ -426,7 +439,7 @@
auto authData = buildAuthData(creationOptions.rp.id, flags, counter, buildAttestedCredentialData(Vector<uint8_t>(aaguidLength, 0), credentialId, cosePublicKey));
auto attestationObject = buildAttestationObject(WTFMove(authData), String { emptyString() }, { }, AttestationConveyancePreference::None);
- receiveRespond(AuthenticatorAttestationResponse::create(credentialId, attestationObject, AuthenticatorAttachment::Platform));
+ receiveRespond(AuthenticatorAttestationResponse::create(credentialId, attestationObject, AuthenticatorAttachment::Platform, transports()));
return;
}
@@ -453,7 +466,7 @@
if (error) {
LOG_ERROR("Couldn't attest: %s", String(error.localizedDescription).utf8().data());
auto attestationObject = buildAttestationObject(WTFMove(authData), String { emptyString() }, { }, AttestationConveyancePreference::None);
- receiveRespond(AuthenticatorAttestationResponse::create(credentialId, attestationObject, AuthenticatorAttachment::Platform));
+ receiveRespond(AuthenticatorAttestationResponse::create(credentialId, attestationObject, AuthenticatorAttachment::Platform, transports()));
return;
}
// Attestation Certificate and Attestation Issuing CA
@@ -472,7 +485,7 @@
auto attestationObject = buildAttestationObject(WTFMove(authData), "apple"_s, WTFMove(attestationStatementMap), creationOptions.attestation);
deleteDuplicateCredential();
- receiveRespond(AuthenticatorAttestationResponse::create(credentialId, attestationObject, AuthenticatorAttachment::Platform));
+ receiveRespond(AuthenticatorAttestationResponse::create(credentialId, attestationObject, AuthenticatorAttachment::Platform, transports()));
}
void LocalAuthenticator::getAssertion()
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm (292912 => 292913)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm 2022-04-15 17:38:42 UTC (rev 292913)
@@ -154,6 +154,9 @@
case AuthenticatorTransport::Internal:
transportString = @"internal";
break;
+ case AuthenticatorTransport::Cable:
+ transportString = @"cable";
+ break;
}
if (transportString)
@@ -337,6 +340,17 @@
return requestContext;
}
+static Vector<WebCore::AuthenticatorTransport> toAuthenticatorTransports(NSArray<NSNumber *> *ascTransports)
+{
+ Vector<WebCore::AuthenticatorTransport> transports;
+ transports.reserveInitialCapacity(ascTransports.count);
+ for (NSNumber *ascTransport : ascTransports) {
+ if (WTF::isValidEnum<WebCore::AuthenticatorTransport>(ascTransport.intValue))
+ transports.uncheckedAppend(static_cast<WebCore::AuthenticatorTransport>(ascTransport.intValue));
+ }
+ return transports;
+}
+
RetainPtr<ASCCredentialRequestContext> WebAuthenticatorCoordinatorProxy::contextForRequest(WebAuthenticationRequestData&& requestData)
{
RetainPtr<ASCCredentialRequestContext> result;
@@ -361,6 +375,8 @@
ASCPlatformPublicKeyCredentialRegistration *registrationCredential = credential.get();
response.rawId = toArrayBuffer(registrationCredential.credentialID);
response.attestationObject = toArrayBuffer(registrationCredential.attestationObject);
+ if ([registrationCredential respondsToSelector:@selector(transports)])
+ response.transports = toAuthenticatorTransports(registrationCredential.transports);
} else if ([credential isKindOfClass:getASCSecurityKeyPublicKeyCredentialRegistrationClass()]) {
attachment = AuthenticatorAttachment::CrossPlatform;
response.isAuthenticatorAttestationResponse = true;
@@ -368,6 +384,8 @@
ASCSecurityKeyPublicKeyCredentialRegistration *registrationCredential = credential.get();
response.rawId = toArrayBuffer(registrationCredential.credentialID);
response.attestationObject = toArrayBuffer(registrationCredential.attestationObject);
+ if ([registrationCredential respondsToSelector:@selector(transports)])
+ response.transports = toAuthenticatorTransports(registrationCredential.transports);
} else if ([credential isKindOfClass:getASCPlatformPublicKeyCredentialAssertionClass()]) {
attachment = AuthenticatorAttachment::Platform;
response.isAuthenticatorAttestationResponse = false;
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapAuthenticator.cpp (292912 => 292913)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapAuthenticator.cpp 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapAuthenticator.cpp 2022-04-15 17:38:42 UTC (rev 292913)
@@ -114,7 +114,7 @@
void CtapAuthenticator::continueMakeCredentialAfterResponseReceived(Vector<uint8_t>&& data)
{
- auto response = readCTAPMakeCredentialResponse(data, AuthenticatorAttachment::CrossPlatform, std::get<PublicKeyCredentialCreationOptions>(requestData().options).attestation);
+ auto response = readCTAPMakeCredentialResponse(data, AuthenticatorAttachment::CrossPlatform, transports(), std::get<PublicKeyCredentialCreationOptions>(requestData().options).attestation);
if (!response) {
auto error = getResponseCode(data);
@@ -384,6 +384,14 @@
return extensions->googleLegacyAppidSupport;
}
+Vector<AuthenticatorTransport> CtapAuthenticator::transports() const
+{
+
+ if (auto& infoTransports = m_info.transports())
+ return *infoTransports;
+ return Vector { driver().transport() };
+}
+
} // namespace WebKit
#endif // ENABLE(WEB_AUTHN)
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapAuthenticator.h (292912 => 292913)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapAuthenticator.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapAuthenticator.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -70,6 +70,8 @@
bool tryDowngrade();
bool processGoogleLegacyAppIdSupportExtension();
+ Vector<WebCore::AuthenticatorTransport> transports() const;
+
fido::AuthenticatorGetInfoResponse m_info;
bool m_isDowngraded { false };
size_t m_remainingAssertionResponses { 0 };
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapDriver.h (292912 => 292913)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapDriver.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapDriver.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -27,6 +27,7 @@
#if ENABLE(WEB_AUTHN)
+#include <WebCore/AuthenticatorTransport.h>
#include <WebCore/FidoConstants.h>
#include <wtf/Forward.h>
#include <wtf/Function.h>
@@ -45,15 +46,19 @@
void setProtocol(fido::ProtocolVersion protocol) { m_protocol = protocol; }
+ WebCore::AuthenticatorTransport transport() const { return m_transport; }
+ fido::ProtocolVersion protocol() const { return m_protocol; }
+
virtual void transact(Vector<uint8_t>&& data, ResponseCallback&&) = 0;
virtual void cancel() { };
protected:
- CtapDriver() = default;
- fido::ProtocolVersion protocol() const { return m_protocol; }
+ CtapDriver(WebCore::AuthenticatorTransport transport)
+ : m_transport(transport) { }
private:
fido::ProtocolVersion m_protocol { fido::ProtocolVersion::kCtap };
+ WebCore::AuthenticatorTransport m_transport;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapHidDriver.cpp (292912 => 292913)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapHidDriver.cpp 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapHidDriver.cpp 2022-04-15 17:38:42 UTC (rev 292913)
@@ -157,7 +157,8 @@
}
CtapHidDriver::CtapHidDriver(UniqueRef<HidConnection>&& connection)
- : m_worker(makeUniqueRef<Worker>(WTFMove(connection)))
+ : CtapDriver(WebCore::AuthenticatorTransport::Usb)
+ , m_worker(makeUniqueRef<Worker>(WTFMove(connection)))
, m_nonce(kHidInitNonceLength)
{
}
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapNfcDriver.cpp (292912 => 292913)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapNfcDriver.cpp 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/fido/CtapNfcDriver.cpp 2022-04-15 17:38:42 UTC (rev 292913)
@@ -37,7 +37,8 @@
using namespace fido;
CtapNfcDriver::CtapNfcDriver(Ref<NfcConnection>&& connection)
- : m_connection(WTFMove(connection))
+ : CtapDriver(AuthenticatorTransport::Nfc)
+ , m_connection(WTFMove(connection))
{
}
Modified: trunk/Source/WebKit/UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp (292912 => 292913)
--- trunk/Source/WebKit/UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Source/WebKit/UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp 2022-04-15 17:38:42 UTC (rev 292913)
@@ -157,7 +157,7 @@
case ApduResponse::Status::SW_NO_ERROR: {
auto& options = std::get<PublicKeyCredentialCreationOptions>(requestData().options);
auto appId = processGoogleLegacyAppIdSupportExtension(options.extensions);
- auto response = readU2fRegisterResponse(!appId ? options.rp.id : appId, apduResponse.data(), AuthenticatorAttachment::CrossPlatform, options.attestation);
+ auto response = readU2fRegisterResponse(!appId ? options.rp.id : appId, apduResponse.data(), AuthenticatorAttachment::CrossPlatform, { driver().transport() }, options.attestation);
if (!response) {
receiveRespond(ExceptionData { UnknownError, "Couldn't parse the U2F register response."_s });
return;
Modified: trunk/Tools/ChangeLog (292912 => 292913)
--- trunk/Tools/ChangeLog 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Tools/ChangeLog 2022-04-15 17:38:42 UTC (rev 292913)
@@ -1,3 +1,17 @@
+2022-04-15 J Pascoe <[email protected]>
+
+ [WebAuthn] Implement getTransports() and getAuthenticatorData() on AuthenticatorAttestationResponse
+ https://bugs.webkit.org/show_bug.cgi?id=238966
+ rdar://problem/91449906
+
+ Reviewed by Brent Fulgham.
+
+ Add tests for parsing transports from getInfo.
+
+ * TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp:
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/Tests/WebCore/FidoTestData.h:
+
2022-04-14 Wenson Hsieh <[email protected]>
Undo option after invoking "Markup Image" says "Undo Paste"
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp (292912 => 292913)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp 2022-04-15 17:38:42 UTC (rev 292913)
@@ -34,6 +34,7 @@
#include "FidoTestData.h"
#include <_javascript_Core/ArrayBuffer.h>
#include <WebCore/AuthenticatorAttachment.h>
+#include <WebCore/AuthenticatorTransport.h>
#include <WebCore/BufferSource.h>
#include <WebCore/CBORReader.h>
#include <WebCore/CBORValue.h>
@@ -353,9 +354,9 @@
// 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(convertBytesToVector(TestData::kTestMakeCredentialResponse, sizeof(TestData::kTestMakeCredentialResponse)), AuthenticatorAttachment::CrossPlatform);
+ auto makeCredentialResponse = readCTAPMakeCredentialResponse(convertBytesToVector(TestData::kTestMakeCredentialResponse, sizeof(TestData::kTestMakeCredentialResponse)), AuthenticatorAttachment::CrossPlatform, { });
ASSERT_TRUE(makeCredentialResponse);
- auto cborAttestationObject = cbor::CBORReader::read(convertBytesToVector(reinterpret_cast<uint8_t*>(makeCredentialResponse->attestationObject()->data()), makeCredentialResponse->attestationObject()->byteLength()));
+ auto cborAttestationObject = cbor::CBORReader::read(convertArrayBufferToVector(makeCredentialResponse->attestationObject()));
ASSERT_TRUE(cborAttestationObject);
ASSERT_TRUE(cborAttestationObject->isMap());
@@ -610,6 +611,24 @@
EXPECT_EQ(AuthenticatorSupportedOptions::ClientPinAvailability::kSupportedButPinNotSet, getInfoResponse->options().clientPinAvailability());
}
+TEST(CTAPResponseTest, TestReadGetInfoResponseDeviceYubikey5c)
+{
+ auto getInfoResponse = readCTAPGetInfoResponse(convertBytesToVector(TestData::kTestGetInfoResponseDeviceYubikey5c, sizeof(TestData::kTestGetInfoResponseDeviceYubikey5c)));
+ 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_FALSE(getInfoResponse->options().isPlatformDevice());
+ EXPECT_EQ(AuthenticatorSupportedOptions::ResidentKeyAvailability::kSupported, getInfoResponse->options().residentKeyAvailability());
+ EXPECT_TRUE(getInfoResponse->options().userPresenceRequired());
+ EXPECT_EQ(AuthenticatorSupportedOptions::UserVerificationAvailability::kNotSupported, getInfoResponse->options().userVerificationAvailability());
+ EXPECT_EQ(AuthenticatorSupportedOptions::ClientPinAvailability::kSupportedAndPinSet, getInfoResponse->options().clientPinAvailability());
+ EXPECT_TRUE(getInfoResponse->transports());
+ EXPECT_EQ(getInfoResponse->transports()->size(), 1u);
+ EXPECT_EQ(AuthenticatorTransport::Usb, getInfoResponse->transports()->first());
+}
+
TEST(CTAPResponseTest, TestReadGetInfoResponseWithIncorrectFormat)
{
EXPECT_FALSE(readCTAPGetInfoResponse(convertBytesToVector(kTestAuthenticatorGetInfoResponseWithNoVersion, sizeof(kTestAuthenticatorGetInfoResponseWithNoVersion))));
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/FidoTestData.h (292912 => 292913)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/FidoTestData.h 2022-04-15 17:23:23 UTC (rev 292912)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/FidoTestData.h 2022-04-15 17:38:42 UTC (rev 292913)
@@ -1446,6 +1446,41 @@
0x08,
};
+constexpr uint8_t kTestGetInfoResponseDeviceYubikey5c[] = {
+ // Success
+ 0x00,
+ 0xAA, 0x01, 0x83, 0x66, 0x55, 0x32, 0x46, 0x5F, 0x56, 0x32, 0x68, 0x46,
+ 0x49, 0x44, 0x4F, 0x5F, 0x32, 0x5F, 0x30, 0x6C, 0x46, 0x49, 0x44, 0x4F,
+ 0x5F, 0x32, 0x5F, 0x31, 0x5F, 0x50, 0x52, 0x45, 0x02, 0x82, 0x6B, 0x63,
+ 0x72, 0x65, 0x64, 0x50, 0x72, 0x6F, 0x74, 0x65, 0x63, 0x74, 0x6B, 0x68,
+ 0x6D, 0x61, 0x63, 0x2D, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x03, 0x50,
+ 0xEE, 0x88, 0x28, 0x79, 0x72, 0x1C, 0x49, 0x13, 0x97, 0x75, 0x3D, 0xFC,
+ 0xCE, 0x97, 0x07, 0x2A, 0x04, 0xA5, 0x62, 0x72, 0x6B, 0xF5, 0x62, 0x75,
+ 0x70, 0xF5, 0x64, 0x70, 0x6C, 0x61, 0x74, 0xF4, 0x69, 0x63, 0x6C, 0x69,
+ 0x65, 0x6E, 0x74, 0x50, 0x69, 0x6E, 0xF5, 0x75, 0x63, 0x72, 0x65, 0x64,
+ 0x65, 0x6E, 0x74, 0x69, 0x61, 0x6C, 0x4D, 0x67, 0x6D, 0x74, 0x50, 0x72,
+ 0x65, 0x76, 0x69, 0x65, 0x77, 0xF5, 0x05, 0x19, 0x04, 0xB0, 0x06, 0x81,
+ 0x01,
+ // key(07) - maxCredentialCountInList
+ 0x07,
+ // value - unsigned(8)
+ 0x08,
+ // key(08) - maxCredentialIdLength
+ 0x08,
+ // value - unsigned(128)
+ 0x18, 0x80,
+ // key(09) - transports
+ 0x09,
+ // array(1)
+ 0x81,
+ // text(3) - "usb"
+ 0x63, 0x75, 0x73, 0x62,
+ 0x0A, 0x82, 0xA2, 0x63, 0x61, 0x6C, 0x67, 0x26, 0x64, 0x74, 0x79, 0x70,
+ 0x65, 0x6A, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x2D, 0x6B, 0x65, 0x79,
+ 0xA2, 0x63, 0x61, 0x6C, 0x67, 0x27, 0x64, 0x74, 0x79, 0x70, 0x65, 0x6A,
+ 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x2D, 0x6B, 0x65, 0x79,
+};
+
} // namespace TestData
} // namespace TestWebKitAPI