|
Embedded SDK
Embedded SDK
|
#include <stdint.h>#include <stddef.h>#include <stdbool.h>#include "bip32.h"#include "lcx_sha256.h"#include "address_book.h"#include "identity.h"#include "os_address_book.h"

Go to the source code of this file.
Functions | |
| bool | address_book_generate_group_handle (uint8_t group_handle[GROUP_HANDLE_SIZE]) |
| Generate a device-authenticated group handle. | |
| bool | address_book_verify_group_handle (const uint8_t group_handle[GROUP_HANDLE_SIZE], uint8_t gid_out[GID_SIZE]) |
| Verify a group handle and extract the gid. | |
| bool | address_book_compute_hmac_proof (const uint8_t gid[GID_SIZE], const char *name, uint8_t hmac_out[CX_SHA256_SIZE]) |
| Compute HMAC_PROOF for an Identity contact. | |
| bool | address_book_verify_hmac_proof (const uint8_t gid[GID_SIZE], const char *name, const uint8_t hmac_expected[CX_SHA256_SIZE]) |
| Verify HMAC_PROOF for an Identity contact. | |
| bool | address_book_compute_hmac_rest (const uint8_t gid[GID_SIZE], const char *scope, const uint8_t *identifier, uint8_t identifier_len, blockchain_family_e family, uint64_t chain_id, uint8_t hmac_out[CX_SHA256_SIZE]) |
| Compute HMAC_REST for an Identity contact. | |
| bool | address_book_verify_hmac_rest (const uint8_t gid[GID_SIZE], const char *scope, const uint8_t *identifier, uint8_t identifier_len, blockchain_family_e family, uint64_t chain_id, const uint8_t hmac_expected[CX_SHA256_SIZE]) |
| Verify HMAC_REST for an Identity contact. | |
| bool | address_book_compute_hmac_proof_ledger_account (const char *name, const path_bip32_t *bip32_path, blockchain_family_e family, uint64_t chain_id, uint8_t hmac_out[CX_SHA256_SIZE]) |
| Compute an HMAC-SHA256 Proof of Registration for a Ledger Account. | |
| bool | address_book_verify_hmac_proof_ledger_account (const char *name, const path_bip32_t *bip32_path, blockchain_family_e family, uint64_t chain_id, const uint8_t hmac_expected[CX_SHA256_SIZE]) |
| Verify an HMAC Proof of Registration for a Ledger Account. | |
| bool | address_book_send_hmac_proof (uint8_t type, const uint8_t hmac_proof[CX_SHA256_SIZE]) |
| Send an HMAC proof response for Edit operations. | |
| bool | address_book_send_register_identity_response (const uint8_t group_handle[GROUP_HANDLE_SIZE], const uint8_t hmac_proof[CX_SHA256_SIZE], const uint8_t hmac_rest[CX_SHA256_SIZE]) |
| Send the Register Identity response carrying the group handle and both HMACs. | |
| bool address_book_compute_hmac_proof | ( | const uint8_t | gid[GID_SIZE], |
| const char * | name, | ||
| uint8_t | hmac_out[CX_SHA256_SIZE] ) |
Compute HMAC_PROOF for an Identity contact.
Serializes the HMAC message: gid(32) | name_len(1) | name Then delegates to the OS syscall.
| [in] | gid | 32-byte wallet-generated contact ID |
| [in] | name | Contact name (null-terminated) |
| [out] | hmac_out | Output buffer for the 32-byte HMAC |
Definition at line 264 of file address_book_crypto.c.
| bool address_book_compute_hmac_proof_ledger_account | ( | const char * | name, |
| const path_bip32_t * | bip32_path, | ||
| blockchain_family_e | family, | ||
| uint64_t | chain_id, | ||
| uint8_t | hmac_out[CX_SHA256_SIZE] ) |
Compute an HMAC-SHA256 Proof of Registration for a Ledger Account.
Serializes: name_len(1) | name | depth(1) | indices | family(1) [| chain_id(8)] Then delegates to the OS syscall.
| [in] | name | Account name (null-terminated) |
| [in] | bip32_path | Derivation path of the account |
| [in] | family | Blockchain family |
| [in] | chain_id | Chain ID (ignored for non-Ethereum families) |
| [out] | hmac_out | Output buffer for the 32-byte HMAC proof |
Definition at line 452 of file address_book_crypto.c.
| bool address_book_compute_hmac_rest | ( | const uint8_t | gid[GID_SIZE], |
| const char * | scope, | ||
| const uint8_t * | identifier, | ||
| uint8_t | identifier_len, | ||
| blockchain_family_e | family, | ||
| uint64_t | chain_id, | ||
| uint8_t | hmac_out[CX_SHA256_SIZE] ) |
Compute HMAC_REST for an Identity contact.
Serializes: gid(32) | scope_len(1) | scope | id_len(1) | identifier | family(1) [| chain_id(8) for FAMILY_ETHEREUM] Then delegates to the OS syscall.
| [in] | gid | 32-byte contact ID |
| [in] | scope | Contact scope (null-terminated, may be empty) |
| [in] | identifier | Raw identifier bytes |
| [in] | identifier_len | Length of identifier |
| [in] | family | Blockchain family |
| [in] | chain_id | Chain ID (ignored for non-Ethereum) |
| [out] | hmac_out | Output buffer for the 32-byte HMAC |
Definition at line 331 of file address_book_crypto.c.
| bool address_book_generate_group_handle | ( | uint8_t | group_handle[GROUP_HANDLE_SIZE] | ) |
Generate a device-authenticated group handle.
Generates a random 32-byte gid, then authenticates it via OS syscall: group_handle = gid(32) || HMAC-SHA256(K_group, gid)(32)
| [out] | group_handle | Output buffer (64 bytes): gid || MAC |
Definition at line 209 of file address_book_crypto.c.
| bool address_book_send_hmac_proof | ( | uint8_t | type, |
| const uint8_t | hmac_proof[CX_SHA256_SIZE] ) |
Send an HMAC proof response for Edit operations.
type(1) | hmac(32) — for Edit operations.
Response format: type(1) | hmac(32)
| [in] | type | Message type (TYPE_EDIT_CONTACT_NAME, TYPE_EDIT_IDENTIFIER, ...) |
| [in] | hmac_proof | 32-byte HMAC proof |
Definition at line 158 of file address_book_crypto.c.
| bool address_book_send_register_identity_response | ( | const uint8_t | group_handle[GROUP_HANDLE_SIZE], |
| const uint8_t | hmac_proof[CX_SHA256_SIZE], | ||
| const uint8_t | hmac_rest[CX_SHA256_SIZE] ) |
Send the Register Identity response carrying the group handle and both HMACs.
type(1) | group_handle(64) | hmac_proof(32) | hmac_rest(32) = 129 B — for Register Identity.
Response format: TYPE_REGISTER_IDENTITY(1) | group_handle(64) | hmac_proof(32) | hmac_rest(32) = 129 B
| [in] | group_handle | Device-authenticated group handle (gid || MAC) |
| [in] | hmac_proof | HMAC over (gid, name) |
| [in] | hmac_rest | HMAC over (gid, scope, identifier, family [, chain_id]) |
Definition at line 182 of file address_book_crypto.c.
| bool address_book_verify_group_handle | ( | const uint8_t | group_handle[GROUP_HANDLE_SIZE], |
| uint8_t | gid_out[GID_SIZE] ) |
Verify a group handle and extract the gid.
Verifies MAC(K_group, gid) via OS syscall. On success, copies gid into gid_out.
| [in] | group_handle | 64-byte handle to verify: gid(32) || MAC(32) |
| [out] | gid_out | Extracted gid (32 bytes), only valid on success |
Definition at line 235 of file address_book_crypto.c.
| bool address_book_verify_hmac_proof | ( | const uint8_t | gid[GID_SIZE], |
| const char * | name, | ||
| const uint8_t | hmac_expected[CX_SHA256_SIZE] ) |
Verify HMAC_PROOF for an Identity contact.
| [in] | gid | 32-byte contact ID |
| [in] | name | Contact name (null-terminated) |
| [in] | hmac_expected | 32-byte HMAC to verify against |
Definition at line 293 of file address_book_crypto.c.
| bool address_book_verify_hmac_proof_ledger_account | ( | const char * | name, |
| const path_bip32_t * | bip32_path, | ||
| blockchain_family_e | family, | ||
| uint64_t | chain_id, | ||
| const uint8_t | hmac_expected[CX_SHA256_SIZE] ) |
Verify an HMAC Proof of Registration for a Ledger Account.
| [in] | name | Account name (null-terminated) |
| [in] | bip32_path | Derivation path of the account |
| [in] | family | Blockchain family |
| [in] | chain_id | Chain ID (0 for non-Ethereum) |
| [in] | hmac_expected | 32-byte HMAC proof to verify against |
Definition at line 486 of file address_book_crypto.c.
| bool address_book_verify_hmac_rest | ( | const uint8_t | gid[GID_SIZE], |
| const char * | scope, | ||
| const uint8_t * | identifier, | ||
| uint8_t | identifier_len, | ||
| blockchain_family_e | family, | ||
| uint64_t | chain_id, | ||
| const uint8_t | hmac_expected[CX_SHA256_SIZE] ) |
Verify HMAC_REST for an Identity contact.
| [in] | gid | 32-byte contact ID |
| [in] | scope | Contact scope (null-terminated) |
| [in] | identifier | Raw identifier bytes |
| [in] | identifier_len | Length of identifier |
| [in] | family | Blockchain family |
| [in] | chain_id | Chain ID (0 for non-Ethereum) |
| [in] | hmac_expected | 32-byte HMAC to verify against |
Definition at line 369 of file address_book_crypto.c.