chromium/device/fido/cable/fido_tunnel_device.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "device/fido/cable/fido_tunnel_device.h"

#include "base/metrics/histogram_functions.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "components/cbor/reader.h"
#include "components/cbor/values.h"
#include "components/cbor/writer.h"
#include "components/device_event_log/device_event_log.h"
#include "crypto/random.h"
#include "device/fido/cable/cable_discovery_data.h"
#include "device/fido/cable/v2_constants.h"
#include "device/fido/cbor_extract.h"
#include "device/fido/features.h"
#include "device/fido/fido_constants.h"
#include "device/fido/fido_device.h"
#include "device/fido/fido_parsing_utils.h"
#include "device/fido/fido_types.h"
#include "device/fido/network_context_factory.h"
#include "net/storage_access_api/status.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "third_party/boringssl/src/include/openssl/aes.h"
#include "third_party/boringssl/src/include/openssl/digest.h"
#include "third_party/boringssl/src/include/openssl/hkdf.h"

IntKey;
Is;
StepOrByte;
Stop;

namespace device::cablev2 {

namespace {

// CableV2TunnelEvent enumerates several steps that occur during establishing a
// caBLEv2 tunnel. Do not change the assigned values since they are used in
// histograms, only append new values. Keep synced with enums.xml.
enum class CableV2TunnelEvent {};

void RecordEvent(CableV2TunnelEvent event) {}

std::array<uint8_t, 8> RandomId() {}

}  // namespace

FidoTunnelDevice::QRInfo::QRInfo() = default;
FidoTunnelDevice::QRInfo::~QRInfo() = default;
FidoTunnelDevice::PairedInfo::PairedInfo() = default;
FidoTunnelDevice::PairedInfo::~PairedInfo() = default;

constexpr net::NetworkTrafficAnnotationTag kTrafficAnnotation =;

FidoTunnelDevice::FidoTunnelDevice(
    NetworkContextFactory network_context_factory,
    std::optional<base::RepeatingCallback<void(std::unique_ptr<Pairing>)>>
        pairing_callback,
    std::optional<base::RepeatingCallback<void(Event)>> event_callback,
    base::span<const uint8_t> secret,
    base::span<const uint8_t, kQRSeedSize> local_identity_seed,
    const CableEidArray& decrypted_eid,
    bool must_support_ctap)
    :{}

FidoTunnelDevice::FidoTunnelDevice(
    FidoRequestType request_type,
    NetworkContextFactory network_context_factory,
    std::unique_ptr<Pairing> pairing,
    base::OnceClosure pairing_is_invalid,
    std::optional<base::RepeatingCallback<void(Event)>> event_callback)
    :{}

FidoTunnelDevice::~FidoTunnelDevice() {}

bool FidoTunnelDevice::MatchAdvert(
    const std::array<uint8_t, kAdvertSize>& advert) {}

void FidoTunnelDevice::DiscoverSupportedProtocolAndDeviceInfo(
    base::OnceClosure done) {}

FidoDevice::CancelToken FidoTunnelDevice::DeviceTransact(
    std::vector<uint8_t> command,
    DeviceCallback callback) {}

FidoDevice::CancelToken FidoTunnelDevice::DeviceTransactJSON(
    std::vector<uint8_t> json,
    DeviceCallback callback) {}

void FidoTunnelDevice::Cancel(CancelToken token) {}

std::string FidoTunnelDevice::GetId() const {}

FidoTransportProtocol FidoTunnelDevice::DeviceTransport() const {}

FidoTunnelDevice* FidoTunnelDevice::GetTunnelDevice() {}

base::flat_set<cablev2::Feature> FidoTunnelDevice::features() const {}

base::WeakPtr<FidoDevice> FidoTunnelDevice::GetWeakPtr() {}

FidoDevice::CancelToken FidoTunnelDevice::DoTransact(MessageType msg_type,
                                                     std::vector<uint8_t> msg,
                                                     DeviceCallback callback) {}

void FidoTunnelDevice::OnTunnelReady(
    WebSocketAdapter::Result result,
    std::optional<std::array<uint8_t, kRoutingIdSize>> routing_id,
    WebSocketAdapter::ConnectSignalSupport connect_signal_support) {}

void FidoTunnelDevice::OnTunnelData(
    std::optional<base::span<const uint8_t>> data) {}

void FidoTunnelDevice::OnError() {}

bool FidoTunnelDevice::ProcessConnectSignal(base::span<const uint8_t> data) {}

// g_num_established_connection_instances is incremented when an
// `EstablishedConnection` is created and decremented during its destructor.
// This is purely for checking that none leak in tests.
static int g_num_established_connection_instances;

int FidoTunnelDevice::GetNumEstablishedConnectionInstancesForTesting() {}

FidoTunnelDevice::EstablishedConnection::EstablishedConnection(
    std::unique_ptr<WebSocketAdapter> websocket_client,
    std::string id_for_logging,
    int protocol_revision,
    std::unique_ptr<Crypter> crypter,
    const HandshakeHash& handshake_hash,
    QRInfo* maybe_qr_info)
    :{}

FidoTunnelDevice::EstablishedConnection::~EstablishedConnection() {}

void FidoTunnelDevice::EstablishedConnection::Transact(
    MessageType msg_type,
    std::vector<uint8_t> message,
    DeviceCallback callback) {}

void FidoTunnelDevice::EstablishedConnection::Close() {}

void FidoTunnelDevice::EstablishedConnection::OnTunnelData(
    std::optional<base::span<const uint8_t>> data) {}

bool FidoTunnelDevice::EstablishedConnection::ProcessUpdate(
    base::span<const uint8_t> plaintext) {}

void FidoTunnelDevice::EstablishedConnection::OnRemoteClose() {}

void FidoTunnelDevice::EstablishedConnection::OnTimeout() {}

}  // namespace device::cablev2