#include "device/fido/cable/fido_cable_handshake_handler.h"
#include <array>
#include <cstdint>
#include <limits>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/numerics/safe_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "components/cbor/reader.h"
#include "components/cbor/values.h"
#include "crypto/hkdf.h"
#include "crypto/hmac.h"
#include "crypto/sha2.h"
#include "device/bluetooth/test/bluetooth_test.h"
#include "device/bluetooth/test/mock_bluetooth_adapter.h"
#include "device/fido/cable/fido_ble_frames.h"
#include "device/fido/cable/fido_cable_device.h"
#include "device/fido/cable/mock_fido_ble_connection.h"
#include "device/fido/fido_constants.h"
#include "device/fido/fido_parsing_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace device {
namespace {
_;
Invoke;
Test;
TestDeviceFuture;
NiceMockBluetoothAdapter;
constexpr auto kControlPointLength = …;
constexpr std::array<uint8_t, 16> kAuthenticatorSessionRandom = …;
constexpr std::array<uint8_t, 32> kTestSessionPreKey = …;
constexpr std::array<uint8_t, 32> kIncorrectSessionPreKey = …;
constexpr std::array<uint8_t, 8> kTestNonce = …;
constexpr std::array<uint8_t, 8> kIncorrectNonce = …;
constexpr std::array<uint8_t, 50> kValidAuthenticatorHello = …;
constexpr std::array<uint8_t, 43> kInvalidAuthenticatorHello = …;
constexpr char kIncorrectHandshakeKey[] = …;
std::vector<uint8_t> GetExpectedEncryptionKey(
base::span<const uint8_t> client_random_nonce) { … }
std::vector<uint8_t> ConstructAuthenticatorHelloReply(
base::span<const uint8_t> hello_msg,
std::string_view handshake_key) { … }
std::vector<uint8_t> ConstructSerializedOutgoingFragment(
base::span<const uint8_t> data) { … }
class FakeCableAuthenticator { … };
}
class FidoCableHandshakeHandlerTest : public Test { … };
MATCHER(IsControlFrame, "") { … }
TEST_F(FidoCableHandshakeHandlerTest, HandShakeSuccess) { … }
TEST_F(FidoCableHandshakeHandlerTest, HandShakeWithIncorrectSessionPreKey) { … }
TEST_F(FidoCableHandshakeHandlerTest, HandshakeFailWithIncorrectNonce) { … }
TEST_F(FidoCableHandshakeHandlerTest,
HandshakeFailWithIncorrectAuthenticatorResponse) { … }
}