Minor fixes after review

This commit is contained in:
Lucas PASCAL
2022-09-16 14:43:51 +02:00
parent 0769eaa651
commit 3f294f9582
3 changed files with 13 additions and 6 deletions

View File

@@ -58,6 +58,9 @@
#define OFFSET_LC 4
#define OFFSET_CDATA 5
#define ERR_APDU_EMPTY 0x6982
#define ERR_APDU_SIZE_MISMATCH 0x6983
void handleGetPublicKey(uint8_t p1,
uint8_t p2,
const uint8_t *dataBuffer,

View File

@@ -770,9 +770,11 @@ void app_main(void) {
// no apdu received, well, reset the session, and reset the
// bootloader configuration
if (rx == 0) {
THROW(0x6982);
THROW(ERR_APDU_EMPTY);
}
if (rx > OFFSET_LC && rx != (G_io_apdu_buffer[OFFSET_LC] + 5)) {
THROW(ERR_APDU_SIZE_MISMATCH);
}
PRINTF("New APDU received:\n%.*H\n", rx, G_io_apdu_buffer);
handleApdu(&flags, &tx);
}