| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_U2F_U2F_MESSAGE_H_ | 5 #ifndef DEVICE_U2F_U2F_MESSAGE_H_ |
| 6 #define DEVICE_U2F_U2F_MESSAGE_H_ | 6 #define DEVICE_U2F_U2F_MESSAGE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 U2fMessage(uint32_t channel_id, Type type, const std::vector<uint8_t>& data); | 34 U2fMessage(uint32_t channel_id, Type type, const std::vector<uint8_t>& data); |
| 35 U2fMessage(std::unique_ptr<U2fInitPacket> init_packet, size_t remaining_size); | 35 U2fMessage(std::unique_ptr<U2fInitPacket> init_packet, size_t remaining_size); |
| 36 ~U2fMessage(); | 36 ~U2fMessage(); |
| 37 | 37 |
| 38 static std::unique_ptr<U2fMessage> Create(uint32_t channel_id, | 38 static std::unique_ptr<U2fMessage> Create(uint32_t channel_id, |
| 39 Type type, | 39 Type type, |
| 40 const std::vector<uint8_t>& data); | 40 const std::vector<uint8_t>& data); |
| 41 // Reconstruct a message from serialized message data | 41 // Reconstruct a message from serialized message data |
| 42 static std::unique_ptr<U2fMessage> CreateFromSerializedData( | 42 static std::unique_ptr<U2fMessage> CreateFromSerializedData( |
| 43 scoped_refptr<net::IOBufferWithSize> buf); | 43 const std::vector<uint8_t>& buf); |
| 44 // Pop front of queue with next packet | 44 // Pop front of queue with next packet |
| 45 scoped_refptr<net::IOBufferWithSize> PopNextPacket(); | 45 scoped_refptr<net::IOBufferWithSize> PopNextPacket(); |
| 46 // Adds a continuation packet to the packet list, from the serialized | 46 // Adds a continuation packet to the packet list, from the serialized |
| 47 // response value | 47 // response value |
| 48 bool AddContinuationPacket(scoped_refptr<net::IOBufferWithSize> packet_buf); | 48 bool AddContinuationPacket(const std::vector<uint8_t>& packet_buf); |
| 49 size_t NumPackets(); | 49 size_t NumPackets(); |
| 50 // Returns entire message payload | 50 // Returns entire message payload |
| 51 std::vector<uint8_t> GetMessagePayload() const; | 51 std::vector<uint8_t> GetMessagePayload() const; |
| 52 uint32_t channel_id() { return channel_id_; } | 52 uint32_t channel_id() { return channel_id_; } |
| 53 // Message construction complete | 53 // Message construction complete |
| 54 bool MessageComplete(); | 54 bool MessageComplete(); |
| 55 std::list<std::unique_ptr<U2fPacket>>::const_iterator begin(); | 55 std::list<std::unique_ptr<U2fPacket>>::const_iterator begin(); |
| 56 std::list<std::unique_ptr<U2fPacket>>::const_iterator end(); | 56 std::list<std::unique_ptr<U2fPacket>>::const_iterator end(); |
| 57 | 57 |
| 58 private: | 58 private: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 73 // Maximum payload length therefore is 64-7 + 128 * (64-5) = 7609 bytes | 73 // Maximum payload length therefore is 64-7 + 128 * (64-5) = 7609 bytes |
| 74 static constexpr size_t kMaxMessageSize = 7609; | 74 static constexpr size_t kMaxMessageSize = 7609; |
| 75 | 75 |
| 76 std::list<std::unique_ptr<U2fPacket>> packets_; | 76 std::list<std::unique_ptr<U2fPacket>> packets_; |
| 77 size_t remaining_size_; | 77 size_t remaining_size_; |
| 78 uint32_t channel_id_; | 78 uint32_t channel_id_; |
| 79 }; | 79 }; |
| 80 } // namespace device | 80 } // namespace device |
| 81 | 81 |
| 82 #endif // DEVICE_U2F_U2F_MESSAGE_H_ | 82 #endif // DEVICE_U2F_U2F_MESSAGE_H_ |
| OLD | NEW |