Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
ledger_account_edit.c File Reference

Edit Ledger Account flow (P1=0x12, struct type 0x30). More...

#include <string.h>
#include "os_apdu.h"
#include "status_words.h"
#include "tlv_library.h"
#include "buffer.h"
#include "bip32.h"
#include "address_book.h"
#include "address_book_entrypoints.h"
#include "address_book_crypto.h"
#include "address_book_common.h"
#include "ledger_account.h"
#include "io.h"
#include "nbgl_use_case.h"
Include dependency graph for ledger_account_edit.c:

Go to the source code of this file.

Classes

struct  s_edit_ledger_account_ctx

Macros

#define STRUCT_VERSION   0x01
#define EDIT_LEDGER_ACCOUNT_TAGS(X)

Functions

static bool handle_struct_type (const tlv_data_t *data, void *context_ptr)
 Handler for tag STRUCTURE_TYPE.
static bool handle_struct_version (const tlv_data_t *data, void *context_ptr)
 Handler for tag STRUCTURE_VERSION.
static bool handle_contact_name (const tlv_data_t *data, void *context_ptr)
 Handler for tag CONTACT_NAME.
static bool handle_previous_name (const tlv_data_t *data, void *context_ptr)
 Handler for tag PREVIOUS_NAME.
static bool handle_derivation_path (const tlv_data_t *data, void *context_ptr)
 Handler for tag DERIVATION_PATH.
static bool handle_chain_id (const tlv_data_t *data, void *context_ptr)
 Handler for tag CHAIN_ID.
static bool handle_blockchain_family (const tlv_data_t *data, void *context_ptr)
 Handler for tag BLOCKCHAIN_FAMILY.
static bool handle_hmac_proof (const tlv_data_t *data, void *context_ptr)
 Handler for tag HMAC_PROOF.
static bool verify_fields (const s_edit_ledger_account_ctx *context)
 Check that all mandatory TLV tags were received.
static void print_payload (const s_edit_ledger_account_ctx *context)
 Print the received descriptor.
static bool build_and_send_response (void)
 Build and send response.
static void review_choice (bool confirm)
 NBGL callback invoked after the user confirms or rejects the edit.
bolos_err_t edit_ledger_account (uint8_t *buffer_in, size_t buffer_in_length)
 Edit the name of an existing Ledger Account.

Detailed Description

Edit Ledger Account flow (P1=0x12, struct type 0x30).

Flow:

  1. Receive fully assembled payload (multi-chunk reassembly handled by address_book.c)
  2. Parse TLV payload (previous_name + new_name + derivation_path + chain_id + blockchain_family + hmac_proof)
  3. Verify HMAC proof of the previous registration
  4. Display UI: reuse the Register Ledger Account review (display_register_ledger_account_review)
  5. On confirm: compute new HMAC Proof of Registration and send to host

Active under HAVE_ADDRESS_BOOK_LEDGER_ACCOUNT.

Definition in file ledger_account_edit.c.

Macro Definition Documentation

◆ EDIT_LEDGER_ACCOUNT_TAGS

#define EDIT_LEDGER_ACCOUNT_TAGS ( X)
Value:
X(0x01, TAG_STRUCTURE_TYPE, handle_struct_type, ENFORCE_UNIQUE_TAG) \
X(0x02, TAG_STRUCTURE_VERSION, handle_struct_version, ENFORCE_UNIQUE_TAG) \
X(0xf0, TAG_CONTACT_NAME, handle_contact_name, ENFORCE_UNIQUE_TAG) \
X(0xf3, TAG_PREVIOUS_NAME, handle_previous_name, ENFORCE_UNIQUE_TAG) \
X(0x69, TAG_DERIVATION_PATH, handle_derivation_path, ENFORCE_UNIQUE_TAG) \
X(0x23, TAG_CHAIN_ID, handle_chain_id, ENFORCE_UNIQUE_TAG) \
X(0x29, TAG_HMAC_PROOF, handle_hmac_proof, ENFORCE_UNIQUE_TAG) \
X(0x51, TAG_BLOCKCHAIN_FAMILY, handle_blockchain_family, ENFORCE_UNIQUE_TAG)
static bool handle_contact_name(const tlv_data_t *data, void *context_ptr)
Handler for tag CONTACT_NAME.
static bool handle_hmac_proof(const tlv_data_t *data, void *context_ptr)
Handler for tag HMAC_PROOF.
static bool handle_previous_name(const tlv_data_t *data, void *context_ptr)
Handler for tag PREVIOUS_NAME.
static bool handle_struct_type(const tlv_data_t *data, void *context_ptr)
Handler for tag STRUCTURE_TYPE.
static bool handle_struct_version(const tlv_data_t *data, void *context_ptr)
Handler for tag STRUCTURE_VERSION.
static bool handle_blockchain_family(const tlv_data_t *data, void *context_ptr)
Handler for tag BLOCKCHAIN_FAMILY.
static bool handle_chain_id(const tlv_data_t *data, void *context_ptr)
Handler for tag CHAIN_ID.
static bool handle_derivation_path(const tlv_data_t *data, void *context_ptr)
Handler for tag DERIVATION_PATH.
@ ENFORCE_UNIQUE_TAG

