Skip to content

Commit

Permalink
Fix PIN Pad
Browse files Browse the repository at this point in the history
Add missing braces arround if block
Hardcode some length as parameter are wrong in protocol
  • Loading branch information
cslashm committed May 24, 2018
1 parent 0be513c commit ca49343
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,10 @@ uint8_t PC_TO_RDR_Secure(void)
CHK_PARAM_CARD_PRESENT |\
CHK_PARAM_ABORT );

if (error != 0)
if (error != 0) {
G_io_ccid.bulk_header.bulkin.dwLength = 0;
return error;
}

bBWI = G_io_ccid.bulk_header.bulkout.bSpecific_0;
wLevelParameter = (G_io_ccid.bulk_header.bulkout.bSpecific_1 + ((uint16_t)G_io_ccid.bulk_header.bulkout.bSpecific_2<<8));
Expand Down
58 changes: 31 additions & 27 deletions lib_stusb/STM32_USB_Device_Library/Class/CCID/src/usbd_ccid_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,36 +526,40 @@ uint8_t SC_Secure(uint32_t dwLength, uint8_t bBWI, uint16_t wLevelParameter,
UNUSED(returnLen);
// return SLOTERROR_CMD_NOT_SUPPORTED;
uint16_t ret_len,off;
switch(pbuf[0]) {
case 0: // verify pin
ret_len = dwLength - 15;
os_memmove(G_io_apdu_buffer, pbuf+15, dwLength-15);
switch(pbuf[0])
{
case 0: // verify pin
off = 15;
//ret_len = dwLength - 15;
ret_len = 5;
break;
case 1: // modify pin
switch(pbuf[11])
{
case 3:
off = 20;
break;
case 1: // modify pin
switch(pbuf[11]) {
case 3:
off = 20;
break;
case 2:
case 1:
off = 19;
break;
// 0 and 4-0xFF
default:
off = 18;
break;
}
ret_len = dwLength-off;
// provide with the complete apdu
os_memmove(G_io_apdu_buffer, pbuf+off, dwLength-off);
case 2:
case 1:
off = 19;
break;
default: // unsupported
G_io_ccid.bulk_header.bulkin.dwLength = 0;
RDR_to_PC_DataBlock(SLOTERROR_CMD_NOT_SUPPORTED);
CCID_Send_Reply(&USBD_Device);
return SLOTERROR_CMD_NOT_SUPPORTED;
// 0 and 4-0xFF
default:
off = 18;
break;
}
//ret_len = dwLength - off;
ret_len = 5;
break;
default: // unsupported
G_io_ccid.bulk_header.bulkin.dwLength = 0;
RDR_to_PC_DataBlock(SLOTERROR_CMD_NOT_SUPPORTED);
CCID_Send_Reply(&USBD_Device);
return SLOTERROR_CMD_NOT_SUPPORTED;
}
return SC_XferBlock(G_io_apdu_buffer, ret_len, &ret_len);
pbuf += off;
pbuf[0] = 0xEF;
return SC_XferBlock(pbuf, ret_len, &ret_len);
}

// prepare the apdu to be processed by the application
Expand Down

0 comments on commit ca49343

Please sign in to comment.