blob: ebced959dd1df42def7d49f1bb1b4746039715aa [file] [log] [blame]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
using zx;
/// The maximum message payload is based on the packet size of 64 bytes for full speed devices.
/// See the CTAP specification for the calculation of this value.
const MAX_DATA_LENGTH uint64 = 7609;
/// CTAPHID commands as defined in the CTAP specification.
/// Note that the logical rather than numeric ordering here matches that in the specification.
type CtapHidCommand = flexible enum : uint8 {
/// Mandatory commands required by a CTAPHID device.
MSG = 0x03;
CBOR = 0x10;
INIT = 0x06;
PING = 0x01;
CANCEL = 0x11;
ERROR = 0x3f;
/// Optional commands required by a CTAPHID device. Some devices may not support these.
WINK = 0x08;
LOCK = 0x04;
/// Vendor specific commands may appear in the following range.
/// Fields in Message are a combination of the packet tables in the CTAP specification.
type Message = table {
1: channel_id uint32;
2: command_id CtapHidCommand;
3: payload_len uint16;
4: data vector<uint8>:MAX_DATA_LENGTH;
/// All defined values and fields for this protocol come from the CTAP specification at
closed protocol SecurityKeyDevice {
/// Send a message (request) to a FIDO key.
strict SendMessage(Message) -> () error zx.Status;
/// Wait for and receive a message (response) from a FIDO key.
/// Returns ZX_ERR_ACCESS_DENIED if `channel_id` does not match the
/// channel_id in `response`.
strict GetMessage(struct {
channel_id uint32;
}) -> (Message) error zx.Status;