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 #ifndef DEVICE_U2F_U2F_DEVICE_H_ | 5 #ifndef DEVICE_U2F_U2F_DEVICE_H_ |
6 #define DEVICE_U2F_U2F_DEVICE_H_ | 6 #define DEVICE_U2F_U2F_DEVICE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "u2f_apdu_response.h" | 12 #include "u2f_apdu_response.h" |
| 13 #include "u2f_return_code.h" |
13 | 14 |
14 namespace device { | 15 namespace device { |
15 | 16 |
16 class U2fApduCommand; | 17 class U2fApduCommand; |
17 | 18 |
18 // Device abstraction for an individual U2F device. A U2F device defines the | 19 // Device abstraction for an individual U2F device. A U2F device defines the |
19 // standardized Register, Sign, and GetVersion methods. | 20 // standardized Register, Sign, and GetVersion methods. |
20 class U2fDevice { | 21 class U2fDevice { |
21 public: | 22 public: |
22 enum class ProtocolVersion { | 23 enum class ProtocolVersion { |
23 U2F_V2, | 24 U2F_V2, |
24 UNKNOWN, | 25 UNKNOWN, |
25 }; | 26 }; |
26 enum class ReturnCode : uint8_t { | |
27 SUCCESS, | |
28 FAILURE, | |
29 INVALID_PARAMS, | |
30 CONDITIONS_NOT_SATISFIED, | |
31 }; | |
32 | 27 |
33 using MessageCallback = | 28 using MessageCallback = |
34 base::Callback<void(ReturnCode, std::vector<uint8_t>)>; | 29 base::Callback<void(U2fReturnCode, std::vector<uint8_t>)>; |
35 using VersionCallback = | 30 using VersionCallback = |
36 base::Callback<void(bool success, ProtocolVersion version)>; | 31 base::Callback<void(bool success, ProtocolVersion version)>; |
37 using DeviceCallback = | 32 using DeviceCallback = |
38 base::Callback<void(bool success, | 33 base::Callback<void(bool success, |
39 std::unique_ptr<U2fApduResponse> response)>; | 34 std::unique_ptr<U2fApduResponse> response)>; |
40 using WinkCallback = base::Callback<void()>; | 35 using WinkCallback = base::Callback<void()>; |
41 | 36 |
42 virtual ~U2fDevice(); | 37 virtual ~U2fDevice(); |
43 | 38 |
44 // Raw messages parameters are defined by the specification at | 39 // Raw messages parameters are defined by the specification at |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 std::unique_ptr<U2fApduResponse> response); | 83 std::unique_ptr<U2fApduResponse> response); |
89 | 84 |
90 base::WeakPtrFactory<U2fDevice> weak_factory_; | 85 base::WeakPtrFactory<U2fDevice> weak_factory_; |
91 | 86 |
92 DISALLOW_COPY_AND_ASSIGN(U2fDevice); | 87 DISALLOW_COPY_AND_ASSIGN(U2fDevice); |
93 }; | 88 }; |
94 | 89 |
95 } // namespace device | 90 } // namespace device |
96 | 91 |
97 #endif // DEVICE_U2F_U2F_DEVICE_H_ | 92 #endif // DEVICE_U2F_U2F_DEVICE_H_ |
OLD | NEW |