Skip to content

Commit d67b4b5

Browse files
authored
Bixin dev:check pin before device verify (#109)
* Revert "feat:Supports passphrase entry at the device" * feat:check pin before device verify
1 parent e71750d commit d67b4b5

File tree

18 files changed

+15
-541
lines changed

18 files changed

+15
-541
lines changed

legacy/firmware/config.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,11 +710,9 @@ const uint8_t *config_getSeed(void) {
710710
char mnemonic[MAX_MNEMONIC_LEN + 1] = {0};
711711
if (config_getMnemonic(mnemonic, sizeof(mnemonic))) {
712712
char passphrase[MAX_PASSPHRASE_LEN + 1] = {0};
713-
if (!protectPassphraseOnDevice(passphrase)) {
713+
if (!protectPassphrase(passphrase)) {
714714
memzero(mnemonic, sizeof(mnemonic));
715715
memzero(passphrase, sizeof(passphrase));
716-
fsm_sendFailure(FailureType_Failure_ActionCancelled,
717-
_("Passphrase dismissed"));
718716
return NULL;
719717
}
720718
// passphrase is used - confirm on the display

legacy/firmware/fsm_msg_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,8 @@ void fsm_msgBixinMessageSE(const BixinMessageSE *msg) {
779779
}
780780

781781
void fsm_msgBixinVerifyDeviceRequest(const BixinVerifyDeviceRequest *msg) {
782+
CHECK_PIN
783+
782784
layoutDialogSwipe(NULL, _("Cancel"), _("Confirm"), _("SECURITY CHECK"), NULL,
783785
_("Check this device with\nOneKey secure server?"), NULL,
784786
NULL, NULL, NULL);

legacy/firmware/language.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,6 @@ const char *languages[][2] = {
231231
// fsm_msg_common.h fsm_msg_common.h fsm_msg_common.h
232232
// fsm_msg_common.h fsm_msg_common.h fsm_msg_common.h
233233
{"Do you really want to", "请确认"},
234-
//
235-
{"Do you really want to \ndisable passphrase protection?",
236-
"要禁用passphrase加密吗?"},
237-
//
238-
{"Do you really want to \nenable passphrase protection?",
239-
"要启用passphrase加密吗?"},
240234
// fsm_msg_common.h
241235
{"Do you want to", "请确认"},
242236
// layout2.c
@@ -268,11 +262,7 @@ const char *languages[][2] = {
268262
// layout2.c layout2.c
269263
{"English", "简体中文"},
270264
//
271-
{"Enter", "填入"},
272-
//
273265
{"Enter PIN to unlock", "输入PIN码解锁"},
274-
//
275-
{"Enter Passphrase", "输入Passphrase"},
276266
// protect.c
277267
{"Enter new wipe code:", "输入新的擦除PIN码"},
278268
//
@@ -557,8 +547,6 @@ const char *languages[][2] = {
557547
{"Public Key:", "公钥"},
558548
// layout2.c
559549
{"QR Code", "二维码"},
560-
//
561-
{"Quit", "退出"},
562550
// layout2.c
563551
{"Quota:", "单次限额"},
564552
{"REJECT", "拒绝"},
@@ -654,10 +642,6 @@ const char *languages[][2] = {
654642
{"Starting up", "启动中"},
655643
// config.c
656644
{"Storage failure", ""},
657-
//
658-
{"Submit", "提交"},
659-
//
660-
{"Switch", "切换"},
661645
// protect.c
662646
{"The new PIN must be different from your wipe code.", ""},
663647
// recovery.c

legacy/firmware/layout2.c

Lines changed: 11 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ void layoutShowPassphrase(const char *passphrase) {
13871387
const char **str =
13881388
split_message((const uint8_t *)passphrase, strlen(passphrase), 21);
13891389
for (int i = 0; i < 3; i++) {
1390-
oledDrawString(0, (i + 1) * 9, str[i], FONT_FIXED);
1390+
oledDrawString(0, i * 9 + 4, str[i], FONT_FIXED);
13911391
}
13921392
oledDrawStringCenterAdapter(OLED_WIDTH / 2, OLED_HEIGHT - 2 * 9 - 1,
13931393
_("Use this passphrase?"), FONT_STANDARD);
@@ -1999,40 +1999,28 @@ void layoutProgressAdapter(const char *desc, int permil) {
19991999
}
20002000

20012001
void _layout_iterm_select(int x, int y, const BITMAP *bmp, const char *text,
2002-
uint8_t font, bool vert) {
2002+
uint8_t font) {
20032003
int l = 0;
20042004
int y0 = font & FONT_DOUBLE ? 8 : 0;
20052005
oledBox(x - 4, y - 8, x + 4, y + 16 + y0, false);
2006-
oledDrawBitmap(x - 4, y - 10, &bmp_btn_up);
2006+
oledDrawBitmap(x - 4, y - 8, &bmp_btn_up);
20072007
l = oledStringWidth(text, font);
20082008
if (bmp) {
20092009
oledDrawBitmap(x - 4, y + 1, bmp);
20102010
} else {
20112011
oledDrawStringAdapter(x - l / 2, y, text, font);
2012-
if (vert) {
2013-
oledInvert(x - l / 2 - 1, y - 1, x + l / 2, y + 8);
2014-
oledClearPixel(x - l / 2 - 1, y - 1);
2015-
oledClearPixel(x - l / 2 - 1, y + 8);
2016-
oledClearPixel(x + l / 2, y - 1);
2017-
oledClearPixel(x + l / 2, y + 8);
2018-
}
20192012
}
20202013

2021-
oledDrawBitmap(x - 4, y + 11 + y0, &bmp_btn_down);
2014+
oledDrawBitmap(x - 4, y + 10 + y0, &bmp_btn_down);
20222015
oledRefresh();
20232016
}
20242017

20252018
void layoutItemsSelect(int x, int y, const char *text, uint8_t font) {
2026-
_layout_iterm_select(x, y, NULL, text, font, false);
2027-
}
2028-
2029-
void layoutItemsSelect_ex(int x, int y, const char *text, uint8_t font,
2030-
bool vert) {
2031-
_layout_iterm_select(x, y, NULL, text, font, vert);
2019+
_layout_iterm_select(x, y, NULL, text, font);
20322020
}
20332021

20342022
void layoutBmpSelect(int x, int y, const BITMAP *bmp) {
2035-
_layout_iterm_select(x, y, bmp, NULL, FONT_STANDARD, false);
2023+
_layout_iterm_select(x, y, bmp, NULL, FONT_STANDARD);
20362024
}
20372025

20382026
void layoutInputPin(uint8_t pos, const char *text, int index,
@@ -2099,98 +2087,6 @@ void layoutInputWord(const char *text, uint8_t prefix_len, const char *prefix,
20992087

21002088
oledRefresh();
21012089
}
2102-
static char *input[4] = {"abc", "ABC", "123", "=/<"};
2103-
static char *input1[4] = {"ab", "AB", "01", "=<"};
2104-
2105-
void layoutInputMethod(uint8_t index) {
2106-
layoutItemsSelectAdapter(&bmp_btn_up, &bmp_btn_down, NULL, &bmp_btn_confirm,
2107-
NULL, _("OK"), index + 1, 4, NULL, NULL,
2108-
input[index], index > 0 ? input[index - 1] : NULL,
2109-
index < 3 ? input[index + 1] : NULL);
2110-
}
2111-
2112-
void layoutInputPassphrase(const char *text, uint8_t prefix_len,
2113-
const char *prefix, uint8_t char_index,
2114-
uint8_t input_type) {
2115-
int l, y = 10;
2116-
char word_show[9] = "_________";
2117-
char buf[2] = {0};
2118-
char index_str[16] = "";
2119-
uint8_t location = 0;
2120-
2121-
int x = 6, icon_x = 80;
2122-
2123-
if (prefix_len < 9) {
2124-
memcpy(word_show, prefix, prefix_len);
2125-
} else {
2126-
memcpy(word_show, prefix + prefix_len - 8, 8);
2127-
}
2128-
2129-
oledClear_ex();
2130-
2131-
// index
2132-
uint2str(prefix_len + 1, index_str);
2133-
strcat(index_str + strlen(index_str), "/");
2134-
uint2str(50, index_str + strlen(index_str));
2135-
oledDrawStringAdapter(1, 1, index_str, FONT_SMALL);
2136-
2137-
// input type
2138-
oledDrawString(icon_x, 1, input[input_type], FONT_SMALL);
2139-
2140-
l = oledStringWidth(input[input_type], FONT_SMALL);
2141-
2142-
oledInvert(icon_x - 2, 0, icon_x + l, 6);
2143-
oledClearPixel(icon_x - 2, 0);
2144-
oledClearPixel(icon_x - 2, 6);
2145-
oledClearPixel(icon_x + l, 0);
2146-
oledClearPixel(icon_x + l, 6);
2147-
oledRefresh();
2148-
2149-
// title
2150-
oledDrawStringCenterAdapter(OLED_WIDTH / 2, y, text, FONT_STANDARD);
2151-
2152-
y += 18;
2153-
if (prefix_len < 9) {
2154-
for (uint32_t i = 0; i < sizeof(word_show); i++) {
2155-
buf[0] = word_show[i];
2156-
l = oledStringWidth(buf, FONT_STANDARD);
2157-
oledDrawStringAdapter(x + 13 * i + 7 - l / 2, y, buf, FONT_STANDARD);
2158-
}
2159-
} else {
2160-
oledDrawStringAdapter(0, y, "..", FONT_STANDARD);
2161-
for (uint32_t i = 0; i < sizeof(word_show); i++) {
2162-
buf[0] = word_show[i];
2163-
l = oledStringWidth(buf, FONT_STANDARD);
2164-
oledDrawStringAdapter(x + 13 * i + 7 - l / 2, y, buf, FONT_STANDARD);
2165-
}
2166-
}
2167-
2168-
location = prefix_len > 8 ? 8 : prefix_len;
2169-
if (char_index == 0) {
2170-
layoutItemsSelect_ex(x + 13 * location + 7, y, input1[input_type],
2171-
FONT_STANDARD, true);
2172-
layoutButtonYesAdapter(_("Switch"), &bmp_btn_switch);
2173-
} else if (char_index == 0xFF) {
2174-
layoutBmpSelect(x + 13 * location + 7, y, &bmp_btn_confirm);
2175-
layoutButtonYesAdapter(_("Submit"), &bmp_btn_confirm);
2176-
} else {
2177-
buf[0] = char_index;
2178-
layoutItemsSelect_ex(x + 13 * location + 7, y, buf, FONT_STANDARD, false);
2179-
if (prefix_len == (MAX_PASSPHRASE_LEN - 1)) {
2180-
layoutButtonYesAdapter(_("Submit"), &bmp_btn_confirm);
2181-
} else {
2182-
layoutButtonYesAdapter(_("Enter"), &bmp_btn_confirm);
2183-
}
2184-
}
2185-
2186-
if (prefix_len == 0) {
2187-
layoutButtonNoAdapter(_("Quit"), &bmp_btn_back);
2188-
} else {
2189-
layoutButtonNoAdapter(_("Back"), &bmp_btn_back);
2190-
}
2191-
2192-
oledRefresh();
2193-
}
21942090

21952091
void layoutItemsSelectAdapter(const BITMAP *bmp_up, const BITMAP *bmp_down,
21962092
const BITMAP *bmp_no, const BITMAP *bmp_yes,
@@ -2244,11 +2140,11 @@ void layoutItemsSelectAdapter(const BITMAP *bmp_up, const BITMAP *bmp_down,
22442140
oledDrawStringCenterAdapter(OLED_WIDTH / 2, y1, current, FONT_STANDARD);
22452141
}
22462142

2247-
oledInvert(x - 2, y1 - 1, x + l + 1, y1 + cur_font->pixel);
2248-
oledClearPixel(x - 2, y1 - 1);
2249-
oledClearPixel(x - 2, y1 + cur_font->pixel);
2250-
oledClearPixel(x + l + 1, y1 - 1);
2251-
oledClearPixel(x + l + 1, y1 + cur_font->pixel);
2143+
oledInvert(x - 3, y1 - 1, x + l + 2, y1 + cur_font->pixel);
2144+
oledClearPixel(x - 3, y1 - 1);
2145+
oledClearPixel(x - 3, y1 + cur_font->pixel);
2146+
oledClearPixel(x + l + 2, y1 - 1);
2147+
oledClearPixel(x + l + 2, y1 + cur_font->pixel);
22522148

22532149
if (next) {
22542150
oledDrawStringCenterAdapter(OLED_WIDTH / 2, y1 + cur_font->pixel + step,

legacy/firmware/layout2.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@ void layoutDialogSwipeCenterAdapter(const BITMAP *icon, const BITMAP *bmp_no,
152152
const char *line5, const char *line6);
153153

154154
void layoutItemsSelect(int x, int y, const char *text, uint8_t font);
155-
void layoutItemsSelect_ex(int x, int y, const char *text, uint8_t font,
156-
bool vert);
157-
158155
void layoutBmpSelect(int x, int y, const BITMAP *bmp);
159156
void layoutItemsSelectAdapter(const BITMAP *bmp_up, const BITMAP *bmp_down,
160157
const BITMAP *bmp_no, const BITMAP *bmp_yes,
@@ -169,11 +166,6 @@ void layoutInputPin(uint8_t pos, const char *text, int index,
169166
void layoutInputWord(const char *text, uint8_t prefix_len, const char *prefix,
170167
const char *letter);
171168

172-
void layoutInputMethod(uint8_t index);
173-
void layoutInputPassphrase(const char *text, uint8_t prefix_len,
174-
const char *prefix, uint8_t char_index,
175-
uint8_t input_type);
176-
177169
void layoutDeviceParameters(int num);
178170
void layoutEnterSleep(void);
179171

legacy/firmware/menu_list.c

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -314,31 +314,6 @@ void menu_blindSign(int index) {
314314
}
315315
}
316316

317-
void menu_set_passphrase(int index) {
318-
(void)index;
319-
320-
uint8_t key = KEY_NULL;
321-
322-
if (index) {
323-
layoutDialogAdapter_ex(
324-
NULL, &bmp_btn_back, _("Cancel"), &bmp_btn_forward, _("Confirm"), NULL,
325-
NULL, _("Do you really want to \ndisable passphrase protection?"), NULL,
326-
NULL, NULL, NULL);
327-
} else {
328-
layoutDialogAdapter_ex(
329-
NULL, &bmp_btn_back, _("Cancel"), &bmp_btn_forward, _("Confirm"), NULL,
330-
NULL, _("Do you really want to \nenable passphrase protection?"), NULL,
331-
NULL, NULL, NULL);
332-
}
333-
334-
key = protectWaitKey(0, 1);
335-
if (key != KEY_CONFIRM) {
336-
return;
337-
}
338-
339-
config_setPassphraseProtection(index ? false : true);
340-
}
341-
342317
static struct menu_item ble_set_menu_items[] = {
343318
{"On", NULL, true, menu_para_set_ble, NULL, true},
344319
{"Off", NULL, true, menu_para_set_ble, NULL, true}};
@@ -397,19 +372,6 @@ static struct menu shutdown_set_menu = {
397372
.previous = &settings_menu,
398373
};
399374

400-
static struct menu_item passphrase_set_menu_items[] = {
401-
{"On", NULL, true, menu_set_passphrase, NULL, true},
402-
{"Off", NULL, true, menu_set_passphrase, NULL, true}};
403-
404-
static struct menu passphrase_set_menu = {
405-
.start = 0,
406-
.current = 0,
407-
.counts = COUNT_OF(passphrase_set_menu_items),
408-
.title = NULL,
409-
.items = passphrase_set_menu_items,
410-
.previous = &security_set_menu,
411-
};
412-
413375
static struct menu_item settings_menu_items[] = {
414376
{"Bluetooth", NULL, false, .sub_menu = &ble_set_menu, menu_para_ble_state,
415377
false},
@@ -432,8 +394,6 @@ static struct menu settings_menu = {
432394
static struct menu_item security_set_menu_items[] = {
433395
{"Change PIN", NULL, true, menu_changePin, NULL, false},
434396
{"Blind Signing", NULL, true, menu_blindSign, NULL, false},
435-
{"Passphrase", NULL, false, .sub_menu = &passphrase_set_menu,
436-
menu_para_passphrase, true},
437397
{"Reset", NULL, true, menu_erase_device, NULL, false},
438398
//{"Check Mnemonic", NULL, true, menu_showMnemonic, NULL}
439399
};

legacy/firmware/menu_para.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ char* menu_para_sol_switch(void) {
5656
return config_getCoinSwitch(COIN_SWITCH_SOLANA) ? _(" On") : _(" Off");
5757
};
5858

59-
char* menu_para_passphrase(void) {
60-
bool passphrase_protection = false;
61-
config_getPassphraseProtection(&passphrase_protection);
62-
return passphrase_protection ? _(" On") : _(" Off");
63-
};
64-
6559
void menu_para_set_ble(int index) {
6660
bool ble_state = index ? false : true;
6761
if (ble_state != ble_get_switch()) {

legacy/firmware/menu_para.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ char* menu_para_shutdown(void);
77
char* menu_para_autolock(void);
88
char* menu_para_eth_eip_switch(void);
99
char* menu_para_sol_switch(void);
10-
char* menu_para_passphrase(void);
1110

1211
void menu_para_set_ble(int index);
1312
void menu_para_set_language(int index);

0 commit comments

Comments
 (0)