Skip to content

Commit 52738e6

Browse files
committed
Make lint happier
1 parent d04ed9a commit 52738e6

File tree

5 files changed

+40
-39
lines changed

5 files changed

+40
-39
lines changed

src/apdu_constants.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ void handleSetPlugin(uint8_t p1,
116116
unsigned int *tx);
117117

118118
void handlePerformPrivacyOperation(uint8_t p1,
119-
uint8_t p2,
120-
uint8_t *workBuffer,
121-
uint16_t dataLength,
122-
unsigned int *flags,
123-
unsigned int *tx);
119+
uint8_t p2,
120+
uint8_t *workBuffer,
121+
uint16_t dataLength,
122+
unsigned int *flags,
123+
unsigned int *tx);
124124

125125
#ifdef HAVE_ETH2
126126

src/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,11 +542,11 @@ void handleApdu(unsigned int *flags, unsigned int *tx) {
542542

543543
case INS_PERFORM_PRIVACY_OPERATION:
544544
handlePerformPrivacyOperation(G_io_apdu_buffer[OFFSET_P1],
545-
G_io_apdu_buffer[OFFSET_P2],
546-
G_io_apdu_buffer + OFFSET_CDATA,
547-
G_io_apdu_buffer[OFFSET_LC],
548-
flags,
549-
tx);
545+
G_io_apdu_buffer[OFFSET_P2],
546+
G_io_apdu_buffer + OFFSET_CDATA,
547+
G_io_apdu_buffer[OFFSET_LC],
548+
flags,
549+
tx);
550550
break;
551551

552552
case INS_SIGN:

src_features/performPrivacyOperation/cmd_performPrivacyOperation.c

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
#include "feature_performPrivacyOperation.h"
66

77
#define P2_PUBLIC_ENCRYPTION_KEY 0x00
8-
#define P2_SHARED_SECRET 0x01
8+
#define P2_SHARED_SECRET 0x01
99

