Remove trailing whitespaces

This commit is contained in:
TamtamHero
2020-10-07 16:56:40 +02:00
parent 93a7d1e9c4
commit eac45259da
24 changed files with 64 additions and 65 deletions

View File

@@ -33,7 +33,7 @@ void handle_check_address(check_address_parameters_t* params, chain_config_t* ch
uint8_t privateKeyData[32];
cx_ecfp_public_key_t publicKey;
} locals_union2;
if ((bip32PathLength < 0x01) ||
(bip32PathLength > MAX_BIP32_PATH) ||
@@ -61,7 +61,6 @@ 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) {
os_memcpy(params->address_to_check, locals_union1.address, 45);
PRINTF("Addresses doesn't match\n");
return;
}

View File

@@ -11,7 +11,7 @@ void copy_transaction_parameters(create_transaction_parameters_t* sign_transacti
txStringProperties_t stack_data;
memset(&stack_data, 0, sizeof(stack_data));
strncpy(stack_data.fullAddress, sign_transaction_params->destination_address, sizeof(stack_data.fullAddress));
if ((stack_data.fullAddress[sizeof(stack_data.fullAddress) - 1] != '\0') ||
if ((stack_data.fullAddress[sizeof(stack_data.fullAddress) - 1] != '\0') ||
(sign_transaction_params->amount_length > 32) ||
(sign_transaction_params->fee_amount_length > 8)) {
os_lib_end();

View File

@@ -16,7 +16,7 @@ void poorstream_flush(poorstream_t *stream) {
*(stream->pointer + 4) = (stream->accumulator >> 24);
*(stream->pointer + 5) = (stream->accumulator >> 16);
*(stream->pointer + 6) = (stream->accumulator >> 8);
*(stream->pointer + 7) = (stream->accumulator >> 0);
*(stream->pointer + 7) = (stream->accumulator >> 0);
}
void poorstream_write_bits(poorstream_t *stream, uint64_t bits, uint32_t num_bits) {

View File

@@ -30,11 +30,11 @@ typedef struct internalStorage_t {
} internalStorage_t;
typedef struct tokenContext_t {
#ifdef HAVE_STARKWARE
#ifdef HAVE_STARKWARE
uint8_t data[4 + 32 + 32 + 32 + 32];
#else
#else
uint8_t data[4 + 32 + 32];
#endif
#endif
uint32_t dataFieldPos;
#ifdef HAVE_STARKWARE
uint8_t quantum[32];

View File

@@ -9,21 +9,21 @@ static unsigned char const C_cx_Stark256_n[] = {
//n: 0x0800000000000010ffffffffffffffffb781126dcae7b2321e66a241adc64d2f
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xb7, 0x81, 0x12, 0x6d, 0xca, 0xe7, 0xb2, 0x32, 0x1e, 0x66, 0xa2, 0x41, 0xad, 0xc6, 0x4d, 0x2f};
// C_cx_secp256k1_n - (C_cx_secp256k1_n % C_cx_Stark256_n)
static unsigned char const STARK_DERIVE_BIAS[] = {
0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x0e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7,
0x38, 0xa1, 0x3b, 0x4b, 0x92, 0x0e, 0x94, 0x11, 0xae, 0x6d, 0xa5, 0xf4, 0x0b, 0x03, 0x58, 0xb1
};
};
void starkDerivePrivateKey(uint32_t *bip32Path, uint32_t bip32PathLength, uint8_t *privateKeyData) {
#if 0
// Sanity check
void starkDerivePrivateKey(uint32_t *bip32Path, uint32_t bip32PathLength, uint8_t *privateKeyData) {
#if 0
// Sanity check
if (bip32Path[0] != STARK_BIP32_PATH_0) {
PRINTF("Invalid Stark derivation path %d\n", bip32Path[0]);
THROW(0x6a80);
}
os_perso_derive_node_bip32(CX_CURVE_256K1, bip32Path, bip32PathLength, privateKeyData, NULL);
os_perso_derive_node_bip32(CX_CURVE_256K1, bip32Path, bip32PathLength, privateKeyData, NULL);
PRINTF("Private key before processing %.*H\n", 32, privateKeyData);
// TODO - support additional schemes
cx_math_modm(privateKeyData, 32, C_cx_Stark256_n, 32);
@@ -31,12 +31,12 @@ void starkDerivePrivateKey(uint32_t *bip32Path, uint32_t bip32PathLength, uint8_
#else
uint8_t tmp[33];
uint8_t index = 0;
// Sanity check
// Sanity check
if ((bip32PathLength < 2) || (bip32Path[0] != STARK_BIP32_PATH_0) || (bip32Path[1] != STARK_BIP32_PATH_1)) {
PRINTF("Invalid Stark derivation path %d %d\n", bip32Path[0], bip32Path[1]);
THROW(0x6a80);
}
os_perso_derive_node_bip32(CX_CURVE_256K1, bip32Path, bip32PathLength, tmp, NULL);
os_perso_derive_node_bip32(CX_CURVE_256K1, bip32Path, bip32PathLength, tmp, NULL);
PRINTF("Private key before processing %.*H\n", 32, tmp);
for(;;) {
tmp[32] = index;
@@ -48,13 +48,13 @@ void starkDerivePrivateKey(uint32_t *bip32Path, uint32_t bip32PathLength, uint8_
index++;
}
#endif
#endif
}
void stark_get_amount_string(uint8_t *contractAddress, uint8_t *quantum256, uint8_t *amount64, char *tmp100, char *target100) {
uint256_t amountPre, quantum, amount;
uint8_t decimals;
char *ticker = (char*)PIC(chainConfig->coinName);
uint8_t decimals;
char *ticker = (char*)PIC(chainConfig->coinName);
PRINTF("stark_get_amount_string %.*H\n", 20, contractAddress);

View File

@@ -22,4 +22,4 @@ int stark_sign(uint8_t *signautre, /* out */
uint8_t *privateKeyData, FieldElement token1,
FieldElement token2, FieldElement msg);
#endif
#endif

View File

@@ -81,7 +81,7 @@ void pedersen(FieldElement res, /* out */
ECPoint hash;
memcpy(hash, PEDERSEN_SHIFT, sizeof(hash));
accum_ec_mul(&hash, a, 1, 1);
accum_ec_mul(&hash, a+1, FIELD_ELEMENT_SIZE-1, 0);
accum_ec_mul(&hash, b, 1, 3);
@@ -114,7 +114,7 @@ int stark_sign(uint8_t *signature, /* out */
}
// ERC20Token(address)
static const uint8_t ERC20_SELECTOR[] = { 0xf4, 0x72, 0x61, 0xb0 };
static const uint8_t ERC20_SELECTOR[] = { 0xf4, 0x72, 0x61, 0xb0 };
// ETH()
static const uint8_t ETH_SELECTOR[] = { 0x83, 0x22, 0xff, 0xf2 };
@@ -126,11 +126,11 @@ void compute_token_id(cx_sha3_t *sha3, uint8_t *contractAddress, uint8_t *quantu
os_memset(tmp, 0, sizeof(tmp));
os_memmove(tmp, ERC20_SELECTOR, 4);
os_memmove(tmp + 16, contractAddress, 20);
cx_hash((cx_hash_t*)sha3, 0, tmp, sizeof(tmp), NULL, 0);
cx_hash((cx_hash_t*)sha3, 0, tmp, sizeof(tmp), NULL, 0);
}
else {
PRINTF("compute_token_id for ETH\n");
cx_hash((cx_hash_t*)sha3, 0, ETH_SELECTOR, sizeof(ETH_SELECTOR), NULL, 0);
cx_hash((cx_hash_t*)sha3, 0, ETH_SELECTOR, sizeof(ETH_SELECTOR), NULL, 0);
}
PRINTF("compute_token_id quantum %.*H\n", 32, quantum);
cx_hash((cx_hash_t*)sha3, CX_LAST, quantum, 32, output, 32);

View File

@@ -16,9 +16,9 @@ typedef struct check_address_parameters_s {
// IN
unsigned char* coin_configuration;
unsigned char coin_configuration_length;
// serialized path, segwit, version prefix, hash used, dictionary etc.
// serialized path, segwit, version prefix, hash used, dictionary etc.
// fields and serialization format depends on spesific coin app
unsigned char* address_parameters;
unsigned char* address_parameters;
unsigned char address_parameters_length;
char *address_to_check;
char *extra_id_to_check;
@@ -31,7 +31,7 @@ typedef struct get_printable_amount_parameters_s {
// IN
unsigned char* coin_configuration;
unsigned char coin_configuration_length;
unsigned char* amount;
unsigned char* amount;
unsigned char amount_length;
bool is_fee;
// OUT
@@ -41,9 +41,9 @@ typedef struct get_printable_amount_parameters_s {
typedef struct create_transaction_parameters_s {
unsigned char* coin_configuration;
unsigned char coin_configuration_length;
unsigned char* amount;
unsigned char* amount;
unsigned char amount_length;
unsigned char* fee_amount;
unsigned char* fee_amount;
unsigned char fee_amount_length;
char *destination_address;
char *destination_address_extra_id;

View File

@@ -23,11 +23,11 @@
#define MAX_TICKER_LEN 12 // 10 characters + ' ' + '\0'
typedef struct tokenDefinition_t {
#ifdef HAVE_CONTRACT_NAME_IN_DESCRIPTOR
#ifdef HAVE_CONTRACT_NAME_IN_DESCRIPTOR
uint8_t contractName[20];
#endif
#endif
uint8_t address[20];
uint8_t ticker[MAX_TICKER_LEN];
uint8_t ticker[MAX_TICKER_LEN];
uint8_t decimals;
} tokenDefinition_t;

View File

@@ -1,5 +1,5 @@
#include "shared_context.h"
#include "os_io_seproxyhal.h"
extern const ux_flow_step_t * const ux_idle_flow [];

View File

@@ -43,11 +43,11 @@ void getEthAddressFromKey(cx_ecfp_public_key_t *publicKey, uint8_t *out,
cx_sha3_t *sha3Context);
void getEthAddressStringFromKey(cx_ecfp_public_key_t *publicKey, uint8_t *out,
cx_sha3_t *sha3Context,
cx_sha3_t *sha3Context,
chain_config_t* chain_config);
void getEthAddressStringFromBinary(uint8_t *address, uint8_t *out,
cx_sha3_t *sha3Context,
cx_sha3_t *sha3Context,
chain_config_t* chain_config);
bool adjustDecimals(char *src, uint32_t srcLength, char *target,

View File

@@ -19,7 +19,7 @@ void handleGetAppConfiguration(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint
#endif
#ifdef HAVE_STARKWARE
G_io_apdu_buffer[0] |= APP_FLAG_STARKWARE;
#endif
#endif
G_io_apdu_buffer[1] = LEDGER_MAJOR_VERSION;
G_io_apdu_buffer[2] = LEDGER_MINOR_VERSION;
G_io_apdu_buffer[3] = LEDGER_PATCH_VERSION;

View File

@@ -39,7 +39,7 @@ void handleProvideErc20TokenInformation(uint8_t p1, uint8_t p2, uint8_t *workBuf
tmpCtx.transactionContext.currentTokenIndex = (tmpCtx.transactionContext.currentTokenIndex + 1) % MAX_TOKEN;
tokenDefinition_t* token = &tmpCtx.transactionContext.tokens[tmpCtx.transactionContext.currentTokenIndex];
if (dataLength < 1) {
THROW(0x6A80);
}
@@ -139,12 +139,12 @@ void handleProvideErc20TokenInformation(uint8_t p1, uint8_t p2, uint8_t *workBuf
}
offset += 4;
dataLength -= 4;
#ifdef HAVE_TOKENS_EXTRA_LIST
#ifdef HAVE_TOKENS_EXTRA_LIST
tokenDefinition_t *currentToken = NULL;
uint32_t index;
for (index=0; index < NUM_TOKENS_EXTRA; index++) {
currentToken = (tokenDefinition_t *)PIC(&TOKENS_EXTRA[index]);
currentToken = (tokenDefinition_t *)PIC(&TOKENS_EXTRA[index]);
if (os_memcmp(currentToken->address, token->address, 20) == 0) {
strcpy((char*)token->ticker, (char*)currentToken->ticker);
token->decimals = currentToken->decimals;

View File

@@ -27,7 +27,7 @@ void handleSignPersonalMessage(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint
if (appState != APP_STATE_IDLE) {
reset_app_context();
}
appState = APP_STATE_SIGNING_MESSAGE;
appState = APP_STATE_SIGNING_MESSAGE;
tmpCtx.messageSigningContext.pathLength = workBuffer[0];
if ((tmpCtx.messageSigningContext.pathLength < 0x01) ||
(tmpCtx.messageSigningContext.pathLength > MAX_BIP32_PATH)) {
@@ -48,7 +48,7 @@ void handleSignPersonalMessage(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint
if (dataLength < 4) {
PRINTF("Invalid data\n");
THROW(0x6a80);
}
}
tmpCtx.messageSigningContext.remainingLength = U4BE(workBuffer, 0);
workBuffer += 4;
dataLength -= 4;

View File

@@ -13,7 +13,7 @@ static const char const SIGN_MAGIC[] = "\x19"
void handleSignEIP712Message(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint16_t dataLength, unsigned int *flags, unsigned int *tx) {
uint8_t i;
UNUSED(tx);
if ((p1 != 00) || (p2 != 00)) {
THROW(0x6B00);
@@ -45,7 +45,7 @@ void handleSignEIP712Message(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint16
if (dataLength < 32 + 32) {
PRINTF("Invalid data\n");
THROW(0x6a80);
}
}
memmove(tmpCtx.messageSigningContext712.domainHash, workBuffer, 32);
memmove(tmpCtx.messageSigningContext712.messageHash, workBuffer + 32, 32);
@@ -53,12 +53,12 @@ void handleSignEIP712Message(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint16
io_seproxyhal_touch_signMessage_ok(NULL);
#else //NO_CONSENT
#if defined(TARGET_BLUE)
// TODO implement
// TODO implement
ui_approval_message_sign_blue_init();
#else
ux_flow_init(0, ux_sign_712_v0_flow, NULL);
#endif // #if TARGET_ID
#endif // NO_CONSENT
*flags |= IO_ASYNCH_REPLY;
*flags |= IO_ASYNCH_REPLY;
}

View File

@@ -13,9 +13,9 @@ unsigned int io_seproxyhal_touch_signMessage712_v0_ok(const bagl_element_t *e) {
io_seproxyhal_io_heartbeat();
cx_keccak_init(&global_sha3, 256);
cx_hash((cx_hash_t *)&global_sha3, 0, (uint8_t*)EIP_712_MAGIC, sizeof(EIP_712_MAGIC), NULL, 0);
cx_hash((cx_hash_t *)&global_sha3, 0, tmpCtx.messageSigningContext712.domainHash,
cx_hash((cx_hash_t *)&global_sha3, 0, tmpCtx.messageSigningContext712.domainHash,
sizeof(tmpCtx.messageSigningContext712.domainHash), NULL, 0);
cx_hash((cx_hash_t *)&global_sha3, CX_LAST, tmpCtx.messageSigningContext712.messageHash,
cx_hash((cx_hash_t *)&global_sha3, CX_LAST, tmpCtx.messageSigningContext712.messageHash,
sizeof(tmpCtx.messageSigningContext712.messageHash), hash, sizeof(hash));
PRINTF("EIP712 hash to sign %.*H\n", 32, hash);
io_seproxyhal_io_heartbeat();

View File

@@ -2,11 +2,11 @@
#include "ui_callbacks.h"
void prepare_domain_hash_v0() {
snprintf(strings.tmp.tmp, 70, "0x%.*H", 32, tmpCtx.messageSigningContext712.domainHash);
snprintf(strings.tmp.tmp, 70, "0x%.*H", 32, tmpCtx.messageSigningContext712.domainHash);
}
void prepare_message_hash_v0() {
snprintf(strings.tmp.tmp, 70, "0x%.*H", 32, tmpCtx.messageSigningContext712.messageHash);
snprintf(strings.tmp.tmp, 70, "0x%.*H", 32, tmpCtx.messageSigningContext712.messageHash);
}
UX_FLOW_DEF_NOCB(

View File

@@ -16,11 +16,11 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint16_t dataLength
if (dataLength < 1) {
PRINTF("Invalid data\n");
THROW(0x6a80);
}
}
if (appState != APP_STATE_IDLE) {
reset_app_context();
}
appState = APP_STATE_SIGNING_TX;
appState = APP_STATE_SIGNING_TX;
tmpCtx.transactionContext.pathLength = workBuffer[0];
if ((tmpCtx.transactionContext.pathLength < 0x01) ||
(tmpCtx.transactionContext.pathLength > MAX_BIP32_PATH)) {
@@ -33,7 +33,7 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint16_t dataLength
if (dataLength < 4) {
PRINTF("Invalid data\n");
THROW(0x6a80);
}
}
tmpCtx.transactionContext.bip32Path[i] = U4BE(workBuffer, 0);
workBuffer += 4;
dataLength -= 4;

View File

@@ -3,7 +3,7 @@
#include "shared_context.h"
#include "ui_callbacks.h"
void prepare_escape_3() {
void prepare_escape_3() {
uint8_t address[41];
getEthAddressStringFromBinary(tmpContent.txContent.destination, address, &global_sha3, chainConfig);
strings.common.fullAddress[0] = '0';
@@ -23,7 +23,7 @@ void prepare_escape_4() {
else {
tokenDefinition_t *token = &tmpCtx.transactionContext.tokens[dataContext.tokenContext.quantumIndex];
decimals = token->decimals;
ticker = (char*)token->ticker;
ticker = (char*)token->ticker;
}
readu256BE(dataContext.tokenContext.data + 4 + 32 + 32 + 32, &amountPre);
readu256BE(dataContext.tokenContext.quantum, &quantum);

View File

@@ -3,7 +3,7 @@
#include "shared_context.h"
#include "ui_callbacks.h"
void prepare_register_3() {
void prepare_register_3() {
uint8_t address[41];
getEthAddressStringFromBinary(tmpContent.txContent.destination, address, &global_sha3, chainConfig);
strings.common.fullAddress[0] = '0';
@@ -12,7 +12,7 @@ void prepare_register_3() {
strings.common.fullAddress[42] = '\0';
}
void prepare_register_4() {
void prepare_register_4() {
uint8_t privateKeyData[32];
uint8_t address[41];
cx_ecfp_private_key_t privateKey;
@@ -33,8 +33,8 @@ void prepare_register_4() {
strings.common.fullAddress[42] = '\0';
}
void prepare_register_5() {
snprintf(strings.tmp.tmp, 70, "0x%.*H", 32, dataContext.tokenContext.data + 4);
void prepare_register_5() {
snprintf(strings.tmp.tmp, 70, "0x%.*H", 32, dataContext.tokenContext.data + 4);
}
UX_FLOW_DEF_NOCB(ux_approval_starkware_register_1_step,

View File

@@ -3,7 +3,7 @@
#include "shared_context.h"
#include "ui_callbacks.h"
void prepare_verify_escape_3() {
void prepare_verify_escape_3() {
uint8_t address[41];
getEthAddressStringFromBinary(tmpContent.txContent.destination, address, &global_sha3, chainConfig);
strings.common.fullAddress[0] = '0';

View File

@@ -14,11 +14,11 @@ void prepare_verify_vault_id_2() {
else
if (contractProvisioned == CONTRACT_STARKWARE_FULL_WITHDRAWAL) {
strcpy(strings.common.fullAddress, "Full Withdrawal");
}
}
else
if (contractProvisioned == CONTRACT_STARKWARE_FREEZE) {
strcpy(strings.common.fullAddress, "Freeze");
}
}
}
void prepare_verify_vault_id_3() {

View File

@@ -5,7 +5,7 @@
void prepare_register_4();
void prepare_withdraw_3() {
void prepare_withdraw_3() {
uint8_t address[41];
getEthAddressStringFromBinary(tmpContent.txContent.destination, address, &global_sha3, chainConfig);
strings.common.fullAddress[0] = '0';
@@ -14,8 +14,8 @@ void prepare_withdraw_3() {
strings.common.fullAddress[42] = '\0';
}
void prepare_withdraw_5() {
char *ticker = (char*)PIC(chainConfig->coinName);
void prepare_withdraw_5() {
char *ticker = (char*)PIC(chainConfig->coinName);
if (dataContext.tokenContext.quantumIndex != MAX_TOKEN) {
tokenDefinition_t *token = &tmpCtx.transactionContext.tokens[dataContext.tokenContext.quantumIndex];

View File

@@ -1,5 +1,5 @@
#ifdef HAVE_STARKWARE
#include "shared_context.h"
#include "apdu_constants.h"
#ifdef TARGET_BLUE