From a1e911aa4c06a88d563a692f54e840f0a87fd3e7 Mon Sep 17 00:00:00 2001 From: Saleem Rashid Date: Sat, 9 Dec 2017 16:23:37 +0000 Subject: [PATCH] transaction: Do not hardcode HASHER_SHA2 --- firmware/signing.c | 6 +++--- firmware/transaction.c | 4 ++-- firmware/transaction.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/firmware/signing.c b/firmware/signing.c index 5c74d3d249..3402cdea8d 100644 --- a/firmware/signing.c +++ b/firmware/signing.c @@ -463,7 +463,7 @@ void signing_init(uint32_t _inputs_count, uint32_t _outputs_count, const CoinInf multisig_fp_mismatch = false; next_nonsegwit_input = 0xffffffff; - tx_init(&to, inputs_count, outputs_count, version, lock_time, 0); + tx_init(&to, inputs_count, outputs_count, version, lock_time, 0, coin->hasher_type); // segwit hashes for hashPrevouts and hashSequence hasher_Init(&hashers[0], coin->hasher_type); hasher_Init(&hashers[1], coin->hasher_type); @@ -883,7 +883,7 @@ void signing_txack(TransactionType *tx) } return; case STAGE_REQUEST_2_PREV_META: - tx_init(&tp, tx->inputs_cnt, tx->outputs_cnt, tx->version, tx->lock_time, tx->extra_data_len); + tx_init(&tp, tx->inputs_cnt, tx->outputs_cnt, tx->version, tx->lock_time, tx->extra_data_len, coin->hasher_type); progress_meta_step = progress_step / (tp.inputs_len + tp.outputs_len); idx2 = 0; if (tp.inputs_len > 0) { @@ -957,7 +957,7 @@ void signing_txack(TransactionType *tx) case STAGE_REQUEST_4_INPUT: progress = 500 + ((signatures * progress_step + idx2 * progress_meta_step) >> PROGRESS_PRECISION); if (idx2 == 0) { - tx_init(&ti, inputs_count, outputs_count, version, lock_time, 0); + tx_init(&ti, inputs_count, outputs_count, version, lock_time, 0, coin->hasher_type); hasher_Reset(&hashers[0]); } // check prevouts and script type diff --git a/firmware/transaction.c b/firmware/transaction.c index ec2ed1dd1c..c7cce44f14 100644 --- a/firmware/transaction.c +++ b/firmware/transaction.c @@ -561,7 +561,7 @@ uint32_t tx_serialize_extra_data_hash(TxStruct *tx, const uint8_t *data, uint32_ return datalen; } -void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len, uint32_t version, uint32_t lock_time, uint32_t extra_data_len) +void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len, uint32_t version, uint32_t lock_time, uint32_t extra_data_len, HasherType hasher_type) { tx->inputs_len = inputs_len; tx->outputs_len = outputs_len; @@ -573,7 +573,7 @@ void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len, uint32_t v tx->extra_data_received = 0; tx->size = 0; tx->is_segwit = false; - hasher_Init(&(tx->hasher), HASHER_SHA2); + hasher_Init(&(tx->hasher), hasher_type); } void tx_hash_final(TxStruct *t, uint8_t *hash, bool reverse) diff --git a/firmware/transaction.h b/firmware/transaction.h index 2e9230d3b0..a65f58970c 100644 --- a/firmware/transaction.h +++ b/firmware/transaction.h @@ -65,7 +65,7 @@ uint32_t tx_serialize_footer(TxStruct *tx, uint8_t *out); uint32_t tx_serialize_input(TxStruct *tx, const TxInputType *input, uint8_t *out); uint32_t tx_serialize_output(TxStruct *tx, const TxOutputBinType *output, uint8_t *out); -void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len, uint32_t version, uint32_t lock_time, uint32_t extra_data_len); +void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len, uint32_t version, uint32_t lock_time, uint32_t extra_data_len, HasherType hasher_type); uint32_t tx_serialize_header_hash(TxStruct *tx); uint32_t tx_serialize_input_hash(TxStruct *tx, const TxInputType *input); uint32_t tx_serialize_output_hash(TxStruct *tx, const TxOutputBinType *output);