39#include "status_words.h"
51#if defined(HAVE_ADDRESS_BOOK)
54#define STRUCT_VERSION 0x01
66#define EDIT_CONTACT_NAME_TAGS(X) \
67 X(0x01, TAG_STRUCTURE_TYPE, handle_struct_type, ENFORCE_UNIQUE_TAG) \
68 X(0x02, TAG_STRUCTURE_VERSION, handle_struct_version, ENFORCE_UNIQUE_TAG) \
69 X(0xf0, TAG_CONTACT_NAME, handle_contact_name, ENFORCE_UNIQUE_TAG) \
70 X(0xf3, TAG_PREVIOUS_NAME, handle_previous_name, ENFORCE_UNIQUE_TAG) \
71 X(0xf6, TAG_GROUP_HANDLE, handle_group_handle, ENFORCE_UNIQUE_TAG) \
72 X(0x29, TAG_HMAC_PROOF, handle_hmac_proof, ENFORCE_UNIQUE_TAG)
91 PRINTF(
"[Edit Contact Name] Invalid STRUCTURE_TYPE value\n");
110 PRINTF(
"[Edit Contact Name] Invalid STRUCTURE_VERSION value\n");
129 PRINTF(
"[Edit Contact Name] CONTACT_NAME: failed to parse\n");
148 PRINTF(
"[Edit Contact Name] PREVIOUS_CONTACT_NAME: failed to parse\n");
167 PRINTF(
"[Edit Contact Name] GROUP_HANDLE: invalid length (expected %d bytes)\n",
188 PRINTF(
"[Edit Contact Name] HMAC_PROOF: invalid length (expected %d bytes)\n",
208 TAG_STRUCTURE_VERSION,
214 PRINTF(
"[Edit Contact Name] Missing mandatory fields!\n");
228 PRINTF(
"****************************************************************************\n");
229 PRINTF(
"[Edit Contact Name] - Retrieved Descriptor:\n");
231 PRINTF(
"[Edit Contact Name] - New name: %s\n", context->
edit->
contact_name);
244 uint8_t hmac_proof[CX_SHA256_SIZE] = {0};
249 PRINTF(
"[Edit Contact Name] Error: Failed to compute new HMAC_PROOF\n");
250 explicit_bzero(hmac_proof,
sizeof(hmac_proof));
255 explicit_bzero(hmac_proof,
sizeof(hmac_proof));
272 PRINTF(
"[Edit Contact Name] Error: Failed to build and send HMAC proof\n");
290 g_ab_ui.pairs[nbPairs].item =
"Old name";
293 g_ab_ui.pairs[nbPairs].item =
"New name";
297 g_ab_ui.list.nbPairs = nbPairs;
299 "Review change to contact details",
300#ifdef SCREEN_SIZE_WALLET
319 const buffer_t payload = {.ptr = buffer_in, .size = buffer_in_length};
327 if (!edit_contact_name_tlv_parser(&payload, &ctx, &ctx.
received_tags)) {
328 PRINTF(
"[Edit Contact Name] TLV parsing failed\n");
329 return SWO_INCORRECT_DATA;
332 return SWO_INCORRECT_DATA;
338 PRINTF(
"[Edit Contact Name] Group handle verification failed\n");
339 return SWO_SECURITY_CONDITION_NOT_SATISFIED;
346 PRINTF(
"[Edit Contact Name] HMAC_PROOF verification failed\n");
347 return SWO_SECURITY_CONDITION_NOT_SATISFIED;
352 return SWO_NO_RESPONSE;
void address_book_finalize_review(bool success, const char *successMsg, const char *errorMsg, nbgl_callback_t finalize)
Common handling of a confirmed Address Book review's outcome.
void address_book_handle_review_rejected(nbgl_callback_t finalize)
Common handling of a rejected Address Book review.
ab_payload_u g_ab_payload
bool address_book_handle_printable_string(const tlv_data_t *data, char *output_buffer, size_t buffer_size)
Generic handler for printable string extraction.
void address_book_display_review(const nbgl_icon_details_t *icon, const char *reviewTitle, const char *confirmText, nbgl_choiceCallback_t choiceCallback)
Display a confirmation review for an Address Book operation.
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_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_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.
void finalize_ui_edit_contact_name(void)
Handle called to finalize the UI flow for editing a contact name.
void on_edit_contact_name_applied(const edit_contact_name_t *edit)
Notification that a contact name edit was successfully applied.
Register / Edit Contact Name / Edit Scope / Edit Identifier.
#define GROUP_HANDLE_SIZE
group_handle = gid(32) | MAC(K_group, gid)(32)
#define TYPE_EDIT_CONTACT_NAME
#define LARGE_ADDRESS_BOOK_ICON
API of the Advanced BOLOS Graphical Library, for typical application use-cases.
bool tlv_enforce_u8_value(const tlv_data_t *data, uint8_t expected_value)
Enforce that a TLV data contains the expected uint8 value.
bool get_buffer_from_tlv_data(const tlv_data_t *data, buffer_t *out, uint16_t min_size, uint16_t max_size)
Extract a sized buffer from TLV data (zero-copy).
TLV_reception_internal_t TLV_reception_t
#define DEFINE_TLV_PARSER(TAG_LIST, COMMON_HANDLER, PARSE_FUNCTION_NAME)
Creates a parser function for a given TLV use case.
struct tlv_data_s tlv_data_t
#define TLV_CHECK_RECEIVED_TAGS(received,...)