mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-09 06:50:58 +00:00
signing: copy content of root HDNode in signing_init
Instead of just storing a pointer, store the content, in case they later get overwritten.
This commit is contained in:
parent
9226589604
commit
5cbeb970c9
@ -28,11 +28,12 @@
|
|||||||
#include "secp256k1.h"
|
#include "secp256k1.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "messages.pb.h"
|
#include "messages.pb.h"
|
||||||
|
#include "memzero.h"
|
||||||
|
|
||||||
static uint32_t inputs_count;
|
static uint32_t inputs_count;
|
||||||
static uint32_t outputs_count;
|
static uint32_t outputs_count;
|
||||||
static const CoinInfo *coin;
|
static const CoinInfo *coin;
|
||||||
static const HDNode *root;
|
static CONFIDENTIAL HDNode root;
|
||||||
static CONFIDENTIAL HDNode node;
|
static CONFIDENTIAL HDNode node;
|
||||||
static bool signing = false;
|
static bool signing = false;
|
||||||
enum {
|
enum {
|
||||||
@ -457,7 +458,7 @@ bool compile_input_script_sig(TxInputType *tinput)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy(&node, root, sizeof(HDNode));
|
memcpy(&node, &root, sizeof(HDNode));
|
||||||
if (hdnode_private_ckd_cached(&node, tinput->address_n, tinput->address_n_count, NULL) == 0) {
|
if (hdnode_private_ckd_cached(&node, tinput->address_n, tinput->address_n_count, NULL) == 0) {
|
||||||
// Failed to derive private key
|
// Failed to derive private key
|
||||||
return false;
|
return false;
|
||||||
@ -478,7 +479,7 @@ void signing_init(const SignTx *msg, const CoinInfo *_coin, const HDNode *_root)
|
|||||||
inputs_count = msg->inputs_count;
|
inputs_count = msg->inputs_count;
|
||||||
outputs_count = msg->outputs_count;
|
outputs_count = msg->outputs_count;
|
||||||
coin = _coin;
|
coin = _coin;
|
||||||
root = _root;
|
memcpy(&root, _root, sizeof(HDNode));
|
||||||
version = msg->version;
|
version = msg->version;
|
||||||
lock_time = msg->lock_time;
|
lock_time = msg->lock_time;
|
||||||
expiry = msg->expiry;
|
expiry = msg->expiry;
|
||||||
@ -659,7 +660,7 @@ static bool signing_check_output(TxOutputType *txoutput) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
spending += txoutput->amount;
|
spending += txoutput->amount;
|
||||||
int co = compile_output(coin, root, txoutput, &bin_output, !is_change);
|
int co = compile_output(coin, &root, txoutput, &bin_output, !is_change);
|
||||||
if (!is_change) {
|
if (!is_change) {
|
||||||
layoutProgress(_("Signing transaction"), progress);
|
layoutProgress(_("Signing transaction"), progress);
|
||||||
}
|
}
|
||||||
@ -1207,7 +1208,7 @@ void signing_txack(TransactionType *tx)
|
|||||||
return;
|
return;
|
||||||
case STAGE_REQUEST_4_OUTPUT:
|
case STAGE_REQUEST_4_OUTPUT:
|
||||||
progress = 500 + ((signatures * progress_step + (inputs_count + idx2) * progress_meta_step) >> PROGRESS_PRECISION);
|
progress = 500 + ((signatures * progress_step + (inputs_count + idx2) * progress_meta_step) >> PROGRESS_PRECISION);
|
||||||
if (compile_output(coin, root, tx->outputs, &bin_output, false) <= 0) {
|
if (compile_output(coin, &root, tx->outputs, &bin_output, false) <= 0) {
|
||||||
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile output"));
|
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile output"));
|
||||||
signing_abort();
|
signing_abort();
|
||||||
return;
|
return;
|
||||||
@ -1330,7 +1331,7 @@ void signing_txack(TransactionType *tx)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case STAGE_REQUEST_5_OUTPUT:
|
case STAGE_REQUEST_5_OUTPUT:
|
||||||
if (compile_output(coin, root, tx->outputs, &bin_output,false) <= 0) {
|
if (compile_output(coin, &root, tx->outputs, &bin_output,false) <= 0) {
|
||||||
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile output"));
|
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to compile output"));
|
||||||
signing_abort();
|
signing_abort();
|
||||||
return;
|
return;
|
||||||
@ -1428,4 +1429,6 @@ void signing_abort(void)
|
|||||||
layoutHome();
|
layoutHome();
|
||||||
signing = false;
|
signing = false;
|
||||||
}
|
}
|
||||||
|
memzero(&root, sizeof(root));
|
||||||
|
memzero(&node, sizeof(node));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user