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

Address Book APDU dispatcher. More...

#include <string.h>
#include "os_apdu.h"
#include "os_helpers.h"
#include "os_print.h"
#include "os_utils.h"
#include "address_book.h"
#include "apdu_chunks.h"
#include "status_words.h"
#include "identity.h"
#include "ledger_account.h"
Include dependency graph for address_book.c:

Go to the source code of this file.

Macros

#define P1_REGISTER_IDENTITY   0x01
#define P1_EDIT_CONTACT_NAME   0x02
#define P1_EDIT_IDENTIFIER   0x03
#define P1_EDIT_SCOPE   0x04
#define P1_PROVIDE_CONTACT   0x20
#define P1_REGISTER_LEDGER_ACCOUNT   0x11
#define P1_EDIT_LEDGER_ACCOUNT   0x12
#define P1_PROVIDE_LEDGER_ACCOUNT_CONTACT   0x21

Functions

bolos_err_t addr_book_handle_apdu (uint8_t *buffer, size_t buffer_len, uint8_t p1, uint8_t p2)

Detailed Description

Address Book APDU dispatcher.

Entry point for all Address Book sub-commands. Routes each APDU to the appropriate handler based on P1:

  • P1 0x01 → Register Identity (always active)
  • P1 0x02 → Edit Contact Name (always active)
  • P1 0x03 → Edit Identifier (always active)
  • P1 0x04 → Edit Scope (always active)
  • P1 0x11 → Register Ledger Account (HAVE_ADDRESS_BOOK_LEDGER_ACCOUNT)
  • P1 0x12 → Edit Ledger Account (HAVE_ADDRESS_BOOK_LEDGER_ACCOUNT)
  • P1 0x20 → Provide Contact (always active)
  • P1 0x21 → Provide Ledger Account Contact (HAVE_ADDRESS_BOOK_LEDGER_ACCOUNT)

Chunked transport

Every sub-command uses the same chunked transport, regardless of payload size. The first chunk (P2=0x00) is prefixed with a 2-byte big-endian total payload length. Continuation chunks (P2=0x80) are appended directly. The shared helper apdu_chunks_reassemble() accumulates the data and returns the assembled buffer. Once complete, the handler is then dispatched on P1. A uniform format keeps the protocol consistent and eases future payload-size evolutions.

Definition in file address_book.c.

Macro Definition Documentation

◆ P1_EDIT_CONTACT_NAME

#define P1_EDIT_CONTACT_NAME   0x02

Definition at line 62 of file address_book.c.

◆ P1_EDIT_IDENTIFIER

#define P1_EDIT_IDENTIFIER   0x03

Definition at line 63 of file address_book.c.

◆ P1_EDIT_LEDGER_ACCOUNT

#define P1_EDIT_LEDGER_ACCOUNT   0x12

Definition at line 69 of file address_book.c.

◆ P1_EDIT_SCOPE

#define P1_EDIT_SCOPE   0x04

Definition at line 64 of file address_book.c.

◆ P1_PROVIDE_CONTACT

#define P1_PROVIDE_CONTACT   0x20

Definition at line 65 of file address_book.c.

◆ P1_PROVIDE_LEDGER_ACCOUNT_CONTACT

#define P1_PROVIDE_LEDGER_ACCOUNT_CONTACT   0x21

Definition at line 70 of file address_book.c.

◆ P1_REGISTER_IDENTITY

#define P1_REGISTER_IDENTITY   0x01

Definition at line 61 of file address_book.c.

◆ P1_REGISTER_LEDGER_ACCOUNT

#define P1_REGISTER_LEDGER_ACCOUNT   0x11

Definition at line 68 of file address_book.c.

Function Documentation

◆ addr_book_handle_apdu()

bolos_err_t addr_book_handle_apdu ( uint8_t * buffer,
size_t buffer_len,
uint8_t p1,
uint8_t p2 )

Definition at line 74 of file address_book.c.