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

Unified Diff: device/u2f/u2f_packet.h

Issue 2502103002: Add FIDO U2F message and packet classes (Closed)
Patch Set: Add FIDO U2F message and packet classes Created 4 years, 1 month 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
Index: device/u2f/u2f_packet.h
diff --git a/device/u2f/u2f_packet.h b/device/u2f/u2f_packet.h
new file mode 100644
index 0000000000000000000000000000000000000000..960d0fb4bff0527c74e5658e27fd05c7c0ef78f1
--- /dev/null
+++ b/device/u2f/u2f_packet.h
@@ -0,0 +1,64 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef DEVICE_U2F_U2F_PACKET_H_
+#define DEVICE_U2F_U2F_PACKET_H_
+
+#include "base/macros.h"
+#include "net/base/io_buffer.h"
+
+namespace device {
+class U2fPacket : public base::RefCountedThreadSafe<U2fPacket> {
+ public:
+ static const size_t kChannelIdSize = 4;
+ // Packet size of 64 bytes + 1 byte report ID
+ static const size_t kPacketSize = 65;
+
+ U2fPacket(const std::vector<uint8_t> data,
+ const uint8_t channel_id[kChannelIdSize]);
+ scoped_refptr<net::IOBufferWithSize> GetBuffer();
+
+ protected:
+ std::vector<uint8_t> data_;
+ uint8_t channel_id_[kChannelIdSize];
+ scoped_refptr<net::IOBufferWithSize> serialized_;
+ virtual ~U2fPacket();
+ U2fPacket();
Reilly Grant (use Gerrit) 2016/11/30 20:53:47 Same ordering issue here. Destructor and fields sh
Casey Piper 2016/11/30 22:05:46 Done.
+
+ private:
+ friend class base::RefCountedThreadSafe<U2fPacket>;
+};
+
+class U2fInitPacket : public U2fPacket {
+ public:
+ U2fInitPacket(const uint8_t channel_id[kChannelIdSize],
+ const uint8_t cmd,
+ const std::vector<uint8_t> data,
+ const uint16_t payload_length);
+
+ scoped_refptr<U2fInitPacket> Create(scoped_refptr<net::IOBufferWithSize> buf);
+
+ protected:
+ ~U2fInitPacket() final;
+
+ private:
+ U2fInitPacket(scoped_refptr<net::IOBufferWithSize> buf);
+ uint8_t command_;
+};
+
+class U2fContPacket : public U2fPacket {
+ public:
+ U2fContPacket(const uint8_t channel_id[kChannelIdSize],
+ const uint8_t sequence,
+ std::vector<uint8_t> data);
+
+ protected:
+ ~U2fContPacket() final;
+
+ private:
+ uint8_t sequence_;
+};
+} // namespace device
+
+#endif // DEVICE_U2F_U2F_PACKET_H_

Powered by Google App Engine
This is Rietveld 408576698