Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2990)

Unified Diff: device/u2f/u2f_device.cc

Issue 2835133003: Reland of Add U2F request state machines (Closed)
Patch Set: Initialize base class variables in initialization list Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/u2f/u2f_device.cc
diff --git a/device/u2f/u2f_device.cc b/device/u2f/u2f_device.cc
index dc9e5ec127be1845cb71dc3f1d731cf4cab7caf3..1b2f2b7089403ece0ff1e221d78922f45be760aa 100644
--- a/device/u2f/u2f_device.cc
+++ b/device/u2f/u2f_device.cc
@@ -10,7 +10,8 @@
namespace device {
-U2fDevice::U2fDevice() : weak_factory_(this) {}
+U2fDevice::U2fDevice()
+ : channel_id_(kBroadcastChannel), capabilities_(0), weak_factory_(this) {}
U2fDevice::~U2fDevice() {}
@@ -20,7 +21,7 @@ void U2fDevice::Register(const std::vector<uint8_t>& app_param,
std::unique_ptr<U2fApduCommand> register_cmd =
U2fApduCommand::CreateRegister(app_param, challenge_param);
if (!register_cmd) {
- callback.Run(ReturnCode::INVALID_PARAMS, std::vector<uint8_t>());
+ callback.Run(U2fReturnCode::INVALID_PARAMS, std::vector<uint8_t>());
return;
}
DeviceTransact(std::move(register_cmd),
@@ -35,7 +36,7 @@ void U2fDevice::Sign(const std::vector<uint8_t>& app_param,
std::unique_ptr<U2fApduCommand> sign_cmd =
U2fApduCommand::CreateSign(app_param, challenge_param, key_handle);
if (!sign_cmd) {
- callback.Run(ReturnCode::INVALID_PARAMS, std::vector<uint8_t>());
+ callback.Run(U2fReturnCode::INVALID_PARAMS, std::vector<uint8_t>());
return;
}
DeviceTransact(std::move(sign_cmd),
@@ -59,22 +60,22 @@ void U2fDevice::OnRegisterComplete(
bool success,
std::unique_ptr<U2fApduResponse> register_response) {
if (!success || !register_response) {
- callback.Run(ReturnCode::FAILURE, std::vector<uint8_t>());
+ callback.Run(U2fReturnCode::FAILURE, std::vector<uint8_t>());
return;
}
switch (register_response->status()) {
case U2fApduResponse::Status::SW_CONDITIONS_NOT_SATISFIED:
- callback.Run(ReturnCode::CONDITIONS_NOT_SATISFIED,
+ callback.Run(U2fReturnCode::CONDITIONS_NOT_SATISFIED,
std::vector<uint8_t>());
break;
case U2fApduResponse::Status::SW_NO_ERROR:
- callback.Run(ReturnCode::SUCCESS, register_response->data());
+ callback.Run(U2fReturnCode::SUCCESS, register_response->data());
break;
case U2fApduResponse::Status::SW_WRONG_DATA:
- callback.Run(ReturnCode::INVALID_PARAMS, std::vector<uint8_t>());
+ callback.Run(U2fReturnCode::INVALID_PARAMS, std::vector<uint8_t>());
break;
default:
- callback.Run(ReturnCode::FAILURE, std::vector<uint8_t>());
+ callback.Run(U2fReturnCode::FAILURE, std::vector<uint8_t>());
break;
}
}
@@ -83,22 +84,21 @@ void U2fDevice::OnSignComplete(const MessageCallback& callback,
bool success,
std::unique_ptr<U2fApduResponse> sign_response) {
if (!success || !sign_response) {
- callback.Run(ReturnCode::FAILURE, std::vector<uint8_t>());
+ callback.Run(U2fReturnCode::FAILURE, std::vector<uint8_t>());
return;
}
switch (sign_response->status()) {
case U2fApduResponse::Status::SW_CONDITIONS_NOT_SATISFIED:
- callback.Run(ReturnCode::CONDITIONS_NOT_SATISFIED,
+ callback.Run(U2fReturnCode::CONDITIONS_NOT_SATISFIED,
std::vector<uint8_t>());
break;
case U2fApduResponse::Status::SW_NO_ERROR:
- callback.Run(ReturnCode::SUCCESS, sign_response->data());
+ callback.Run(U2fReturnCode::SUCCESS, sign_response->data());
break;
case U2fApduResponse::Status::SW_WRONG_DATA:
- callback.Run(ReturnCode::INVALID_PARAMS, std::vector<uint8_t>());
- break;
+ case U2fApduResponse::Status::SW_WRONG_LENGTH:
default:
- callback.Run(ReturnCode::FAILURE, std::vector<uint8_t>());
+ callback.Run(U2fReturnCode::INVALID_PARAMS, std::vector<uint8_t>());
break;
}
}

Powered by Google App Engine
This is Rietveld 408576698