pin: change show_pin_timeout() to display arbitrary message

Don't pre-check old PIN when removing PIN protection.
pull/25/head
Andrew Kozlik 5 years ago committed by Pavol Rusnak
parent 3d82cca381
commit 456a2c68d6
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -17,6 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include "py/runtime.h"
#include "py/mphal.h"
#include "py/objstr.h"
@ -31,9 +33,13 @@
STATIC mp_obj_t ui_wait_callback = mp_const_none;
STATIC secbool wrapped_ui_wait_callback(uint32_t wait, uint32_t progress) {
STATIC secbool wrapped_ui_wait_callback(uint32_t wait, uint32_t progress, const char* message) {
if (mp_obj_is_callable(ui_wait_callback)) {
if (mp_call_function_2(ui_wait_callback, mp_obj_new_int(wait), mp_obj_new_int(progress)) == mp_const_true) {
mp_obj_t args[3];
args[0] = mp_obj_new_int(wait);
args[1] = mp_obj_new_int(progress);
args[2] = mp_obj_new_str(message, strlen(message));
if (mp_call_function_n_kw(ui_wait_callback, 3, 0, args) == mp_const_true) {
return sectrue;
}
}

@ -17,8 +17,10 @@ async def change_pin(ctx, msg):
# get current pin, return failure if invalid
if config.has_pin():
curpin = await request_pin_ack(ctx, "Enter old PIN", config.get_pin_rem())
if not config.check_pin(pin_to_int(curpin)):
raise wire.PinInvalid("PIN invalid")
# if removing, defer check to change_pin()
if not msg.remove:
if not config.check_pin(pin_to_int(curpin)):
raise wire.PinInvalid("PIN invalid")
else:
curpin = ""

@ -5,11 +5,11 @@ def pin_to_int(pin: str) -> int:
return int("1" + pin)
def show_pin_timeout(seconds: int, progress: int) -> bool:
def show_pin_timeout(seconds: int, progress: int, message: str) -> bool:
if progress == 0:
ui.display.bar(0, 0, ui.WIDTH, ui.HEIGHT, ui.BG)
ui.display.text_center(
ui.WIDTH // 2, 37, "Verifying PIN", ui.BOLD, ui.FG, ui.BG, ui.WIDTH
ui.WIDTH // 2, 37, message, ui.BOLD, ui.FG, ui.BG, ui.WIDTH
)
ui.display.loader(progress, 0, ui.FG, ui.BG)
if seconds == 0:

@ -1 +1 @@
Subproject commit 24df1ca2b768d62162e9ab95602698d26c371746
Subproject commit 0e897f673a2150607bae553e21604b253352644e
Loading…
Cancel
Save