diff --git a/src_daosend/main.c b/src_daosend/main.c index 1b24c27..509d9f1 100644 --- a/src_daosend/main.c +++ b/src_daosend/main.c @@ -340,6 +340,17 @@ static const bagl_element_t const bagl_ui_idle[] = { }; +// TODO : replace with 1.2 SDK +int app_cx_ecfp_init_private_key(cx_curve_t curve, unsigned char WIDE *rawkey, + int key_len, cx_ecfp_private_key_t *key) { + key->curve = curve; + key->d_len = key_len; + if (rawkey != NULL) { + os_memmove(key->d, rawkey, key_len); + } + return key_len; +} + unsigned int io_seproxyhal_touch_exit(bagl_element_t *e) { // Go back to the dashboard os_sched_exit(0); @@ -383,7 +394,8 @@ unsigned int io_seproxyhal_touch_tx_ok(bagl_element_t *e) { os_perso_derive_seed_bip32(tmpCtx.transactionContext.bip32Path, tmpCtx.transactionContext.pathLength, privateKeyData, NULL); - cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey); + app_cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, + &privateKey); os_memset(privateKeyData, 0, sizeof(privateKeyData)); signatureLength = cx_ecdsa_sign(&privateKey, CX_RND_RFC6979 | CX_LAST, CX_SHA256, @@ -557,8 +569,8 @@ void sample_main(void) { } os_perso_derive_seed_bip32(bip32Path, bip32PathLength, privateKeyData, NULL); - cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, - &privateKey); + app_cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, + 32, &privateKey); cx_ecfp_generate_pair(CX_CURVE_256K1, &tmpCtx.publicKeyContext.publicKey, &privateKey, 1); @@ -633,8 +645,8 @@ void sample_main(void) { } os_perso_derive_seed_bip32(bip32Path, bip32PathLength, privateKeyData, NULL); - cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, - &privateKey); + app_cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, + 32, &privateKey); cx_ecfp_generate_pair(CX_CURVE_256K1, &tmpCtx.publicKeyContext.publicKey, &privateKey, 1); diff --git a/src_genericwallet/main.c b/src_genericwallet/main.c index d22eeaa..e2c9b72 100644 --- a/src_genericwallet/main.c +++ b/src_genericwallet/main.c @@ -355,6 +355,17 @@ static const bagl_element_t const bagl_ui_idle[] = { }; +// TODO : replace with 1.2 SDK +int app_cx_ecfp_init_private_key(cx_curve_t curve, unsigned char WIDE *rawkey, + int key_len, cx_ecfp_private_key_t *key) { + key->curve = curve; + key->d_len = key_len; + if (rawkey != NULL) { + os_memmove(key->d, rawkey, key_len); + } + return key_len; +} + unsigned int io_seproxyhal_touch_exit(bagl_element_t *e) { // Go back to the dashboard os_sched_exit(0); @@ -398,7 +409,8 @@ unsigned int io_seproxyhal_touch_tx_ok(bagl_element_t *e) { os_perso_derive_seed_bip32(tmpCtx.transactionContext.bip32Path, tmpCtx.transactionContext.pathLength, privateKeyData, NULL); - cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey); + app_cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, + &privateKey); os_memset(privateKeyData, 0, sizeof(privateKeyData)); signatureLength = cx_ecdsa_sign(&privateKey, CX_RND_RFC6979 | CX_LAST, CX_SHA256, @@ -556,8 +568,8 @@ void sample_main(void) { } os_perso_derive_seed_bip32(bip32Path, bip32PathLength, privateKeyData, NULL); - cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, - &privateKey); + app_cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, + 32, &privateKey); cx_ecfp_generate_pair(CX_CURVE_256K1, &tmpCtx.publicKeyContext.publicKey, &privateKey, 1); diff --git a/src_tmp/app_cx_sha3.c b/src_tmp/app_cx_sha3.c index a27f510..ed3c773 100644 --- a/src_tmp/app_cx_sha3.c +++ b/src_tmp/app_cx_sha3.c @@ -284,11 +284,11 @@ int app_cx_hash(cx_hash_t *hash, int mode, unsigned char WIDE *in, int len, // --- last block --- if (mode & CX_LAST) { os_memset(block + blen, 0, (200 - blen)); - block[blen] |= (hash->algo == CX_SHA3 ? 0x06 : 0x01); + block[blen] |= 0x01; block[block_size - 1] |= 0x80; app_cx_sha3_block((app_cx_sha3_t *)hash); // provide result - len = ((cx_sha3_t *)hash)->output_size; + len = ((app_cx_sha3_t *)hash)->output_size; if (out) { os_memmove(out, acc, len); } diff --git a/src_tmp/app_cx_sha3.h b/src_tmp/app_cx_sha3.h index c865715..af3dd75 100644 --- a/src_tmp/app_cx_sha3.h +++ b/src_tmp/app_cx_sha3.h @@ -20,6 +20,10 @@ #pragma once +#ifndef uint64bits_t +typedef unsigned long long uint64bits_t; +#endif + struct app_cx_sha3_s { struct cx_hash_header_s header;