Commit 75c7fdb2 authored by Nina Satragno's avatar Nina Satragno Committed by Commit Bot

[fido] Remove unused code.

Remove some code that was unused. Replace the single use of one of these
classes by a hardcoded vector instead.

Fixed: 1148047
Change-Id: I33d5ada65570f5802b6a7c6edae7bfc23ac52912
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533420Reviewed-by: default avatarMartin Kreichgauer <martinkr@google.com>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Cr-Commit-Position: refs/heads/master@{#826577}
parent bf490fd1
......@@ -129,8 +129,6 @@ component("fido") {
"credential_management_handler.cc",
"credential_management_handler.h",
"ctap2_device_operation.h",
"ctap_empty_authenticator_request.cc",
"ctap_empty_authenticator_request.h",
"ctap_get_assertion_request.cc",
"ctap_get_assertion_request.h",
"ctap_make_credential_request.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "device/fido/ctap_empty_authenticator_request.h"
#include "base/numerics/safe_conversions.h"
namespace device {
namespace internal {
std::vector<uint8_t> CtapEmptyAuthenticatorRequest::Serialize() const {
return std::vector<uint8_t>{base::strict_cast<uint8_t>(cmd_)};
}
} // namespace internal
} // namespace device
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DEVICE_FIDO_CTAP_EMPTY_AUTHENTICATOR_REQUEST_H_
#define DEVICE_FIDO_CTAP_EMPTY_AUTHENTICATOR_REQUEST_H_
#include <stdint.h>
#include <string>
#include <vector>
#include "base/component_export.h"
#include "device/fido/fido_constants.h"
namespace device {
namespace internal {
// Represents CTAP requests with empty parameters, including
// AuthenticatorGetInfo, AuthenticatorCancel, AuthenticatorReset and
// AuthenticatorGetNextAssertion commands.
class COMPONENT_EXPORT(DEVICE_FIDO) CtapEmptyAuthenticatorRequest {
public:
CtapRequestCommand cmd() const { return cmd_; }
std::vector<uint8_t> Serialize() const;
protected:
explicit CtapEmptyAuthenticatorRequest(CtapRequestCommand cmd) : cmd_(cmd) {}
private:
CtapRequestCommand cmd_;
};
} // namespace internal
class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorGetNextAssertionRequest
: public internal::CtapEmptyAuthenticatorRequest {
public:
AuthenticatorGetNextAssertionRequest()
: CtapEmptyAuthenticatorRequest(
CtapRequestCommand::kAuthenticatorGetNextAssertion) {}
};
class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorGetInfoRequest
: public internal::CtapEmptyAuthenticatorRequest {
public:
AuthenticatorGetInfoRequest()
: CtapEmptyAuthenticatorRequest(
CtapRequestCommand::kAuthenticatorGetInfo) {}
};
class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorResetRequest
: public internal::CtapEmptyAuthenticatorRequest {
public:
AuthenticatorResetRequest()
: CtapEmptyAuthenticatorRequest(CtapRequestCommand::kAuthenticatorReset) {
}
};
} // namespace device
#endif // DEVICE_FIDO_CTAP_EMPTY_AUTHENTICATOR_REQUEST_H_
......@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "components/cbor/reader.h"
#include "device/fido/ctap_empty_authenticator_request.h"
#include "device/fido/ctap_get_assertion_request.h"
#include "device/fido/ctap_make_credential_request.h"
#include "device/fido/fido_constants.h"
......@@ -73,17 +72,4 @@ TEST(CTAPRequestTest, TestConstructGetAssertionRequest) {
test_data::kTestComplexCtapGetAssertionRequest));
}
TEST(CTAPRequestTest, TestConstructCtapAuthenticatorRequestParam) {
static constexpr uint8_t kSerializedGetInfoCmd = 0x04;
static constexpr uint8_t kSerializedGetNextAssertionCmd = 0x08;
static constexpr uint8_t kSerializedResetCmd = 0x07;
EXPECT_THAT(AuthenticatorGetInfoRequest().Serialize(),
::testing::ElementsAre(kSerializedGetInfoCmd));
EXPECT_THAT(AuthenticatorGetNextAssertionRequest().Serialize(),
::testing::ElementsAre(kSerializedGetNextAssertionCmd));
EXPECT_THAT(AuthenticatorResetRequest().Serialize(),
::testing::ElementsAre(kSerializedResetCmd));
}
} // namespace device
......@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/stl_util.h"
#include "components/device_event_log/device_event_log.h"
#include "device/fido/ctap_empty_authenticator_request.h"
#include "device/fido/device_response_converter.h"
#include "device/fido/fido_constants.h"
......@@ -50,9 +49,10 @@ void FidoDevice::DiscoverSupportedProtocolAndDeviceInfo(
supported_protocol_ = ProtocolVersion::kCtap2;
FIDO_LOG(DEBUG)
<< "Sending CTAP2 AuthenticatorGetInfo request to authenticator.";
DeviceTransact(AuthenticatorGetInfoRequest().Serialize(),
base::BindOnce(&FidoDevice::OnDeviceInfoReceived, GetWeakPtr(),
std::move(done)));
DeviceTransact(
{static_cast<uint8_t>(CtapRequestCommand::kAuthenticatorGetInfo)},
base::BindOnce(&FidoDevice::OnDeviceInfoReceived, GetWeakPtr(),
std::move(done)));
}
bool FidoDevice::SupportedProtocolIsInitialized() {
......
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