Better handling of missing EIP721 error codes + add a missing one for EIP712 filtering signature checking

This commit is contained in:
Alexandre Paillier
2022-08-23 12:01:32 +02:00
parent 3f02bf672c
commit 93b0bb08f7
3 changed files with 4 additions and 0 deletions

View File

@@ -35,6 +35,7 @@
#define COMMON_INS_GET_WALLET_ID 0x04
#define APDU_RESPONSE_OK 0x9000
#define APDU_RESPONSE_ERROR_NO_INFO 0x6a00
#define APDU_RESPONSE_INVALID_DATA 0x6a80
#define APDU_RESPONSE_INSUFFICIENT_MEMORY 0x6a84
#define APDU_RESPONSE_INVALID_INS 0x6d00

View File

@@ -25,6 +25,8 @@
void handle_eip712_return_code(bool success) {
if (success) {
apdu_response_code = APDU_RESPONSE_OK;
} else if (apdu_response_code == APDU_RESPONSE_OK) { // somehow not set
apdu_response_code = APDU_RESPONSE_ERROR_NO_INFO;
}
*(uint16_t *) G_io_apdu_buffer = __builtin_bswap16(apdu_response_code);

View File

@@ -110,6 +110,7 @@ static bool verify_filtering_signature(uint8_t dname_length,
if (!cx_ecdsa_verify(&verifying_key, CX_LAST, CX_SHA256, hash, sizeof(hash), sig, sig_length)) {
#ifndef HAVE_BYPASS_SIGNATURES
PRINTF("Invalid EIP-712 filtering signature\n");
apdu_response_code = APDU_RESPONSE_INVALID_DATA;
return false;
#endif
}