Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Omit zero LC when sending an extended length cAPDU #179

Merged
merged 1 commit into from
Jul 1, 2019
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
20 changes: 13 additions & 7 deletions u2f-tests/NFC/u2f_nfc_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,19 @@ uint xchgAPDUExtended(uint cla, uint ins, uint p1, uint p2, uint lc,
capdu[INS] = ins & 0xff;
capdu[P1] = p1 & 0xff;
capdu[P2] = p2 & 0xff;
capdu[4] = 0;
capdu[5] = (lc>>8) & 0xff;
capdu[6]= lc & 0xff;
memcpy((void*)&capdu[7], (const void*)data, lc);
capdu[7+lc]=(uint8_t) ((*rapduLen/256) & 0xff);
capdu[8+lc]=(uint8_t) (*rapduLen & 0xff);
len = lc+9;
if (lc != 0) {
capdu[4] = 0;
capdu[5] = (lc>>8) & 0xff;
capdu[6]= lc & 0xff;
memcpy((void*)&capdu[7], (const void*)data, lc);
capdu[7+lc]=(uint8_t) ((*rapduLen/256) & 0xff);
capdu[8+lc]=(uint8_t) (*rapduLen & 0xff);
len = lc+9;
} else {
capdu[4]=(uint8_t) ((*rapduLen/256) & 0xff);
capdu[5]=(uint8_t) (*rapduLen & 0xff);
len = 6;
}

start = getTimestampMs();
printCmdAPDU(capdu, len);
Expand Down