Commit 7d7d488c authored by Adam Langley's avatar Adam Langley Committed by Commit Bot

device/fido: rename some caBLE constants.

As suggested in https://chromium-review.googlesource.com/c/chromium/src/+/1752937/3/chrome/browser/ui/views/webauthn/authenticator_qr_sheet_view.cc#222

Change-Id: I3401c7c77f6b3989383ecda1d8e68c173aa5ff92
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1754709
Commit-Queue: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Reviewed-by: default avatarMartin Kreichgauer <martinkr@google.com>
Auto-Submit: Adam Langley <agl@chromium.org>
Cr-Commit-Position: refs/heads/master@{#687317}
parent 4f833444
......@@ -189,17 +189,17 @@ struct BLINK_COMMON_EXPORT
return in.version;
}
static const device::EidArray& client_eid(
static const device::CableEidArray& client_eid(
const device::CableDiscoveryData& in) {
return in.client_eid;
}
static const device::EidArray& authenticator_eid(
static const device::CableEidArray& authenticator_eid(
const device::CableDiscoveryData& in) {
return in.authenticator_eid;
}
static const device::SessionPreKeyArray& session_pre_key(
static const device::CableSessionPreKeyArray& session_pre_key(
const device::CableDiscoveryData& in) {
return in.session_pre_key;
}
......
......@@ -26,28 +26,28 @@ namespace mojo {
using device::AuthenticatorAttachment;
using device::AuthenticatorSelectionCriteria;
using device::CableDiscoveryData;
using device::CableEidArray;
using device::CableSessionPreKeyArray;
using device::CoseAlgorithmIdentifier;
using device::CredentialType;
using device::EidArray;
using device::FidoTransportProtocol;
using device::PublicKeyCredentialDescriptor;
using device::PublicKeyCredentialParams;
using device::PublicKeyCredentialRpEntity;
using device::PublicKeyCredentialUserEntity;
using device::SessionPreKeyArray;
using device::UserVerificationRequirement;
const std::vector<uint8_t> kDescriptorId = {'d', 'e', 's', 'c'};
constexpr char kRpId[] = "google.com";
constexpr char kRpName[] = "Google";
constexpr char kTestURL[] = "https://gstatic.com/fakeurl2.png";
constexpr EidArray kClientEid = {{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15}};
constexpr EidArray kAuthenticatorEid = {{0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01}};
constexpr SessionPreKeyArray kSessionPreKey = {
constexpr CableEidArray kClientEid = {{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15}};
constexpr CableEidArray kAuthenticatorEid = {
{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01}};
constexpr CableSessionPreKeyArray kSessionPreKey = {
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}};
......
......@@ -12,11 +12,11 @@
namespace device {
constexpr size_t kEphemeralIdSize = 16;
constexpr size_t kSessionPreKeySize = 32;
constexpr size_t kCableEphemeralIdSize = 16;
constexpr size_t kCableSessionPreKeySize = 32;
using EidArray = std::array<uint8_t, kEphemeralIdSize>;
using SessionPreKeyArray = std::array<uint8_t, kSessionPreKeySize>;
using CableEidArray = std::array<uint8_t, kCableEphemeralIdSize>;
using CableSessionPreKeyArray = std::array<uint8_t, kCableSessionPreKeySize>;
// Encapsulates information required to discover Cable device per single
// credential. When multiple credentials are enrolled to a single account
......@@ -27,9 +27,9 @@ using SessionPreKeyArray = std::array<uint8_t, kSessionPreKeySize>;
// See: https://crbug.com/837088
struct COMPONENT_EXPORT(DEVICE_FIDO) CableDiscoveryData {
CableDiscoveryData(uint8_t version,
const EidArray& client_eid,
const EidArray& authenticator_eid,
const SessionPreKeyArray& session_pre_key);
const CableEidArray& client_eid,
const CableEidArray& authenticator_eid,
const CableSessionPreKeyArray& session_pre_key);
CableDiscoveryData();
CableDiscoveryData(const CableDiscoveryData& data);
CableDiscoveryData& operator=(const CableDiscoveryData& other);
......@@ -37,9 +37,9 @@ struct COMPONENT_EXPORT(DEVICE_FIDO) CableDiscoveryData {
~CableDiscoveryData();
uint8_t version;
EidArray client_eid;
EidArray authenticator_eid;
SessionPreKeyArray session_pre_key;
CableEidArray client_eid;
CableEidArray authenticator_eid;
CableSessionPreKeyArray session_pre_key;
};
} // namespace device
......
......@@ -35,7 +35,7 @@ namespace {
// with the EID as its UUID.
std::unique_ptr<BluetoothAdvertisement::Data> ConstructAdvertisementData(
uint8_t version_number,
base::span<const uint8_t, kEphemeralIdSize> client_eid) {
base::span<const uint8_t, kCableEphemeralIdSize> client_eid) {
auto advertisement_data = std::make_unique<BluetoothAdvertisement::Data>(
BluetoothAdvertisement::AdvertisementType::ADVERTISEMENT_TYPE_BROADCAST);
......@@ -57,7 +57,7 @@ std::unique_ptr<BluetoothAdvertisement::Data> ConstructAdvertisementData(
static constexpr uint8_t kCableFlags = 0x20;
static constexpr uint8_t kCableGoogleManufacturerDataLength =
3u + kEphemeralIdSize;
3u + kCableEphemeralIdSize;
std::array<uint8_t, 4> kCableGoogleManufacturerDataHeader = {
kCableGoogleManufacturerDataLength, kCableGoogleManufacturerDataType,
kCableFlags, version_number};
......@@ -104,9 +104,9 @@ CableDiscoveryData::CableDiscoveryData() = default;
CableDiscoveryData::CableDiscoveryData(
uint8_t version,
const EidArray& client_eid,
const EidArray& authenticator_eid,
const SessionPreKeyArray& session_pre_key)
const CableEidArray& client_eid,
const CableEidArray& authenticator_eid,
const CableSessionPreKeyArray& session_pre_key)
: version(version),
client_eid(client_eid),
authenticator_eid(authenticator_eid),
......@@ -151,7 +151,7 @@ FidoCableDiscovery::~FidoCableDiscovery() {
std::unique_ptr<FidoCableHandshakeHandler>
FidoCableDiscovery::CreateHandshakeHandler(
FidoCableDevice* device,
base::span<const uint8_t, kSessionPreKeySize> session_pre_key,
base::span<const uint8_t, kCableSessionPreKeySize> session_pre_key,
base::span<const uint8_t, 8> nonce) {
return std::make_unique<FidoCableHandshakeHandler>(device, nonce,
session_pre_key);
......@@ -260,7 +260,7 @@ void FidoCableDiscovery::StopAdvertisements(base::OnceClosure callback) {
}
void FidoCableDiscovery::OnAdvertisementRegistered(
const EidArray& client_eid,
const CableEidArray& client_eid,
scoped_refptr<BluetoothAdvertisement> advertisement) {
FIDO_LOG(DEBUG) << "Advertisement registered.";
advertisements_.emplace(client_eid, std::move(advertisement));
......@@ -317,7 +317,7 @@ void FidoCableDiscovery::CableDeviceFound(BluetoothAdapter* adapter,
void FidoCableDiscovery::ConductEncryptionHandshake(
std::unique_ptr<FidoCableDevice> cable_device,
base::span<const uint8_t, kSessionPreKeySize> session_pre_key,
base::span<const uint8_t, kCableSessionPreKeySize> session_pre_key,
base::span<const uint8_t, 8> nonce) {
auto handshake_handler =
CreateHandshakeHandler(cable_device.get(), session_pre_key, nonce);
......@@ -376,7 +376,7 @@ FidoCableDiscovery::GetCableDiscoveryDataFromServiceData(
if (service_data->empty() || !(service_data->at(0) >> 5 & 1u))
return nullptr;
EidArray received_authenticator_eid;
CableEidArray received_authenticator_eid;
bool extract_success = fido_parsing_utils::ExtractArray(
*service_data, 2, &received_authenticator_eid);
if (!extract_success)
......
......@@ -37,7 +37,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoCableDiscovery
protected:
virtual std::unique_ptr<FidoCableHandshakeHandler> CreateHandshakeHandler(
FidoCableDevice* device,
base::span<const uint8_t, kSessionPreKeySize> session_pre_key,
base::span<const uint8_t, kCableSessionPreKeySize> session_pre_key,
base::span<const uint8_t, 8> nonce);
private:
......@@ -62,7 +62,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoCableDiscovery
void StartCableDiscovery();
void StartAdvertisement();
void OnAdvertisementRegistered(
const EidArray& client_eid,
const CableEidArray& client_eid,
scoped_refptr<BluetoothAdvertisement> advertisement);
void OnAdvertisementRegisterError(
BluetoothAdvertisement::ErrorCode error_code);
......@@ -78,7 +78,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoCableDiscovery
void CableDeviceFound(BluetoothAdapter* adapter, BluetoothDevice* device);
void ConductEncryptionHandshake(
std::unique_ptr<FidoCableDevice> device,
base::span<const uint8_t, kSessionPreKeySize> session_pre_key,
base::span<const uint8_t, kCableSessionPreKeySize> session_pre_key,
base::span<const uint8_t, 8> nonce);
void ValidateAuthenticatorHandshakeMessage(
std::unique_ptr<FidoCableDevice> cable_device,
......@@ -96,7 +96,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoCableDiscovery
// active_authenticator_eids_ contains authenticator EIDs for which a
// handshake is currently running. Further advertisements for the same EIDs
// will be ignored.
std::set<EidArray> active_authenticator_eids_;
std::set<CableEidArray> active_authenticator_eids_;
// active_devices_ contains the BLE addresses of devices for which a handshake
// is already running. Further advertisements from these devices will be
// ignored. However, devices may rotate their BLE address at will so this is
......@@ -104,7 +104,8 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoCableDiscovery
std::set<std::string> active_devices_;
size_t advertisement_success_counter_ = 0;
size_t advertisement_failure_counter_ = 0;
std::map<EidArray, scoped_refptr<BluetoothAdvertisement>> advertisements_;
std::map<CableEidArray, scoped_refptr<BluetoothAdvertisement>>
advertisements_;
std::vector<std::unique_ptr<FidoCableHandshakeHandler>>
cable_handshake_handlers_;
base::WeakPtrFactory<FidoCableDiscovery> weak_factory_{this};
......
......@@ -36,40 +36,40 @@ constexpr uint8_t kTestCableVersionNumber = 0x01;
// Constants required for discovering and constructing a Cable device that
// are given by the relying party via an extension.
constexpr EidArray kClientEid = {{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15}};
constexpr CableEidArray kClientEid = {{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13,
0x14, 0x15}};
constexpr char kUuidFormattedClientEid[] =
"00010203-0405-0607-0809-101112131415";
constexpr EidArray kAuthenticatorEid = {{0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01}};
constexpr CableEidArray kAuthenticatorEid = {
{0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01}};
constexpr EidArray kInvalidAuthenticatorEid = {
constexpr CableEidArray kInvalidAuthenticatorEid = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00}};
constexpr SessionPreKeyArray kTestSessionPreKey = {
constexpr CableSessionPreKeyArray kTestSessionPreKey = {
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}};
// TODO(https://crbug.com/837088): Add support for multiple EIDs on Windows.
#if !defined(OS_WIN)
constexpr EidArray kSecondaryClientEid = {{0x15, 0x14, 0x13, 0x12, 0x11, 0x10,
0x09, 0x08, 0x07, 0x06, 0x05, 0x04,
0x03, 0x02, 0x01, 0x00}};
constexpr CableEidArray kSecondaryClientEid = {
{0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04,
0x03, 0x02, 0x01, 0x00}};
constexpr char kUuidFormattedSecondaryClientEid[] =
"15141312-1110-0908-0706-050403020100";
constexpr EidArray kSecondaryAuthenticatorEid = {
constexpr CableEidArray kSecondaryAuthenticatorEid = {
{0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee,
0xee, 0xee, 0xee, 0xee}};
constexpr SessionPreKeyArray kSecondarySessionPreKey = {
constexpr CableSessionPreKeyArray kSecondarySessionPreKey = {
{0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd}};
......@@ -165,7 +165,7 @@ class CableMockAdapter : public MockBluetoothAdapter {
const AdvertisementErrorCallback&));
void AddNewTestBluetoothDevice(
base::span<const uint8_t, kEphemeralIdSize> authenticator_eid) {
base::span<const uint8_t, kCableEphemeralIdSize> authenticator_eid) {
auto mock_device = CreateTestBluetoothDevice();
std::vector<uint8_t> service_data(18);
......@@ -189,7 +189,7 @@ class CableMockAdapter : public MockBluetoothAdapter {
}
void AddNewTestAppleBluetoothDevice(
base::span<const uint8_t, kEphemeralIdSize> authenticator_eid) {
base::span<const uint8_t, kCableEphemeralIdSize> authenticator_eid) {
auto mock_device = CreateTestBluetoothDevice();
// Apple doesn't allow advertising service data, so we advertise a 16 bit
// UUID plus the EID converted into 128 bit UUID.
......@@ -247,7 +247,7 @@ class CableMockAdapter : public MockBluetoothAdapter {
}
void ExpectDiscoveryWithScanCallback(
base::span<const uint8_t, kEphemeralIdSize> eid,
base::span<const uint8_t, kCableEphemeralIdSize> eid,
bool is_apple_device = false) {
EXPECT_CALL(*this, StartScanWithFilter_(_, _))
.WillOnce(
......@@ -297,7 +297,7 @@ class FakeFidoCableDiscovery : public FidoCableDiscovery {
private:
std::unique_ptr<FidoCableHandshakeHandler> CreateHandshakeHandler(
FidoCableDevice* device,
base::span<const uint8_t, kSessionPreKeySize> session_pre_key,
base::span<const uint8_t, kCableSessionPreKeySize> session_pre_key,
base::span<const uint8_t, 8> nonce) override {
return std::make_unique<FakeHandshakeHandler>(device, nonce,
session_pre_key);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment