blob: 459ed6c9cc0a690bab52a0dade626a17e4fcdcfe [file] [log] [blame]
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <base/logging.h>
#include <brillo/flag_helper.h>
#include <brillo/syslog_logging.h>
#include <brillo/vcsid.h>
#include <sysexits.h>
#include "u2fd/u2f_daemon.h"
namespace {
constexpr uint32_t kDefaultVendorId = 0x18d1;
constexpr uint32_t kDefaultProductId = 0x502c;
} // namespace
int main(int argc, char* argv[]) {
DEFINE_bool(force_u2f, false, "force U2F mode even if disabled by policy");
DEFINE_bool(force_g2f, false,
"force U2F mode plus extensions regardless of policy");
DEFINE_bool(g2f_allowlist_data, false,
"append allowlisting data to G2F register responses");
DEFINE_int32(product_id, kDefaultProductId, "Product ID for the HID device");
DEFINE_int32(vendor_id, kDefaultVendorId, "Vendor ID for the HID device");
DEFINE_bool(verbose, false, "verbose logging");
DEFINE_bool(user_keys, false, "Whether to use user-specific keys");
DEFINE_bool(legacy_kh_fallback, false,
"Whether to allow auth with legacy keys when user-specific keys "
"are enabled");
brillo::FlagHelper::Init(argc, argv, "u2fd, U2FHID emulation daemon.");
brillo::InitLog(brillo::kLogToSyslog | brillo::kLogHeader |
if (FLAGS_verbose)
LOG(INFO) << "Daemon version " << brillo::kShortVCSID.value_or("<unknown>");
bool legacy_kh_fallback = FLAGS_legacy_kh_fallback || !FLAGS_user_keys;
u2f::U2fDaemon daemon(FLAGS_force_u2f, FLAGS_force_g2f,
FLAGS_g2f_allowlist_data, legacy_kh_fallback,
FLAGS_vendor_id, FLAGS_product_id);
int rc = daemon.Run();
return rc == EX_UNAVAILABLE ? EX_OK : rc;