Skip to content

Commit 50397ed

Browse files
authored
Sign prefix (and don't display prefix on screen) (#33)
* Sign prefix without displaying it * Bump Version * Snapshots * Add toml dependency to requirements.txt * ragger tests snapshots * return message through apdu buffer
1 parent 87b53e3 commit 50397ed

File tree

39 files changed

+24
-5
lines changed

39 files changed

+24
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ GIT_DESCRIBE=$(shell git describe --tags --abbrev=8 --always --long --dirty 2>/d
3131
VERSION_TAG=$(shell echo $(GIT_DESCRIBE) | sed 's/^v//g')
3232
APPVERSION_M=1
3333
APPVERSION_N=4
34-
APPVERSION_P=4
34+
APPVERSION_P=5
3535
APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
3636
APPNAME = "Mina"
3737

src/sign_msg.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ void sign_message(uint8_t *dataBuffer, uint8_t dataLength)
4949
uint8_t bits[TX_BITSTRINGS_BYTES];
5050
ROInput roinput = roinput_create(input_fields, bits);
5151

52+
// Add PREFIX to the buffer
53+
const uint8_t prefix_len = strlen(PREFIX);
54+
uint8_t prefixed_buffer[5 + TX_BITSTRINGS_BYTES];
55+
56+
if (dataLength + prefix_len > sizeof(prefixed_buffer)) {
57+
THROW(INVALID_PARAMETER);
58+
}
59+
60+
memcpy(prefixed_buffer, PREFIX, prefix_len);
61+
memcpy(prefixed_buffer + prefix_len, dataBuffer, dataLength);
62+
dataLength += prefix_len;
63+
dataBuffer = prefixed_buffer;
64+
5265
if ((dataLength < ACCOUNT_LENGTH + NETWORK_LENGTH) || (dataLength > 5 + TX_BITSTRINGS_BYTES)) {
5366
THROW(INVALID_PARAMETER);
5467
}
@@ -85,5 +98,7 @@ void sign_message(uint8_t *dataBuffer, uint8_t dataLength)
8598

8699
memmove(G_io_apdu_buffer, &sig, sizeof(sig));
87100

88-
sendResponse(sizeof(sig), true);
101+
G_io_apdu_buffer[sizeof(sig)] = dataLength;
102+
memmove(G_io_apdu_buffer + sizeof(sig) + 1, dataBuffer, dataLength);
103+
sendResponse(sizeof(sig) + 1 + dataLength, true);
89104
}

src/sign_msg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#define NETWORK_OFFSET 4
99
#define MSG_OFFSET 5
1010

11+
#define PREFIX "Message : "
12+
1113
void handle_sign_msg(uint8_t p1, uint8_t p2, uint8_t *dataBuffer,
1214
uint8_t dataLength, volatile unsigned int *flags);
1315

tests/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ base58
22
bip32
33
ragger[tests,speculos]==1.32.1
44
ledgerblue
5+
toml
2.08 KB
Loading
2.08 KB
Loading
2.08 KB
Loading
2.08 KB
Loading
2.06 KB
Loading
2.08 KB
Loading

0 commit comments

Comments
 (0)