Apply clang-format

This commit is contained in:
TamtamHero
2020-12-01 16:20:13 +01:00
parent 1421a74be5
commit 17bd07a346
80 changed files with 8859 additions and 5091 deletions

View File

@@ -7,8 +7,8 @@
#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);
PRINTF("Address to check %s\n",params->address_to_check);
PRINTF("Params on the address %d\n", (unsigned int) params);
PRINTF("Address to check %s\n", params->address_to_check);
PRINTF("Inside handle_check_address\n");
params->result = 0;
if (params->address_to_check == 0) {
@@ -17,27 +17,23 @@ void handle_check_address(check_address_parameters_t* params, chain_config_t* ch
}
uint8_t i;
uint8_t *bip32_path_ptr = params->address_parameters;
uint8_t* bip32_path_ptr = params->address_parameters;
uint8_t bip32PathLength = *(bip32_path_ptr++);
cx_sha3_t local_sha3;
// Common memory is used for locals that are not used concurrently
union group1
{
union group1 {
uint32_t bip32Path[MAX_BIP32_PATH];
cx_ecfp_private_key_t privateKey;
char address[51];
} locals_union1;
union group2
{
union group2 {
uint8_t privateKeyData[32];
cx_ecfp_public_key_t publicKey;
} locals_union2;
if ((bip32PathLength < 0x01) ||
(bip32PathLength > MAX_BIP32_PATH) ||
(bip32PathLength*4 != params->address_parameters_length - 1)) {
if ((bip32PathLength < 0x01) || (bip32PathLength > MAX_BIP32_PATH) ||
(bip32PathLength * 4 != params->address_parameters_length - 1)) {
PRINTF("Invalid path\n");
return;
}
@@ -45,22 +41,34 @@ void handle_check_address(check_address_parameters_t* params, chain_config_t* ch
locals_union1.bip32Path[i] = U4BE(bip32_path_ptr, 0);
bip32_path_ptr += 4;
}
os_perso_derive_node_bip32(CX_CURVE_256K1, locals_union1.bip32Path, bip32PathLength, locals_union2.privateKeyData, NULL);
os_perso_derive_node_bip32(CX_CURVE_256K1,
locals_union1.bip32Path,
bip32PathLength,
locals_union2.privateKeyData,
NULL);
ZERO(&locals_union1);
cx_ecfp_init_private_key(CX_CURVE_256K1, locals_union2.privateKeyData, 32, &locals_union1.privateKey);
cx_ecfp_init_private_key(CX_CURVE_256K1,
locals_union2.privateKeyData,
32,
&locals_union1.privateKey);
ZERO(&locals_union2);
cx_ecfp_generate_pair(CX_CURVE_256K1, &locals_union2.publicKey, &locals_union1.privateKey, 1);
ZERO(&locals_union1);
getEthAddressStringFromKey(&locals_union2.publicKey, (uint8_t*)locals_union1.address, &local_sha3, chain_config);
getEthAddressStringFromKey(&locals_union2.publicKey,
(uint8_t*) locals_union1.address,
&local_sha3,
chain_config);
ZERO(&locals_union2);
uint8_t offset_0x = 0;
if(memcmp(params->address_to_check, "0x", 2) == 0){
if (memcmp(params->address_to_check, "0x", 2) == 0) {
offset_0x = 2;
}
if ((strlen(locals_union1.address) != strlen(params->address_to_check + offset_0x)) ||
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;
}