Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
address_book_crypto.h
Go to the documentation of this file.
1/*****************************************************************************
2 * (c) 2026 Ledger SAS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16#pragma once
17
18#include <stdint.h>
19#include <stddef.h>
20#include <stdbool.h>
21#include "bip32.h"
22#include "lcx_sha256.h"
23#include "address_book.h"
24#include "identity.h"
25#include "os_address_book.h"
26
27#ifdef HAVE_ADDRESS_BOOK
28
30
31bool address_book_verify_group_handle(const uint8_t group_handle[GROUP_HANDLE_SIZE],
32 uint8_t gid_out[GID_SIZE]);
33
34bool address_book_compute_hmac_proof(const uint8_t gid[GID_SIZE],
35 const char *name,
36 uint8_t hmac_out[CX_SHA256_SIZE]);
37
38bool address_book_verify_hmac_proof(const uint8_t gid[GID_SIZE],
39 const char *name,
40 const uint8_t hmac_expected[CX_SHA256_SIZE]);
41
42bool address_book_compute_hmac_rest(const uint8_t gid[GID_SIZE],
43 const char *scope,
44 const uint8_t *identifier,
45 uint8_t identifier_len,
47 uint64_t chain_id,
48 uint8_t hmac_out[CX_SHA256_SIZE]);
49
50bool address_book_verify_hmac_rest(const uint8_t gid[GID_SIZE],
51 const char *scope,
52 const uint8_t *identifier,
53 uint8_t identifier_len,
55 uint64_t chain_id,
56 const uint8_t hmac_expected[CX_SHA256_SIZE]);
57
58#ifdef HAVE_ADDRESS_BOOK_LEDGER_ACCOUNT
59
61 const path_bip32_t *bip32_path,
63 uint64_t chain_id,
64 uint8_t hmac_out[CX_SHA256_SIZE]);
65
67 const path_bip32_t *bip32_path,
69 uint64_t chain_id,
70 const uint8_t hmac_expected[CX_SHA256_SIZE]);
71
72#endif // HAVE_ADDRESS_BOOK_LEDGER_ACCOUNT
73
75bool address_book_send_hmac_proof(uint8_t type, const uint8_t hmac_proof[CX_SHA256_SIZE]);
76
79 const uint8_t hmac_proof[CX_SHA256_SIZE],
80 const uint8_t hmac_rest[CX_SHA256_SIZE]);
81
82#endif // HAVE_ADDRESS_BOOK
blockchain_family_e
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_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_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_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_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_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_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.
Register / Edit Contact Name / Edit Scope / Edit Identifier.
#define GID_SIZE
32-byte random group ID generated by the device
Definition identity.h:47
#define GROUP_HANDLE_SIZE
group_handle = gid(32) | MAC(K_group, gid)(32)
Definition identity.h:48
SHA-2 (Secure Hash Algorithm 2).