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

Side by Side Diff: device/u2f/u2f_device.cc

Issue 2821263005: Add U2F request state machines (Closed)
Patch Set: Add U2fRequest, U2fSign, and U2fRegister classes 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "u2f_device.h" 5 #include "u2f_device.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "u2f_apdu_command.h" 8 #include "u2f_apdu_command.h"
9 #include "u2f_apdu_response.h" 9 #include "u2f_apdu_response.h"
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 switch (sign_response->status()) { 89 switch (sign_response->status()) {
90 case U2fApduResponse::Status::SW_CONDITIONS_NOT_SATISFIED: 90 case U2fApduResponse::Status::SW_CONDITIONS_NOT_SATISFIED:
91 callback.Run(ReturnCode::CONDITIONS_NOT_SATISFIED, 91 callback.Run(ReturnCode::CONDITIONS_NOT_SATISFIED,
92 std::vector<uint8_t>()); 92 std::vector<uint8_t>());
93 break; 93 break;
94 case U2fApduResponse::Status::SW_NO_ERROR: 94 case U2fApduResponse::Status::SW_NO_ERROR:
95 callback.Run(ReturnCode::SUCCESS, sign_response->data()); 95 callback.Run(ReturnCode::SUCCESS, sign_response->data());
96 break; 96 break;
97 case U2fApduResponse::Status::SW_WRONG_DATA: 97 case U2fApduResponse::Status::SW_WRONG_DATA:
98 case U2fApduResponse::Status::SW_WRONG_LENGTH:
99 default:
98 callback.Run(ReturnCode::INVALID_PARAMS, std::vector<uint8_t>()); 100 callback.Run(ReturnCode::INVALID_PARAMS, std::vector<uint8_t>());
99 break; 101 break;
100 default:
101 callback.Run(ReturnCode::FAILURE, std::vector<uint8_t>());
102 break;
103 } 102 }
104 } 103 }
105 104
106 void U2fDevice::OnVersionComplete( 105 void U2fDevice::OnVersionComplete(
107 const VersionCallback& callback, 106 const VersionCallback& callback,
108 bool success, 107 bool success,
109 std::unique_ptr<U2fApduResponse> version_response) { 108 std::unique_ptr<U2fApduResponse> version_response) {
110 if (success && version_response && 109 if (success && version_response &&
111 version_response->status() == U2fApduResponse::Status::SW_NO_ERROR && 110 version_response->status() == U2fApduResponse::Status::SW_NO_ERROR &&
112 version_response->data() == 111 version_response->data() ==
(...skipping 13 matching lines...) Expand all
126 U2fApduResponse::Status::SW_NO_ERROR && 125 U2fApduResponse::Status::SW_NO_ERROR &&
127 legacy_version_response->data() == 126 legacy_version_response->data() ==
128 std::vector<uint8_t>({'U', '2', 'F', '_', 'V', '2'})) { 127 std::vector<uint8_t>({'U', '2', 'F', '_', 'V', '2'})) {
129 callback.Run(success, ProtocolVersion::U2F_V2); 128 callback.Run(success, ProtocolVersion::U2F_V2);
130 return; 129 return;
131 } 130 }
132 callback.Run(success, ProtocolVersion::UNKNOWN); 131 callback.Run(success, ProtocolVersion::UNKNOWN);
133 } 132 }
134 133
135 } // namespace device 134 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698