Skip to content

Commit

Permalink
backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
abenso committed Sep 10, 2024
1 parent 44b9aa1 commit 195dafc
Show file tree
Hide file tree
Showing 653 changed files with 1,537 additions and 88 deletions.
60 changes: 51 additions & 9 deletions app/src/apdu_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "actions.h"
#include "addr.h"
#include "apdu_handler_legacy.h"
#include "app_main.h"
#include "coin.h"
#include "crypto.h"
Expand Down Expand Up @@ -124,7 +125,7 @@ __Z_INLINE void handleSign(volatile uint32_t *flags, volatile uint32_t *tx, uint
THROW(APDU_CODE_OK);
}

const char *error_msg = tx_parse(get_tx_type());
const char *error_msg = tx_parse(tx_get_buffer_length(), get_tx_type());
CHECK_APP_CANARY()
if (error_msg != NULL) {
const int error_msg_length = strnlen(error_msg, sizeof(G_io_apdu_buffer));
Expand Down Expand Up @@ -215,6 +216,42 @@ void handleApdu(volatile uint32_t *flags, volatile uint32_t *tx, uint32_t rx) {
break;
}

case BCOMP_GET_VERSION: {
CHECK_PIN_VALIDATED()
legacy_handleGetVersion(tx);
break;
}

case BCOMP_VERIFY_ADDRESS: {
CHECK_PIN_VALIDATED()
legacy_handleGetAddr(flags, tx, rx, 1);
break;
}

case BCOMP_GET_PUBKEY: {
CHECK_PIN_VALIDATED()
legacy_handleGetAddr(flags, tx, rx, 0);
break;
}

case BCOMP_SIGN_JSON_TX: {
CHECK_PIN_VALIDATED()
legacy_handleSignTransaction(flags, tx, rx);
break;
}

case BCOMP_SIGN_TX_HASH: {
CHECK_PIN_VALIDATED()
legacy_handleSignHash(flags, tx, rx);
break;
}

case BCOMP_MAKE_TRANSFER_TX: {
CHECK_PIN_VALIDATED()
legacy_handleSignTransferTx(flags, tx, rx);
break;
}

#if defined(APP_TESTING)
case INS_TEST: {
handleTest(flags, tx, rx);
Expand All @@ -228,15 +265,20 @@ void handleApdu(volatile uint32_t *flags, volatile uint32_t *tx, uint32_t rx) {
}
CATCH(EXCEPTION_IO_RESET) { THROW(EXCEPTION_IO_RESET); }
CATCH_OTHER(e) {
switch (e & 0xF000) {
case 0x6000:
case APDU_CODE_OK:
sw = e;
break;
default:
sw = 0x6800 | (e & 0x7FF);
break;
if (e == APDU_CODE_LEGACY_PARSER_ERROR) {
sw = e;
} else {
switch (e & 0xF000) {
case 0x6000:
case APDU_CODE_OK:
sw = e;
break;
default:
sw = 0x6800 | (e & 0x7FF);
break;
}
}

G_io_apdu_buffer[*tx] = sw >> 8;
G_io_apdu_buffer[*tx + 1] = sw & 0xFF;
*tx += 2;
Expand Down
Loading

0 comments on commit 195dafc

Please sign in to comment.