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

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

Issue 2743623006: Modify U2F apdu classes to use unique pointers (Closed)
Patch Set: Created 3 years, 9 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 #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"
(...skipping 13 matching lines...) Expand all
24 UNKNOWN, 24 UNKNOWN,
25 }; 25 };
26 enum class ReturnCode { SUCCESS, HW_FAILURE, INVALID_PARAMS }; 26 enum class ReturnCode { SUCCESS, HW_FAILURE, INVALID_PARAMS };
27 27
28 using MessageCallback = 28 using MessageCallback =
29 base::Callback<void(ReturnCode, std::vector<uint8_t>)>; 29 base::Callback<void(ReturnCode, std::vector<uint8_t>)>;
30 using VersionCallback = 30 using VersionCallback =
31 base::Callback<void(bool success, ProtocolVersion version)>; 31 base::Callback<void(bool success, ProtocolVersion version)>;
32 using DeviceCallback = 32 using DeviceCallback =
33 base::Callback<void(bool success, 33 base::Callback<void(bool success,
34 scoped_refptr<U2fApduResponse> response)>; 34 std::unique_ptr<U2fApduResponse> response)>;
35 35
36 ~U2fDevice(); 36 ~U2fDevice();
37 37
38 // Raw messages parameters are defined by the specification at 38 // Raw messages parameters are defined by the specification at
39 // https://fidoalliance.org/specs/fido-u2f-v1.0-nfc-bt-amendment-20150514/fido -u2f-raw-message-formats.html 39 // https://fidoalliance.org/specs/fido-u2f-v1.0-nfc-bt-amendment-20150514/fido -u2f-raw-message-formats.html
40 void Register(const std::vector<uint8_t>& appid_digest, 40 void Register(const std::vector<uint8_t>& appid_digest,
41 const ProtocolVersion version, 41 const ProtocolVersion version,
42 const std::vector<uint8_t>& challenge_digest, 42 const std::vector<uint8_t>& challenge_digest,
43 const MessageCallback& callback); 43 const MessageCallback& callback);
44 void Version(const VersionCallback& callback); 44 void Version(const VersionCallback& callback);
45 void Sign(const std::vector<uint8_t>& appid_digest, 45 void Sign(const std::vector<uint8_t>& appid_digest,
46 const std::vector<uint8_t>& challenge_digest, 46 const std::vector<uint8_t>& challenge_digest,
47 const std::vector<uint8_t>& key_handle, 47 const std::vector<uint8_t>& key_handle,
48 const MessageCallback& callback); 48 const MessageCallback& callback);
49 49
50 protected: 50 protected:
51 U2fDevice(); 51 U2fDevice();
52 52
53 // Pure virtual function defined by each device type, implementing 53 // Pure virtual function defined by each device type, implementing
54 // the device communication transaction. 54 // the device communication transaction.
55 virtual void DeviceTransact(scoped_refptr<U2fApduCommand> command, 55 virtual void DeviceTransact(std::unique_ptr<U2fApduCommand> command,
56 const DeviceCallback& callback) = 0; 56 const DeviceCallback& callback) = 0;
57 57
58 private: 58 private:
59 // TODO Callback functions for device calls 59 // TODO Callback functions for device calls
60 void OnRegisterComplete(const MessageCallback& callback, 60 void OnRegisterComplete(const MessageCallback& callback,
61 bool success, 61 bool success,
62 scoped_refptr<U2fApduResponse> register_response); 62 std::unique_ptr<U2fApduResponse> register_response);
63 void OnSignComplete(const MessageCallback& callback, 63 void OnSignComplete(const MessageCallback& callback,
64 bool success, 64 bool success,
65 scoped_refptr<U2fApduResponse> sign_response); 65 std::unique_ptr<U2fApduResponse> sign_response);
66 void OnVersionComplete(const VersionCallback& callback, 66 void OnVersionComplete(const VersionCallback& callback,
67 bool success, 67 bool success,
68 scoped_refptr<U2fApduResponse> version_response); 68 std::unique_ptr<U2fApduResponse> version_response);
69 void OnLegacyVersionComplete( 69 void OnLegacyVersionComplete(
70 const VersionCallback& callback, 70 const VersionCallback& callback,
71 bool success, 71 bool success,
72 scoped_refptr<U2fApduResponse> legacy_version_response); 72 std::unique_ptr<U2fApduResponse> legacy_version_response);
73 73
74 base::WeakPtrFactory<U2fDevice> weak_factory_; 74 base::WeakPtrFactory<U2fDevice> weak_factory_;
75 75
76 DISALLOW_COPY_AND_ASSIGN(U2fDevice); 76 DISALLOW_COPY_AND_ASSIGN(U2fDevice);
77 }; 77 };
78 78
79 } // namespace device 79 } // namespace device
80 80
81 #endif // DEVICE_U2F_U2F_DEVICE_H_ 81 #endif // DEVICE_U2F_U2F_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698