#if HAVE_LIBFIDO2
#include "alloc-util.h"
+#include "ansi-color.h"
#include "ask-password-api.h"
#include "dlfcn-util.h"
#include "format-table.h"
#endif
#if HAVE_LIBFIDO2
-static int check_device_is_fido2_with_hmac_secret(const char *path) {
+static int check_device_is_fido2_with_hmac_secret(
+ const char *path,
+ bool *ret_has_rk,
+ bool *ret_has_client_pin,
+ bool *ret_has_up,
+ bool *ret_has_uv) {
+
_cleanup_(fido_dev_free_wrapper) fido_dev_t *d = NULL;
int r;
return log_error_errno(SYNTHETIC_ERRNO(EIO),
"Failed to open FIDO2 device %s: %s", path, sym_fido_strerr(r));
- r = verify_features(d, path, LOG_DEBUG, NULL, NULL, NULL, NULL);
- if (r == -ENODEV) /* Not a FIDO2 device, or not implementing 'hmac-secret' */
+ r = verify_features(d, path, LOG_DEBUG, ret_has_rk, ret_has_client_pin, ret_has_up, ret_has_uv);
+ if (r == -ENODEV) { /* Not a FIDO2 device, or not implementing 'hmac-secret' */
+ *ret_has_rk = *ret_has_client_pin = *ret_has_up = *ret_has_uv = false;
return false;
+ }
if (r < 0)
return r;
goto finish;
}
- t = table_new("path", "manufacturer", "product", "compatible");
+ t = table_new("path", "manufacturer", "product", "compatible", "rk", "clientpin", "up", "uv");
if (!t) {
r = log_oom();
goto finish;
for (size_t i = 0; i < found; i++) {
const fido_dev_info_t *entry;
+ bool has_rk, has_client_pin, has_up, has_uv;
entry = sym_fido_dev_info_ptr(di, i);
if (!entry) {
goto finish;
}
- r = check_device_is_fido2_with_hmac_secret(sym_fido_dev_info_path(entry));
+ r = check_device_is_fido2_with_hmac_secret(sym_fido_dev_info_path(entry), &has_rk, &has_client_pin, &has_up, &has_uv);
if (r < 0)
goto finish;
bool compatible = r > 0;
TABLE_PATH, sym_fido_dev_info_path(entry),
TABLE_STRING, sym_fido_dev_info_manufacturer_string(entry),
TABLE_STRING, sym_fido_dev_info_product_string(entry),
- TABLE_BOOLEAN_CHECKMARK, compatible);
+ TABLE_BOOLEAN_CHECKMARK, compatible,
+ TABLE_BOOLEAN_CHECKMARK, has_rk,
+ TABLE_BOOLEAN_CHECKMARK, has_client_pin,
+ TABLE_BOOLEAN_CHECKMARK, has_up,
+ TABLE_BOOLEAN_CHECKMARK, has_uv);
if (r < 0) {
table_log_add_error(r);
goto finish;
goto finish;
}
+ if (table_get_rows(t) > 1)
+ printf("\n"
+ "%1$sLegend: RK %2$s Resident key%3$s\n"
+ "%1$s CLIENTPIN %2$s PIN request%3$s\n"
+ "%1$s UP %2$s User presence%3$s\n"
+ "%1$s UV %2$s User verification%3$s\n",
+ ansi_grey(),
+ special_glyph(SPECIAL_GLYPH_ARROW_RIGHT),
+ ansi_normal());
+
r = 0;
finish:
goto finish;
}
- r = check_device_is_fido2_with_hmac_secret(sym_fido_dev_info_path(entry));
+ r = check_device_is_fido2_with_hmac_secret(
+ sym_fido_dev_info_path(entry),
+ /* ret_has_rk= */ NULL,
+ /* ret_has_client_pin= */ NULL,
+ /* ret_has_up= */ NULL,
+ /* ret_has_uv= */ NULL);
if (r < 0)
goto finish;
if (!r) {