chromium/third_party/blink/public/mojom/webauthn/virtual_authenticator.mojom

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

module blink.test.mojom;

import "third_party/blink/public/mojom/webauthn/authenticator.mojom";

// Application protocol that the virtual authenticator should simulate.
enum ClientToAuthenticatorProtocol {
  U2F,
  CTAP2,
};

// A specific versioned release of the CTAP2 protocol.
enum Ctap2Version {
  CTAP2_0,
  CTAP2_1,
};

// Attributes that the virtual authenticator should simulate.
struct VirtualAuthenticatorOptions {
  // protocol is the client-to-authenticator protocol that the virtual
  // authenticator simulates.
  ClientToAuthenticatorProtocol protocol;
  // ctap2_version indicates which minor version of CTAP2 the authenticator
  // should simulate if |protocol| is CTAP2. It is ignored otherwise.
  Ctap2Version ctap2_version;
  blink.mojom.AuthenticatorTransport transport;
  blink.mojom.AuthenticatorAttachment attachment;
  bool has_resident_key;
  bool has_user_verification;
  bool is_user_present = true;
  bool has_large_blob;
  bool has_cred_blob;
  bool has_min_pin_length;
  bool has_prf;
  bool default_backup_eligibility;
  bool default_backup_state;
};

// Encapsulates both public (key handle) and private information associated
// with a single registration on a single virtual authenticator device.
struct RegisteredKey {
  array<uint8> key_handle;
  string rp_id;
  // The EC private key in PKCS#8 format.
  array<uint8> private_key;
  int32 counter;
};

// Represents a stateful virtual authenticator device.
interface VirtualAuthenticator {
  GetUniqueId() => (string id);

  AddRegistration(RegisteredKey key) => (bool added);
  GetRegistrations() => (array<RegisteredKey> keys);
  // Removes a registration identified by |key_handle|. Returns |true| if the
  // registration was found and removed, |false| otherwise.
  RemoveRegistration(array<uint8> key_handle) => (bool removed);
  ClearRegistrations() => ();

  // Returns the large blob associated with |key_handle|, if any.
  GetLargeBlob(array<uint8> key_handle) => (array<uint8>? blob);
  // Sets or replaces the per-credential large blob associated with |key_handle|.
  SetLargeBlob(array<uint8> key_handle, array<uint8> blob) => (bool set);

  // Sets whether the authenticator will reply to user verification requests
  // successfully (UV = true) or not.
  SetUserVerified(bool verified) => ();
};

// Manages a virtual environment where the Web Authentication API talks to a
// set of virtual authenticators instead of real physical devices.
interface VirtualAuthenticatorManager {
  CreateAuthenticator(VirtualAuthenticatorOptions options) => (pending_remote<VirtualAuthenticator> authenticator);
  GetAuthenticators() => (array<pending_remote<VirtualAuthenticator>> authenticators);
  RemoveAuthenticator(string id) => (bool removed);
  ClearAuthenticators() => ();
};