jcs's openbsd hax
openbsd
at jcs 45 lines 882 B view raw
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 "fido.h" 8 9static int 10fido_dev_reset_tx(fido_dev_t *dev, int *ms) 11{ 12 const unsigned char cbor[] = { CTAP_CBOR_RESET }; 13 14 if (fido_tx(dev, CTAP_CMD_CBOR, cbor, sizeof(cbor), ms) < 0) { 15 fido_log_debug("%s: fido_tx", __func__); 16 return (FIDO_ERR_TX); 17 } 18 19 return (FIDO_OK); 20} 21 22static int 23fido_dev_reset_wait(fido_dev_t *dev, int *ms) 24{ 25 int r; 26 27 if ((r = fido_dev_reset_tx(dev, ms)) != FIDO_OK || 28 (r = fido_rx_cbor_status(dev, ms)) != FIDO_OK) 29 return (r); 30 31 if (dev->flags & FIDO_DEV_PIN_SET) { 32 dev->flags &= ~FIDO_DEV_PIN_SET; 33 dev->flags |= FIDO_DEV_PIN_UNSET; 34 } 35 36 return (FIDO_OK); 37} 38 39int 40fido_dev_reset(fido_dev_t *dev) 41{ 42 int ms = dev->timeout_ms; 43 44 return (fido_dev_reset_wait(dev, &ms)); 45}