From 5e5138066afa2db79f5658ccb7ab23ec7bb2430d Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 26 Apr 2016 11:53:58 +0200 Subject: [PATCH] adapt the reorder of hash_final functions --- bootloader/usb.c | 2 +- firmware/crypto.c | 8 ++++---- firmware/reset.c | 2 +- firmware/signing.c | 4 ++-- firmware/transaction.c | 4 ++-- vendor/trezor-crypto | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bootloader/usb.c b/bootloader/usb.c index e9355d6673..0f17df6a0c 100644 --- a/bootloader/usb.c +++ b/bootloader/usb.c @@ -426,7 +426,7 @@ static void hid_rx_callback(usbd_device *dev, uint8_t ep) return; } uint8_t hash[32]; - sha256_Final(hash, &ctx); + sha256_Final(&ctx, hash); layoutFirmwareHash(hash); do { delay(100000); diff --git a/firmware/crypto.c b/firmware/crypto.c index b57a2828d7..22f545ecfc 100644 --- a/firmware/crypto.c +++ b/firmware/crypto.c @@ -110,7 +110,7 @@ int cryptoMessageSign(const HDNode *node, const uint8_t *message, size_t message sha256_Update(&ctx, varint, l); sha256_Update(&ctx, message, message_len); uint8_t hash[32]; - sha256_Final(hash, &ctx); + sha256_Final(&ctx, hash); sha256_Raw(hash, 32, hash); uint8_t pby; int result = hdnode_sign_digest(node, hash, signature + 1, &pby); @@ -151,7 +151,7 @@ int cryptoMessageVerify(const uint8_t *message, size_t message_len, const uint8_ uint32_t l = ser_length(message_len, varint); sha256_Update(&ctx, varint, l); sha256_Update(&ctx, message, message_len); - sha256_Final(hash, &ctx); + sha256_Final(&ctx, hash); sha256_Raw(hash, 32, hash); // e = -hash bn_read_be(hash, &e); @@ -357,7 +357,7 @@ int cryptoMultisigFingerprint(const MultisigRedeemScriptType *multisig, uint8_t sha256_Update(&ctx, ptr[i]->node.public_key.bytes, 33); } sha256_Update(&ctx, (const uint8_t *)&n, sizeof(uint32_t)); - sha256_Final(hash, &ctx); + sha256_Final(&ctx, hash); layoutProgressUpdate(true); return 1; } @@ -385,6 +385,6 @@ int cryptoIdentityFingerprint(const IdentityType *identity, uint8_t *hash) if (identity->has_path && identity->path[0]) { sha256_Update(&ctx, (const uint8_t *)(identity->path), strlen(identity->path)); } - sha256_Final(hash, &ctx); + sha256_Final(&ctx, hash); return 1; } diff --git a/firmware/reset.c b/firmware/reset.c index 8ec4c1bc7b..1ecad15f4d 100644 --- a/firmware/reset.c +++ b/firmware/reset.c @@ -89,7 +89,7 @@ void reset_entropy(const uint8_t *ext_entropy, uint32_t len) sha256_Init(&ctx); sha256_Update(&ctx, int_entropy, 32); sha256_Update(&ctx, ext_entropy, len); - sha256_Final(int_entropy, &ctx); + sha256_Final(&ctx, int_entropy); strlcpy(storage.mnemonic, mnemonic_from_data(int_entropy, strength / 8), sizeof(storage.mnemonic)); memset(int_entropy, 0, 32); awaiting_entropy = false; diff --git a/firmware/signing.c b/firmware/signing.c index 43999fd0df..cfc28d6984 100644 --- a/firmware/signing.c +++ b/firmware/signing.c @@ -416,7 +416,7 @@ void signing_txack(TransactionType *tx) idx1++; send_req_3_output(); } else { - sha256_Final(hash_check, &tc); + sha256_Final(&tc, hash_check); // check fees if (spending > to_spend) { fsm_sendFailure(FailureType_Failure_NotEnoughFunds, "Not enough funds"); @@ -527,7 +527,7 @@ void signing_txack(TransactionType *tx) idx2++; send_req_4_output(); } else { - sha256_Final(hash, &tc); + sha256_Final(&tc, hash); if (memcmp(hash, hash_check, 32) != 0) { fsm_sendFailure(FailureType_Failure_Other, "Transaction has changed during signing"); signing_abort(); diff --git a/firmware/transaction.c b/firmware/transaction.c index 61b98090bf..45b70da2d0 100644 --- a/firmware/transaction.c +++ b/firmware/transaction.c @@ -223,7 +223,7 @@ uint32_t compile_script_multisig_hash(const MultisigRedeemScriptType *multisig, d[1] = 0xAE; sha256_Update(&ctx, d, 2); - sha256_Final(hash, &ctx); + sha256_Final(&ctx, hash); return 1; } @@ -425,7 +425,7 @@ void tx_init(TxStruct *tx, uint32_t inputs_len, uint32_t outputs_len, uint32_t v void tx_hash_final(TxStruct *t, uint8_t *hash, bool reverse) { - sha256_Final(hash, &(t->ctx)); + sha256_Final(&(t->ctx), hash); sha256_Raw(hash, 32, hash); if (!reverse) return; uint8_t i, k; diff --git a/vendor/trezor-crypto b/vendor/trezor-crypto index 55edf71e27..ed6debf8c4 160000 --- a/vendor/trezor-crypto +++ b/vendor/trezor-crypto @@ -1 +1 @@ -Subproject commit 55edf71e274c4b803f9b0acb2847df51532fa302 +Subproject commit ed6debf8c4ec5ef9c7ef31a1a7eddf76aa33ccd8