Skip to content

Commit

Permalink
Require Blind Sign mode for Application TXs
Browse files Browse the repository at this point in the history
  • Loading branch information
0xPxt committed Dec 18, 2024
1 parent 7e0800b commit a8bfa95
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ DEFINES += PRODUCTION_BUILD=$(PRODUCTION_BUILD)

include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.app_testing

DEFINES += REVIEW_SCREEN_ENABLED SHORTCUT_MODE_ENABLED
DEFINES += REVIEW_SCREEN_ENABLED APP_BLINDSIGN_MODE_ENABLED

ifndef COIN
COIN=ALGO
Expand Down
5 changes: 5 additions & 0 deletions app/src/apdu_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "addr.h"
#include "crypto.h"
#include "coin.h"
#include "parser.h"
#include "zxmacros.h"

static bool tx_initialized = false;
Expand Down Expand Up @@ -151,6 +152,10 @@ __Z_INLINE void handle_sign_msgpack(volatile uint32_t *flags, volatile uint32_t
int error_msg_length = strlen(error_msg);
memcpy(G_io_apdu_buffer, error_msg, error_msg_length);
*tx += (error_msg_length);
if (strcmp(error_msg, parser_getErrorDescription(parser_blindsign_mode_required)) == 0) {
*flags |= IO_ASYNCH_REPLY;
view_blindsign_error_show();
}
THROW(APDU_CODE_DATA_INVALID);
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/common/parser_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ typedef enum {
parser_display_idx_out_of_range,
parser_display_page_out_of_range,
parser_unexpected_error,
parser_blindsign_mode_required,

// Coin generic
parser_unexpected_type,
parser_unexpected_method,
Expand Down
6 changes: 6 additions & 0 deletions app/src/parser_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "parser_impl.h"
#include "msgpack.h"
#include "app_mode.h"

static uint8_t num_items;
static uint8_t common_num_items;
Expand Down Expand Up @@ -1163,6 +1164,9 @@ parser_error_t _read(parser_context_t *c, parser_tx_t *v)
CHECK_ERROR(_readTxAssetConfig(c, v))
break;
case TX_APPLICATION:
if (!app_mode_blindsign()) {
return parser_blindsign_mode_required;
}
CHECK_ERROR(_readTxApplication(c, v))
break;
default:
Expand Down Expand Up @@ -1222,6 +1226,8 @@ const char *parser_getErrorDescription(parser_error_t err) {
return "display page out of range";
case parser_unexpected_error:
return "Unexpected error in parser";
case parser_blindsign_mode_required:
return "Blind signing mode required";
case parser_unexpected_type:
return "Unexpected type";
case parser_unexpected_method:
Expand Down

0 comments on commit a8bfa95

Please sign in to comment.