Changeset 285698 in webkit
- Timestamp:
- Nov 11, 2021, 5:42:42 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 22 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h (modified) (7 diffs)
-
Source/WebCore/Modules/webauthn/PublicKeyCredentialDescriptor.h (modified) (4 diffs)
-
Source/WebCore/Modules/webauthn/PublicKeyCredentialRequestOptions.h (modified) (4 diffs)
-
Source/WebCore/Modules/webauthn/cbor/CBORValue.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/webauthn/cbor/CBORValue.h (modified) (3 diffs)
-
Source/WebCore/Modules/webauthn/fido/DeviceRequestConverter.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/webauthn/fido/U2fCommandConstructor.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/webauthn/fido/U2fCommandConstructor.h (modified) (3 diffs)
-
Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.h (modified) (2 diffs)
-
Source/WebCore/bindings/js/BufferSource.h (modified) (3 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm (modified) (3 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm (modified) (4 diffs)
-
Source/WebKit/UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp (modified) (17 diffs)
-
Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WebCore/U2fCommandConstructorTest.cpp (modified) (12 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r285694 r285698 1 2021-11-11 Brent Fulgham <bfulgham@apple.com> 2 3 [WebAuthn] Stop serializing BufferSource and Vector<uint8_t> duplicates of identifiers 4 https://bugs.webkit.org/show_bug.cgi?id=233011 5 <rdar://problem/85313807> 6 7 Reviewed by Chris Dumez. 8 9 The original WebAuthn logic converted WebCore::BufferSource objects to Vector<uint8_t> 10 during serialization, which created a weird design where some code dealt with BufferSource 11 objects, and other with Vectors, and lots of converting to and from these types. It also caused 12 WebAuthn data structures to have two places where this information might live, with the 13 UIProcess using one representation, and the WebContent process using another. 14 15 This patch revises the code as follows: 16 17 1. The identifiers are always stored as BufferSource, and the same member is used in UIProcess 18 and WebContent process when accessing this information. 19 2. We now serialize BufferSource directly. 20 21 Tested by existing WebAuthn test cases (API and Layout tests) 22 23 * Modules/webauthn/PublicKeyCredentialCreationOptions.h: 24 (WebCore::PublicKeyCredentialCreationOptions::encode const): 25 (WebCore::PublicKeyCredentialCreationOptions::decode): 26 * Modules/webauthn/PublicKeyCredentialDescriptor.h: 27 (WebCore::PublicKeyCredentialDescriptor::encode const): 28 (WebCore::PublicKeyCredentialDescriptor::decode): 29 * Modules/webauthn/PublicKeyCredentialRequestOptions.h: 30 (WebCore::PublicKeyCredentialRequestOptions::decode): 31 * Modules/webauthn/cbor/CBORValue.cpp: 32 (cbor::CBORValue::CBORValue): 33 * Modules/webauthn/cbor/CBORValue.h: 34 * Modules/webauthn/fido/DeviceRequestConverter.cpp: 35 (fido::convertUserEntityToCBOR): 36 (fido::convertDescriptorToCBOR): 37 * Modules/webauthn/fido/U2fCommandConstructor.cpp: 38 (fido::WebCore::constructU2fSignCommand): 39 (fido::convertToU2fCheckOnlySignCommand): 40 (fido::convertToU2fSignCommand): 41 * Modules/webauthn/fido/U2fCommandConstructor.h: 42 * Modules/webauthn/fido/U2fResponseConverter.cpp: 43 (fido::readU2fSignResponse): 44 * Modules/webauthn/fido/U2fResponseConverter.h: 45 * bindings/js/BufferSource.h: 46 (WebCore::BufferSource::encode const): 47 (WebCore::BufferSource::decode): 48 (WebCore::toBufferSource): 49 1 50 2021-11-11 Michael Catanzaro <mcatanzaro@gnome.org> 2 51 -
trunk/Source/WebCore/Modules/webauthn/PublicKeyCredentialCreationOptions.h
r285475 r285698 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All rights reserved.2 * Copyright (C) 2018-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 52 52 53 53 struct UserEntity : public Entity { 54 BufferSource id; // id becomes idVector once it is passed to UIProcess. 55 Vector<uint8_t> idVector; 54 BufferSource id; 56 55 String displayName; 57 56 }; … … 77 76 UserEntity user; 78 77 79 BufferSource challenge; // challenge becomes challengeVector once it is passed to UIProcess.78 BufferSource challenge; 80 79 Vector<Parameters> pubKeyCredParams; 81 80 … … 86 85 mutable std::optional<AuthenticationExtensionsClientInputs> extensions; 87 86 88 Vector<uint8_t> challengeVector;89 90 87 template<class Encoder> void encode(Encoder&) const; 91 88 template<class Decoder> static std::optional<PublicKeyCredentialCreationOptions> decode(Decoder&); … … 144 141 { 145 142 encoder << rp.id << rp.name << rp.icon; 146 encoder << static_cast<uint64_t>(user.id.length()); 147 encoder.encodeFixedLengthData(user.id.data(), user.id.length(), 1); 143 encoder << user.id; 148 144 encoder << user.displayName << user.name << user.icon << pubKeyCredParams << timeout << excludeCredentials << authenticatorSelection << attestation << extensions; 149 145 encoder << static_cast<uint64_t>(challenge.length()); … … 161 157 if (!decoder.decode(result.rp.icon)) 162 158 return std::nullopt; 163 if (!decoder.decode(result.user.id Vector))159 if (!decoder.decode(result.user.id)) 164 160 return std::nullopt; 165 161 if (!decoder.decode(result.user.displayName)) … … 199 195 result.extensions = WTFMove(*extensions); 200 196 201 if (!decoder.decode(result.challenge Vector))197 if (!decoder.decode(result.challenge)) 202 198 return std::nullopt; 203 199 -
trunk/Source/WebCore/Modules/webauthn/PublicKeyCredentialDescriptor.h
r278253 r285698 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All rights reserved.2 * Copyright (C) 2018-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 36 36 struct PublicKeyCredentialDescriptor { 37 37 PublicKeyCredentialType type; 38 BufferSource id; // id becomes idVector once it is passed to UIProcess. 39 Vector<uint8_t> idVector; 38 BufferSource id; 40 39 Vector<AuthenticatorTransport> transports; 41 40 … … 48 47 { 49 48 encoder << type; 50 encoder << static_cast<uint64_t>(id.length()); 51 encoder.encodeFixedLengthData(id.data(), id.length(), 1); 49 encoder << id; 52 50 encoder << transports; 53 51 } … … 59 57 if (!decoder.decode(result.type)) 60 58 return std::nullopt; 61 if (!decoder.decode(result.id Vector))59 if (!decoder.decode(result.id)) 62 60 return std::nullopt; 63 61 if (!decoder.decode(result.transports)) -
trunk/Source/WebCore/Modules/webauthn/PublicKeyCredentialRequestOptions.h
r285475 r285698 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All rights reserved.2 * Copyright (C) 2018-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 39 39 struct PublicKeyCredentialRequestOptions { 40 40 #if ENABLE(WEB_AUTHN) 41 BufferSource challenge; // challenge becomes challengeVector once it is passed to UIProcess.41 BufferSource challenge; 42 42 std::optional<unsigned> timeout; 43 43 mutable String rpId; … … 46 46 std::optional<AuthenticatorAttachment> authenticatorAttachment; 47 47 mutable std::optional<AuthenticationExtensionsClientInputs> extensions; 48 49 Vector<uint8_t> challengeVector;50 48 51 49 template<class Encoder> void encode(Encoder&) const; … … 92 90 result.extensions = WTFMove(*extensions); 93 91 94 if (!decoder.decode(result.challenge Vector))92 if (!decoder.decode(result.challenge)) 95 93 return std::nullopt; 96 94 -
trunk/Source/WebCore/Modules/webauthn/cbor/CBORValue.cpp
r237983 r285698 1 1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Copyright (C) 2018 Apple Inc. All rights reserved.2 // Copyright (C) 2018-2021 Apple Inc. All rights reserved. 3 3 // 4 4 // Redistribution and use in source and binary forms, with or without … … 33 33 #if ENABLE(WEB_AUTHN) 34 34 35 #include "BufferSource.h" 35 36 #include <new> 36 37 #include <utility> … … 98 99 : m_type(Type::ByteString) 99 100 , m_byteStringValue(WTFMove(inBytes)) 101 { 102 } 103 104 CBORValue::CBORValue(const WebCore::BufferSource& bufferSource) 105 : m_type(Type::ByteString) 106 , m_byteStringValue(bufferSource.data(), bufferSource.length()) 100 107 { 101 108 } -
trunk/Source/WebCore/Modules/webauthn/cbor/CBORValue.h
r258293 r285698 1 1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Copyright (C) 2018 Apple Inc. All rights reserved.2 // Copyright (C) 2018-2021 Apple Inc. All rights reserved. 3 3 // 4 4 // Redistribution and use in source and binary forms, with or without … … 37 37 #include <wtf/Vector.h> 38 38 #include <wtf/text/WTFString.h> 39 40 namespace WebCore { 41 class BufferSource; 42 } 39 43 40 44 namespace cbor { … … 128 132 explicit CBORValue(BinaryValue&&); 129 133 134 explicit CBORValue(const WebCore::BufferSource&); 135 130 136 explicit CBORValue(const char*); 131 137 explicit CBORValue(String&&); -
trunk/Source/WebCore/Modules/webauthn/fido/DeviceRequestConverter.cpp
r278253 r285698 1 1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Copyright (C) 2018 Apple Inc. All rights reserved.2 // Copyright (C) 2018-2021 Apple Inc. All rights reserved. 3 3 // 4 4 // Redistribution and use in source and binary forms, with or without … … 62 62 if (!userEntity.icon.isEmpty()) 63 63 userMap.emplace(CBORValue(kIconUrlMapKey), CBORValue(userEntity.icon)); 64 userMap.emplace(CBORValue(kEntityIdMapKey), CBORValue(userEntity.id Vector));64 userMap.emplace(CBORValue(kEntityIdMapKey), CBORValue(userEntity.id)); 65 65 userMap.emplace(CBORValue(kDisplayNameMapKey), CBORValue(userEntity.displayName)); 66 66 return CBORValue(WTFMove(userMap)); … … 84 84 CBORValue::MapValue cborDescriptorMap; 85 85 cborDescriptorMap[CBORValue(kCredentialTypeKey)] = CBORValue(publicKeyCredentialTypeToString(descriptor.type)); 86 cborDescriptorMap[CBORValue(kCredentialIdKey)] = CBORValue(descriptor.id Vector);86 cborDescriptorMap[CBORValue(kCredentialIdKey)] = CBORValue(descriptor.id); 87 87 return CBORValue(WTFMove(cborDescriptorMap)); 88 88 } -
trunk/Source/WebCore/Modules/webauthn/fido/U2fCommandConstructor.cpp
r278340 r285698 1 1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Copyright (C) 2019 Apple Inc. All rights reserved.2 // Copyright (C) 2019-2021 Apple Inc. All rights reserved. 3 3 // 4 4 // Redistribution and use in source and binary forms, with or without … … 62 62 } 63 63 64 static std::optional<Vector<uint8_t>> constructU2fSignCommand(const Vector<uint8_t>& applicationParameter, const Vector<uint8_t>& challengeParameter, const Vector<uint8_t>& keyHandle, bool checkOnly)64 static std::optional<Vector<uint8_t>> constructU2fSignCommand(const Vector<uint8_t>& applicationParameter, const Vector<uint8_t>& challengeParameter, const BufferSource& keyHandle, bool checkOnly) 65 65 { 66 if (keyHandle. size() > kMaxKeyHandleLength)66 if (keyHandle.length() > kMaxKeyHandleLength) 67 67 return std::nullopt; 68 68 69 69 Vector<uint8_t> data; 70 data.reserveInitialCapacity(kU2fChallengeParamLength + kU2fApplicationParamLength + 1 + keyHandle. size());70 data.reserveInitialCapacity(kU2fChallengeParamLength + kU2fApplicationParamLength + 1 + keyHandle.length()); 71 71 data.appendVector(challengeParameter); 72 72 data.appendVector(applicationParameter); 73 data.append(static_cast<uint8_t>(keyHandle. size()));74 data.append Vector(keyHandle);73 data.append(static_cast<uint8_t>(keyHandle.length())); 74 data.append(keyHandle.data(), keyHandle.length()); 75 75 76 76 apdu::ApduCommand command; … … 112 112 return std::nullopt; 113 113 114 return constructU2fSignCommand(produceRpIdHash(request.rp.id), clientDataHash, keyHandle.id Vector, true /* checkOnly */);114 return constructU2fSignCommand(produceRpIdHash(request.rp.id), clientDataHash, keyHandle.id, true /* checkOnly */); 115 115 } 116 116 117 std::optional<Vector<uint8_t>> convertToU2fSignCommand(const Vector<uint8_t>& clientDataHash, const PublicKeyCredentialRequestOptions& request, const Vector<uint8_t>& keyHandle, bool isAppId)117 std::optional<Vector<uint8_t>> convertToU2fSignCommand(const Vector<uint8_t>& clientDataHash, const PublicKeyCredentialRequestOptions& request, const WebCore::BufferSource& keyHandle, bool isAppId) 118 118 { 119 119 if (!isConvertibleToU2fSignCommand(request)) -
trunk/Source/WebCore/Modules/webauthn/fido/U2fCommandConstructor.h
r278253 r285698 1 1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Copyright (C) 2019 Apple Inc. All rights reserved.2 // Copyright (C) 2019-2021 Apple Inc. All rights reserved. 3 3 // 4 4 // Redistribution and use in source and binary forms, with or without … … 35 35 36 36 namespace WebCore { 37 class BufferSource; 37 38 struct AuthenticationExtensionsClientInputs; 38 39 struct PublicKeyCredentialCreationOptions; … … 64 65 65 66 // Extracts APDU encoded U2F sign command from PublicKeyCredentialRequestOptions. 66 WEBCORE_EXPORT std::optional<Vector<uint8_t>> convertToU2fSignCommand(const Vector<uint8_t>& clientDataHash, const WebCore::PublicKeyCredentialRequestOptions&, const Vector<uint8_t>& keyHandle, bool isAppId = false);67 WEBCORE_EXPORT std::optional<Vector<uint8_t>> convertToU2fSignCommand(const Vector<uint8_t>& clientDataHash, const WebCore::PublicKeyCredentialRequestOptions&, const WebCore::BufferSource& keyHandle, bool isAppId = false); 67 68 68 69 WEBCORE_EXPORT Vector<uint8_t> constructBogusU2fRegistrationCommand(); -
trunk/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.cpp
r278358 r285698 164 164 } 165 165 166 RefPtr<AuthenticatorAssertionResponse> readU2fSignResponse(const String& rpId, const Vector<uint8_t>& keyHandle, const Vector<uint8_t>& u2fData, AuthenticatorAttachment attachment)166 RefPtr<AuthenticatorAssertionResponse> readU2fSignResponse(const String& rpId, const WebCore::BufferSource& keyHandle, const Vector<uint8_t>& u2fData, AuthenticatorAttachment attachment) 167 167 { 168 if ( keyHandle.isEmpty() || u2fData.size() <= signatureIndex)168 if (!keyHandle.length() || u2fData.size() <= signatureIndex) 169 169 return nullptr; 170 170 … … 179 179 // FIXME: Find a way to remove the need of constructing a vector here. 180 180 Vector<uint8_t> signature { u2fData.data() + signatureIndex, u2fData.size() - signatureIndex }; 181 return AuthenticatorAssertionResponse::create(keyHandle, authData, signature, { }, attachment); 181 Vector<uint8_t> keyHandleVector { keyHandle.data(), keyHandle.length() }; 182 return AuthenticatorAssertionResponse::create(keyHandleVector, authData, signature, { }, attachment); 182 183 } 183 184 -
trunk/Source/WebCore/Modules/webauthn/fido/U2fResponseConverter.h
r278358 r285698 37 37 #include <wtf/Forward.h> 38 38 39 namespace WebCore { 40 class BufferSource; 41 } 42 39 43 namespace fido { 40 44 … … 45 49 // Converts a U2F authentication response to WebAuthN getAssertion response. 46 50 // https://fidoalliance.org/specs/fido-v2.0-id-20180227/fido-client-to-authenticator-protocol-v2.0-id-20180227.html#u2f-authenticatorGetAssertion-interoperability 47 WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAssertionResponse> readU2fSignResponse(const String& rpId, const Vector<uint8_t>& keyHandle, const Vector<uint8_t>& u2fData, WebCore::AuthenticatorAttachment);51 WEBCORE_EXPORT RefPtr<WebCore::AuthenticatorAssertionResponse> readU2fSignResponse(const String& rpId, const WebCore::BufferSource& keyHandle, const Vector<uint8_t>& u2fData, WebCore::AuthenticatorAttachment); 48 52 49 53 } // namespace fido -
trunk/Source/WebCore/bindings/js/BufferSource.h
r284213 r285698 1 1 /* 2 2 * Copyright (C) 2016 Igalia S.L. 3 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 30 31 #include <variant> 31 32 #include <wtf/RefPtr.h> 33 34 #if PLATFORM(COCOA) && defined(__OBJC__) 35 OBJC_CLASS NSData; 36 #endif 32 37 33 38 namespace WebCore { … … 65 70 } 66 71 72 template<class Encoder> void encode(Encoder&) const; 73 template<class Decoder> static std::optional<BufferSource> decode(Decoder&); 74 67 75 private: 68 76 VariantType m_variant; 69 77 }; 70 78 79 template<class Encoder> 80 void BufferSource::encode(Encoder& encoder) const 81 { 82 encoder << static_cast<uint64_t>(length()); 83 if (!length()) 84 return; 85 86 encoder.encodeFixedLengthData(data(), length() * sizeof(uint8_t), alignof(uint8_t)); 87 } 88 89 template<class Decoder> 90 std::optional<BufferSource> BufferSource::decode(Decoder& decoder) 91 { 92 std::optional<uint64_t> size; 93 decoder >> size; 94 if (!size) 95 return std::nullopt; 96 if (!*size) 97 return BufferSource(); 98 99 auto dataSize = CheckedSize { *size }; 100 if (UNLIKELY(dataSize.hasOverflowed())) 101 return std::nullopt; 102 103 const uint8_t* data = decoder.decodeFixedLengthReference(dataSize, alignof(uint8_t)); 104 if (!data) 105 return std::nullopt; 106 return BufferSource(JSC::ArrayBuffer::tryCreate(static_cast<const void*>(data), dataSize.value())); 107 } 108 109 inline BufferSource toBufferSource(const uint8_t* data, size_t length) 110 { 111 return BufferSource(JSC::ArrayBuffer::tryCreate(data, length)); 112 } 113 114 #if PLATFORM(COCOA) && defined(__OBJC__) 115 inline BufferSource toBufferSource(NSData *data) 116 { 117 return BufferSource(JSC::ArrayBuffer::tryCreate(static_cast<const uint8_t*>(data.bytes), data.length)); 118 } 119 120 inline RetainPtr<NSData> toNSData(const BufferSource& data) 121 { 122 return adoptNS([[NSData alloc] initWithBytes:data.data() length:data.length()]); 123 } 124 #endif 125 71 126 } // namespace WebCore 127 128 #if PLATFORM(COCOA) && defined(__OBJC__) 129 using WebCore::toNSData; 130 #endif -
trunk/Source/WebKit/ChangeLog
r285694 r285698 1 2021-11-11 Brent Fulgham <bfulgham@apple.com> 2 3 [WebAuthn] Stop serializing BufferSource and Vector<uint8_t> duplicates of identifiers 4 https://bugs.webkit.org/show_bug.cgi?id=233011 5 <rdar://problem/85313807> 6 7 Reviewed by Chris Dumez. 8 9 The original WebAuthn logic converted WebCore::BufferSource objects to Vector<uint8_t> 10 during serialization, which created a weird design where some code dealt with BufferSource 11 objects, and other with Vectors, and lots of converting to and from these types. It also caused 12 WebAuthn data structures to have two places where this information might live, with the 13 UIProcess using one representation, and the WebContent process using another. 14 15 This patch revises the code as follows: 16 17 1. The identifiers are always stored as BufferSource, and the same member is used in UIProcess 18 and WebContent process when accessing this information. 19 2. We now serialize BufferSource directly. 20 21 Tested by existing WebAuthn test cases (API and Layout tests) 22 23 * UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm: 24 (publicKeyCredentialUserEntity): 25 (publicKeyCredentialDescriptors): 26 * UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm: 27 (WebKit::LocalAuthenticatorInternal::produceHashSet): 28 (WebKit::LocalAuthenticator::continueMakeCredentialAfterUserVerification): 29 (WebKit::LocalAuthenticator::deleteDuplicateCredential const): 30 * UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm: 31 (WebKit::toASCDescriptor): 32 (WebKit::configureRegistrationRequestContext): 33 (WebKit::configurationAssertionRequestContext): 34 * UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp: 35 (WebKit::U2fAuthenticator::issueSignCommand): 36 (WebKit::U2fAuthenticator::continueSignCommandAfterResponseReceived): 37 1 38 2021-11-11 Michael Catanzaro <mcatanzaro@gnome.org> 2 39 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm
r285617 r285698 390 390 result.name = userEntity.name; 391 391 result.icon = userEntity.icon; 392 result.id Vector = vectorFromNSData(userEntity.identifier);392 result.id = WebCore::toBufferSource(userEntity.identifier); 393 393 result.displayName = userEntity.displayName; 394 394 … … 439 439 440 440 for (_WKPublicKeyCredentialDescriptor *credential : credentials) 441 result.uncheckedAppend({ WebCore::PublicKeyCredentialType::PublicKey, { }, vectorFromNSData(credential.identifier), authenticatorTransports(credential.transports) });441 result.uncheckedAppend({ WebCore::PublicKeyCredentialType::PublicKey, WebCore::toBufferSource(credential.identifier), authenticatorTransports(credential.transports) }); 442 442 443 443 return result; -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm
r284532 r285698 85 85 HashSet<String> result; 86 86 for (auto& credentialDescriptor : credentialDescriptors) { 87 if (emptyTransportsOrContain(credentialDescriptor.transports, AuthenticatorTransport::Internal) && credentialDescriptor.type == PublicKeyCredentialType::PublicKey && credentialDescriptor.id Vector.size() == credentialIdLength)88 result.add(base64EncodeToString(credentialDescriptor.id Vector.data(), credentialDescriptor.idVector.size()));87 if (emptyTransportsOrContain(credentialDescriptor.transports, AuthenticatorTransport::Internal) && credentialDescriptor.type == PublicKeyCredentialType::PublicKey && credentialDescriptor.id.length() == credentialIdLength) 88 result.add(base64EncodeToString(credentialDescriptor.id.data(), credentialDescriptor.id.length())); 89 89 } 90 90 return result; … … 354 354 355 355 cbor::CBORValue::MapValue userEntityMap; 356 userEntityMap[cbor::CBORValue(fido::kEntityIdMapKey)] = cbor::CBORValue(creationOptions.user.id Vector);356 userEntityMap[cbor::CBORValue(fido::kEntityIdMapKey)] = cbor::CBORValue(creationOptions.user.id); 357 357 userEntityMap[cbor::CBORValue(fido::kEntityNameMapKey)] = cbor::CBORValue(creationOptions.user.name); 358 358 auto userEntity = cbor::CBORWriter::write(cbor::CBORValue(WTFMove(userEntityMap))); … … 687 687 auto* userHandle = credential->userHandle(); 688 688 ASSERT(userHandle); 689 if (userHandle->byteLength() != creationOptions.user.id Vector.size())689 if (userHandle->byteLength() != creationOptions.user.id.length()) 690 690 return false; 691 if (memcmp(userHandle->data(), creationOptions.user.id Vector.data(), userHandle->byteLength()))691 if (memcmp(userHandle->data(), creationOptions.user.id.data(), userHandle->byteLength())) 692 692 return false; 693 693 -
trunk/Source/WebKit/UIProcess/WebAuthentication/Cocoa/WebAuthenticatorCoordinatorProxy.mm
r285537 r285698 48 48 { 49 49 return ArrayBuffer::create(reinterpret_cast<const uint8_t*>(data.bytes), data.length); 50 }51 52 static inline RetainPtr<NSData> toNSData(const BufferSource& data)53 {54 return adoptNS([[NSData alloc] initWithBytes:data.data() length:data.length()]);55 50 } 56 51 … … 152 147 } 153 148 154 return adoptNS([allocASCPublicKeyCredentialDescriptorInstance() initWithCredentialID:toNSData(descriptor.id Vector).get() transports:transports.get()]);149 return adoptNS([allocASCPublicKeyCredentialDescriptorInstance() initWithCredentialID:toNSData(descriptor.id).get() transports:transports.get()]); 155 150 } 156 151 … … 179 174 auto credentialCreationOptions = adoptNS([allocASCPublicKeyCredentialCreationOptionsInstance() init]); 180 175 181 [credentialCreationOptions setChallenge:toNSData(options.challenge Vector).get()];176 [credentialCreationOptions setChallenge:toNSData(options.challenge).get()]; 182 177 [credentialCreationOptions setRelyingPartyIdentifier:options.rp.id]; 183 178 [credentialCreationOptions setUserName:options.user.name]; 184 [credentialCreationOptions setUserIdentifier:toNSData(options.user.id Vector).get()];179 [credentialCreationOptions setUserIdentifier:toNSData(options.user.id.data()).get()]; 185 180 [credentialCreationOptions setUserDisplayName:options.user.displayName]; 186 181 [credentialCreationOptions setUserVerificationPreference:userVerification.get()]; … … 237 232 [requestContext setRelyingPartyIdentifier:options.rpId]; 238 233 239 auto challenge = toNSData(options.challenge Vector);234 auto challenge = toNSData(options.challenge); 240 235 241 236 if (requestTypes & ASCCredentialRequestTypePlatformPublicKeyAssertion) -
trunk/Source/WebKit/UIProcess/WebAuthentication/fido/U2fAuthenticator.cpp
r284095 r285698 105 105 return; 106 106 } 107 auto u2fCmd = convertToU2fSignCommand(requestData().hash, requestOptions, requestOptions.allowCredentials[index].id Vector, m_isAppId);107 auto u2fCmd = convertToU2fSignCommand(requestData().hash, requestOptions, requestOptions.allowCredentials[index].id, m_isAppId); 108 108 ASSERT(u2fCmd); 109 109 issueNewCommand(WTFMove(*u2fCmd), CommandType::SignCommand); … … 210 210 if (m_isAppId) { 211 211 ASSERT(requestOptions.extensions && !requestOptions.extensions->appid.isNull()); 212 response = readU2fSignResponse(requestOptions.extensions->appid, requestOptions.allowCredentials[m_nextListIndex - 1].id Vector, apduResponse.data(), AuthenticatorAttachment::CrossPlatform);212 response = readU2fSignResponse(requestOptions.extensions->appid, requestOptions.allowCredentials[m_nextListIndex - 1].id, apduResponse.data(), AuthenticatorAttachment::CrossPlatform); 213 213 } else 214 response = readU2fSignResponse(requestOptions.rpId, requestOptions.allowCredentials[m_nextListIndex - 1].id Vector, apduResponse.data(), AuthenticatorAttachment::CrossPlatform);214 response = readU2fSignResponse(requestOptions.rpId, requestOptions.allowCredentials[m_nextListIndex - 1].id, apduResponse.data(), AuthenticatorAttachment::CrossPlatform); 215 215 if (!response) { 216 216 receiveRespond(ExceptionData { UnknownError, "Couldn't parse the U2F sign response."_s }); -
trunk/Tools/ChangeLog
r285677 r285698 1 2021-11-11 Brent Fulgham <bfulgham@apple.com> 2 3 [WebAuthn] Stop serializing BufferSource and Vector<uint8_t> duplicates of identifiers 4 https://bugs.webkit.org/show_bug.cgi?id=233011 5 <rdar://problem/85313807> 6 7 Reviewed by Chris Dumez. 8 9 The original WebAuthn logic converted WebCore::BufferSource objects to Vector<uint8_t> 10 during serialization, which created a weird design where some code dealt with BufferSource 11 objects, and other with Vectors, and lots of converting to and from these types. It also caused 12 WebAuthn data structures to have two places where this information might live, with the 13 UIProcess using one representation, and the WebContent process using another. 14 15 This patch revises the code as follows: 16 17 1. The identifiers are always stored as BufferSource, and the same member is used in UIProcess 18 and WebContent process when accessing this information. 19 2. We now serialize BufferSource directly. 20 21 Tested by existing WebAuthn test cases (API and Layout tests) 22 23 * TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp: 24 (TestWebKitAPI::TEST): 25 * TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp: 26 (TestWebKitAPI::getTestCredentialRawIdBytes): 27 (TestWebKitAPI::TEST): 28 * TestWebKitAPI/Tests/WebCore/U2fCommandConstructorTest.cpp: 29 (TestWebKitAPI::constructMakeCredentialRequest): 30 (TestWebKitAPI::TEST): 31 * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm: 32 (TestWebKitAPI::TEST): 33 1 34 2021-11-11 Andres Gonzalez <andresg_22@apple.com> 2 35 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapRequestTest.cpp
r285475 r285698 1 1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Copyright (C) 2018 Apple Inc. All rights reserved.2 // Copyright (C) 2018-2021 Apple Inc. All rights reserved. 3 3 // 4 4 // Redistribution and use in source and binary forms, with or without … … 57 57 user.name = "johnpsmith@example.com"; 58 58 user.icon = "https://pics.acme.com/00/p/aBjjjpqPb.png"; 59 user.id Vector.append(TestData::kUserId, sizeof(TestData::kUserId));59 user.id = WebCore::toBufferSource(TestData::kUserId, sizeof(TestData::kUserId)); 60 60 user.displayName = "John P. Smith"; 61 61 … … 63 63 PublicKeyCredentialCreationOptions::AuthenticatorSelectionCriteria selection { AuthenticatorAttachment::Platform, true, UserVerificationRequirement::Preferred }; 64 64 65 PublicKeyCredentialCreationOptions options { rp, user, { }, params, std::nullopt, { }, selection, AttestationConveyancePreference::None, std::nullopt , { }};65 PublicKeyCredentialCreationOptions options { rp, user, { }, params, std::nullopt, { }, selection, AttestationConveyancePreference::None, std::nullopt }; 66 66 Vector<uint8_t> hash; 67 67 hash.append(TestData::kClientDataHash, sizeof(TestData::kClientDataHash)); … … 80 80 user.name = "johnpsmith@example.com"; 81 81 user.icon = "https://pics.acme.com/00/p/aBjjjpqPb.png"; 82 user.id Vector.append(TestData::kUserId, sizeof(TestData::kUserId));82 user.id = WebCore::toBufferSource(TestData::kUserId, sizeof(TestData::kUserId)); 83 83 user.displayName = "John P. Smith"; 84 84 … … 86 86 PublicKeyCredentialCreationOptions::AuthenticatorSelectionCriteria selection { AuthenticatorAttachment::Platform, false, UserVerificationRequirement::Discouraged }; 87 87 88 PublicKeyCredentialCreationOptions options { rp, user, { }, params, std::nullopt, { }, selection, AttestationConveyancePreference::None, std::nullopt , { }};88 PublicKeyCredentialCreationOptions options { rp, user, { }, params, std::nullopt, { }, selection, AttestationConveyancePreference::None, std::nullopt }; 89 89 Vector<uint8_t> hash; 90 90 hash.append(TestData::kClientDataHash, sizeof(TestData::kClientDataHash)); … … 103 103 user.name = "johnpsmith@example.com"; 104 104 user.icon = "https://pics.acme.com/00/p/aBjjjpqPb.png"; 105 user.id Vector.append(TestData::kUserId, sizeof(TestData::kUserId));105 user.id = WebCore::toBufferSource(TestData::kUserId, sizeof(TestData::kUserId)); 106 106 user.displayName = "John P. Smith"; 107 107 … … 109 109 PublicKeyCredentialCreationOptions::AuthenticatorSelectionCriteria selection { AuthenticatorAttachment::Platform, false, UserVerificationRequirement::Required }; 110 110 111 PublicKeyCredentialCreationOptions options { rp, user, { }, params, std::nullopt, { }, selection, AttestationConveyancePreference::None, std::nullopt , { }};111 PublicKeyCredentialCreationOptions options { rp, user, { }, params, std::nullopt, { }, selection, AttestationConveyancePreference::None, std::nullopt }; 112 112 Vector<uint8_t> hash; 113 113 hash.append(TestData::kClientDataHash, sizeof(TestData::kClientDataHash)); … … 126 126 user.name = "johnpsmith@example.com"; 127 127 user.icon = "https://pics.acme.com/00/p/aBjjjpqPb.png"; 128 user.id Vector.append(TestData::kUserId, sizeof(TestData::kUserId));128 user.id = WebCore::toBufferSource(TestData::kUserId, sizeof(TestData::kUserId)); 129 129 user.displayName = "John P. Smith"; 130 130 … … 136 136 pin.auth.append(TestData::kCtap2PinAuth, sizeof(TestData::kCtap2PinAuth)); 137 137 138 PublicKeyCredentialCreationOptions options { rp, user, { }, params, std::nullopt, { }, selection, AttestationConveyancePreference::None, std::nullopt , { }};138 PublicKeyCredentialCreationOptions options { rp, user, { }, params, std::nullopt, { }, selection, AttestationConveyancePreference::None, std::nullopt }; 139 139 Vector<uint8_t> hash; 140 140 hash.append(TestData::kClientDataHash, sizeof(TestData::kClientDataHash)); … … 158 158 0x08, 0xd9, 0x4f, 0xcb, 0xee, 0x82, 0xb9, 0xb2, 0xef, 0x66, 0x77, 159 159 0xaf, 0x0a, 0xdc, 0xc3, 0x58, 0x52, 0xea, 0x6b, 0x9e }; 160 descriptor1.id Vector.append(id1, sizeof(id1));160 descriptor1.id = WebCore::toBufferSource(id1, sizeof(id1)); 161 161 options.allowCredentials.append(descriptor1); 162 162 … … 169 169 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 170 170 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; 171 descriptor2.id Vector.append(id2, sizeof(id2));171 descriptor2.id = WebCore::toBufferSource(id2, sizeof(id2)); 172 172 options.allowCredentials.append(descriptor2); 173 173 … … 195 195 0x08, 0xd9, 0x4f, 0xcb, 0xee, 0x82, 0xb9, 0xb2, 0xef, 0x66, 0x77, 196 196 0xaf, 0x0a, 0xdc, 0xc3, 0x58, 0x52, 0xea, 0x6b, 0x9e }; 197 descriptor1.id Vector.append(id1, sizeof(id1));197 descriptor1.id = WebCore::toBufferSource(id1, sizeof(id1)); 198 198 options.allowCredentials.append(descriptor1); 199 199 … … 206 206 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 207 207 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; 208 descriptor2.id Vector.append(id2, sizeof(id2));208 descriptor2.id = WebCore::toBufferSource(id2, sizeof(id2)); 209 209 options.allowCredentials.append(descriptor2); 210 210 … … 232 232 0x08, 0xd9, 0x4f, 0xcb, 0xee, 0x82, 0xb9, 0xb2, 0xef, 0x66, 0x77, 233 233 0xaf, 0x0a, 0xdc, 0xc3, 0x58, 0x52, 0xea, 0x6b, 0x9e }; 234 descriptor1.id Vector.append(id1, sizeof(id1));234 descriptor1.id = WebCore::toBufferSource(id1, sizeof(id1)); 235 235 options.allowCredentials.append(descriptor1); 236 236 … … 243 243 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 244 244 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; 245 descriptor2.id Vector.append(id2, sizeof(id2));245 descriptor2.id = WebCore::toBufferSource(id2, sizeof(id2)); 246 246 options.allowCredentials.append(descriptor2); 247 247 … … 269 269 0x08, 0xd9, 0x4f, 0xcb, 0xee, 0x82, 0xb9, 0xb2, 0xef, 0x66, 0x77, 270 270 0xaf, 0x0a, 0xdc, 0xc3, 0x58, 0x52, 0xea, 0x6b, 0x9e }; 271 descriptor1.id Vector.append(id1, sizeof(id1));271 descriptor1.id = WebCore::toBufferSource(id1, sizeof(id1)); 272 272 options.allowCredentials.append(descriptor1); 273 273 … … 280 280 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 281 281 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; 282 descriptor2.id Vector.append(id2, sizeof(id2));282 descriptor2.id = WebCore::toBufferSource(id2, sizeof(id2)); 283 283 options.allowCredentials.append(descriptor2); 284 284 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/CtapResponseTest.cpp
r283605 r285698 1 1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Copyright (C) 2018 Apple Inc. All rights reserved.2 // Copyright (C) 2018-2021 Apple Inc. All rights reserved. 3 3 // 4 4 // Redistribution and use in source and binary forms, with or without … … 35 35 #include <JavaScriptCore/ArrayBuffer.h> 36 36 #include <WebCore/AuthenticatorAttachment.h> 37 #include <WebCore/BufferSource.h> 37 38 #include <WebCore/CBORReader.h> 38 39 #include <WebCore/CBORValue.h> … … 334 335 335 336 // Return a key handle used for GetAssertion request. 336 Vector<uint8_t> getTestCredentialRawIdBytes() 337 { 338 Vector<uint8_t> testCredentialRawIdBytes; 339 testCredentialRawIdBytes.reserveInitialCapacity(sizeof(TestData::kU2fSignKeyHandle)); 340 testCredentialRawIdBytes.append(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)); 341 return testCredentialRawIdBytes; 337 BufferSource getTestCredentialRawIdBytes() 338 { 339 return WebCore::toBufferSource(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)); 342 340 } 343 341 … … 559 557 TEST(CTAPResponseTest, TestParseU2fSignWithNullKeyHandle) 560 558 { 561 auto response = readU2fSignResponse(TestData::kRelyingPartyId, Vector<uint8_t>(), getTestSignResponse(), AuthenticatorAttachment::CrossPlatform);559 auto response = readU2fSignResponse(TestData::kRelyingPartyId, BufferSource(), getTestSignResponse(), AuthenticatorAttachment::CrossPlatform); 562 560 EXPECT_FALSE(response); 563 561 } -
trunk/Tools/TestWebKitAPI/Tests/WebCore/U2fCommandConstructorTest.cpp
r250659 r285698 1 1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Copyright (C) 2019 Apple Inc. All rights reserved.2 // Copyright (C) 2019-2021 Apple Inc. All rights reserved. 3 3 // 4 4 // Redistribution and use in source and binary forms, with or without … … 51 51 52 52 PublicKeyCredentialCreationOptions::UserEntity user; 53 user.id Vector = convertBytesToVector(TestData::kUserId, sizeof(TestData::kUserId));53 user.id = WebCore::toBufferSource(TestData::kUserId, sizeof(TestData::kUserId)); 54 54 user.name = "johnpsmith@example.com"; 55 55 user.displayName = "John P. Smith"; … … 113 113 PublicKeyCredentialDescriptor credentialDescriptor; 114 114 credentialDescriptor.type = PublicKeyCredentialType::PublicKey; 115 credentialDescriptor.id Vector = convertBytesToVector(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle));115 credentialDescriptor.id = WebCore::toBufferSource(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)); 116 116 Vector<PublicKeyCredentialDescriptor> excludeList; 117 117 excludeList.append(credentialDescriptor); … … 129 129 PublicKeyCredentialDescriptor credentialDescriptor; 130 130 credentialDescriptor.type = static_cast<PublicKeyCredentialType>(-1); 131 credentialDescriptor.id Vector = convertBytesToVector(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle));131 credentialDescriptor.id = WebCore::toBufferSource(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)); 132 132 Vector<PublicKeyCredentialDescriptor> excludeList; 133 133 excludeList.append(credentialDescriptor); … … 146 146 147 147 PublicKeyCredentialCreationOptions::UserEntity user; 148 user.id Vector = convertBytesToVector(TestData::kUserId, sizeof(TestData::kUserId));148 user.id = WebCore::toBufferSource(TestData::kUserId, sizeof(TestData::kUserId)); 149 149 user.name = "johnpsmith@example.com"; 150 150 user.displayName = "John P. Smith"; … … 188 188 PublicKeyCredentialDescriptor credentialDescriptor; 189 189 credentialDescriptor.type = PublicKeyCredentialType::PublicKey; 190 credentialDescriptor.id Vector = convertBytesToVector(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle));190 credentialDescriptor.id = WebCore::toBufferSource(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)); 191 191 Vector<PublicKeyCredentialDescriptor> allowedList; 192 192 allowedList.append(WTFMove(credentialDescriptor)); … … 194 194 EXPECT_TRUE(isConvertibleToU2fSignCommand(getAssertionReq)); 195 195 196 const auto u2fSignCommand = convertToU2fSignCommand(convertBytesToVector(TestData::kClientDataHash, sizeof(TestData::kClientDataHash)), getAssertionReq, convertBytesToVector(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)));196 const auto u2fSignCommand = convertToU2fSignCommand(convertBytesToVector(TestData::kClientDataHash, sizeof(TestData::kClientDataHash)), getAssertionReq, WebCore::toBufferSource(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle))); 197 197 ASSERT_TRUE(u2fSignCommand); 198 198 EXPECT_EQ(*u2fSignCommand, convertBytesToVector(TestData::kU2fSignCommandApdu, sizeof(TestData::kU2fSignCommandApdu))); … … 204 204 PublicKeyCredentialDescriptor credentialDescriptor; 205 205 credentialDescriptor.type = PublicKeyCredentialType::PublicKey; 206 credentialDescriptor.id Vector = convertBytesToVector(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle));206 credentialDescriptor.id = WebCore::toBufferSource(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)); 207 207 Vector<PublicKeyCredentialDescriptor> allowedList; 208 208 allowedList.append(WTFMove(credentialDescriptor)); … … 215 215 getAssertionReq.extensions = WTFMove(extensions); 216 216 217 const auto u2fSignCommand = convertToU2fSignCommand(convertBytesToVector(TestData::kClientDataHash, sizeof(TestData::kClientDataHash)), getAssertionReq, convertBytesToVector(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)), true);217 const auto u2fSignCommand = convertToU2fSignCommand(convertBytesToVector(TestData::kClientDataHash, sizeof(TestData::kClientDataHash)), getAssertionReq, WebCore::toBufferSource(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)), true); 218 218 ASSERT_TRUE(u2fSignCommand); 219 219 EXPECT_EQ(*u2fSignCommand, convertBytesToVector(TestData::kU2fAppIDSignCommandApdu, sizeof(TestData::kU2fAppIDSignCommandApdu))); … … 231 231 PublicKeyCredentialDescriptor credentialDescriptor; 232 232 credentialDescriptor.type = PublicKeyCredentialType::PublicKey; 233 credentialDescriptor.id Vector = convertBytesToVector(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle));233 credentialDescriptor.id = WebCore::toBufferSource(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)); 234 234 Vector<PublicKeyCredentialDescriptor> allowedList; 235 235 allowedList.append(WTFMove(credentialDescriptor)); … … 245 245 PublicKeyCredentialDescriptor credentialDescriptor; 246 246 credentialDescriptor.type = PublicKeyCredentialType::PublicKey; 247 credentialDescriptor.id Vector = convertBytesToVector(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle));247 credentialDescriptor.id = WebCore::toBufferSource(TestData::kU2fSignKeyHandle, sizeof(TestData::kU2fSignKeyHandle)); 248 248 Vector<PublicKeyCredentialDescriptor> allowedList; 249 249 allowedList.append(WTFMove(credentialDescriptor)); … … 252 252 253 253 Vector<uint8_t> keyHandle(kMaxKeyHandleLength, 0xff); 254 const auto validSignCommand = convertToU2fSignCommand(convertBytesToVector(TestData::kClientDataHash, sizeof(TestData::kClientDataHash)), getAssertionReq, keyHandle);254 const auto validSignCommand = convertToU2fSignCommand(convertBytesToVector(TestData::kClientDataHash, sizeof(TestData::kClientDataHash)), getAssertionReq, WebCore::toBufferSource(keyHandle.data(), keyHandle.size())); 255 255 EXPECT_TRUE(validSignCommand); 256 256 257 257 keyHandle.append(0xff); 258 const auto invalidSignCommand = convertToU2fSignCommand(convertBytesToVector(TestData::kClientDataHash, sizeof(TestData::kClientDataHash)), getAssertionReq, keyHandle);258 const auto invalidSignCommand = convertToU2fSignCommand(convertBytesToVector(TestData::kClientDataHash, sizeof(TestData::kClientDataHash)), getAssertionReq, WebCore::toBufferSource(keyHandle.data(), keyHandle.size())); 259 259 EXPECT_FALSE(invalidSignCommand); 260 260 } -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm
r285619 r285698 1 1 /* 2 * Copyright (C) 2019 Apple Inc. All rights reserved.2 * Copyright (C) 2019-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 1624 1624 EXPECT_WK_STREQ(result.user.name, "jappleseed@example.com"); 1625 1625 EXPECT_TRUE(result.user.icon.isNull()); 1626 EXPECT_EQ(result.user.id Vector.size(), sizeof(identifier));1627 EXPECT_EQ(memcmp(result.user.id Vector.data(), identifier, sizeof(identifier)), 0);1626 EXPECT_EQ(result.user.id.length(), sizeof(identifier)); 1627 EXPECT_EQ(memcmp(result.user.id.data(), identifier, sizeof(identifier)), 0); 1628 1628 EXPECT_WK_STREQ(result.user.displayName, "J Appleseed"); 1629 1629 … … 1668 1668 EXPECT_WK_STREQ(result.user.name, "jappleseed@example.com"); 1669 1669 EXPECT_TRUE(result.user.icon.isNull()); 1670 EXPECT_EQ(result.user.id Vector.size(), sizeof(identifier));1671 EXPECT_EQ(memcmp(result.user.id Vector.data(), identifier, sizeof(identifier)), 0);1670 EXPECT_EQ(result.user.id.length(), sizeof(identifier)); 1671 EXPECT_EQ(memcmp(result.user.id.data(), identifier, sizeof(identifier)), 0); 1672 1672 EXPECT_WK_STREQ(result.user.displayName, "J Appleseed"); 1673 1673 … … 1682 1682 EXPECT_EQ(result.excludeCredentials.size(), 1lu); 1683 1683 EXPECT_EQ(result.excludeCredentials[0].type, WebCore::PublicKeyCredentialType::PublicKey); 1684 EXPECT_EQ(result.excludeCredentials[0].id Vector.size(), sizeof(identifier));1685 EXPECT_EQ(memcmp(result.excludeCredentials[0].id Vector.data(), identifier, sizeof(identifier)), 0);1684 EXPECT_EQ(result.excludeCredentials[0].id.length(), sizeof(identifier)); 1685 EXPECT_EQ(memcmp(result.excludeCredentials[0].id.data(), identifier, sizeof(identifier)), 0); 1686 1686 1687 1687 EXPECT_EQ(result.authenticatorSelection->authenticatorAttachment, std::nullopt); … … 1735 1735 EXPECT_WK_STREQ(result.user.name, "jappleseed@example.com"); 1736 1736 EXPECT_WK_STREQ(result.user.icon, @"https//www.example.com/icon.jpg"); 1737 EXPECT_EQ(result.user.id Vector.size(), sizeof(identifier));1738 EXPECT_EQ(memcmp(result.user.id Vector.data(), identifier, sizeof(identifier)), 0);1737 EXPECT_EQ(result.user.id.length(), sizeof(identifier)); 1738 EXPECT_EQ(memcmp(result.user.id.data(), identifier, sizeof(identifier)), 0); 1739 1739 EXPECT_WK_STREQ(result.user.displayName, "J Appleseed"); 1740 1740 … … 1749 1749 EXPECT_EQ(result.excludeCredentials.size(), 2lu); 1750 1750 EXPECT_EQ(result.excludeCredentials[0].type, WebCore::PublicKeyCredentialType::PublicKey); 1751 EXPECT_EQ(result.excludeCredentials[0].id Vector.size(), sizeof(identifier));1752 EXPECT_EQ(memcmp(result.excludeCredentials[0].id Vector.data(), identifier, sizeof(identifier)), 0);1751 EXPECT_EQ(result.excludeCredentials[0].id.length(), sizeof(identifier)); 1752 EXPECT_EQ(memcmp(result.excludeCredentials[0].id.data(), identifier, sizeof(identifier)), 0); 1753 1753 EXPECT_EQ(result.excludeCredentials[0].transports.size(), 3lu); 1754 1754 EXPECT_EQ(result.excludeCredentials[0].transports[0], AuthenticatorTransport::Usb); … … 1805 1805 EXPECT_WK_STREQ(result.user.name, "jappleseed@example.com"); 1806 1806 EXPECT_WK_STREQ(result.user.icon, @"https//www.example.com/icon.jpg"); 1807 EXPECT_EQ(result.user.id Vector.size(), sizeof(identifier));1808 EXPECT_EQ(memcmp(result.user.id Vector.data(), identifier, sizeof(identifier)), 0);1807 EXPECT_EQ(result.user.id.length(), sizeof(identifier)); 1808 EXPECT_EQ(memcmp(result.user.id.data(), identifier, sizeof(identifier)), 0); 1809 1809 EXPECT_WK_STREQ(result.user.displayName, "J Appleseed"); 1810 1810 … … 1819 1819 EXPECT_EQ(result.excludeCredentials.size(), 2lu); 1820 1820 EXPECT_EQ(result.excludeCredentials[0].type, WebCore::PublicKeyCredentialType::PublicKey); 1821 EXPECT_EQ(result.excludeCredentials[0].id Vector.size(), sizeof(identifier));1822 EXPECT_EQ(memcmp(result.excludeCredentials[0].id Vector.data(), identifier, sizeof(identifier)), 0);1821 EXPECT_EQ(result.excludeCredentials[0].id.length(), sizeof(identifier)); 1822 EXPECT_EQ(memcmp(result.excludeCredentials[0].id.data(), identifier, sizeof(identifier)), 0); 1823 1823 EXPECT_EQ(result.excludeCredentials[0].transports.size(), 3lu); 1824 1824 EXPECT_EQ(result.excludeCredentials[0].transports[0], AuthenticatorTransport::Usb); … … 1932 1932 EXPECT_EQ(result.allowCredentials.size(), 1lu); 1933 1933 EXPECT_EQ(result.allowCredentials[0].type, WebCore::PublicKeyCredentialType::PublicKey); 1934 EXPECT_EQ(result.allowCredentials[0].id Vector.size(), sizeof(identifier));1935 EXPECT_EQ(memcmp(result.allowCredentials[0].id Vector.data(), identifier, sizeof(identifier)), 0);1934 EXPECT_EQ(result.allowCredentials[0].id.length(), sizeof(identifier)); 1935 EXPECT_EQ(memcmp(result.allowCredentials[0].id.data(), identifier, sizeof(identifier)), 0); 1936 1936 1937 1937 EXPECT_EQ(result.userVerification, UserVerificationRequirement::Preferred); … … 1966 1966 EXPECT_EQ(result.allowCredentials.size(), 2lu); 1967 1967 EXPECT_EQ(result.allowCredentials[0].type, WebCore::PublicKeyCredentialType::PublicKey); 1968 EXPECT_EQ(result.allowCredentials[0].id Vector.size(), sizeof(identifier));1969 EXPECT_EQ(memcmp(result.allowCredentials[0].id Vector.data(), identifier, sizeof(identifier)), 0);1968 EXPECT_EQ(result.allowCredentials[0].id.length(), sizeof(identifier)); 1969 EXPECT_EQ(memcmp(result.allowCredentials[0].id.data(), identifier, sizeof(identifier)), 0); 1970 1970 EXPECT_EQ(result.allowCredentials[0].transports.size(), 3lu); 1971 1971 EXPECT_EQ(result.allowCredentials[0].transports[0], AuthenticatorTransport::Usb);
Note:
See TracChangeset
for help on using the changeset viewer.