Definition at line 65 of file ledger_account_edit.c.

◆ STRUCT_VERSION

#define STRUCT_VERSION   0x01

Definition at line 52 of file ledger_account_edit.c.

Function Documentation

◆ build_and_send_response()

bool build_and_send_response ( void )
static

Build and send response.

Compute HMAC Proof of Registration and send it to the host Response format: type(1) | hmac_proof(32).

Returns
true if successful, false otherwise

Definition at line 293 of file ledger_account_edit.c.

◆ edit_ledger_account()

bolos_err_t edit_ledger_account ( uint8_t * buffer_in,
size_t buffer_in_length )

Edit the name of an existing Ledger Account.

Parameters
[in]buffer_inthe input buffer containing the account data
[in]buffer_in_lengththe length of the input buffer
Returns
bolos_err_t the result of the edit

Definition at line 344 of file ledger_account_edit.c.

◆ handle_blockchain_family()

bool handle_blockchain_family ( const tlv_data_t * data,
void * context_ptr )
static

Handler for tag BLOCKCHAIN_FAMILY.

Parameters
[in]datathe tlv data
[in]context_ptrthe received payload
Returns
whether the handling was successful

Definition at line 191 of file ledger_account_edit.c.

◆ handle_chain_id()

bool handle_chain_id ( const tlv_data_t * data,
void * context_ptr )
static

Handler for tag CHAIN_ID.

Parameters
[in]datathe tlv data
[in]context_ptrthe received payload
Returns
whether the handling was successful

Definition at line 177 of file ledger_account_edit.c.

◆ handle_contact_name()

bool handle_contact_name ( const tlv_data_t * data,
void * context_ptr )
static

Handler for tag CONTACT_NAME.

Parameters
[in]datathe tlv data
[in]context_ptrthe received payload
Returns
whether the handling was successful

Definition at line 124 of file ledger_account_edit.c.

◆ handle_derivation_path()

bool handle_derivation_path ( const tlv_data_t * data,
void * context_ptr )
static

Handler for tag DERIVATION_PATH.

Parameters
[in]datathe tlv data
[in]context_ptrthe received payload
Returns
whether the handling was successful

Definition at line 163 of file ledger_account_edit.c.

◆ handle_hmac_proof()

bool handle_hmac_proof ( const tlv_data_t * data,
void * context_ptr )
static

Handler for tag HMAC_PROOF.

Parameters
[in]datathe tlv data
[in]context_ptrthe received payload
Returns
whether the handling was successful

Definition at line 206 of file ledger_account_edit.c.

◆ handle_previous_name()

bool handle_previous_name ( const tlv_data_t * data,
void * context_ptr )
static

Handler for tag PREVIOUS_NAME.

Parameters
[in]datathe tlv data
[in]context_ptrthe received payload
Returns
whether the handling was successful

Definition at line 144 of file ledger_account_edit.c.

◆ handle_struct_type()

bool handle_struct_type ( const tlv_data_t * data,
void * context_ptr )
static

Handler for tag STRUCTURE_TYPE.

Parameters
[in]datathe tlv data
[in]context_ptrthe received payload
Returns
whether the handling was successful

Definition at line 86 of file ledger_account_edit.c.

◆ handle_struct_version()

bool handle_struct_version ( const tlv_data_t * data,
void * context_ptr )
static

Handler for tag STRUCTURE_VERSION.

Parameters
[in]datathe tlv data
[in]context_ptrthe received payload
Returns
whether the handling was successful

Definition at line 105 of file ledger_account_edit.c.

◆ print_payload()

void print_payload ( const s_edit_ledger_account_ctx * context)
static

Print the received descriptor.

Parameters
[in]contextthe received payload Only for debug purpose.

Definition at line 258 of file ledger_account_edit.c.

◆ review_choice()

void review_choice ( bool confirm)
static

NBGL callback invoked after the user confirms or rejects the edit.

Parameters
[in]confirmtrue if user confirmed, false if rejected

Definition at line 317 of file ledger_account_edit.c.

◆ verify_fields()

bool verify_fields ( const s_edit_ledger_account_ctx * context)
static

Check that all mandatory TLV tags were received.

Parameters
[in]contextthe received payload
Returns
whether all mandatory fields are present

Definition at line 228 of file ledger_account_edit.c.