summaryrefslogtreecommitdiff
path: root/src/assert.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/assert.c')
-rw-r--r--src/assert.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/assert.c b/src/assert.c
index a21b308..b71d00e 100644
--- a/src/assert.c
+++ b/src/assert.c
@@ -152,8 +152,8 @@ fido_dev_get_assert_tx(fido_dev_t *dev, fido_assert_t *assert,
152 } 152 }
153 153
154 /* frame and transmit */ 154 /* frame and transmit */
155 if (cbor_build_frame(CTAP_CBOR_ASSERT, argv, 7, &f) < 0 || 155 if (cbor_build_frame(CTAP_CBOR_ASSERT, argv, nitems(argv), &f) < 0 ||
156 fido_tx(dev, CTAP_FRAME_INIT | CTAP_CMD_CBOR, f.ptr, f.len) < 0) { 156 fido_tx(dev, CTAP_CMD_CBOR, f.ptr, f.len) < 0) {
157 fido_log_debug("%s: fido_tx", __func__); 157 fido_log_debug("%s: fido_tx", __func__);
158 r = FIDO_ERR_TX; 158 r = FIDO_ERR_TX;
159 goto fail; 159 goto fail;
@@ -170,14 +170,14 @@ fail:
170static int 170static int
171fido_dev_get_assert_rx(fido_dev_t *dev, fido_assert_t *assert, int ms) 171fido_dev_get_assert_rx(fido_dev_t *dev, fido_assert_t *assert, int ms)
172{ 172{
173 const uint8_t cmd = CTAP_FRAME_INIT | CTAP_CMD_CBOR; 173 unsigned char reply[FIDO_MAXMSG];
174 unsigned char reply[2048];
175 int reply_len; 174 int reply_len;
176 int r; 175 int r;
177 176
178 fido_assert_reset_rx(assert); 177 fido_assert_reset_rx(assert);
179 178
180 if ((reply_len = fido_rx(dev, cmd, &reply, sizeof(reply), ms)) < 0) { 179 if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply),
180 ms)) < 0) {
181 fido_log_debug("%s: fido_rx", __func__); 181 fido_log_debug("%s: fido_rx", __func__);
182 return (FIDO_ERR_RX); 182 return (FIDO_ERR_RX);
183 } 183 }
@@ -211,10 +211,9 @@ fido_dev_get_assert_rx(fido_dev_t *dev, fido_assert_t *assert, int ms)
211static int 211static int
212fido_get_next_assert_tx(fido_dev_t *dev) 212fido_get_next_assert_tx(fido_dev_t *dev)
213{ 213{
214 const unsigned char cbor[] = { CTAP_CBOR_NEXT_ASSERT }; 214 const unsigned char cbor[] = { CTAP_CBOR_NEXT_ASSERT };
215 const uint8_t cmd = CTAP_FRAME_INIT | CTAP_CMD_CBOR;
216 215
217 if (fido_tx(dev, cmd, cbor, sizeof(cbor)) < 0) { 216 if (fido_tx(dev, CTAP_CMD_CBOR, cbor, sizeof(cbor)) < 0) {
218 fido_log_debug("%s: fido_tx", __func__); 217 fido_log_debug("%s: fido_tx", __func__);
219 return (FIDO_ERR_TX); 218 return (FIDO_ERR_TX);
220 } 219 }
@@ -225,12 +224,12 @@ fido_get_next_assert_tx(fido_dev_t *dev)
225static int 224static int
226fido_get_next_assert_rx(fido_dev_t *dev, fido_assert_t *assert, int ms) 225fido_get_next_assert_rx(fido_dev_t *dev, fido_assert_t *assert, int ms)
227{ 226{
228 const uint8_t cmd = CTAP_FRAME_INIT | CTAP_CMD_CBOR; 227 unsigned char reply[FIDO_MAXMSG];
229 unsigned char reply[2048];
230 int reply_len; 228 int reply_len;
231 int r; 229 int r;
232 230
233 if ((reply_len = fido_rx(dev, cmd, &reply, sizeof(reply), ms)) < 0) { 231 if ((reply_len = fido_rx(dev, CTAP_CMD_CBOR, &reply, sizeof(reply),
232 ms)) < 0) {
234 fido_log_debug("%s: fido_rx", __func__); 233 fido_log_debug("%s: fido_rx", __func__);
235 return (FIDO_ERR_RX); 234 return (FIDO_ERR_RX);
236 } 235 }
@@ -363,8 +362,8 @@ check_extensions(int authdata_ext, int ext)
363 return (0); 362 return (0);
364} 363}
365 364
366static int 365int
367get_signed_hash(int cose_alg, fido_blob_t *dgst, const fido_blob_t *clientdata, 366fido_get_signed_hash(int cose_alg, fido_blob_t *dgst, const fido_blob_t *clientdata,
368 const fido_blob_t *authdata_cbor) 367 const fido_blob_t *authdata_cbor)
369{ 368{
370 cbor_item_t *item = NULL; 369 cbor_item_t *item = NULL;
@@ -534,7 +533,7 @@ int
534fido_assert_verify(const fido_assert_t *assert, size_t idx, int cose_alg, 533fido_assert_verify(const fido_assert_t *assert, size_t idx, int cose_alg,
535 const void *pk) 534 const void *pk)
536{ 535{
537 unsigned char buf[1024]; 536 unsigned char buf[1024]; /* XXX */
538 fido_blob_t dgst; 537 fido_blob_t dgst;
539 const fido_assert_stmt *stmt = NULL; 538 const fido_assert_stmt *stmt = NULL;
540 int ok = -1; 539 int ok = -1;
@@ -579,9 +578,9 @@ fido_assert_verify(const fido_assert_t *assert, size_t idx, int cose_alg,
579 goto out; 578 goto out;
580 } 579 }
581 580
582 if (get_signed_hash(cose_alg, &dgst, &assert->cdh, 581 if (fido_get_signed_hash(cose_alg, &dgst, &assert->cdh,
583 &stmt->authdata_cbor) < 0) { 582 &stmt->authdata_cbor) < 0) {
584 fido_log_debug("%s: get_signed_hash", __func__); 583 fido_log_debug("%s: fido_get_signed_hash", __func__);
585 r = FIDO_ERR_INTERNAL; 584 r = FIDO_ERR_INTERNAL;
586 goto out; 585 goto out;
587 } 586 }