From 0d427f2cd28123ee29932dda7c71d8c57af7e3e7 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Sat, 20 Dec 2014 02:36:28 +0100 Subject: [PATCH] fix confirm layouts in multisig operation --- firmware/crypto.c | 3 ++- firmware/signing.c | 7 +++++++ firmware/transaction.c | 3 +++ trezor-crypto | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/firmware/crypto.c b/firmware/crypto.c index 9da57667f4..e8146f38a4 100644 --- a/firmware/crypto.c +++ b/firmware/crypto.c @@ -25,6 +25,7 @@ #include "aes.h" #include "hmac.h" #include "bip32.h" +#include "layout2.h" uint32_t ser_length(uint32_t len, uint8_t *out) { @@ -264,7 +265,7 @@ uint8_t *cryptoHDNodePathToPubkey(const HDNodePathType *hdnodepath) for (i = 0; i < hdnodepath->address_n_count; i++) { if (hdnode_public_ckd(&node, hdnodepath->address_n[i]) == 0) { return 0; - }; + } } return node.public_key; } diff --git a/firmware/signing.c b/firmware/signing.c index 1ee9e0e8cf..80643432d2 100644 --- a/firmware/signing.c +++ b/firmware/signing.c @@ -323,6 +323,7 @@ void signing_txack(TransactionType *tx) case STAGE_REQUEST_3_OUTPUT: layoutProgress("Signing", 1000 * progress / progress_total, progress); progress++; co = compile_output(coin, root, tx->outputs, &bin_output, idx1i == 0); + layoutProgress("Signing", 1000 * progress / progress_total, progress); progress++; if (co < 0) { fsm_sendFailure(FailureType_Failure_Other, "Signing cancelled by user"); signing_abort(); @@ -392,6 +393,11 @@ void signing_txack(TransactionType *tx) memcpy(input.multisig.signatures[pubkey_idx].bytes, resp.serialized.signature.bytes, resp.serialized.signature.size); input.multisig.signatures[pubkey_idx].size = resp.serialized.signature.size; input.script_sig.size = serialize_script_multisig(&(input.multisig), input.script_sig.bytes); + if (input.script_sig.size == 0) { + fsm_sendFailure(FailureType_Failure_Other, "Failed to serialize multisig script"); + signing_abort(); + return; + } } else { // SPENDADDRESS input.script_sig.size = serialize_script_sig(resp.serialized.signature.bytes, resp.serialized.signature.size, pubkey, 33, input.script_sig.bytes); } @@ -422,6 +428,7 @@ void signing_txack(TransactionType *tx) signing_abort(); return; } + layoutProgress("Signing", 1000 * progress / progress_total, progress); progress++; send_req_4_output(); } } diff --git a/firmware/transaction.c b/firmware/transaction.c index 2a75685ae5..0e45fba829 100644 --- a/firmware/transaction.c +++ b/firmware/transaction.c @@ -209,6 +209,9 @@ uint32_t serialize_script_multisig(const MultisigRedeemScriptType *multisig, uin out[r] = 0x01; r++; } uint32_t script_len = compile_script_multisig(multisig, 0); + if (script_len == 0) { + return 0; + } r += op_push(script_len, out + r); r += compile_script_multisig(multisig, out + r); return r; diff --git a/trezor-crypto b/trezor-crypto index 10a92c3c62..c6ca89a850 160000 --- a/trezor-crypto +++ b/trezor-crypto @@ -1 +1 @@ -Subproject commit 10a92c3c6276d5b1955331b7a33ebe9d6a32c37e +Subproject commit c6ca89a8507bd9310c0c92c180525989629fb7d4