Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
transaction_check.h
Go to the documentation of this file.
1/*****************************************************************************
2 * (c) 2026 Ledger SAS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
25
26#pragma once
27
28/* Includes ------------------------------------------------------------------*/
29#include <stdbool.h>
30#include <stddef.h>
31#include <stdint.h>
32#include "os_types.h"
33#include "buffer.h"
34#include "lcx_ecdsa.h"
35#include "lcx_sha3.h"
36#include "nbgl_use_case.h"
38
39#if defined(HAVE_TX_CHECK)
40
41/* Exported enumerations -----------------------------------------------------*/
46
56
57/* Exported types, structures, unions ----------------------------------------*/
58
60typedef struct {
63 const uint8_t *tx_hash;
65 const uint8_t *domain_hash;
67 const void *app_data;
69
70/* Exported defines --------------------------------------------------------*/
71
76// clang-format off
77#define TRANSACTION_CHECK_MAX_PAYLOAD_SIZE \
78 ((1 + 1 + 1) /* STRUCTURE_TYPE */ \
79 + (1 + 1 + 1) /* STRUCTURE_VERSION */ \
80 + (1 + 1 + TRANSACTION_CHECK_MAX_ADDRESS_SIZE) /* ADDRESS */ \
81 + (1 + 1 + 8) /* CHAIN_ID */ \
82 + (1 + 1 + TRANSACTION_CHECK_HASH_SIZE) /* TX_HASH */ \
83 + (1 + 1 + TRANSACTION_CHECK_HASH_SIZE) /* DOMAIN_HASH */ \
84 + (2 + 1 + 1) /* NORMALIZED_RISK */ \
85 + (2 + 1 + 1) /* NORMALIZED_CATEGORY */ \
86 + (2 + 1 + TRANSACTION_CHECK_MSG_SIZE) /* PROVIDER_MSG */ \
87 + (2 + 1 + TRANSACTION_CHECK_URL_SIZE) /* TINY_URL */ \
88 + (2 + 1 + 1) /* SIMULATION_TYPE */ \
89 + (1 + 1 + CX_ECDSA_SHA256_SIG_MAX_ASN1_LENGTH)) /* DER_SIGNATURE */
90// clang-format on
91
92/* Exported functions prototypes--------------------------------------------- */
93
94#if defined(HAVE_TX_CHECK_APDU)
110bolos_err_t tx_check_handle_apdu(const uint8_t *buffer,
111 size_t buffer_len,
112 uint8_t p1,
113 uint8_t p2,
114 uint8_t *buffer_out,
115 size_t *buffer_out_length);
116#endif // HAVE_TX_CHECK_APDU
117
129
143tx_check_status_t tx_check_opt_in(bool response_expected);
144
152
165
169void tx_check_clear(void);
170
171#endif // HAVE_TX_CHECK
ECDSA (Elliptic Curve Digital Signature Algorithm).
SHA-3 (Secure Hash Algorithm 3).
API of the Advanced BOLOS Graphical Library, for typical application use-cases.
The necessary parameters to build a warning page preceding a review. One can either use predefinedSet...
const uint8_t * tx_hash
transaction_check_type_t type
const uint8_t * domain_hash
enum transaction_check_type_e transaction_check_type_t
tx_check_status_t tx_check_provide_descriptor(const buffer_t *payload)
Parse, verify and store a Transaction Check descriptor.
uint16_t tx_check_status_to_sw(tx_check_status_t status)
Standard status word of a Transaction Check status.
void tx_check_apply_report(nbgl_warning_t *warning, const tx_check_context_t *ctx)
Bind the stored report to the operation being signed and fill the review warning.
void tx_check_clear(void)
Erase the stored report.
bolos_err_t tx_check_handle_apdu(const uint8_t *buffer, size_t buffer_len, uint8_t p1, uint8_t p2, uint8_t *buffer_out, size_t *buffer_out_length)
Handle the SDK default APDU (CLA 0xB0, INS DEFAULT_APDU_INS_TRANSACTION_CHECK).
tx_check_setting_t
@ TX_CHECK_SETTING_OPT_IN
The user has seen the opt-in screen.
@ TX_CHECK_SETTING_ENABLE
Transaction Check is enabled.
tx_check_status_t tx_check_opt_in(bool response_expected)
Display the opt-in screen if the user has not seen it yet.
tx_check_status_t
@ TX_CHECK_PENDING
Opt-in screen displayed, the choice comes later.
@ TX_CHECK_NOT_ALLOWED
Report bound to the review in progress, swap, or app busy.
@ TX_CHECK_DISABLED
Transaction Check disabled by the user.
@ TX_CHECK_INVALID_DESCRIPTOR
Descriptor malformed or rejected by the app.
@ TX_CHECK_SUCCESS
Descriptor stored, or opt-in already done.
@ TX_CHECK_INVALID_SIGNATURE
Descriptor signature rejected.