Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nfc: specify cla on get response #817

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/nfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,12 @@ rx_init(fido_dev_t *d, unsigned char *buf, size_t count, int ms)
}

static int
tx_get_response(fido_dev_t *d, uint8_t count)
tx_get_response(fido_dev_t *d, uint8_t count, bool cbor)
{
uint8_t apdu[5];

memset(apdu, 0, sizeof(apdu));
apdu[0] = cbor ? 0x80 : 0x00;
apdu[1] = 0xc0; /* GET_RESPONSE */
apdu[4] = count;

Expand Down Expand Up @@ -233,7 +234,7 @@ rx_apdu(fido_dev_t *d, uint8_t sw[2], unsigned char **buf, size_t *count, int *m
}

static int
rx_msg(fido_dev_t *d, unsigned char *buf, size_t count, int ms)
rx_msg(fido_dev_t *d, unsigned char *buf, size_t count, int ms, bool cbor)
{
uint8_t sw[2];
const size_t bufsiz = count;
Expand All @@ -244,7 +245,7 @@ rx_msg(fido_dev_t *d, unsigned char *buf, size_t count, int ms)
}

while (sw[0] == SW1_MORE_DATA)
if (tx_get_response(d, sw[1]) < 0 ||
if (tx_get_response(d, sw[1], cbor) < 0 ||
rx_apdu(d, sw, &buf, &count, &ms) < 0) {
fido_log_debug("%s: chain", __func__);
return -1;
Expand All @@ -268,7 +269,7 @@ rx_cbor(fido_dev_t *d, unsigned char *buf, size_t count, int ms)
{
int r;

if ((r = rx_msg(d, buf, count, ms)) < 2)
if ((r = rx_msg(d, buf, count, ms, true)) < 2)
return -1;

return r - 2;
Expand All @@ -283,7 +284,7 @@ fido_nfc_rx(fido_dev_t *d, uint8_t cmd, unsigned char *buf, size_t count, int ms
case CTAP_CMD_CBOR:
return rx_cbor(d, buf, count, ms);
case CTAP_CMD_MSG:
return rx_msg(d, buf, count, ms);
return rx_msg(d, buf, count, ms, false);
default:
fido_log_debug("%s: cmd=%02x", __func__, cmd);
return -1;
Expand Down
Loading