Skip to content

Commit d95e67d

Browse files
authored
Merge branch 'feat/inheritance/base' into feat/inheritance/seed-based-wallet-auth
2 parents 38aad23 + 06e1459 commit d95e67d

File tree

13 files changed

+1073
-21
lines changed

13 files changed

+1073
-21
lines changed

apps/inheritance_app/inheritance_auth_wallet.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ static bool send_result() {
281281
*****************************************************************************/
282282

283283
void inheritance_auth_wallet(inheritance_query_t *query) {
284-
auth = (auth_wallet_config_t *)cy_malloc(sizeof(auth_wallet_config_t));
284+
auth = (auth_wallet_config_t *)malloc(sizeof(auth_wallet_config_t));
285+
ASSERT(auth != NULL);
285286
memzero(auth, sizeof(auth_wallet_config_t));
286287

287288
memcpy(auth->data.wallet_id,
@@ -300,4 +301,8 @@ void inheritance_auth_wallet(inheritance_query_t *query) {
300301
auth_wallet_get_pairs() && auth_wallet_get_signature() && send_result()) {
301302
delay_scr_init(ui_text_inheritance_wallet_auth_success, DELAY_TIME);
302303
}
304+
305+
memzero(auth, sizeof(auth_wallet_config_t));
306+
free(auth);
307+
auth = NULL;
303308
}

apps/inheritance_app/inheritance_main.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
*****************************************************************************/
2020

2121
#include "app_registry.h"
22-
#include "events.h"
23-
#include "inheritance/core.pb.h"
24-
#include "inheritance_context.h"
2522
/*****************************************************************************
2623
* MACROS AND DEFINES
2724
*****************************************************************************/

apps/inheritance_app/inheritance_priv.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
/*****************************************************************************
1414
* INCLUDES
1515
*****************************************************************************/
16-
#include <inheritance/core.pb.h>
1716
#include <stdint.h>
1817

19-
#include "inheritance_context.h"
20-
#include "nem.h"
18+
#include "ed25519.h"
19+
#include "inheritance/core.pb.h"
20+
#include "wallet.h"
2121

2222
/*****************************************************************************
2323
* PRIVATE MACROS AND DEFINES

apps/manager_app/device_authentication_api.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@
7070
#include "atca_basic.h"
7171
#include "device_authentication_api.h"
7272

73-
#define SIGNATURE_SIZE 64
74-
#define POSTFIX1_SIZE 7
75-
#define POSTFIX2_SIZE 23
7673
#define RANDOM_CHALLENGE_SIZE 32
7774

7875
atecc_data_t atecc_data = {0};

apps/manager_app/device_authentication_api.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
* MACROS AND DEFINES
2727
*****************************************************************************/
2828
#define DEFAULT_ATECC_RETRIES 5
29+
#define SIGNATURE_SIZE 64
30+
#define POSTFIX1_SIZE 7
31+
#define POSTFIX2_SIZE 23
2932
#define DEVICE_SERIAL_SIZE 32
3033

3134
/*****************************************************************************

common/core/core_api.c

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#include <core.pb.h>
6666

6767
#include "assert_conf.h"
68+
#include "core_session.h"
6869
#include "pb_encode.h"
6970
#include "status_api.h"
7071
#include "usb_api.h"
@@ -130,7 +131,6 @@ void send_response_to_host(const uint8_t *msg, const uint32_t size) {
130131
core_msg.cmd.applet_id = get_applet_id();
131132

132133
send_core_msg(&core_msg, msg, size);
133-
return;
134134
}
135135

136136
void send_core_error_msg_to_host(uint32_t core_error_type) {
@@ -139,7 +139,6 @@ void send_core_error_msg_to_host(uint32_t core_error_type) {
139139
core_msg.error.type = (core_error_type_t)core_error_type;
140140

141141
send_core_msg(&core_msg, NULL, 0);
142-
return;
143142
}
144143

145144
void send_app_version_list_to_host(
@@ -154,5 +153,54 @@ void send_app_version_list_to_host(
154153
sizeof(core_app_version_result_response_t));
155154

156155
send_core_msg(&core_msg, NULL, 0);
157-
return;
158-
}
156+
}
157+
158+
void send_core_session_start_response_to_host(const uint8_t *payload) {
159+
core_msg_t core_msg = CORE_MSG_INIT_ZERO;
160+
core_msg.which_type = CORE_MSG_SESSION_START_TAG;
161+
core_msg.session_start.which_cmd = CORE_SESSION_START_CMD_RESPONSE_TAG;
162+
core_msg.session_start.response.which_response =
163+
CORE_SESSION_START_RESPONSE_CONFIRMATION_INITIATE_TAG;
164+
uint32_t offset = 0;
165+
memcpy(core_msg.session_start.response.confirmation_initiate
166+
.device_random_public,
167+
payload + offset,
168+
SESSION_PUB_KEY_SIZE);
169+
offset += SESSION_PUB_KEY_SIZE;
170+
memcpy(core_msg.session_start.response.confirmation_initiate.device_id,
171+
payload + offset,
172+
DEVICE_SERIAL_SIZE);
173+
offset += DEVICE_SERIAL_SIZE;
174+
memcpy(core_msg.session_start.response.confirmation_initiate.signature,
175+
payload + offset,
176+
SIGNATURE_SIZE);
177+
offset += SIGNATURE_SIZE;
178+
memcpy(core_msg.session_start.response.confirmation_initiate.postfix1,
179+
payload + offset,
180+
POSTFIX1_SIZE);
181+
offset += POSTFIX1_SIZE;
182+
memcpy(core_msg.session_start.response.confirmation_initiate.postfix2,
183+
payload + offset,
184+
POSTFIX2_SIZE);
185+
186+
send_core_msg(&core_msg, NULL, 0);
187+
}
188+
189+
void send_core_session_start_ack_to_host() {
190+
core_msg_t core_msg = CORE_MSG_INIT_ZERO;
191+
core_msg.which_type = CORE_MSG_SESSION_START_TAG;
192+
core_msg.session_start.which_cmd = CORE_SESSION_START_CMD_RESPONSE_TAG;
193+
core_msg.session_start.response.which_response =
194+
CORE_SESSION_START_RESPONSE_CONFIRMATION_START_TAG;
195+
send_core_msg(&core_msg, NULL, 0);
196+
}
197+
198+
void send_core_session_close_response_to_host() {
199+
core_msg_t core_msg = CORE_MSG_INIT_ZERO;
200+
core_msg.which_type = CORE_MSG_SESSION_CLOSE_TAG;
201+
core_msg.session_close.which_cmd = CORE_SESSION_CLOSE_CMD_RESPONSE_TAG;
202+
core_msg.session_close.response.which_response =
203+
CORE_SESSION_CLOSE_RESPONSE_CLEAR_TAG;
204+
205+
send_core_msg(&core_msg, NULL, 0);
206+
}

common/core/core_api.h

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void send_response_to_host(const uint8_t *msg, const uint32_t size);
4949
*
5050
* @param which_error The enum type of the error which needs to be sent
5151
*/
52-
void send_core_error_msg_to_host(uint32_t which_error);
52+
void send_core_error_msg_to_host(uint32_t core_error_type);
5353

5454
/**
5555
* @brief Helper API for core to send a response containing a list of
@@ -60,4 +60,35 @@ void send_core_error_msg_to_host(uint32_t which_error);
6060
*/
6161
void send_app_version_list_to_host(
6262
const core_app_version_result_response_t *version_resp);
63-
#endif /* CORE_API_H */
63+
64+
/**
65+
* @brief Sends a response to the host after receiving a session start payload.
66+
*
67+
* This function constructs a core message containing the confirmation
68+
* initiation response for a session start. It extracts relevant information
69+
* from the payload, such as device random public key, device ID, signature, and
70+
* postfix values.
71+
*
72+
* @param payload Pointer to the received payload data.
73+
*/
74+
void send_core_session_start_response_to_host(const uint8_t *payload);
75+
76+
/**
77+
* @brief Sends an acknowledgment to the host after successfully starting a
78+
* session.
79+
*
80+
* This function constructs a core message with the confirmation start response
81+
* for a session start. It indicates that the session has been initiated
82+
* successfully.
83+
*/
84+
void send_core_session_start_ack_to_host();
85+
86+
/**
87+
* @brief Sends a response to the host when closing a session.
88+
*
89+
* This function constructs a core message to acknowledge the session close
90+
* request. It specifies that the session should be cleared.
91+
*/
92+
void send_core_session_close_response_to_host();
93+
94+
#endif /* CORE_API_H */

0 commit comments

Comments
 (0)