| Index: device/u2f/u2f_packet.h
|
| diff --git a/device/u2f/u2f_packet.h b/device/u2f/u2f_packet.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cf8e96d57d31c798925c15f6bc089438430d3aeb
|
| --- /dev/null
|
| +++ b/device/u2f/u2f_packet.h
|
| @@ -0,0 +1,64 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef DEVICE_U2F_U2F_PACKET_H_
|
| +#define DEVICE_U2F_U2F_PACKET_H_
|
| +
|
| +#include "base/macros.h"
|
| +#include "net/base/io_buffer.h"
|
| +
|
| +namespace device {
|
| +class U2fPacket : public base::RefCountedThreadSafe<U2fPacket> {
|
| + public:
|
| + static const size_t kChannelIdSize = 4;
|
| + // Packet size of 64 bytes + 1 byte report ID
|
| + static const size_t kPacketSize = 65;
|
| +
|
| + U2fPacket(const std::vector<uint8_t> data,
|
| + const char channel_id[kChannelIdSize]);
|
| + scoped_refptr<net::IOBufferWithSize> GetBuffer();
|
| +
|
| + protected:
|
| + std::vector<uint8_t> data_;
|
| + char channel_id_[kChannelIdSize];
|
| + scoped_refptr<net::IOBufferWithSize> serialized_;
|
| + virtual ~U2fPacket();
|
| + U2fPacket();
|
| +
|
| + private:
|
| + friend class base::RefCountedThreadSafe<U2fPacket>;
|
| +};
|
| +
|
| +class U2fInitPacket : public U2fPacket {
|
| + public:
|
| + U2fInitPacket(const char channel_id[kChannelIdSize],
|
| + const char cmd,
|
| + const std::vector<uint8_t> data,
|
| + const uint16_t payload_length);
|
| +
|
| + scoped_refptr<U2fInitPacket> Create(scoped_refptr<net::IOBufferWithSize> buf);
|
| +
|
| + protected:
|
| + ~U2fInitPacket() final;
|
| +
|
| + private:
|
| + U2fInitPacket(scoped_refptr<net::IOBufferWithSize> buf);
|
| + char command_;
|
| +};
|
| +
|
| +class U2fContPacket : public U2fPacket {
|
| + public:
|
| + U2fContPacket(const char channel_id[kChannelIdSize],
|
| + const char sequence,
|
| + std::vector<uint8_t> data);
|
| +
|
| + protected:
|
| + ~U2fContPacket() final;
|
| +
|
| + private:
|
| + char sequence_;
|
| +};
|
| +} // namespace device
|
| +
|
| +#endif // DEVICE_U2F_U2F_PACKET_H_
|
|
|