From 041eaa5e4b4c7b6001730de351ab44a10fff5a63 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 16 May 2016 18:58:13 +0200 Subject: [PATCH] refactor u2f dialogs into a separate function --- firmware/layout2.c | 4 ++++ firmware/layout2.h | 1 + firmware/u2f.c | 8 ++------ 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/firmware/layout2.c b/firmware/layout2.c index 4d77c385ac..73b566c8e0 100644 --- a/firmware/layout2.c +++ b/firmware/layout2.c @@ -335,3 +335,7 @@ void layoutSignIdentity(const IdentityType *identity, const char *challenge) NULL, NULL); } + +void layoutU2FDialog(const char *verb, const char *appid) { + layoutDialog(DIALOG_ICON_QUESTION, "Cancel", verb, NULL, verb, "U2F security key?", "", appid, "", NULL); +} diff --git a/firmware/layout2.h b/firmware/layout2.h index 1b725d5c5c..6cbe30c436 100644 --- a/firmware/layout2.h +++ b/firmware/layout2.h @@ -40,5 +40,6 @@ void layoutDecryptMessage(const uint8_t *msg, uint32_t len, const char *address) void layoutAddress(const char *address, const char *desc); void layoutPublicKey(const uint8_t *pubkey); void layoutSignIdentity(const IdentityType *identity, const char *challenge); +void layoutU2FDialog(const char *verb, const char *appid); #endif diff --git a/firmware/u2f.c b/firmware/u2f.c index a40c368c7f..330945c55b 100644 --- a/firmware/u2f.c +++ b/firmware/u2f.c @@ -568,9 +568,7 @@ void u2f_register(const APDU *a) // error: testof-user-presence is required send_u2f_error(U2F_SW_CONDITIONS_NOT_SATISFIED); buttonUpdate(); // Clear button state - layoutDialog(DIALOG_ICON_QUESTION, "Cancel", "Register", - NULL, "Register U2F", "security key", - "", getReadableAppId(req->appId), "", NULL); + layoutU2FDialog("Register", getReadableAppId(req->appId)); dialog_timeout = U2F_TIMEOUT; last_req_state = REG; return; @@ -701,9 +699,7 @@ void u2f_authenticate(const APDU *a) // error: testof-user-presence is required send_u2f_error(U2F_SW_CONDITIONS_NOT_SATISFIED); buttonUpdate(); // Clear button state - layoutDialog(DIALOG_ICON_QUESTION, "Cancel", "Authenticate", NULL, - "Authenticate U2F", "security key", - "", getReadableAppId(req->appId), "", NULL); + layoutU2FDialog("Authenticate", getReadableAppId(req->appId)); dialog_timeout = U2F_TIMEOUT; last_req_state = AUTH; return;