Skip to content

Commit

Permalink
fix(legacy): fix OK-20989 & OK-21003 & OK-20988 & OK-20993 & OK-20994 (
Browse files Browse the repository at this point in the history
  • Loading branch information
lyxyx authored Jul 6, 2023
1 parent e49355c commit 796cdd5
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 39 deletions.
19 changes: 10 additions & 9 deletions legacy/firmware/ada.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ static bool layoutOutput(const CardanoTxOutput *output) {
ret = true;
break;
}
if (key == KEY_CANCEL) {
if (key == KEY_CANCEL || key == KEY_NULL) {
return false;
}
}
Expand Down Expand Up @@ -488,7 +488,7 @@ static bool layoutOutput(const CardanoTxOutput *output) {
ret = true;
break;
}
if (key == KEY_CANCEL) {
if (key == KEY_CANCEL || key == KEY_NULL) {
return false;
}
}
Expand Down Expand Up @@ -562,7 +562,7 @@ static bool layoutOutput(const CardanoTxOutput *output) {
case KEY_CANCEL:
return false;
default:
goto refresh_addr;
return false;
}
} else {
oledClear();
Expand All @@ -578,7 +578,7 @@ static bool layoutOutput(const CardanoTxOutput *output) {
ret = true;
break;
}
if (key == KEY_CANCEL) {
if (key == KEY_CANCEL || key == KEY_NULL) {
ret = false;
break;
}
Expand All @@ -604,7 +604,7 @@ static bool layoutFinal(void) {
return true;
break;
}
if (key == KEY_CANCEL) {
if (key == KEY_CANCEL || key == KEY_NULL) {
return false;
}
}
Expand Down Expand Up @@ -633,7 +633,7 @@ static bool layoutFee(void) {
if (key == KEY_CONFIRM) {
break;
}
if (key == KEY_CANCEL) {
if (key == KEY_CANCEL || key == KEY_NULL) {
return false;
}
}
Expand Down Expand Up @@ -790,6 +790,7 @@ bool txHashBuilder_addToken(const CardanoToken *msg) {
ret = false;
break;
default:
ret = false;
break;
}
if (!ret) {
Expand Down Expand Up @@ -863,7 +864,7 @@ static bool layoutCertificate(const CardanoTxCertificate *cert) {
if (key == KEY_CONFIRM) {
break;
}
if (key == KEY_CANCEL) {
if (key == KEY_CANCEL || key == KEY_NULL) {
return false;
}
}
Expand All @@ -884,7 +885,7 @@ static bool layoutCertificate(const CardanoTxCertificate *cert) {
if (key == KEY_CONFIRM) {
break;
}
if (key == KEY_CANCEL) {
if (key == KEY_CANCEL || key == KEY_NULL) {
return false;
}
}
Expand All @@ -907,7 +908,7 @@ static bool layoutCertificate(const CardanoTxCertificate *cert) {
if (key == KEY_CONFIRM) {
break;
}
if (key == KEY_CANCEL) {
if (key == KEY_CANCEL || key == KEY_NULL) {
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions legacy/firmware/fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ bool fsm_layoutPathWarning(uint32_t address_n_count,
&bmp_bottom_right_confirm, NULL, desc, NULL, NULL, NULL,
NULL);

if (!protectButton(ButtonRequestType_ButtonRequest_UnknownDerivationPath,
false)) {
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_UnknownDerivationPath,
true, 0, 1) != KEY_CONFIRM) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
return false;
}
Expand Down
12 changes: 11 additions & 1 deletion legacy/firmware/language.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ const char *languages[][2] = {
{"Decrypted signed message", "解密签名消息"},
// cosmos.c
{"Delegate", "委托"},
{"Delegate Resource Contract", "资源委托合约"},
{"Delegator", "代理方"},
{"Deposit", "存款"},
{"Deposit Amount", "存款金额"},
Expand Down Expand Up @@ -419,6 +420,9 @@ const char *languages[][2] = {
{"For more information", "了解更多"},
// layout2.c
{"Format:", "格式:"},
// tron.c
{"Freeze Balance V2 Contract", "冻结余额 V2 合约"},
// layout2.c
{"From", "发送方"},
// layout2.c
{"GPG sign for:", ""},
Expand Down Expand Up @@ -793,6 +797,9 @@ const char *languages[][2] = {
{"U2F Register", "U2F 注册"},
// menu_list.c
{"USB Lock", "USB 锁"},
// tron.c
{"UnDelegate Resource Contract", "取消资源委托合约"},
{"UnFreeze Balance V2 Contract", "解冻余额 V2 合约"},
// fsm_msg_ethereum.h
{"Unable to show EIP-712 data. Sign at your own risk.",
"无法显示 EIP-712 数据.\n请谨慎甄别项目方后决定是否签名, 自负风险"},
Expand Down Expand Up @@ -848,6 +855,9 @@ const char *languages[][2] = {
{"Warning!", "警告"},
// layout2.c
{"Welcome to OneKey!", "感谢使用 OneKey!"},
// tron.c
{"Withdraw Balance Contract", "余额提现合约"},
{"Withdraw Expire Unfreeze Contract", "撤销到期解冻合约"},
// cosmos.c
{"Withdraw Reward", "提取奖励"},
{"Withdraw Validator Commission", "提取验证者佣金"},
Expand Down Expand Up @@ -1012,7 +1022,7 @@ const char *languages[][2] = {
//
{"transaction is set to", "被设定为"},
// layout2.c layout2.c
{"transaction?", "交易?"},
{"transaction?", "交易吗?"},
{"user: ", "用户:"},
// u2f.c
{"was used to register", "注册"},
Expand Down
17 changes: 12 additions & 5 deletions legacy/firmware/layout2.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void chargeDisTimer(void) {
#endif
#define LOCKTIME_TIMESTAMP_MIN_VALUE 500000000

void hide_icons(void) { hide_icon = true; }
void hide_icons(bool hide) { hide_icon = hide; }

const char *address_n_str(const uint32_t *address_n, size_t address_n_count,
bool address_is_account) {
Expand Down Expand Up @@ -271,6 +271,8 @@ uint8_t refreshBleIcon(bool force_flag) {
if (sys_bleState() == true) {
if (force_flag || false == ble_conn_status_old) {
ble_conn_status_old = true;
oledClearBitmap(OLED_WIDTH - 2 * LOGO_WIDTH - 16, 0,
&bmp_status_ble_connect);
if (usb_status) {
oledDrawBitmap(OLED_WIDTH - 2 * LOGO_WIDTH - 16, 0,
&bmp_status_ble_connect);
Expand All @@ -285,6 +287,7 @@ uint8_t refreshBleIcon(bool force_flag) {
ble_conn_status_old = false;
ret = 1;
}
oledClearBitmap(OLED_WIDTH - 2 * LOGO_WIDTH - 16, 0, &bmp_status_ble);
if (usb_status) {
oledDrawBitmap(OLED_WIDTH - 2 * LOGO_WIDTH - 16, 0, &bmp_status_ble);
} else {
Expand Down Expand Up @@ -448,7 +451,11 @@ uint8_t layoutStatusLogoEx(bool need_fresh, bool force_fresh) {

refreshNfcIcon(force_fresh);

ret = refreshBleIcon(force_fresh);
if (layoutLast == layoutHome) {
refreshBleIcon(true);
} else {
refreshBleIcon(force_fresh);
}

disLongPressBleTips();

Expand Down Expand Up @@ -962,7 +969,7 @@ bool layoutConfirmOutput(const CoinInfo *coin, AmountUnit amount_unit,
case KEY_CANCEL:
return false;
default:
break;
return false;
}

return true;
Expand Down Expand Up @@ -1120,7 +1127,7 @@ bool layoutConfirmTx(const CoinInfo *coin, AmountUnit amount_unit,
if (key == KEY_CONFIRM) {
break;
}
if (key == KEY_CANCEL) {
if (key == KEY_CANCEL || key == KEY_NULL) {
return false;
}
}
Expand All @@ -1137,7 +1144,7 @@ bool layoutConfirmTx(const CoinInfo *coin, AmountUnit amount_unit,
if (key == KEY_CONFIRM) {
break;
}
if (key == KEY_CANCEL) {
if (key == KEY_CANCEL || key == KEY_NULL) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/layout2.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,6 @@ bool layoutSignHash(const char *chain_name, bool verify, const char *signer,
bool layoutPaginated(const char *title, const uint8_t *data, uint16_t len);

void onboarding(uint8_t key);
void hide_icons(void);
void hide_icons(bool hide);

#endif
6 changes: 5 additions & 1 deletion legacy/firmware/menu_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,13 @@ void menu_set_trezor_compatibility(int index) {
}
}

bool trezor_comp_mode = false;
config_getTrezorCompMode(&trezor_comp_mode);
config_setTrezorCompMode(index ? false : true);
#if !EMULATOR
svc_system_reset();
if ((index && trezor_comp_mode) || (!index && !trezor_comp_mode)) {
svc_system_reset();
}
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion legacy/firmware/pinmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void pinmatrix_draw(const char *text) {
&bmp_digit5, &bmp_digit6, &bmp_digit7, &bmp_digit8, &bmp_digit9,
};
oledClear();
hide_icons();
hide_icons(true);
if (text) {
oledDrawStringCenterAdapter(OLED_WIDTH / 2, 0, text, FONT_STANDARD);
}
Expand Down
2 changes: 2 additions & 0 deletions legacy/firmware/protect.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ uint8_t protectWaitKey(uint32_t time_out, uint8_t mode) {
timer_out_set(timer_out_oper, time_out);
while (1) {
if (layoutEnterSleep(1)) {
key = KEY_NULL;
protectAbortedBySleep = true;
break;
}
Expand Down Expand Up @@ -1252,6 +1253,7 @@ void enter_sleep(void) {
oledBufferRestore(oled_prev);
oledRefresh();
device_sleep_state = SLEEP_NONE;
hide_icons(false);
return;
}
}
Expand Down
28 changes: 17 additions & 11 deletions legacy/firmware/signing.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include "signing.h"
#include "buttons.h"
#include "config.h"
#include "crypto.h"
#include "ecdsa.h"
Expand Down Expand Up @@ -793,7 +794,8 @@ void phase1_request_next_input(void) {

// Confirm original TXID.
layoutConfirmReplacement(description, orig_hash);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0,
1) != KEY_CONFIRM) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return;
Expand Down Expand Up @@ -2055,8 +2057,8 @@ static bool compile_output(TxOutputType *in, TxOutputBinType *out,
layoutConfirmOpReturn(in->op_return_data.bytes,
in->op_return_data.size);
}
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput,
false)) {
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_ConfirmOutput,
true, 0, 1) != KEY_CONFIRM) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return false;
Expand Down Expand Up @@ -2425,8 +2427,8 @@ static bool signing_add_orig_output(TxOutputType *orig_output) {
for (int page = 0; page < 2; ++page) {
layoutConfirmModifyOutput(coin, amount_unit, &output, orig_output,
page);
if (!protectButton(ButtonRequestType_ButtonRequest_ConfirmOutput,
false)) {
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_ConfirmOutput,
true, 0, 1) != KEY_CONFIRM) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return false;
Expand All @@ -2451,7 +2453,8 @@ static bool signing_add_orig_output(TxOutputType *orig_output) {
static bool payment_confirm_tx(void) {
if (has_unverified_external_input) {
layoutConfirmUnverifiedExternalInputs();
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0,
1) != KEY_CONFIRM) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return false;
Expand All @@ -2475,8 +2478,8 @@ static bool payment_confirm_tx(void) {
fee = total_in - total_out;
if (fee > ((uint64_t)tx_weight * coin->maxfee_kb) / 4000) {
layoutFeeOverThreshold(coin, amount_unit, fee);
if (!protectButton(ButtonRequestType_ButtonRequest_FeeOverThreshold,
false)) {
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_FeeOverThreshold,
true, 0, 1) != KEY_CONFIRM) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return false;
Expand All @@ -2488,7 +2491,8 @@ static bool payment_confirm_tx(void) {

if (change_count > MAX_SILENT_CHANGE_COUNT) {
layoutChangeCountOverThreshold(change_count);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0,
1) != KEY_CONFIRM) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return false;
Expand Down Expand Up @@ -2548,7 +2552,8 @@ static bool payment_confirm_tx(void) {
// Fee modification.
if (fee != orig_fee) {
layoutConfirmModifyFee(coin, amount_unit, orig_fee, fee, tx_weight);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0,
1) != KEY_CONFIRM) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return false;
Expand All @@ -2560,7 +2565,8 @@ static bool payment_confirm_tx(void) {
if (info.lock_time != 0) {
bool lock_time_disabled = (info.min_sequence == SEQUENCE_FINAL);
layoutConfirmNondefaultLockTime(info.lock_time, lock_time_disabled);
if (!protectButton(ButtonRequestType_ButtonRequest_SignTx, false)) {
if (protectWaitKeyValue(ButtonRequestType_ButtonRequest_SignTx, true, 0,
1) != KEY_CONFIRM) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
signing_abort();
return false;
Expand Down
7 changes: 5 additions & 2 deletions legacy/firmware/solana.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ void solana_sign_tx(const SolanaSignTx *msg, const HDNode *node,

uint8_t key;
button_scan:
key = protectButtonValue(ButtonRequestType_ButtonRequest_ProtectCall,
false, true, 0);
key = protectWaitKeyValue(ButtonRequestType_ButtonRequest_ProtectCall,
true, 0, 0);
if (key == KEY_CANCEL) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
return;
Expand All @@ -154,6 +154,9 @@ void solana_sign_tx(const SolanaSignTx *msg, const HDNode *node,
if (i == num_summary_steps - 1) {
goto button_scan;
}
} else if (key == KEY_NULL) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
return;
}
}
}
Expand Down
Loading

0 comments on commit 796cdd5

Please sign in to comment.