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