65
65
#include <core.pb.h>
66
66
67
67
#include "assert_conf.h"
68
+ #include "core_session.h"
68
69
#include "pb_encode.h"
69
70
#include "status_api.h"
70
71
#include "usb_api.h"
@@ -130,7 +131,6 @@ void send_response_to_host(const uint8_t *msg, const uint32_t size) {
130
131
core_msg .cmd .applet_id = get_applet_id ();
131
132
132
133
send_core_msg (& core_msg , msg , size );
133
- return ;
134
134
}
135
135
136
136
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) {
139
139
core_msg .error .type = (core_error_type_t )core_error_type ;
140
140
141
141
send_core_msg (& core_msg , NULL , 0 );
142
- return ;
143
142
}
144
143
145
144
void send_app_version_list_to_host (
@@ -154,5 +153,54 @@ void send_app_version_list_to_host(
154
153
sizeof (core_app_version_result_response_t ));
155
154
156
155
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
+ }
0 commit comments