mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
layout: print bip32 path in GetAddress dialog
This commit is contained in:
parent
61044b3fc3
commit
de3b78bd0b
@ -163,7 +163,7 @@ void fsm_sendFailure(FailureType code, const char *text)
|
|||||||
msg_write(MessageType_MessageType_Failure, resp);
|
msg_write(MessageType_MessageType_Failure, resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CoinInfo *fsm_getCoin(bool has_name, const char *name)
|
static const CoinInfo *fsm_getCoin(bool has_name, const char *name)
|
||||||
{
|
{
|
||||||
const CoinInfo *coin;
|
const CoinInfo *coin;
|
||||||
if (has_name) {
|
if (has_name) {
|
||||||
@ -179,7 +179,7 @@ const CoinInfo *fsm_getCoin(bool has_name, const char *name)
|
|||||||
return coin;
|
return coin;
|
||||||
}
|
}
|
||||||
|
|
||||||
HDNode *fsm_getDerivedNode(const char *curve, uint32_t *address_n, size_t address_n_count)
|
static HDNode *fsm_getDerivedNode(const char *curve, const uint32_t *address_n, size_t address_n_count)
|
||||||
{
|
{
|
||||||
static CONFIDENTIAL HDNode node;
|
static CONFIDENTIAL HDNode node;
|
||||||
if (!storage_getRootNode(&node, curve, true)) {
|
if (!storage_getRootNode(&node, curve, true)) {
|
||||||
@ -696,7 +696,7 @@ void fsm_msgGetAddress(GetAddress *msg)
|
|||||||
}
|
}
|
||||||
bool qrcode = false;
|
bool qrcode = false;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
layoutAddress(address, desc, qrcode, msg->script_type == InputScriptType_SPENDWITNESS);
|
layoutAddress(address, desc, qrcode, msg->script_type == InputScriptType_SPENDWITNESS, msg->address_n, msg->address_n_count);
|
||||||
if (protectButton(ButtonRequestType_ButtonRequest_Address, false)) {
|
if (protectButton(ButtonRequestType_ButtonRequest_Address, false)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -734,7 +734,7 @@ void fsm_msgEthereumGetAddress(EthereumGetAddress *msg)
|
|||||||
|
|
||||||
bool qrcode = false;
|
bool qrcode = false;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
layoutAddress(address, desc, qrcode, false);
|
layoutAddress(address, desc, qrcode, false, msg->address_n, msg->address_n_count);
|
||||||
if (protectButton(ButtonRequestType_ButtonRequest_Address, false)) {
|
if (protectButton(ButtonRequestType_ButtonRequest_Address, false)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1156,7 +1156,7 @@ void fsm_msgNEMGetAddress(NEMGetAddress *msg)
|
|||||||
|
|
||||||
bool qrcode = false;
|
bool qrcode = false;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
layoutAddress(resp->address, desc, qrcode, true);
|
layoutAddress(resp->address, desc, qrcode, true, msg->address_n, msg->address_n_count);
|
||||||
if (protectButton(ButtonRequestType_ButtonRequest_Address, false)) {
|
if (protectButton(ButtonRequestType_ButtonRequest_Address, false)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ void layoutFeeOverThreshold(const CoinInfo *coin, uint64_t fee)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// split longer string into 4 rows, rowlen chars each
|
// split longer string into 4 rows, rowlen chars each
|
||||||
const char **split_message(const uint8_t *msg, uint32_t len, uint32_t rowlen)
|
static const char **split_message(const uint8_t *msg, uint32_t len, uint32_t rowlen)
|
||||||
{
|
{
|
||||||
static char str[4][32 + 1];
|
static char str[4][32 + 1];
|
||||||
if (rowlen > 32) {
|
if (rowlen > 32) {
|
||||||
@ -289,7 +289,45 @@ void layoutResetWord(const char *word, int pass, int word_pos, bool last)
|
|||||||
oledRefresh();
|
oledRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void layoutAddress(const char *address, const char *desc, bool qrcode, bool ignorecase)
|
static const char *address_n_str(const uint32_t *address_n, size_t address_n_count)
|
||||||
|
{
|
||||||
|
if (address_n_count > 8) {
|
||||||
|
return _("Unknown long path");
|
||||||
|
}
|
||||||
|
if (address_n_count == 0) {
|
||||||
|
return _("Path: m");
|
||||||
|
}
|
||||||
|
|
||||||
|
// "Path: m" / i '
|
||||||
|
static char address_str[7 + 8 * (1 + 9 + 1) + 1];
|
||||||
|
char *c = address_str + sizeof(address_str) - 1;
|
||||||
|
|
||||||
|
*c = 0; c--;
|
||||||
|
|
||||||
|
for (int n = (int)address_n_count - 1; n >= 0; n--) {
|
||||||
|
uint32_t i = address_n[n];
|
||||||
|
if (i & 0x80000000) {
|
||||||
|
*c = '\''; c--;
|
||||||
|
}
|
||||||
|
i = i & 0x7fffffff;
|
||||||
|
do {
|
||||||
|
*c = '0' + (i % 10); c--;
|
||||||
|
i /= 10;
|
||||||
|
} while (i > 0);
|
||||||
|
*c = '/'; c--;
|
||||||
|
}
|
||||||
|
*c = 'm'; c--;
|
||||||
|
*c = ' '; c--;
|
||||||
|
*c = ':'; c--;
|
||||||
|
*c = 'h'; c--;
|
||||||
|
*c = 't'; c--;
|
||||||
|
*c = 'a'; c--;
|
||||||
|
*c = 'P';
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void layoutAddress(const char *address, const char *desc, bool qrcode, bool ignorecase, const uint32_t *address_n, size_t address_n_count)
|
||||||
{
|
{
|
||||||
if (layoutLast != layoutAddress) {
|
if (layoutLast != layoutAddress) {
|
||||||
layoutSwipe();
|
layoutSwipe();
|
||||||
@ -313,7 +351,7 @@ void layoutAddress(const char *address, const char *desc, bool qrcode, bool igno
|
|||||||
|
|
||||||
oledInvert(0, 0, 63, 63);
|
oledInvert(0, 0, 63, 63);
|
||||||
if (side > 0 && side <= 29) {
|
if (side > 0 && side <= 29) {
|
||||||
int offset = 32 - side;
|
int offset = 32 - side;
|
||||||
for (int i = 0; i < side; i++) {
|
for (int i = 0; i < side; i++) {
|
||||||
for (int j = 0; j< side; j++) {
|
for (int j = 0; j< side; j++) {
|
||||||
int a = j * side + i;
|
int a = j * side + i;
|
||||||
@ -343,6 +381,7 @@ void layoutAddress(const char *address, const char *desc, bool qrcode, bool igno
|
|||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
oledDrawString(0, (i + 1) * 9 + 4, str[i]);
|
oledDrawString(0, (i + 1) * 9 + 4, str[i]);
|
||||||
}
|
}
|
||||||
|
oledDrawString(0, 42, address_n_str(address_n, address_n_count));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!qrcode) {
|
if (!qrcode) {
|
||||||
|
@ -50,7 +50,7 @@ void layoutCipherKeyValue(bool encrypt, const char *key);
|
|||||||
void layoutEncryptMessage(const uint8_t *msg, uint32_t len, bool signing);
|
void layoutEncryptMessage(const uint8_t *msg, uint32_t len, bool signing);
|
||||||
void layoutDecryptMessage(const uint8_t *msg, uint32_t len, const char *address);
|
void layoutDecryptMessage(const uint8_t *msg, uint32_t len, const char *address);
|
||||||
void layoutResetWord(const char *word, int pass, int word_pos, bool last);
|
void layoutResetWord(const char *word, int pass, int word_pos, bool last);
|
||||||
void layoutAddress(const char *address, const char *desc, bool qrcode, bool ignorecase);
|
void layoutAddress(const char *address, const char *desc, bool qrcode, bool ignorecase, const uint32_t *address_n, size_t address_n_count);
|
||||||
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 layoutDecryptIdentity(const IdentityType *identity);
|
void layoutDecryptIdentity(const IdentityType *identity);
|
||||||
|
@ -430,7 +430,7 @@ void u2f_version(const APDU *a)
|
|||||||
send_u2f_msg(version_response, sizeof(version_response));
|
send_u2f_msg(version_response, sizeof(version_response));
|
||||||
}
|
}
|
||||||
|
|
||||||
void getReadableAppId(const uint8_t appid[U2F_APPID_SIZE], const char **appname, const BITMAP **appicon) {
|
static void getReadableAppId(const uint8_t appid[U2F_APPID_SIZE], const char **appname, const BITMAP **appicon) {
|
||||||
static char buf[8+2+8+1];
|
static char buf[8+2+8+1];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < sizeof(u2f_well_known)/sizeof(U2FWellKnown); i++) {
|
for (unsigned int i = 0; i < sizeof(u2f_well_known)/sizeof(U2FWellKnown); i++) {
|
||||||
@ -448,7 +448,7 @@ void getReadableAppId(const uint8_t appid[U2F_APPID_SIZE], const char **appname,
|
|||||||
*appicon = NULL;
|
*appicon = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const HDNode *getDerivedNode(uint32_t *address_n, size_t address_n_count)
|
static const HDNode *getDerivedNode(uint32_t *address_n, size_t address_n_count)
|
||||||
{
|
{
|
||||||
static CONFIDENTIAL HDNode node;
|
static CONFIDENTIAL HDNode node;
|
||||||
if (!storage_getRootNode(&node, NIST256P1_NAME, false)) {
|
if (!storage_getRootNode(&node, NIST256P1_NAME, false)) {
|
||||||
@ -467,7 +467,7 @@ const HDNode *getDerivedNode(uint32_t *address_n, size_t address_n_count)
|
|||||||
return &node;
|
return &node;
|
||||||
}
|
}
|
||||||
|
|
||||||
const HDNode *generateKeyHandle(const uint8_t app_id[], uint8_t key_handle[])
|
static const HDNode *generateKeyHandle(const uint8_t app_id[], uint8_t key_handle[])
|
||||||
{
|
{
|
||||||
uint8_t keybase[U2F_APPID_SIZE + KEY_PATH_LEN];
|
uint8_t keybase[U2F_APPID_SIZE + KEY_PATH_LEN];
|
||||||
|
|
||||||
@ -499,7 +499,7 @@ const HDNode *generateKeyHandle(const uint8_t app_id[], uint8_t key_handle[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const HDNode *validateKeyHandle(const uint8_t app_id[], const uint8_t key_handle[])
|
static const HDNode *validateKeyHandle(const uint8_t app_id[], const uint8_t key_handle[])
|
||||||
{
|
{
|
||||||
uint32_t key_path[KEY_PATH_ENTRIES];
|
uint32_t key_path[KEY_PATH_ENTRIES];
|
||||||
key_path[0] = U2F_KEY_PATH;
|
key_path[0] = U2F_KEY_PATH;
|
||||||
|
Loading…
Reference in New Issue
Block a user