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

Provide Ledger Account Contact flow (P1=0x21, struct type 0x34). More...

#include <string.h>
#include "os_utils.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 dependency graph for ledger_account_provide_contact.c:

Go to the source code of this file.

Classes

struct  s_provide_ledger_account_ctx

Macros

#define STRUCT_VERSION   0x01
#define PROVIDE_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_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_provide_ledger_account_ctx *context)
 Check that all mandatory TLV tags were received.
static void print_payload (const s_provide_ledger_account_ctx *context)
 Print the received descriptor.
bolos_err_t provide_ledger_account_contact (uint8_t *buffer_in, size_t buffer_in_length)
 Deliver a verified Ledger Account contact to the coin application.

Detailed Description

Provide Ledger Account Contact flow (P1=0x21, struct type 0x34).

Delivers a previously registered Ledger Account to the coin application so that the application can substitute the human-readable account name for the raw derived address during transaction review.

Unlike the Identity Provide Contact flow (P1=0x20), a Ledger Account has no external address, no group_handle, no scope, and no hmac_rest. The only proof required is the HMAC Proof of Registration returned by register_ledger_account (P1=0x11).

Flow:

  1. Receive fully assembled payload (multi-chunk reassembly handled by address_book.c)
  2. Parse TLV payload (contact_name + derivation_path + chain_id + blockchain_family
    • hmac_proof)
  3. Verify HMAC Proof of Registration
  4. Call handle_provide_ledger_account() so the coin app can store the contact
  5. Return SWO_SUCCESS (9000, no data)

Active under HAVE_ADDRESS_BOOK && HAVE_ADDRESS_BOOK_LEDGER_ACCOUNT.

Definition in file ledger_account_provide_contact.c.

Macro Definition Documentation

◆ PROVIDE_LEDGER_ACCOUNT_TAGS

#define PROVIDE_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(0x69, TAG_DERIVATION_PATH, handle_derivation_path, ENFORCE_UNIQUE_TAG) \
X(0x23, TAG_CHAIN_ID, handle_chain_id, ENFORCE_UNIQUE_TAG) \
X(0x51, TAG_BLOCKCHAIN_FAMILY, handle_blockchain_family, ENFORCE_UNIQUE_TAG) \
X(0x29, TAG_HMAC_PROOF, handle_hmac_proof, 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_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 68 of file ledger_account_provide_contact.c.

◆ STRUCT_VERSION

#define STRUCT_VERSION   0x01

Definition at line 58 of file ledger_account_provide_contact.c.

Function Documentation

◆ 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
[out]context_ptrthe received payload
Returns
whether the handling was successful

Definition at line 174 of file ledger_account_provide_contact.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
[out]context_ptrthe received payload
Returns
whether the handling was successful

Definition at line 160 of file ledger_account_provide_contact.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
[out]context_ptrthe received payload
Returns
whether the handling was successful

Definition at line 126 of file ledger_account_provide_contact.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
[out]context_ptrthe received payload
Returns
whether the handling was successful

Definition at line 146 of file ledger_account_provide_contact.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
[out]context_ptrthe received payload
Returns
whether the handling was successful

Definition at line 188 of file ledger_account_provide_contact.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 88 of file ledger_account_provide_contact.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 107 of file ledger_account_provide_contact.c.

◆ print_payload()

void print_payload ( const s_provide_ledger_account_ctx * context)
static

Print the received descriptor.

Parameters
[in]contextthe received payload

Definition at line 238 of file ledger_account_provide_contact.c.

◆ provide_ledger_account_contact()

bolos_err_t provide_ledger_account_contact ( uint8_t * buffer_in,
size_t buffer_in_length )

Deliver a verified Ledger Account contact to the coin application.

Parses, verifies the HMAC Proof of Registration, and passes the account to the coin app callback. Returns SWO_SUCCESS (9000) with no response data.

Parameters
[in]buffer_inthe fully assembled TLV payload
[in]buffer_in_lengththe length of the payload
Returns
bolos_err_t the result of the command

Definition at line 276 of file ledger_account_provide_contact.c.

◆ verify_fields()

bool verify_fields ( const s_provide_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 210 of file ledger_account_provide_contact.c.