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

Unified Diff: device/u2f/u2f_apdu_command.h

Issue 2743623006: Modify U2F apdu classes to use unique pointers (Closed)
Patch Set: Use more concise form of base::Passed 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | device/u2f/u2f_apdu_command.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/u2f/u2f_apdu_command.h
diff --git a/device/u2f/u2f_apdu_command.h b/device/u2f/u2f_apdu_command.h
index 98b53ec2677697b41fc16e7917162f32f3439952..54defc79f106e0bda2c822435c0c571449d3fa4c 100644
--- a/device/u2f/u2f_apdu_command.h
+++ b/device/u2f/u2f_apdu_command.h
@@ -5,10 +5,11 @@
#ifndef DEVICE_U2F_U2F_APDU_COMMAND_H_
#define DEVICE_U2F_U2F_APDU_COMMAND_H_
+#include <cinttypes>
+#include <memory>
#include <vector>
#include "base/gtest_prod_util.h"
-#include "base/memory/ref_counted.h"
namespace device {
@@ -20,13 +21,21 @@ namespace device {
// byte, denoting the instruction code, P1 and P2, each one byte denoting
// instruction parameters, a length field (Lc), a data field of length Lc, and
// a maximum expected response length (Le).
-class U2fApduCommand : public base::RefCountedThreadSafe<U2fApduCommand> {
+class U2fApduCommand {
public:
+ U2fApduCommand();
+ U2fApduCommand(uint8_t cla,
+ uint8_t ins,
+ uint8_t p1,
+ uint8_t p2,
+ size_t response_length,
+ std::vector<uint8_t> data,
+ std::vector<uint8_t> suffix);
+ ~U2fApduCommand();
+
// Construct an apdu command from the serialized message data
- static scoped_refptr<U2fApduCommand> CreateFromMessage(
+ static std::unique_ptr<U2fApduCommand> CreateFromMessage(
const std::vector<uint8_t>& data);
- // Create an empty apdu command object
- static scoped_refptr<U2fApduCommand> Create();
// Returns serialized message data
std::vector<uint8_t> GetEncodedCommand() const;
void set_cla(uint8_t cla) { cla_ = cla; }
@@ -38,20 +47,18 @@ class U2fApduCommand : public base::RefCountedThreadSafe<U2fApduCommand> {
response_length_ = response_length;
}
void set_suffix(const std::vector<uint8_t>& suffix) { suffix_ = suffix; }
- static scoped_refptr<U2fApduCommand> CreateRegister(
+ static std::unique_ptr<U2fApduCommand> CreateRegister(
const std::vector<uint8_t>& appid_digest,
const std::vector<uint8_t>& challenge_digest);
- static scoped_refptr<U2fApduCommand> CreateVersion();
+ static std::unique_ptr<U2fApduCommand> CreateVersion();
// Early U2F drafts defined a non-ISO 7816-4 conforming layout
- static scoped_refptr<U2fApduCommand> CreateLegacyVersion();
- static scoped_refptr<U2fApduCommand> CreateSign(
+ static std::unique_ptr<U2fApduCommand> CreateLegacyVersion();
+ static std::unique_ptr<U2fApduCommand> CreateSign(
const std::vector<uint8_t>& appid_digest,
const std::vector<uint8_t>& challenge_digest,
const std::vector<uint8_t>& key_handle);
private:
- friend class base::RefCountedThreadSafe<U2fApduCommand>;
- friend class U2fApduBuilder;
FRIEND_TEST_ALL_PREFIXES(U2fApduTest, TestDeserializeBasic);
FRIEND_TEST_ALL_PREFIXES(U2fApduTest, TestDeserializeComplex);
FRIEND_TEST_ALL_PREFIXES(U2fApduTest, TestSerializeEdgeCases);
@@ -83,16 +90,6 @@ class U2fApduCommand : public base::RefCountedThreadSafe<U2fApduCommand> {
static constexpr size_t kChallengeDigestLen = 32;
static constexpr size_t kAppIdDigestLen = 32;
- U2fApduCommand();
- U2fApduCommand(uint8_t cla,
- uint8_t ins,
- uint8_t p1,
- uint8_t p2,
- size_t response_length,
- std::vector<uint8_t> data,
- std::vector<uint8_t> suffix);
- ~U2fApduCommand();
-
uint8_t cla_;
uint8_t ins_;
uint8_t p1_;
« no previous file with comments | « no previous file | device/u2f/u2f_apdu_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698