reset.c revision 1.2
1/*
2 * Copyright (c) 2018 Yubico AB. All rights reserved.
3 * Use of this source code is governed by a BSD-style
4 * license that can be found in the LICENSE file.
5 */
6
7#include <stdlib.h>
8#include "fido.h"
9
10static int
11fido_dev_reset_tx(fido_dev_t *dev)
12{
13	const unsigned char cbor[] = { CTAP_CBOR_RESET };
14
15	if (fido_tx(dev, CTAP_CMD_CBOR, cbor, sizeof(cbor)) < 0) {
16		fido_log_debug("%s: fido_tx", __func__);
17		return (FIDO_ERR_TX);
18	}
19
20	return (FIDO_OK);
21}
22
23static int
24fido_dev_reset_wait(fido_dev_t *dev, int ms)
25{
26	int r;
27
28	if ((r = fido_dev_reset_tx(dev)) != FIDO_OK ||
29	    (r = fido_rx_cbor_status(dev, ms)) != FIDO_OK)
30		return (r);
31
32	return (FIDO_OK);
33}
34
35int
36fido_dev_reset(fido_dev_t *dev)
37{
38	return (fido_dev_reset_wait(dev, -1));
39}
40