mirror of
https://github.com/token2/libfido2.git
synced 2026-03-13 11:12:49 -07:00
fall back to ctap1 if the key claims to, but does not support ctap2
fixes gh#99
This commit is contained in:
@@ -145,6 +145,13 @@ fido_dev_open_rx(fido_dev_t *dev, int ms)
|
||||
|
||||
dev->cid = dev->attr.cid;
|
||||
|
||||
if (fido_dev_is_fido2(dev)) {
|
||||
if (fido_dev_dummy_get_cbor_info_wait(dev, ms) != FIDO_OK) {
|
||||
fido_log_debug("%s: falling back to u2f", __func__);
|
||||
fido_dev_force_u2f(dev);
|
||||
}
|
||||
}
|
||||
|
||||
return (FIDO_OK);
|
||||
fail:
|
||||
dev->io.close(dev->io_handle);
|
||||
|
||||
@@ -114,6 +114,7 @@ int u2f_authenticate(fido_dev_t *, fido_assert_t *, int);
|
||||
|
||||
/* unexposed fido ops */
|
||||
int fido_dev_authkey(fido_dev_t *, es256_pk_t *);
|
||||
int fido_dev_dummy_get_cbor_info_wait(fido_dev_t *, int);
|
||||
int fido_dev_get_pin_token(fido_dev_t *, const char *, const fido_blob_t *,
|
||||
const es256_pk_t *, fido_blob_t *);
|
||||
int fido_do_ecdh(fido_dev_t *, es256_pk_t **, fido_blob_t **);
|
||||
|
||||
29
src/info.c
29
src/info.c
@@ -278,6 +278,35 @@ fido_dev_get_cbor_info(fido_dev_t *dev, fido_cbor_info_t *ci)
|
||||
return (fido_dev_get_cbor_info_wait(dev, ci, -1));
|
||||
}
|
||||
|
||||
static int
|
||||
fido_dev_dummy_get_cbor_info_rx(fido_dev_t *dev, int ms)
|
||||
{
|
||||
const uint8_t cmd = CTAP_FRAME_INIT | CTAP_CMD_CBOR;
|
||||
unsigned char reply[512];
|
||||
int reply_len;
|
||||
|
||||
fido_log_debug("%s: dev=%p, ms=%d", __func__, (void *)dev, ms);
|
||||
|
||||
if ((reply_len = fido_rx(dev, cmd, &reply, sizeof(reply), ms)) < 0) {
|
||||
fido_log_debug("%s: fido_rx", __func__);
|
||||
return (FIDO_ERR_RX);
|
||||
}
|
||||
|
||||
return (FIDO_OK);
|
||||
}
|
||||
|
||||
int
|
||||
fido_dev_dummy_get_cbor_info_wait(fido_dev_t *dev, int ms)
|
||||
{
|
||||
int r;
|
||||
|
||||
if ((r = fido_dev_get_cbor_info_tx(dev)) != FIDO_OK ||
|
||||
(r = fido_dev_dummy_get_cbor_info_rx(dev, ms)) != FIDO_OK)
|
||||
return (r);
|
||||
|
||||
return (FIDO_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* get/set functions for fido_cbor_info_t; always at the end of the file
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user