1010
void decodeScalar(const uint8_t *scalarIn, uint8_t *scalarOut) {
11-
for (uint8_t i=0; i<32; i++) {
12-
switch(i) {
11+
for (uint8_t i = 0; i < 32; i++) {
12+
switch (i) {
1313
case 0:
1414
scalarOut[0] = (scalarIn[31] & 0x7f) | 0x40;
1515
break;
@@ -18,16 +18,16 @@ void decodeScalar(const uint8_t *scalarIn, uint8_t *scalarOut) {
1818
break;
1919
default:
2020
scalarOut[i] = scalarIn[31 - i];
21-
}
21+
}
2222
}
2323
}
2424

2525
void handlePerformPrivacyOperation(uint8_t p1,
26-
uint8_t p2,
27-
uint8_t *dataBuffer,
28-
uint16_t dataLength,
29-
unsigned int *flags,
30-
unsigned int *tx) {
26+
uint8_t p2,
27+
uint8_t *dataBuffer,
28+
uint16_t dataLength,
29+
unsigned int *flags,
30+
unsigned int *tx) {
3131
UNUSED(dataLength);
3232
uint8_t privateKeyData[INT256_LENGTH];
3333
uint8_t privateKeyDataSwapped[INT256_LENGTH];
@@ -38,14 +38,11 @@ void handlePerformPrivacyOperation(uint8_t p1,
3838
if (dataLength < 1 + 4 * bip32PathLength) {
3939
THROW(0x6700);
4040
}
41-
}
42-
else
43-
if (p2 == P2_SHARED_SECRET) {
41+
} else if (p2 == P2_SHARED_SECRET) {
4442
if (dataLength < 1 + 4 * bip32PathLength + 32) {
4543
THROW(0x6700);
46-
}
47-
}
48-
else {
44+
}
45+
} else {
4946
THROW(0x6B00);
5047
}
5148
cx_ecfp_private_key_t privateKey;
@@ -59,7 +56,7 @@ void handlePerformPrivacyOperation(uint8_t p1,
5956
for (uint8_t i = 0; i < bip32PathLength; i++) {
6057
bip32Path[i] = U4BE(dataBuffer, 0);
6158
dataBuffer += 4;
62-
}
59+
}
6360
os_perso_derive_node_bip32(
6461
CX_CURVE_256K1,
6562
bip32Path,
@@ -71,19 +68,21 @@ void handlePerformPrivacyOperation(uint8_t p1,
7168
getEthAddressStringFromKey(&tmpCtx.publicKeyContext.publicKey,
7269
tmpCtx.publicKeyContext.address,
7370
&global_sha3,
74-
chainConfig->chainId);
71+
chainConfig->chainId);
7572
if (p2 == P2_PUBLIC_ENCRYPTION_KEY) {
7673
decodeScalar(privateKeyData, privateKeyDataSwapped);
7774
cx_ecfp_init_private_key(CX_CURVE_Curve25519, privateKeyDataSwapped, 32, &privateKey);
78-
cx_ecfp_generate_pair(CX_CURVE_Curve25519, &tmpCtx.publicKeyContext.publicKey, &privateKey, 1);
75+
cx_ecfp_generate_pair(CX_CURVE_Curve25519,
76+
&tmpCtx.publicKeyContext.publicKey,
77+
&privateKey,
78+
1);
7979
explicit_bzero(privateKeyDataSwapped, sizeof(privateKeyDataSwapped));
80-
}
81-
else {
80+
} else {
8281
memmove(tmpCtx.publicKeyContext.publicKey.W + 1, dataBuffer, 32);
8382
status = cx_x25519(tmpCtx.publicKeyContext.publicKey.W + 1, privateKeyData, 32);
8483
}
8584
explicit_bzero(&privateKey, sizeof(privateKey));
86-
explicit_bzero(privateKeyData, sizeof(privateKeyData));
85+
explicit_bzero(privateKeyData, sizeof(privateKeyData));
8786

8887
if (status != CX_OK) {
8988
THROW(0x6A80);
@@ -97,24 +96,27 @@ void handlePerformPrivacyOperation(uint8_t p1,
9796
THROW(0x9000);
9897
}
9998
#ifndef NO_CONSENT
100-
else {
99+
else {
101100
snprintf(strings.common.fullAddress,
102101
sizeof(strings.common.fullAddress),
103102
"0x%.*s",
104103
40,
105104
tmpCtx.publicKeyContext.address);
106-
for (uint8_t i=0; i<32; i++) {
105+
for (uint8_t i = 0; i < 32; i++) {
107106
privateKeyData[i] = tmpCtx.publicKeyContext.publicKey.W[32 - i];
108107
}
109-
snprintf(strings.common.fullAmount, sizeof(strings.common.fullAmount) - 1, "%.*H", 32, privateKeyData);
108+
snprintf(strings.common.fullAmount,
109+
sizeof(strings.common.fullAmount) - 1,
110+
"%.*H",
111+
32,
112+
privateKeyData);
110113
if (p2 == P2_PUBLIC_ENCRYPTION_KEY) {
111114
ux_flow_init(0, ux_display_privacy_public_key_flow, NULL);
112-
}
113-
else {
115+
} else {
114116
ux_flow_init(0, ux_display_privacy_shared_secret_flow, NULL);
115117
}
116118

117-
*flags |= IO_ASYNCH_REPLY;
119+
*flags |= IO_ASYNCH_REPLY;
118120
}
119121
#endif // NO_CONSENT
120122
}

src_features/performPrivacyOperation/logic_performPrivacyOperation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "shared_context.h"
22

33
uint32_t set_result_perform_privacy_operation() {
4-
for (uint8_t i=0; i<32; i++) {
4+
for (uint8_t i = 0; i < 32; i++) {
55
G_io_apdu_buffer[i] = tmpCtx.publicKeyContext.publicKey.W[32 - i];
66
}
77
return 32;

src_features/performPrivacyOperation/ui_common_performPrivacyOperation.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ unsigned int io_seproxyhal_touch_privacy_cancel(__attribute__((unused)) const ba
2424
ui_idle();
2525
return 0; // do not redraw the widget
2626
}
27-

0 commit comments

Comments
 (0)