Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
transaction_check.c File Reference
#include <string.h>
#include "os_helpers.h"
#include "os_print.h"
#include "os_utils.h"
#include "status_words.h"
#include "apdu_chunks.h"
#include "transaction_check.h"
#include "transaction_check_entrypoints.h"
#include "transaction_check_internal.h"
Include dependency graph for transaction_check.c:

Go to the source code of this file.

Classes

struct  tx_check_report_t

Macros

#define P1_DESCRIPTOR   0x00
#define P1_OPT_IN   0x01
#define TX_CHECK_WARNINGS

Functions

static bool report_matches (const tx_check_context_t *ctx)
 Check that the stored report applies to the operation being signed.
static const char * warning_text (void)
 Text displayed in the warning, from the report risk and category.
void tx_check_clear (void)
 Erase the stored report.
tx_check_status_t tx_check_provide_descriptor (const buffer_t *payload)
 Parse, verify and store a descriptor, replacing a report not bound to a review.
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.
uint16_t tx_check_status_to_sw (tx_check_status_t status)
 Standard status word of a Transaction Check status.
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 APDU: chunked descriptor (P1 0x00) or opt-in request (P1 0x01).

Variables

static tx_check_report_t s_report

Macro Definition Documentation

◆ P1_DESCRIPTOR

#define P1_DESCRIPTOR   0x00

Definition at line 31 of file transaction_check.c.

◆ P1_OPT_IN

#define P1_OPT_IN   0x01

Definition at line 32 of file transaction_check.c.

◆ TX_CHECK_WARNINGS

#define TX_CHECK_WARNINGS
Value:
@ W3C_THREAT_DETECTED_WARN
Web3 Checks: Threat detected (see reportRisk field).
@ W3C_ISSUE_WARN
Web3 Checks issue (not available).
@ W3C_NO_THREAT_WARN
Web3 Checks: No Threat detected.
@ W3C_RISK_DETECTED_WARN
Web3 Checks: Risk detected (see reportRisk field).

Warning bits set by the Transaction Check.

Definition at line 35 of file transaction_check.c.

Function Documentation

◆ report_matches()

bool report_matches ( const tx_check_context_t * ctx)
static

Check that the stored report applies to the operation being signed.

Parameters
[in]ctxOperation being signed
Returns
true if the report matches the operation

Definition at line 68 of file transaction_check.c.

◆ tx_check_apply_report()

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.

Parameters
[in,out]warningReview warning
[in]ctxOperation being signed

Definition at line 239 of file transaction_check.c.

◆ tx_check_clear()

void tx_check_clear ( void )

Erase the stored report.

Definition at line 156 of file transaction_check.c.

◆ tx_check_handle_apdu()

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 APDU: chunked descriptor (P1 0x00) or opt-in request (P1 0x01).

Handle the SDK default APDU (CLA 0xB0, INS DEFAULT_APDU_INS_TRANSACTION_CHECK).

Parameters
[in]bufferAPDU data
[in]buffer_lenAPDU data length
[in]p1APDU P1
[in]p2APDU P2
[out]buffer_outResponse data
[in,out]buffer_out_lengthResponse capacity in, response length out
Returns
Status word, SWO_NO_RESPONSE when the reply is deferred

Definition at line 315 of file transaction_check.c.

◆ tx_check_provide_descriptor()

tx_check_status_t tx_check_provide_descriptor ( const buffer_t * payload)

Parse, verify and store a descriptor, replacing a report not bound to a review.

Parse, verify and store a Transaction Check descriptor.

Parameters
[in]payloadComplete TLV descriptor
Returns
Transaction Check status

Definition at line 167 of file transaction_check.c.

◆ tx_check_status_to_sw()

uint16_t tx_check_status_to_sw ( tx_check_status_t status)

Standard status word of a Transaction Check status.

Parameters
[in]statusStatus returned by tx_check_provide_descriptor() or tx_check_opt_in()
Returns
Status word of status_words.h, SWO_NO_RESPONSE for TX_CHECK_PENDING

Definition at line 283 of file transaction_check.c.

◆ warning_text()

const char * warning_text ( void )
static

Text displayed in the warning, from the report risk and category.

Returns
Warning text, NULL when no warning is displayed

Definition at line 114 of file transaction_check.c.

Variable Documentation

◆ s_report

tx_check_report_t s_report
static

Definition at line 58 of file transaction_check.c.