Skip to content

Commit

Permalink
backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
abenso committed Sep 12, 2024
1 parent 44b9aa1 commit e8a8fc6
Show file tree
Hide file tree
Showing 661 changed files with 1,550 additions and 94 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
wget https://github.com/Kitware/CMake/releases/download/v3.28.0/cmake-3.28.0-linux-x86_64.sh
sudo mkdir /opt/cmake
sudo sh cmake-3.28.0-linux-x86_64.sh --skip-license --prefix=/opt/cmake
sudo ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
sudo ln -s /opt/cmake/bin/ctest /usr/local/bin/ctest
sudo ln -sf /opt/cmake/bin/cmake /usr/local/bin/cmake
sudo ln -sf /opt/cmake/bin/ctest /usr/local/bin/ctest
- name: Verify CMake version
run: cmake --version
- name: Install deps
Expand Down Expand Up @@ -112,7 +112,9 @@ jobs:
npm install -g yarn
- name: Build and run zemu tests
run: |
make test_all
for i in {1..3}; do
make test_all && break || sleep 10
done
- name: Upload Snapshots (only failure)
if: ${{ failure() }}
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ APPVERSION_M=0
# This is the minor version
APPVERSION_N=0
# This is the patch version
APPVERSION_P=2
APPVERSION_P=3
64 changes: 53 additions & 11 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 All @@ -38,7 +39,7 @@
#undef INS_SIGN
#define INS_SIGN 0x22
#define INS_SIGN_HASH 0x23
#define INS_SIGN_TRANSACTION 0x24
#define INS_SIGN_TRANSFER 0x24

static bool tx_initialized = false;

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 @@ -208,13 +209,49 @@ void handleApdu(volatile uint32_t *flags, volatile uint32_t *tx, uint32_t rx) {
break;
}

case INS_SIGN_TRANSACTION: {
case INS_SIGN_TRANSFER: {
CHECK_PIN_VALIDATED()
set_tx_type(tx_type_transfer);
handleSign(flags, tx, 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 e8a8fc6

Please sign in to comment.