Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheirs committed Dec 12, 2023
1 parent 1d5551c commit 1c478ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions app/src/crypto_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "bech32.h"
#include "zxformat.h"
#include "leb128.h"
#include "zxmacros.h"

#ifdef LEDGER_SPECIFIC
#include "bolos_target.h"
Expand Down Expand Up @@ -130,14 +131,14 @@ zxerr_t crypto_hashExtraDataSection(const section_t *extraData, uint8_t *output,
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX) || defined(TARGET_STAX)
cx_sha256_t sha256 = {0};
cx_sha256_init(&sha256);
cx_sha256_update(&sha256, &extraData->discriminant, 1);
cx_sha256_update(&sha256, extraData->salt.ptr, extraData->salt.len);
cx_sha256_update(&sha256, extraData->bytes.ptr, extraData->bytes.len);
CHECK_CX_OK(cx_sha256_update(&sha256, &extraData->discriminant, 1));
CHECK_CX_OK(cx_sha256_update(&sha256, extraData->salt.ptr, extraData->salt.len));
CHECK_CX_OK(cx_sha256_update(&sha256, extraData->bytes.ptr, extraData->bytes.len));
uint8_t has_tag = (extraData->tag.ptr == NULL) ? 0 : 1;
cx_sha256_update(&sha256, &has_tag, 1);
cx_sha256_update(&sha256, (uint8_t*) &extraData->tag.len, has_tag*sizeof(extraData->tag.len));
cx_sha256_update(&sha256, extraData->tag.ptr, has_tag*extraData->tag.len);
cx_sha256_final(&sha256, output);
CHECK_CX_OK(cx_sha256_update(&sha256, &has_tag, 1));
CHECK_CX_OK(cx_sha256_update(&sha256, (uint8_t*) &extraData->tag.len, has_tag*sizeof(extraData->tag.len)));
CHECK_CX_OK(cx_sha256_update(&sha256, extraData->tag.ptr, has_tag*extraData->tag.len));
CHECK_CX_OK(cx_sha256_final(&sha256, output));
#else
picohash_ctx_t sha256 = {0};
picohash_init_sha256(&sha256);
Expand Down
2 changes: 1 addition & 1 deletion deps/ledger-zxlib

0 comments on commit 1c478ae

Please sign in to comment.