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_PACKET_H_ | |
| 6 #define DEVICE_U2F_U2F_PACKET_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "net/base/io_buffer.h" | |
| 10 | |
| 11 namespace device { | |
| 12 class U2fPacket : public base::RefCountedThreadSafe<U2fPacket> { | |
| 13 public: | |
| 14 U2fPacket(const std::vector<uint8_t> data, const uint8_t channel_id[]); | |
|
juanlang (chromium.org)
2016/12/07 18:29:26
Same comment about passing channel_id as a uint32_
Casey Piper
2016/12/09 00:15:54
Done.
| |
| 15 | |
| 16 scoped_refptr<net::IOBufferWithSize> GetBuffer(); | |
|
juanlang (chromium.org)
2016/12/07 18:29:26
What's the difference between GetBuffer() and GetD
Casey Piper
2016/12/09 00:15:54
I'll change it and hopefully they'll be more clear
| |
| 17 const std::vector<uint8_t> GetData(); | |
| 18 uint8_t* GetChannelId(); | |
| 19 | |
| 20 static const size_t kChannelIdSize = 4; | |
|
juanlang (chromium.org)
2016/12/07 18:29:26
If you use uint32_t for the channel_id, I don't th
Casey Piper
2016/12/09 00:15:54
Done.
| |
| 21 // Packet size of 64 bytes + 1 byte report ID | |
| 22 static const size_t kPacketSize = 65; | |
|
juanlang (chromium.org)
2016/12/07 18:29:26
Seems like an implementation detail that could be
Casey Piper
2016/12/09 00:15:54
Moved to protected.
| |
| 23 | |
| 24 protected: | |
| 25 U2fPacket(); | |
| 26 virtual ~U2fPacket(); | |
| 27 | |
| 28 std::vector<uint8_t> data_; | |
| 29 uint8_t channel_id_[kChannelIdSize]; | |
| 30 scoped_refptr<net::IOBufferWithSize> serialized_; | |
| 31 | |
| 32 private: | |
| 33 friend class base::RefCountedThreadSafe<U2fPacket>; | |
| 34 }; | |
| 35 | |
| 36 class U2fInitPacket : public U2fPacket { | |
| 37 public: | |
| 38 U2fInitPacket(const uint8_t channel_id[kChannelIdSize], | |
| 39 const uint8_t cmd, | |
| 40 const std::vector<uint8_t> data, | |
| 41 const uint16_t payload_length); | |
| 42 | |
| 43 static scoped_refptr<U2fInitPacket> Create( | |
| 44 scoped_refptr<net::IOBufferWithSize> buf, | |
| 45 size_t* remaining_size); | |
| 46 uint8_t GetCommand(); | |
| 47 uint16_t GetPayloadLength(); | |
| 48 | |
| 49 protected: | |
| 50 ~U2fInitPacket() final; | |
| 51 | |
| 52 private: | |
| 53 U2fInitPacket(scoped_refptr<net::IOBufferWithSize> buf, | |
| 54 size_t* remaining_size); | |
| 55 | |
| 56 uint8_t command_; | |
| 57 uint16_t payload_length_; | |
| 58 }; | |
| 59 | |
| 60 class U2fContPacket : public U2fPacket { | |
| 61 public: | |
| 62 U2fContPacket(const uint8_t channel_id[kChannelIdSize], | |
| 63 const uint8_t sequence, | |
| 64 std::vector<uint8_t> data); | |
| 65 static scoped_refptr<U2fContPacket> Create( | |
| 66 scoped_refptr<net::IOBufferWithSize> buf, | |
| 67 size_t* remaining_size); | |
| 68 | |
| 69 uint8_t GetSequence(); | |
| 70 | |
| 71 protected: | |
| 72 ~U2fContPacket() final; | |
| 73 | |
| 74 private: | |
| 75 U2fContPacket(scoped_refptr<net::IOBufferWithSize> buf, | |
| 76 size_t* remaining_size); | |
| 77 | |
| 78 uint8_t sequence_; | |
| 79 }; | |
| 80 } // namespace device | |
| 81 | |
| 82 #endif // DEVICE_U2F_U2F_PACKET_H_ | |
| OLD | NEW |