chromium/device/fido/hid/fido_hid_packet.h

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef DEVICE_FIDO_HID_FIDO_HID_PACKET_H_
#define DEVICE_FIDO_HID_FIDO_HID_PACKET_H_

#include <stddef.h>
#include <stdint.h>

#include <memory>
#include <vector>

#include "base/component_export.h"
#include "base/containers/span.h"
#include "device/fido/fido_constants.h"

namespace device {

// HID Packets are defined by the specification at
// https://fidoalliance.org/specs/fido-v2.0-rd-20161004/fido-client-to-authenticator-protocol-v2.0-rd-20161004.html#message-and-packet-structure
// Packets are one of two types, initialization packets and continuation
// packets. HID Packets have header information and a payload. If a
// FidoHidInitPacket cannot store the entire payload, further payload
// information is stored in HidContinuationPackets.
class COMPONENT_EXPORT(DEVICE_FIDO) FidoHidPacket {};

// FidoHidInitPacket, based on the CTAP specification consists of a header with
// data that is serialized into a IOBuffer. A channel identifier is allocated by
// the CTAP device to ensure its system-wide uniqueness. Command identifiers
// determine the type of message the packet corresponds to. Payload length
// is the length of the entire message payload, and the data is only the portion
// of the payload that will fit into the HidInitPacket.
class COMPONENT_EXPORT(DEVICE_FIDO) FidoHidInitPacket final
    : public FidoHidPacket {};

// FidoHidContinuationPacket, based on the CTAP Specification consists of a
// header with data that is serialized into an IOBuffer. The channel identifier
// will be identical to the identifier in all other packets of the message. The
// packet sequence will be the sequence number of this particular packet, from
// 0x00 to 0x7f.
class COMPONENT_EXPORT(DEVICE_FIDO) FidoHidContinuationPacket final
    : public FidoHidPacket {};

}  // namespace device

#endif  // DEVICE_FIDO_HID_FIDO_HID_PACKET_H_