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

Side by Side Diff: device/u2f/u2f_message.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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_U2F_U2F_MESSAGE_H_
6 #define DEVICE_U2F_U2F_MESSAGE_H_
7
8 #include <list>
9 #include <vector>
10 #include "base/macros.h"
11 #include "device/u2f/u2f_packet.h"
12
13 namespace device {
14
15 class U2fMessage : public base::RefCountedThreadSafe<U2fMessage> {
16 public:
17 enum u2f_message_type : char {
Reilly Grant (use Gerrit) 2016/11/23 22:21:50 Use an enum class named Type. I'd rather we use u
Casey Piper 2016/11/29 22:11:15 Done.
18 CMD_PING = 0x81,
19 CMD_ATR = 0x82,
20 CMD_APDU = 0x83,
21 CMD_LOCK = 0x84,
22 CMD_SYSINFO = 0x85,
23 CMD_INIT = 0x86,
24 CMD_PROMPT = 0x87,
25 CMD_WINK = 0x88,
26 CMD_BLE_UID = 0xb5,
27 CMD_USB_TEST = 0xb9,
28 CMD_DFU = 0xba,
29 CMD_SYNC = 0xbc,
30 CMD_ERROR = 0xbf,
31 };
32
33 static const size_t kInitPacketHeader = 7;
34 static const size_t kContPacketHeader = 5;
35 static const size_t kInitPacketDataSize = 57;
36 static const size_t kContPacketDataSize = 59;
37
38 // Messages are limited to an init packet and 128 cont packets
39 // Maximum payload length therefore is 64-7 + 128 * (64-5) = 7609 bytes
40 static const size_t kMaxMessageSize = 7609;
41
42 U2fMessage(const char channel_id[U2fPacket::kChannelIdSize],
43 const u2f_message_type type,
44 const std::vector<char> data);
Reilly Grant (use Gerrit) 2016/11/23 22:21:50 Use std::vector<uint8_t> for byte strings.
Casey Piper 2016/11/29 22:11:15 Done.
45
46 scoped_refptr<net::IOBufferWithSize> GetNextPacket();
47 size_t NumPackets();
48
49 private:
50 friend class base::RefCountedThreadSafe<U2fMessage>;
51 std::list<scoped_refptr<U2fPacket>> packets_;
52
53 protected:
54 virtual ~U2fMessage();
55 };
56 }
Reilly Grant (use Gerrit) 2016/11/23 22:21:51 } // namespace device
Casey Piper 2016/11/29 22:11:15 Done.
57
58 #endif // DEVICE_U2F_U2F_MESSAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698