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

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..d780a5826c4afc900d9bcfb6a9bfecdc58ca6938
--- /dev/null
+++ b/device/u2f/u2f_packet.h
@@ -0,0 +1,59 @@
+// 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<char> data,
+ const char channel_id[kChannelIdSize]);
+ scoped_refptr<net::IOBufferWithSize> GetBuffer();
+
+ protected:
+ std::vector<char> data_;
+ char channel_id_[kChannelIdSize];
+ scoped_refptr<net::IOBufferWithSize> serialized_;
+ virtual ~U2fPacket();
+
+ private:
+ friend class base::RefCountedThreadSafe<U2fPacket>;
+};
+
+class U2fInitPacket : public U2fPacket {
+ public:
+ U2fInitPacket(const char channel_id[kChannelIdSize],
+ const char cmd,
+ const std::vector<char> data);
+
+ protected:
+ ~U2fInitPacket() final;
+
+ private:
+ char command_;
+};
+
+class U2fContPacket : public U2fPacket {
+ public:
+ U2fContPacket(const char channel_id[kChannelIdSize],
+ const char sequence,
+ std::vector<char> data);
+
+ protected:
+ ~U2fContPacket() final;
+
+ private:
+ char sequence_;
+};
+} // namespace device
+
+#endif // DEVICE_U2F_U2F_PACKET_H_

Powered by Google App Engine
This is Rietveld 408576698