Commit 92822af2 authored by Adam Langley's avatar Adam Langley Committed by Commit Bot

device/fido: fix caBLEv1

I broke caBLEv1 twice (because I can't test it) with 99900ffc: having
any caBLEv2 pairings saved would cause a crash (this is very rare) and,
more importantly, the client and authenticator EID got mixed up so all
the handshakes would fail.

Bug: b/166334693

Change-Id: Idecb57cd44a14b9a689b7f67263e7b59bf2f88c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2378139
Commit-Queue: Adam Langley <agl@chromium.org>
Reviewed-by: default avatarMartin Kreichgauer <martinkr@google.com>
Cr-Commit-Position: refs/heads/master@{#802504}
parent 4d4ac1a9
......@@ -198,13 +198,14 @@ std::unique_ptr<FidoCableHandshakeHandler>
FidoCableDiscovery::CreateV1HandshakeHandler(
FidoCableDevice* device,
const CableDiscoveryData& discovery_data,
const CableEidArray& eid) {
const CableEidArray& authenticator_eid) {
std::unique_ptr<FidoCableHandshakeHandler> handler;
switch (discovery_data.version) {
case CableDiscoveryData::Version::V1: {
// Nonce is embedded as first 8 bytes of client EID.
std::array<uint8_t, 8> nonce;
const bool ok = fido_parsing_utils::ExtractArray(eid, 0, &nonce);
const bool ok = fido_parsing_utils::ExtractArray(
discovery_data.v1->client_eid, 0, &nonce);
DCHECK(ok);
return std::make_unique<FidoCableV1HandshakeHandler>(
......@@ -681,7 +682,8 @@ base::Optional<FidoCableDiscovery::Result>
FidoCableDiscovery::GetCableDiscoveryDataFromAuthenticatorEid(
CableEidArray authenticator_eid) const {
for (const auto& candidate : discovery_data_) {
if (candidate.MatchV1(authenticator_eid)) {
if (candidate.version == CableDiscoveryData::Version::V1 &&
candidate.MatchV1(authenticator_eid)) {
return Result(candidate, authenticator_eid, base::nullopt, base::nullopt);
}
}
......
......@@ -61,7 +61,7 @@ class COMPONENT_EXPORT(DEVICE_FIDO) FidoCableDiscovery
virtual std::unique_ptr<FidoCableHandshakeHandler> CreateV1HandshakeHandler(
FidoCableDevice* device,
const CableDiscoveryData& discovery_data,
const CableEidArray& eid);
const CableEidArray& authenticator_eid);
private:
enum class CableV1DiscoveryEvent : int;
......
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