#include "device/fido/cable/fido_cable_device.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/numerics/safe_math.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "components/device_event_log/device_event_log.h"
#include "device/fido/cable/fido_ble_frames.h"
#include "device/fido/cable/fido_ble_uuids.h"
#include "device/fido/cable/v2_handshake.h"
#include "device/fido/fido_constants.h"
#include "device/fido/fido_parsing_utils.h"
namespace device {
namespace {
constexpr uint32_t kMaxCounter = …;
std::optional<std::vector<uint8_t>> ConstructV1Nonce(
base::span<const uint8_t> nonce,
bool is_sender_client,
uint32_t counter) { … }
}
FidoCableDevice::EncryptionData::EncryptionData() = default;
FidoCableDevice::EncryptionData::~EncryptionData() = default;
FidoCableDevice::FidoCableDevice(BluetoothAdapter* adapter,
std::string address) { … }
FidoCableDevice::FidoCableDevice(std::unique_ptr<FidoBleConnection> connection)
: … { … }
FidoCableDevice::~FidoCableDevice() = default;
std::string FidoCableDevice::GetIdForAddress(const std::string& address) { … }
std::string FidoCableDevice::GetAddress() { … }
void FidoCableDevice::Connect() { … }
void FidoCableDevice::SendPing(std::vector<uint8_t> data,
DeviceCallback callback) { … }
FidoBleConnection::ReadCallback FidoCableDevice::GetReadCallbackForTesting() { … }
void FidoCableDevice::Cancel(CancelToken token) { … }
std::string FidoCableDevice::GetId() const { … }
FidoTransportProtocol FidoCableDevice::DeviceTransport() const { … }
FidoDevice::CancelToken FidoCableDevice::DeviceTransact(
std::vector<uint8_t> command,
DeviceCallback callback) { … }
void FidoCableDevice::OnResponseFrame(FrameCallback callback,
std::optional<FidoBleFrame> frame) { … }
void FidoCableDevice::ResetTransaction() { … }
void FidoCableDevice::Transition() { … }
FidoDevice::CancelToken FidoCableDevice::AddToPendingFrames(
FidoBleDeviceCommand cmd,
std::vector<uint8_t> request,
DeviceCallback callback) { … }
void FidoCableDevice::SendHandshakeMessage(
std::vector<uint8_t> handshake_message,
DeviceCallback callback) { … }
void FidoCableDevice::SetV1EncryptionData(
base::span<const uint8_t, 32> session_key,
base::span<const uint8_t, 8> nonce) { … }
void FidoCableDevice::SetSequenceNumbersForTesting(uint32_t read_seq,
uint32_t write_seq) { … }
base::WeakPtr<FidoDevice> FidoCableDevice::GetWeakPtr() { … }
FidoCableDevice::PendingFrame::PendingFrame(FidoBleFrame in_frame,
FrameCallback in_callback,
CancelToken in_token)
: … { … }
FidoCableDevice::PendingFrame::PendingFrame(PendingFrame&&) = default;
FidoCableDevice::PendingFrame::~PendingFrame() = default;
void FidoCableDevice::OnConnected(bool success) { … }
void FidoCableDevice::OnStatusMessage(std::vector<uint8_t> data) { … }
void FidoCableDevice::OnReadControlPointLength(std::optional<uint16_t> length) { … }
void FidoCableDevice::SendRequestFrame(FidoBleFrame frame,
FrameCallback callback) { … }
void FidoCableDevice::StartTimeout() { … }
void FidoCableDevice::StopTimeout() { … }
void FidoCableDevice::OnTimeout() { … }
void FidoCableDevice::OnBleResponseReceived(DeviceCallback callback,
std::optional<FidoBleFrame> frame) { … }
void FidoCableDevice::ProcessBleDeviceError(base::span<const uint8_t> data) { … }
bool FidoCableDevice::EncryptOutgoingMessage(
std::vector<uint8_t>* message_to_encrypt) { … }
bool FidoCableDevice::DecryptIncomingMessage(FidoBleFrame* incoming_frame) { … }
}