OLD | NEW |
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_sign.h" | 5 #include "u2f_sign.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 | 8 |
9 namespace device { | 9 namespace device { |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 // Try signing current device with the first registered key | 46 // Try signing current device with the first registered key |
47 auto it = registered_keys_.cbegin(); | 47 auto it = registered_keys_.cbegin(); |
48 current_device_->Sign( | 48 current_device_->Sign( |
49 app_param_, challenge_hash_, *it, | 49 app_param_, challenge_hash_, *it, |
50 base::Bind(&U2fSign::OnTryDevice, weak_factory_.GetWeakPtr(), it)); | 50 base::Bind(&U2fSign::OnTryDevice, weak_factory_.GetWeakPtr(), it)); |
51 } | 51 } |
52 | 52 |
53 void U2fSign::OnTryDevice(std::vector<std::vector<uint8_t>>::const_iterator it, | 53 void U2fSign::OnTryDevice(std::vector<std::vector<uint8_t>>::const_iterator it, |
54 U2fReturnCode return_code, | 54 U2fReturnCode return_code, |
55 std::vector<uint8_t> response_data) { | 55 const std::vector<uint8_t>& response_data) { |
56 switch (return_code) { | 56 switch (return_code) { |
57 case U2fReturnCode::SUCCESS: | 57 case U2fReturnCode::SUCCESS: |
58 state_ = State::COMPLETE; | 58 state_ = State::COMPLETE; |
59 cb_.Run(return_code, response_data); | 59 cb_.Run(return_code, response_data); |
60 break; | 60 break; |
61 case U2fReturnCode::CONDITIONS_NOT_SATISFIED: { | 61 case U2fReturnCode::CONDITIONS_NOT_SATISFIED: { |
62 // Key handle is accepted by this device, but waiting on user touch. Move | 62 // Key handle is accepted by this device, but waiting on user touch. Move |
63 // on and try this device again later. | 63 // on and try this device again later. |
64 state_ = State::IDLE; | 64 state_ = State::IDLE; |
65 Transition(); | 65 Transition(); |
(...skipping 17 matching lines...) Expand all Loading... |
83 default: | 83 default: |
84 // Some sort of failure occured. Abandon this device and move on. | 84 // Some sort of failure occured. Abandon this device and move on. |
85 state_ = State::IDLE; | 85 state_ = State::IDLE; |
86 current_device_ = nullptr; | 86 current_device_ = nullptr; |
87 Transition(); | 87 Transition(); |
88 break; | 88 break; |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 } // namespace device | 92 } // namespace device |
OLD | NEW |