mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-23 07:58:09 +00:00
show app icons in u2f dialog
This commit is contained in:
parent
b1e3c52b08
commit
da067913c2
@ -336,6 +336,9 @@ void layoutSignIdentity(const IdentityType *identity, const char *challenge)
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void layoutU2FDialog(const char *verb, const char *appid) {
|
void layoutU2FDialog(const char *verb, const char *appname, const BITMAP *appicon) {
|
||||||
layoutDialog(&bmp_icon_question, NULL, verb, NULL, verb, "U2F security key?", "", appid, "", NULL);
|
if (!appicon) {
|
||||||
|
appicon = &bmp_icon_question;
|
||||||
|
}
|
||||||
|
layoutDialog(appicon, NULL, verb, NULL, verb, "U2F security key?", "", appname, "", NULL);
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,6 @@ void layoutDecryptMessage(const uint8_t *msg, uint32_t len, const char *address)
|
|||||||
void layoutAddress(const char *address, const char *desc);
|
void layoutAddress(const char *address, const char *desc);
|
||||||
void layoutPublicKey(const uint8_t *pubkey);
|
void layoutPublicKey(const uint8_t *pubkey);
|
||||||
void layoutSignIdentity(const IdentityType *identity, const char *challenge);
|
void layoutSignIdentity(const IdentityType *identity, const char *challenge);
|
||||||
void layoutU2FDialog(const char *verb, const char *appid);
|
void layoutU2FDialog(const char *verb, const char *appname, const BITMAP *appicon);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -441,19 +441,23 @@ void u2f_version(const APDU *a)
|
|||||||
send_u2f_msg(version_response, sizeof(version_response));
|
send_u2f_msg(version_response, sizeof(version_response));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *getReadableAppId(const uint8_t appid[U2F_APPID_SIZE]) {
|
void getReadableAppId(const uint8_t appid[U2F_APPID_SIZE], const char **appname, const BITMAP **appicon) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
static char buf[6+2+6+1];
|
static char buf[8+2+8+1];
|
||||||
|
|
||||||
for (i = 0; i < sizeof(u2f_well_known)/sizeof(U2FWellKnown); i++) {
|
for (i = 0; i < sizeof(u2f_well_known)/sizeof(U2FWellKnown); i++) {
|
||||||
if (memcmp(appid, u2f_well_known[i].appid, U2F_APPID_SIZE) == 0)
|
if (memcmp(appid, u2f_well_known[i].appid, U2F_APPID_SIZE) == 0) {
|
||||||
return u2f_well_known[i].appname;
|
*appname = u2f_well_known[i].appname;
|
||||||
|
*appicon = u2f_well_known[i].appicon;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data2hex(appid, 3, &buf[0]);
|
data2hex(appid, 4, &buf[0]);
|
||||||
buf[6] = buf[7] = '.';
|
buf[8] = buf[9] = '.';
|
||||||
data2hex(appid + (U2F_APPID_SIZE - 3), 3, &buf[8]);
|
data2hex(appid + (U2F_APPID_SIZE - 4), 4, &buf[10]);
|
||||||
return buf;
|
*appname = buf;
|
||||||
|
*appicon = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const HDNode *getDerivedNode(uint32_t *address_n, size_t address_n_count)
|
const HDNode *getDerivedNode(uint32_t *address_n, size_t address_n_count)
|
||||||
@ -555,7 +559,10 @@ void u2f_register(const APDU *a)
|
|||||||
getDerivedNode(NULL, 0);
|
getDerivedNode(NULL, 0);
|
||||||
// error: testof-user-presence is required
|
// error: testof-user-presence is required
|
||||||
buttonUpdate(); // Clear button state
|
buttonUpdate(); // Clear button state
|
||||||
layoutU2FDialog("Register", getReadableAppId(req->appId));
|
const char *appname;
|
||||||
|
const BITMAP *appicon;
|
||||||
|
getReadableAppId(req->appId, &appname, &appicon);
|
||||||
|
layoutU2FDialog("Register", appname, appicon);
|
||||||
last_req_state = REG;
|
last_req_state = REG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -679,7 +686,10 @@ void u2f_authenticate(const APDU *a)
|
|||||||
if (last_req_state == INIT) {
|
if (last_req_state == INIT) {
|
||||||
// error: testof-user-presence is required
|
// error: testof-user-presence is required
|
||||||
buttonUpdate(); // Clear button state
|
buttonUpdate(); // Clear button state
|
||||||
layoutU2FDialog("Authenticate", getReadableAppId(req->appId));
|
const char *appname;
|
||||||
|
const BITMAP *appicon;
|
||||||
|
getReadableAppId(req->appId, &appname, &appicon);
|
||||||
|
layoutU2FDialog("Authenticate", appname, appicon);
|
||||||
last_req_state = AUTH;
|
last_req_state = AUTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
const uint8_t appid[U2F_APPID_SIZE];
|
const uint8_t appid[U2F_APPID_SIZE];
|
||||||
const char *appname;
|
const char *appname;
|
||||||
const BITMAP *icon;
|
const BITMAP *appicon;
|
||||||
} U2FWellKnown;
|
} U2FWellKnown;
|
||||||
|
|
||||||
static const U2FWellKnown u2f_well_known[4] = {
|
static const U2FWellKnown u2f_well_known[4] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user