Compare commits
2 Commits
nfc_confor
...
cap_button
Author | SHA1 | Date | |
---|---|---|---|
fd9a4fd6b3 | |||
d5c30eca7c |
18
fido2/apdu.c
18
fido2/apdu.c
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "apdu.h"
|
#include "apdu.h"
|
||||||
|
|
||||||
uint16_t apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu)
|
int apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu)
|
||||||
{
|
{
|
||||||
EXT_APDU_HEADER *hapdu = (EXT_APDU_HEADER *)data;
|
EXT_APDU_HEADER *hapdu = (EXT_APDU_HEADER *)data;
|
||||||
|
|
||||||
@ -62,11 +62,6 @@ uint16_t apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu)
|
|||||||
if (len >= 7 && b0 == 0)
|
if (len >= 7 && b0 == 0)
|
||||||
{
|
{
|
||||||
uint16_t extlen = (hapdu->lc[1] << 8) + hapdu->lc[2];
|
uint16_t extlen = (hapdu->lc[1] << 8) + hapdu->lc[2];
|
||||||
|
|
||||||
if (len - 7 < extlen)
|
|
||||||
{
|
|
||||||
return SW_WRONG_LENGTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
// case 2E (Le) - extended
|
// case 2E (Le) - extended
|
||||||
if (len == 7)
|
if (len == 7)
|
||||||
@ -108,18 +103,9 @@ uint16_t apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu)
|
|||||||
apdu->le = 0x10000;
|
apdu->le = 0x10000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((len > 5) && (len - 5 < hapdu->lc[0]))
|
|
||||||
{
|
|
||||||
return SW_WRONG_LENGTH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!apdu->case_type)
|
if (!apdu->case_type)
|
||||||
{
|
return 1;
|
||||||
return SW_COND_USE_NOT_SATISFIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (apdu->lc)
|
if (apdu->lc)
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,7 @@ typedef struct
|
|||||||
uint8_t case_type;
|
uint8_t case_type;
|
||||||
} __attribute__((packed)) APDU_STRUCT;
|
} __attribute__((packed)) APDU_STRUCT;
|
||||||
|
|
||||||
extern uint16_t apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu);
|
extern int apdu_decode(uint8_t *data, size_t len, APDU_STRUCT *apdu);
|
||||||
|
|
||||||
#define APDU_FIDO_U2F_REGISTER 0x01
|
#define APDU_FIDO_U2F_REGISTER 0x01
|
||||||
#define APDU_FIDO_U2F_AUTHENTICATE 0x02
|
#define APDU_FIDO_U2F_AUTHENTICATE 0x02
|
||||||
|
@ -486,7 +486,7 @@ static int ctap_make_auth_data(struct rpId * rp, CborEncoder * map, uint8_t * au
|
|||||||
|
|
||||||
device_set_status(CTAPHID_STATUS_PROCESSING);
|
device_set_status(CTAPHID_STATUS_PROCESSING);
|
||||||
|
|
||||||
authData->head.flags = (1 << 0); // User presence
|
authData->head.flags = (but << 0);
|
||||||
authData->head.flags |= (ctap_is_pin_set() << 2);
|
authData->head.flags |= (ctap_is_pin_set() << 2);
|
||||||
|
|
||||||
|
|
||||||
|
@ -784,10 +784,9 @@ void nfc_process_iblock(uint8_t * buf, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
APDU_STRUCT apdu;
|
APDU_STRUCT apdu;
|
||||||
uint16_t ret = apdu_decode(buf + block_offset, len - block_offset, &apdu);
|
if (apdu_decode(buf + block_offset, len - block_offset, &apdu)) {
|
||||||
if (ret != 0) {
|
|
||||||
printf1(TAG_NFC,"apdu decode error\r\n");
|
printf1(TAG_NFC,"apdu decode error\r\n");
|
||||||
nfc_write_response(buf[0], ret);
|
nfc_write_response(buf[0], SW_COND_USE_NOT_SATISFIED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf1(TAG_NFC,"apdu ok. %scase=%02x cla=%02x ins=%02x p1=%02x p2=%02x lc=%d le=%d\r\n",
|
printf1(TAG_NFC,"apdu ok. %scase=%02x cla=%02x ins=%02x p1=%02x p2=%02x lc=%d le=%d\r\n",
|
||||||
@ -803,6 +802,7 @@ void nfc_process_iblock(uint8_t * buf, int len)
|
|||||||
|
|
||||||
memmove(&chain_buffer[chain_buffer_len], apdu.data, apdu.lc);
|
memmove(&chain_buffer[chain_buffer_len], apdu.data, apdu.lc);
|
||||||
chain_buffer_len += apdu.lc;
|
chain_buffer_len += apdu.lc;
|
||||||
|
delay(1);
|
||||||
nfc_write_response(buf[0], SW_SUCCESS);
|
nfc_write_response(buf[0], SW_SUCCESS);
|
||||||
printf1(TAG_NFC, "APDU chaining ok. %d/%d\r\n", apdu.lc, chain_buffer_len);
|
printf1(TAG_NFC, "APDU chaining ok. %d/%d\r\n", apdu.lc, chain_buffer_len);
|
||||||
return;
|
return;
|
||||||
@ -810,6 +810,7 @@ void nfc_process_iblock(uint8_t * buf, int len)
|
|||||||
|
|
||||||
// if we have ISO 7816 APDU chain - move there all the data
|
// if we have ISO 7816 APDU chain - move there all the data
|
||||||
if (!chain_buffer_tx && chain_buffer_len > 0) {
|
if (!chain_buffer_tx && chain_buffer_len > 0) {
|
||||||
|
delay(1);
|
||||||
memmove(&apdu.data[chain_buffer_len], apdu.data, apdu.lc);
|
memmove(&apdu.data[chain_buffer_len], apdu.data, apdu.lc);
|
||||||
memmove(apdu.data, chain_buffer, chain_buffer_len);
|
memmove(apdu.data, chain_buffer, chain_buffer_len);
|
||||||
apdu.lc += chain_buffer_len; // here apdu struct does not match with memory!
|
apdu.lc += chain_buffer_len; // here apdu struct does not match with memory!
|
||||||
|
Reference in New Issue
Block a user