Log optiga data to serial console

[skip_ci]
mmilata/optiga-serial
Martin Milata 8 months ago
parent 21959996bd
commit e9b40b6d98

@ -88,6 +88,15 @@
#include "zkp_context.h"
#endif
void optiga_log_printf(const char *prefix, const uint8_t *data, size_t data_size) {
printf("OPTIGA %s ", prefix);
for (size_t i = 0; i < data_size; i++) {
printf("%02X", data[i]);
}
printf("\n");
}
// from util.s
extern void shutdown_privileged(void);
@ -170,6 +179,7 @@ int main(void) {
#endif
#ifdef USE_OPTIGA
optiga_set_log_hex(optiga_log_printf);
optiga_init();
optiga_open_application();
if (sectrue == secret_ok) {

@ -134,16 +134,12 @@ static uint8_t sec_chan_buffer[OPTIGA_MAX_APDU_SIZE + SEC_CHAN_OVERHEAD_SIZE] =
{0};
static size_t sec_chan_size = 0;
#ifdef NDEBUG
#define OPTIGA_LOG(prefix, data, data_size)
#else
static optiga_log_hex_t log_hex = NULL;
void optiga_set_log_hex(optiga_log_hex_t f) { log_hex = f; }
#define OPTIGA_LOG(prefix, data, data_size) \
if (log_hex != NULL) { \
log_hex(prefix, data, data_size); \
}
#endif
static uint16_t calc_crc_byte(uint16_t seed, uint8_t c) {
uint16_t h1 = (seed ^ c) & 0xFF;

@ -44,10 +44,8 @@ optiga_result optiga_resync(void);
optiga_result optiga_soft_reset(void);
optiga_result optiga_set_data_reg_len(size_t size);
#ifndef NDEBUG
typedef void (*optiga_log_hex_t)(const char *prefix, const uint8_t *data,
size_t data_size);
void optiga_set_log_hex(optiga_log_hex_t f);
#endif
#endif

Loading…
Cancel
Save