From d43f7f6698b043eac58f2fef592dc4bdc746cadd Mon Sep 17 00:00:00 2001 From: BTChip github Date: Tue, 24 Nov 2020 10:23:45 +0100 Subject: [PATCH] Cleanup os_mem* functions --- doc/eth_contract_support_embedded.asc | 2 +- src/handle_check_address.c | 6 ++--- src/handle_get_printable_amount.c | 4 ++-- src/main.c | 22 +++++++++---------- src/poorstream.c | 2 +- src/utils.c | 6 ++--- src_common/ethUstream.c | 4 ++-- src_common/ethUtils.c | 2 +- src_common/uint256.c | 2 +- .../getEth2PublicKey/logic_getEth2PublicKey.c | 2 +- src_features/getPublicKey/cmd_getPublicKey.c | 4 ++-- .../getPublicKey/logic_getPublicKey.c | 6 ++--- .../cmd_provideTokenInfo.c | 12 +++++----- .../signMessage/ui_common_signMessage.c | 4 ++-- .../ui_common_signMessage712.c | 4 ++-- src_features/signTx/logic_signTx.c | 2 +- src_features/signTx/ui_common_signTx.c | 4 ++-- .../cmd_stark_getPublicKey.c | 4 ++-- .../logic_stark_getPublicKey.c | 2 +- .../cmd_stark_provideQuantum.c | 2 +- src_features/stark_sign/cmd_stark_sign.c | 10 ++++----- src_plugins/starkware/starkware_plugin.c | 4 ++-- 22 files changed, 55 insertions(+), 55 deletions(-) diff --git a/doc/eth_contract_support_embedded.asc b/doc/eth_contract_support_embedded.asc index 4302dad..67c27c0 100644 --- a/doc/eth_contract_support_embedded.asc +++ b/doc/eth_contract_support_embedded.asc @@ -72,7 +72,7 @@ CONTRACT_STARKWARE_DEPOSIT_TOKEN ```C if ((context->currentFieldLength == STARKWARE_DEPOSIT_TOKEN_DATA_SIZE) && - (os_memcmp(context->workBuffer, STARKWARE_DEPOSIT_TOKEN_ID, 4) == 0) && + (memcmp(context->workBuffer, STARKWARE_DEPOSIT_TOKEN_ID, 4) == 0) && quantumSet) { contractProvisioned = CONTRACT_STARKWARE_DEPOSIT_TOKEN; } diff --git a/src/handle_check_address.c b/src/handle_check_address.c index 7279b88..703ebe2 100644 --- a/src/handle_check_address.c +++ b/src/handle_check_address.c @@ -4,7 +4,7 @@ #include "ethUtils.h" #include "string.h" -#define ZERO(x) os_memset(x, 0, sizeof(x)) +#define ZERO(x) memset(x, 0, sizeof(x)) void handle_check_address(check_address_parameters_t* params, chain_config_t* chain_config) { PRINTF("Params on the address %d\n",(unsigned int)params); @@ -60,10 +60,10 @@ void handle_check_address(check_address_parameters_t* params, chain_config_t* ch } if ((strlen(locals_union1.address) != strlen(params->address_to_check + offset_0x)) || - os_memcmp(locals_union1.address, params->address_to_check + offset_0x, strlen(locals_union1.address)) != 0) { + memcmp(locals_union1.address, params->address_to_check + offset_0x, strlen(locals_union1.address)) != 0) { PRINTF("Addresses doesn't match\n"); return; } PRINTF("Addresses match\n"); params->result = 1; -} \ No newline at end of file +} diff --git a/src/handle_get_printable_amount.c b/src/handle_get_printable_amount.c index 6f7d36d..0d5e0dd 100644 --- a/src/handle_get_printable_amount.c +++ b/src/handle_get_printable_amount.c @@ -10,7 +10,7 @@ void handle_get_printable_amount( get_printable_amount_parameters_t* params, chain_config_t *config) { uint8_t decimals; char ticker[MAX_TICKER_LEN]; - os_memset(params->printable_amount, 0, sizeof(params->printable_amount)); + memset(params->printable_amount, 0, sizeof(params->printable_amount)); if (params->amount_length > 32) { PRINTF("Amount is too big, 32 bytes max but buffer has %u bytes", params->amount_length); os_lib_end(); @@ -30,4 +30,4 @@ void handle_get_printable_amount( get_printable_amount_parameters_t* params, cha } amountToString(params->amount, params->amount_length, decimals, ticker, params->printable_amount, sizeof(params->printable_amount)); -} \ No newline at end of file +} diff --git a/src/main.c b/src/main.c index f1a6371..f47fff6 100644 --- a/src/main.c +++ b/src/main.c @@ -69,7 +69,7 @@ chain_config_t *chainConfig; void reset_app_context() { //PRINTF("!!RESET_APP_CONTEXT\n"); appState = APP_STATE_IDLE; - os_memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN); + memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN); called_from_swap = false; #ifdef HAVE_STARKWARE quantumSet = false; @@ -77,8 +77,8 @@ void reset_app_context() { #ifdef HAVE_ETH2 eth2WithdrawalIndex = 0; #endif - os_memset((uint8_t*)&txContext, 0, sizeof(txContext)); - os_memset((uint8_t*)&tmpContent, 0, sizeof(tmpContent)); + memset((uint8_t*)&txContext, 0, sizeof(txContext)); + memset((uint8_t*)&tmpContent, 0, sizeof(tmpContent)); } void ui_idle(void) { @@ -118,7 +118,7 @@ void io_seproxyhal_send_status(uint32_t sw) { } void format_signature_out(const uint8_t* signature) { - os_memset(G_io_apdu_buffer + 1, 0x00, 64); + memset(G_io_apdu_buffer + 1, 0x00, 64); uint8_t offset = 1; uint8_t xoffset = 4; //point to r value //copy r @@ -355,14 +355,14 @@ tokenDefinition_t* getKnownToken(uint8_t *contractAddress) { currentToken = (tokenDefinition_t *)PIC(&TOKENS_THUNDERCORE[i]); break } - if (os_memcmp(currentToken->address, tmpContent.txContent.destination, 20) == 0) { + if (memcmp(currentToken->address, tmpContent.txContent.destination, 20) == 0) { return currentToken; } } #endif for(size_t i=0; iaddress, contractAddress, 20) == 0)) { + if (tmpCtx.transactionContext.tokenSet[i] && (memcmp(currentToken->address, contractAddress, 20) == 0)) { PRINTF("Token found at index %d\n", i); return currentToken; } @@ -409,7 +409,7 @@ void handleApdu(unsigned int *flags, unsigned int *tx) { switch (G_io_apdu_buffer[OFFSET_INS]) { case INS_GET_PUBLIC_KEY: - os_memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN); + memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN); handleGetPublicKey(G_io_apdu_buffer[OFFSET_P1], G_io_apdu_buffer[OFFSET_P2], G_io_apdu_buffer + OFFSET_CDATA, G_io_apdu_buffer[OFFSET_LC], flags, tx); break; @@ -426,19 +426,19 @@ void handleApdu(unsigned int *flags, unsigned int *tx) { break; case INS_SIGN_PERSONAL_MESSAGE: - os_memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN); + memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN); handleSignPersonalMessage(G_io_apdu_buffer[OFFSET_P1], G_io_apdu_buffer[OFFSET_P2], G_io_apdu_buffer + OFFSET_CDATA, G_io_apdu_buffer[OFFSET_LC], flags, tx); break; case INS_SIGN_EIP_712_MESSAGE: - os_memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN); + memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN); handleSignEIP712Message(G_io_apdu_buffer[OFFSET_P1], G_io_apdu_buffer[OFFSET_P2], G_io_apdu_buffer + OFFSET_CDATA, G_io_apdu_buffer[OFFSET_LC], flags, tx); break; #ifdef HAVE_ETH2 case INS_GET_ETH2_PUBLIC_KEY: - os_memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN); + memset(tmpCtx.transactionContext.tokenSet, 0, MAX_TOKEN); handleGetEth2PublicKey(G_io_apdu_buffer[OFFSET_P1], G_io_apdu_buffer[OFFSET_P2], G_io_apdu_buffer + OFFSET_CDATA, G_io_apdu_buffer[OFFSET_LC], flags, tx); break; @@ -678,7 +678,7 @@ void coin_main_with_config(chain_config_t *config) { } void init_coin_config(chain_config_t *coin_config) { - os_memset(coin_config, 0, sizeof(chain_config_t)); + memset(coin_config, 0, sizeof(chain_config_t)); strcpy(coin_config->coinName, CHAINID_COINNAME " "); coin_config->chainId = CHAIN_ID; coin_config->kind = CHAIN_KIND; diff --git a/src/poorstream.c b/src/poorstream.c index bd371aa..24e4d59 100644 --- a/src/poorstream.c +++ b/src/poorstream.c @@ -3,7 +3,7 @@ #include "poorstream.h" void poorstream_init(poorstream_t *stream, uint8_t *buffer) { - os_memset((void*)stream, 0, sizeof(poorstream_t)); + memset((void*)stream, 0, sizeof(poorstream_t)); stream->pointer = buffer; } diff --git a/src/utils.c b/src/utils.c index b991f5f..8747f3c 100644 --- a/src/utils.c +++ b/src/utils.c @@ -37,8 +37,8 @@ void array_hexstr(char *strbuf, const void *bin, unsigned int len) { void convertUint256BE(uint8_t *data, uint32_t length, uint256_t *target) { uint8_t tmp[32]; - os_memset(tmp, 0, 32); - os_memmove(tmp + 32 - length, data, length); + memset(tmp, 0, 32); + memmove(tmp + 32 - length, data, length); readu256BE(tmp, target); } @@ -113,4 +113,4 @@ bool parse_swap_config(uint8_t* config, uint8_t config_len, char* ticker, uint8_ } *decimals = config[offset]; return true; -} \ No newline at end of file +} diff --git a/src_common/ethUstream.c b/src_common/ethUstream.c index c081c2a..a024986 100644 --- a/src_common/ethUstream.c +++ b/src_common/ethUstream.c @@ -26,7 +26,7 @@ void initTx(txContext_t *context, cx_sha3_t *sha3, txContent_t *content, ustreamProcess_t customProcessor, void *extra) { - os_memset(context, 0, sizeof(txContext_t)); + memset(context, 0, sizeof(txContext_t)); context->sha3 = sha3; context->content = content; context->customProcessor = customProcessor; @@ -59,7 +59,7 @@ void copyTxData(txContext_t *context, uint8_t *out, uint32_t length) { THROW(EXCEPTION); } if (out != NULL) { - os_memmove(out, context->workBuffer, length); + memmove(out, context->workBuffer, length); } if (!(context->processingField && context->fieldSingleByte)) { cx_hash((cx_hash_t*)context->sha3, 0, context->workBuffer, length, NULL, 0); diff --git a/src_common/ethUtils.c b/src_common/ethUtils.c index 8e7ae08..3da9087 100644 --- a/src_common/ethUtils.c +++ b/src_common/ethUtils.c @@ -123,7 +123,7 @@ void getEthAddressFromKey(cx_ecfp_public_key_t *publicKey, uint8_t *out, uint8_t hashAddress[32]; cx_keccak_init(sha3Context, 256); cx_hash((cx_hash_t*)sha3Context, CX_LAST, publicKey->W + 1, 64, hashAddress, 32); - os_memmove(out, hashAddress + 12, 20); + memmove(out, hashAddress + 12, 20); } diff --git a/src_common/uint256.c b/src_common/uint256.c index e67f195..6d585a4 100644 --- a/src_common/uint256.c +++ b/src_common/uint256.c @@ -350,7 +350,7 @@ void read_u64_be(uint8_t *in, uint64_t *out) { void mul256(uint256_t *number1, uint256_t *number2, uint256_t *target) { uint8_t num1[32], num2[32], result[64]; - os_memset(&result, 0, sizeof(result)); + memset(&result, 0, sizeof(result)); for(uint8_t i = 0; i<4; i++){ write_u64_be(num1+i*sizeof(uint64_t), number1->elements[i/2].elements[i%2]); write_u64_be(num2+i*sizeof(uint64_t), number2->elements[i/2].elements[i%2]); diff --git a/src_features/getEth2PublicKey/logic_getEth2PublicKey.c b/src_features/getEth2PublicKey/logic_getEth2PublicKey.c index 91ae7ab..33d005a 100644 --- a/src_features/getEth2PublicKey/logic_getEth2PublicKey.c +++ b/src_features/getEth2PublicKey/logic_getEth2PublicKey.c @@ -4,7 +4,7 @@ uint32_t set_result_get_eth2_publicKey() { uint32_t tx = 0; - os_memmove(G_io_apdu_buffer + tx, tmpCtx.publicKeyContext.publicKey.W, 48); + memmove(G_io_apdu_buffer + tx, tmpCtx.publicKeyContext.publicKey.W, 48); tx += 48; return tx; } diff --git a/src_features/getPublicKey/cmd_getPublicKey.c b/src_features/getPublicKey/cmd_getPublicKey.c index 72dabb6..8042aca 100644 --- a/src_features/getPublicKey/cmd_getPublicKey.c +++ b/src_features/getPublicKey/cmd_getPublicKey.c @@ -35,8 +35,8 @@ void handleGetPublicKey(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint16_t da cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey); io_seproxyhal_io_heartbeat(); cx_ecfp_generate_pair(CX_CURVE_256K1, &tmpCtx.publicKeyContext.publicKey, &privateKey, 1); - os_memset(&privateKey, 0, sizeof(privateKey)); - os_memset(privateKeyData, 0, sizeof(privateKeyData)); + memset(&privateKey, 0, sizeof(privateKey)); + memset(privateKeyData, 0, sizeof(privateKeyData)); io_seproxyhal_io_heartbeat(); getEthAddressStringFromKey(&tmpCtx.publicKeyContext.publicKey, tmpCtx.publicKeyContext.address, &global_sha3, chainConfig); #ifndef NO_CONSENT diff --git a/src_features/getPublicKey/logic_getPublicKey.c b/src_features/getPublicKey/logic_getPublicKey.c index 32a7ef0..a538d96 100644 --- a/src_features/getPublicKey/logic_getPublicKey.c +++ b/src_features/getPublicKey/logic_getPublicKey.c @@ -3,13 +3,13 @@ uint32_t set_result_get_publicKey() { uint32_t tx = 0; G_io_apdu_buffer[tx++] = 65; - os_memmove(G_io_apdu_buffer + tx, tmpCtx.publicKeyContext.publicKey.W, 65); + memmove(G_io_apdu_buffer + tx, tmpCtx.publicKeyContext.publicKey.W, 65); tx += 65; G_io_apdu_buffer[tx++] = 40; - os_memmove(G_io_apdu_buffer + tx, tmpCtx.publicKeyContext.address, 40); + memmove(G_io_apdu_buffer + tx, tmpCtx.publicKeyContext.address, 40); tx += 40; if (tmpCtx.publicKeyContext.getChaincode) { - os_memmove(G_io_apdu_buffer + tx, tmpCtx.publicKeyContext.chainCode, 32); + memmove(G_io_apdu_buffer + tx, tmpCtx.publicKeyContext.chainCode, 32); tx += 32; } return tx; diff --git a/src_features/provideErc20TokenInformation/cmd_provideTokenInfo.c b/src_features/provideErc20TokenInformation/cmd_provideTokenInfo.c index 887cfeb..1b825dd 100644 --- a/src_features/provideErc20TokenInformation/cmd_provideTokenInfo.c +++ b/src_features/provideErc20TokenInformation/cmd_provideTokenInfo.c @@ -47,7 +47,7 @@ void handleProvideErc20TokenInformation(uint8_t p1, uint8_t p2, uint8_t *workBuf THROW(0x6A80); } cx_hash((cx_hash_t*)&sha256, 0, workBuffer + offset, tickerLength, NULL, 0); - os_memmove(token->ticker, workBuffer + offset, tickerLength); + memmove(token->ticker, workBuffer + offset, tickerLength); token->ticker[tickerLength] = ' '; token->ticker[tickerLength + 1] = '\0'; offset += tickerLength; @@ -59,12 +59,12 @@ void handleProvideErc20TokenInformation(uint8_t p1, uint8_t p2, uint8_t *workBuf THROW(0x6A80); } cx_hash((cx_hash_t*)&sha256, CX_LAST, workBuffer + offset, contractNameLength + 20 + 4 + 4, hash, 32); - os_memmove(token->contractName, workBuffer + offset, MIN(contractNameLength, sizeof(token->contractName)-1)); + memmove(token->contractName, workBuffer + offset, MIN(contractNameLength, sizeof(token->contractName)-1)); token->contractName[MIN(contractNameLength, sizeof(token->contractName)-1)] = '\0'; offset += contractNameLength; dataLength -= contractNameLength; - os_memmove(token->address, workBuffer + offset, 20); + memmove(token->address, workBuffer + offset, 20); offset += 20; dataLength -= 20; token->decimals = U4BE(workBuffer, offset); @@ -116,12 +116,12 @@ void handleProvideErc20TokenInformation(uint8_t p1, uint8_t p2, uint8_t *workBuf THROW(0x6A80); } cx_hash_sha256(workBuffer + offset, tickerLength + 20 + 4 + 4, hash, 32); - os_memmove(token->ticker, workBuffer + offset, tickerLength); + memmove(token->ticker, workBuffer + offset, tickerLength); token->ticker[tickerLength] = ' '; token->ticker[tickerLength + 1] = '\0'; offset += tickerLength; dataLength -= tickerLength; - os_memmove(token->address, workBuffer + offset, 20); + memmove(token->address, workBuffer + offset, 20); offset += 20; dataLength -= 20; token->decimals = U4BE(workBuffer, offset); @@ -140,7 +140,7 @@ void handleProvideErc20TokenInformation(uint8_t p1, uint8_t p2, uint8_t *workBuf uint32_t index; for (index=0; index < NUM_TOKENS_EXTRA; index++) { currentToken = (tokenDefinition_t *)PIC(&TOKENS_EXTRA[index]); - if (os_memcmp(currentToken->address, token->address, 20) == 0) { + if (memcmp(currentToken->address, token->address, 20) == 0) { strcpy((char*)token->ticker, (char*)currentToken->ticker); token->decimals = currentToken->decimals; break; diff --git a/src_features/signMessage/ui_common_signMessage.c b/src_features/signMessage/ui_common_signMessage.c index 79c1f4f..3d7e7e0 100644 --- a/src_features/signMessage/ui_common_signMessage.c +++ b/src_features/signMessage/ui_common_signMessage.c @@ -13,14 +13,14 @@ unsigned int io_seproxyhal_touch_signMessage_ok(const bagl_element_t *e) { tmpCtx.messageSigningContext.pathLength, privateKeyData, NULL); io_seproxyhal_io_heartbeat(); cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey); - os_memset(privateKeyData, 0, sizeof(privateKeyData)); + memset(privateKeyData, 0, sizeof(privateKeyData)); unsigned int info = 0; io_seproxyhal_io_heartbeat(); signatureLength = cx_ecdsa_sign(&privateKey, CX_RND_RFC6979 | CX_LAST, CX_SHA256, tmpCtx.messageSigningContext.hash, sizeof(tmpCtx.messageSigningContext.hash), signature, sizeof(signature), &info); - os_memset(&privateKey, 0, sizeof(privateKey)); + memset(&privateKey, 0, sizeof(privateKey)); G_io_apdu_buffer[0] = 27; if (info & CX_ECCINFO_PARITY_ODD) { G_io_apdu_buffer[0]++; diff --git a/src_features/signMessageEIP712/ui_common_signMessage712.c b/src_features/signMessageEIP712/ui_common_signMessage712.c index 20954fd..df6d2bf 100644 --- a/src_features/signMessageEIP712/ui_common_signMessage712.c +++ b/src_features/signMessageEIP712/ui_common_signMessage712.c @@ -24,14 +24,14 @@ unsigned int io_seproxyhal_touch_signMessage712_v0_ok(const bagl_element_t *e) { tmpCtx.messageSigningContext712.pathLength, privateKeyData, NULL); io_seproxyhal_io_heartbeat(); cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey); - os_memset(privateKeyData, 0, sizeof(privateKeyData)); + memset(privateKeyData, 0, sizeof(privateKeyData)); unsigned int info = 0; io_seproxyhal_io_heartbeat(); signatureLength = cx_ecdsa_sign(&privateKey, CX_RND_RFC6979 | CX_LAST, CX_SHA256, hash, sizeof(hash), signature, sizeof(signature), &info); - os_memset(&privateKey, 0, sizeof(privateKey)); + memset(&privateKey, 0, sizeof(privateKey)); G_io_apdu_buffer[0] = 27; if (info & CX_ECCINFO_PARITY_ODD) { G_io_apdu_buffer[0]++; diff --git a/src_features/signTx/logic_signTx.c b/src_features/signTx/logic_signTx.c index b4c7383..cc1336b 100644 --- a/src_features/signTx/logic_signTx.c +++ b/src_features/signTx/logic_signTx.c @@ -158,7 +158,7 @@ void compareOrCopy(char* preapproved_string, char* parsed_string, bool silent_mo have some for checksum purpose, so let's get rid of these diffs */ to_uppercase(preapproved_string, strlen(preapproved_string)); to_uppercase(parsed_string, strlen(parsed_string)); - if(os_memcmp(preapproved_string, parsed_string, strlen(preapproved_string))){ + if(memcmp(preapproved_string, parsed_string, strlen(preapproved_string))){ THROW(ERR_SILENT_MODE_CHECK_FAILED); } } diff --git a/src_features/signTx/ui_common_signTx.c b/src_features/signTx/ui_common_signTx.c index 102de66..bde1553 100644 --- a/src_features/signTx/ui_common_signTx.c +++ b/src_features/signTx/ui_common_signTx.c @@ -15,14 +15,14 @@ unsigned int io_seproxyhal_touch_tx_ok(const bagl_element_t *e) { privateKeyData, NULL); cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey); - os_memset(privateKeyData, 0, sizeof(privateKeyData)); + memset(privateKeyData, 0, sizeof(privateKeyData)); unsigned int info = 0; io_seproxyhal_io_heartbeat(); signatureLength = cx_ecdsa_sign(&privateKey, CX_RND_RFC6979 | CX_LAST, CX_SHA256, tmpCtx.transactionContext.hash, sizeof(tmpCtx.transactionContext.hash), signature, sizeof(signature), &info); - os_memset(&privateKey, 0, sizeof(privateKey)); + memset(&privateKey, 0, sizeof(privateKey)); // Parity is present in the sequence tag in the legacy API if (tmpContent.txContent.vLength == 0) { // Legacy API diff --git a/src_features/stark_getPublicKey/cmd_stark_getPublicKey.c b/src_features/stark_getPublicKey/cmd_stark_getPublicKey.c index 1662046..d1da1aa 100644 --- a/src_features/stark_getPublicKey/cmd_stark_getPublicKey.c +++ b/src_features/stark_getPublicKey/cmd_stark_getPublicKey.c @@ -34,8 +34,8 @@ void handleStarkwareGetPublicKey(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, ui cx_ecfp_init_private_key(CX_CURVE_Stark256, privateKeyData, 32, &privateKey); io_seproxyhal_io_heartbeat(); cx_ecfp_generate_pair(CX_CURVE_Stark256, &tmpCtx.publicKeyContext.publicKey, &privateKey, 1); - os_memset(&privateKey, 0, sizeof(privateKey)); - os_memset(privateKeyData, 0, sizeof(privateKeyData)); + memset(&privateKey, 0, sizeof(privateKey)); + memset(privateKeyData, 0, sizeof(privateKeyData)); io_seproxyhal_io_heartbeat(); #ifndef NO_CONSENT if (p1 == P1_NON_CONFIRM) diff --git a/src_features/stark_getPublicKey/logic_stark_getPublicKey.c b/src_features/stark_getPublicKey/logic_stark_getPublicKey.c index bd03ca4..20fb704 100644 --- a/src_features/stark_getPublicKey/logic_stark_getPublicKey.c +++ b/src_features/stark_getPublicKey/logic_stark_getPublicKey.c @@ -5,7 +5,7 @@ uint32_t set_result_get_stark_publicKey() { uint32_t tx = 0; - os_memmove(G_io_apdu_buffer + tx, tmpCtx.publicKeyContext.publicKey.W, 65); + memmove(G_io_apdu_buffer + tx, tmpCtx.publicKeyContext.publicKey.W, 65); tx += 65; return tx; } diff --git a/src_features/stark_provideQuantum/cmd_stark_provideQuantum.c b/src_features/stark_provideQuantum/cmd_stark_provideQuantum.c index 7ce5e2f..076c6f6 100644 --- a/src_features/stark_provideQuantum/cmd_stark_provideQuantum.c +++ b/src_features/stark_provideQuantum/cmd_stark_provideQuantum.c @@ -34,7 +34,7 @@ void handleStarkwareProvideQuantum(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, if ((p1 != STARK_QUANTUM_ETH) && !addressZero) { for(i=0; iaddress, dataBuffer, 20) == 0)) { + if (tmpCtx.transactionContext.tokenSet[i] && (memcmp(currentToken->address, dataBuffer, 20) == 0)) { break; } } diff --git a/src_features/stark_sign/cmd_stark_sign.c b/src_features/stark_sign/cmd_stark_sign.c index b21f869..c5d4d28 100644 --- a/src_features/stark_sign/cmd_stark_sign.c +++ b/src_features/stark_sign/cmd_stark_sign.c @@ -72,7 +72,7 @@ void handleStarkwareSignMessage(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uin offset += 4; } // Discard the path to use part of dataBuffer as a temporary buffer - os_memmove(dataBuffer, dataBuffer + offset, dataLength - offset); + memmove(dataBuffer, dataBuffer + offset, dataLength - offset); dataContext.starkContext.conditional = (p1 == P1_STARK_CONDITIONAL_TRANSFER); if (dataContext.starkContext.conditional) { memmove(dataContext.starkContext.fact, dataBuffer + 20 + 32 + postOffset + 32 + 4 + 4 + 8 + 4 + 4, 32); @@ -116,7 +116,7 @@ void handleStarkwareSignMessage(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uin offset = 20 + 32 + postOffset + 20 + 32 + postOffset; } else { - os_memmove(dataContext.starkContext.w2, dataBuffer + 20 + 32 + postOffset, 32); + memmove(dataContext.starkContext.w2, dataBuffer + 20 + 32 + postOffset, 32); offset = 20 + 32 + postOffset + 32; } @@ -176,10 +176,10 @@ void handleStarkwareSignMessage(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uin cx_ecfp_init_private_key(CX_CURVE_Stark256, privateKeyData, 32, &privateKey); io_seproxyhal_io_heartbeat(); cx_ecfp_generate_pair(CX_CURVE_Stark256, &publicKey, &privateKey, 1); - os_memset(&privateKey, 0, sizeof(privateKey)); - os_memset(privateKeyData, 0, sizeof(privateKeyData)); + memset(&privateKey, 0, sizeof(privateKey)); + memset(privateKeyData, 0, sizeof(privateKeyData)); io_seproxyhal_io_heartbeat(); - selfTransfer = (os_memcmp(publicKey.W + 1, dataBuffer + 20 + 32 + postOffset, 32) == 0); + selfTransfer = (memcmp(publicKey.W + 1, dataBuffer + 20 + 32 + postOffset, 32) == 0); PRINTF("self transfer %d\n", selfTransfer); io_seproxyhal_io_heartbeat(); // amount to transfer diff --git a/src_plugins/starkware/starkware_plugin.c b/src_plugins/starkware/starkware_plugin.c index 28af1fe..58377e0 100644 --- a/src_plugins/starkware/starkware_plugin.c +++ b/src_plugins/starkware/starkware_plugin.c @@ -275,8 +275,8 @@ void starkware_get_source_address(char *destination) { cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey); io_seproxyhal_io_heartbeat(); cx_ecfp_generate_pair(CX_CURVE_256K1, &publicKey, &privateKey, 1); - os_memset(&privateKey, 0, sizeof(privateKey)); - os_memset(privateKeyData, 0, sizeof(privateKeyData)); + memset(&privateKey, 0, sizeof(privateKey)); + memset(privateKeyData, 0, sizeof(privateKeyData)); io_seproxyhal_io_heartbeat(); destination[0] = '0'; destination[1] = 'x';