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"
|
2022-05-12 17:30:04 +02:00
|
|
|
#include "common_712.h"
|
2020-09-26 15:49:36 +02:00
|
|
|
|
2022-05-03 09:33:46 +02:00
|
|
|
void handleSignEIP712Message_v0(uint8_t p1,
|
|
|
|
|
uint8_t p2,
|
|
|
|
|
const uint8_t *workBuffer,
|
2022-05-12 17:30:04 +02:00
|
|
|
uint8_t dataLength,
|
2022-05-03 09:33:46 +02:00
|
|
|
unsigned int *flags,
|
|
|
|
|
unsigned int *tx) {
|
2022-07-19 11:49:18 +02:00
|
|
|
(void) tx;
|
|
|
|
|
(void) p2;
|
2022-05-16 10:59:20 +02:00
|
|
|
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);
|
|
|
|
|
|
2022-05-12 17:30:04 +02:00
|
|
|
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);
|
2022-05-12 17:30:04 +02:00
|
|
|
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
|
|
|
}
|