Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 class Type : uint8_t { | |
|
juanlang (chromium.org)
2016/11/30 19:41:32
It'd be helpful to reference the U2F specs somewhe
| |
| 18 CMD_PING = 0x81, | |
| 19 CMD_ATR = 0x82, | |
|
juanlang (chromium.org)
2016/11/30 19:41:32
This is not part of the U2F HID standard, please r
Casey Piper
2016/11/30 22:05:46
Done.
| |
| 20 CMD_APDU = 0x83, | |
|
juanlang (chromium.org)
2016/11/30 19:41:32
In the U2F HID standard, this is known as MSG rath
Casey Piper
2016/11/30 22:05:46
Done.
| |
| 21 CMD_LOCK = 0x84, | |
|
juanlang (chromium.org)
2016/11/30 19:41:32
This is not part of the U2F HID standard, please r
Casey Piper
2016/11/30 22:05:46
Done.
| |
| 22 CMD_SYSINFO = 0x85, | |
|
juanlang (chromium.org)
2016/11/30 19:41:32
Ditto.
Casey Piper
2016/11/30 22:05:46
Acknowledged.
| |
| 23 CMD_INIT = 0x86, | |
| 24 CMD_PROMPT = 0x87, | |
|
juanlang (chromium.org)
2016/11/30 19:41:32
Ditto.
Casey Piper
2016/11/30 22:05:46
Acknowledged.
| |
| 25 CMD_WINK = 0x88, | |
| 26 CMD_BLE_UID = 0xb5, | |
|
juanlang (chromium.org)
2016/11/30 19:41:32
Ditto.
Casey Piper
2016/11/30 22:05:46
Acknowledged.
| |
| 27 CMD_USB_TEST = 0xb9, | |
|
juanlang (chromium.org)
2016/11/30 19:41:32
Ditto.
Casey Piper
2016/11/30 22:05:46
Acknowledged.
| |
| 28 CMD_DFU = 0xba, | |
|
juanlang (chromium.org)
2016/11/30 19:41:32
Ditto.
Casey Piper
2016/11/30 22:05:46
Acknowledged.
| |
| 29 CMD_SYNC = 0xbc, | |
|
juanlang (chromium.org)
2016/11/30 19:41:32
No action required, just an FYI:
This is not part
Casey Piper
2016/11/30 22:05:46
Acknowledged.
| |
| 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; | |
|
juanlang (chromium.org)
2016/11/30 19:41:32
Funny that such a small line will generate this vo
Casey Piper
2016/11/30 22:05:46
Done.
| |
| 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 static scoped_refptr<U2fMessage> Create( | |
| 43 const uint8_t channel_id[U2fPacket::kChannelIdSize], | |
| 44 const Type type, | |
| 45 const std::vector<uint8_t>& data); | |
| 46 | |
| 47 scoped_refptr<net::IOBufferWithSize> GetNextPacket(); | |
| 48 size_t NumPackets(); | |
| 49 | |
| 50 std::list<scoped_refptr<U2fPacket>>::const_iterator begin(); | |
| 51 std::list<scoped_refptr<U2fPacket>>::const_iterator end(); | |
| 52 | |
| 53 private: | |
| 54 friend class base::RefCountedThreadSafe<U2fMessage>; | |
| 55 std::list<scoped_refptr<U2fPacket>> packets_; | |
| 56 U2fMessage(const uint8_t channel_id[U2fPacket::kChannelIdSize], | |
| 57 const Type type, | |
| 58 const std::vector<uint8_t>& data); | |
|
Reilly Grant (use Gerrit)
2016/11/30 20:53:46
Keep these definitions in order with blank lines b
Casey Piper
2016/11/30 22:05:46
Acknowledged.
| |
| 59 | |
| 60 protected: | |
| 61 virtual ~U2fMessage(); | |
|
Reilly Grant (use Gerrit)
2016/11/30 20:53:46
Protected before private.
Casey Piper
2016/11/30 22:05:46
Acknowledged.
| |
| 62 }; | |
| 63 } // namespace device | |
| 64 | |
| 65 #endif // DEVICE_U2F_U2F_MESSAGE_H_ | |
| OLD | NEW |