| 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 static const size_t kChannelIdSize = 4; |
| 15 // Packet size of 64 bytes + 1 byte report ID |
| 16 static const size_t kPacketSize = 65; |
| 17 |
| 18 U2fPacket(const std::vector<uint8_t> data, |
| 19 const char channel_id[kChannelIdSize]); |
| 20 scoped_refptr<net::IOBufferWithSize> GetBuffer(); |
| 21 |
| 22 protected: |
| 23 std::vector<uint8_t> data_; |
| 24 char channel_id_[kChannelIdSize]; |
| 25 scoped_refptr<net::IOBufferWithSize> serialized_; |
| 26 virtual ~U2fPacket(); |
| 27 U2fPacket(); |
| 28 |
| 29 private: |
| 30 friend class base::RefCountedThreadSafe<U2fPacket>; |
| 31 }; |
| 32 |
| 33 class U2fInitPacket : public U2fPacket { |
| 34 public: |
| 35 U2fInitPacket(const char channel_id[kChannelIdSize], |
| 36 const char cmd, |
| 37 const std::vector<uint8_t> data, |
| 38 const uint16_t payload_length); |
| 39 |
| 40 scoped_refptr<U2fInitPacket> Create(scoped_refptr<net::IOBufferWithSize> buf); |
| 41 |
| 42 protected: |
| 43 ~U2fInitPacket() final; |
| 44 |
| 45 private: |
| 46 U2fInitPacket(scoped_refptr<net::IOBufferWithSize> buf); |
| 47 char command_; |
| 48 }; |
| 49 |
| 50 class U2fContPacket : public U2fPacket { |
| 51 public: |
| 52 U2fContPacket(const char channel_id[kChannelIdSize], |
| 53 const char sequence, |
| 54 std::vector<uint8_t> data); |
| 55 |
| 56 protected: |
| 57 ~U2fContPacket() final; |
| 58 |
| 59 private: |
| 60 char sequence_; |
| 61 }; |
| 62 } // namespace device |
| 63 |
| 64 #endif // DEVICE_U2F_U2F_PACKET_H_ |
| OLD | NEW |