Merge pull request #10196

e89922a ledger: throw on secret view key export rejection (tobtoht)
This commit is contained in:
tobtoht
2025-11-11 23:01:45 +00:00
2 changed files with 11 additions and 12 deletions

View File

@@ -410,7 +410,7 @@ namespace hw {
this->length_send = set_command_header_noopt(ins, p1); this->length_send = set_command_header_noopt(ins, p1);
if (ins == INS_GET_KEY && p1 == IO_SECRET_KEY) { if (ins == INS_GET_KEY && p1 == IO_SECRET_KEY) {
// export view key user input // export view key user input
this->exchange_wait_on_input(); CHECK_AND_ASSERT_THROW_MES(this->exchange_wait_on_input() == 0, "Key export rejected on device.");
} else { } else {
this->exchange(); this->exchange();
} }
@@ -619,15 +619,14 @@ namespace hw {
send_simple(INS_GET_KEY, 0x02); send_simple(INS_GET_KEY, 0x02);
//View key is retrievied, if allowed, to speed up blockchain parsing //View key is retrievied, if allowed, to speed up blockchain parsing
memmove(this->viewkey.data, this->buffer_recv+0, 32); crypto::secret_key view_secret_key;
if (is_fake_view_key(this->viewkey)) { memmove(view_secret_key.data, this->buffer_recv+0, 32);
MDEBUG("Have Not view key");
this->has_view_key = false; CHECK_AND_ASSERT_THROW_MES(!is_fake_view_key(view_secret_key), "Key export rejected on device.");
} else {
MDEBUG("Have view key"); this->viewkey = view_secret_key;
this->has_view_key = true; this->has_view_key = true;
}
#ifdef DEBUG_HWDEVICE #ifdef DEBUG_HWDEVICE
send_simple(INS_GET_KEY, 0x04); send_simple(INS_GET_KEY, 0x04);
memmove(dbg_viewkey.data, this->buffer_recv+0, 32); memmove(dbg_viewkey.data, this->buffer_recv+0, 32);

View File

@@ -172,8 +172,8 @@ namespace hw {
HMACmap hmac_map; HMACmap hmac_map;
// To speed up blockchain parsing the view key maybe handle here. // To speed up blockchain parsing the view key maybe handle here.
crypto::secret_key viewkey; crypto::secret_key viewkey = crypto::null_skey;
bool has_view_key; bool has_view_key = false;
device *controle_device; device *controle_device;