Files

36 lines
1.1 KiB
C
Raw Permalink Normal View History

2020-09-26 15:49:36 +02:00
#include "shared_context.h"
#include "apdu_constants.h"
2024-01-16 13:51:36 +01:00
#include "common_utils.h"
2022-11-10 13:32:20 +01:00
#include "common_ui.h"
#include "common_712.h"
2020-09-26 15:49:36 +02:00
void handleSignEIP712Message_v0(uint8_t p1,
uint8_t p2,
const uint8_t *workBuffer,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx) {
2022-07-19 11:49:18 +02:00
(void) tx;
(void) p2;
if (p1 != 00) {
2022-10-05 10:21:52 +02:00
THROW(APDU_RESPONSE_INVALID_P1_P2);
2020-09-26 15:49:36 +02:00
}
2020-12-01 16:20:13 +01:00
if (appState != APP_STATE_IDLE) {
reset_app_context();
}
2022-07-08 11:12:50 +02:00
workBuffer = parseBip32(workBuffer, &dataLength, &tmpCtx.messageSigningContext.bip32);
if ((workBuffer == NULL) || (dataLength < (KECCAK256_HASH_BYTESIZE * 2))) {
2022-10-05 10:21:52 +02:00
THROW(APDU_RESPONSE_INVALID_DATA);
2020-12-01 16:20:13 +01:00
}
2022-07-19 11:49:18 +02:00
memmove(tmpCtx.messageSigningContext712.domainHash, workBuffer, KECCAK256_HASH_BYTESIZE);
memmove(tmpCtx.messageSigningContext712.messageHash,
workBuffer + KECCAK256_HASH_BYTESIZE,
KECCAK256_HASH_BYTESIZE);
2020-09-26 15:49:36 +02:00
2022-11-10 13:32:20 +01:00
ui_sign_712_v0();
2020-09-26 15:49:36 +02:00
2020-10-07 16:56:40 +02:00
*flags |= IO_ASYNCH_REPLY;
2020-09-26 15:49:36 +02:00
}