blob: 5a37706c8c7d2f9a1facd11af81a2ab5b031a25d [file] [log] [blame]
Jamie Foxe7f8b4e2023-05-30 18:03:20 +01001/*
2 * Copyright (c) 2023, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#include "dpe_log.h"
Maulik Patelad2f3db2023-05-17 15:41:36 +01009#include "dpe_context_mngr.h"
Jamie Foxe7f8b4e2023-05-30 18:03:20 +010010
11#if (TFM_PARTITION_LOG_LEVEL >= TFM_PARTITION_LOG_LEVEL_DEBUG)
12
13static void print_byte_array(const uint8_t *array, size_t len)
14{
15 size_t i;
16
17 if (array != NULL) {
18 for (i = 0; i < len; ++i) {
19 if ((i & 0xF) == 0) {
20 LOG_DBGFMT("\r\n ");
21 }
22 if (array[i] < 0x10) {
23 LOG_DBGFMT(" 0%x", array[i]);
24 } else {
25 LOG_DBGFMT(" %x", array[i]);
26 }
27 }
28 }
29
30 LOG_DBGFMT("\r\n");
31}
32
33static void log_dice_inputs(const DiceInputValues *input)
34{
35 LOG_DBGFMT(" - DICE code_hash =");
36 print_byte_array(input->code_hash, sizeof(input->code_hash));
37 LOG_DBGFMT(" - DICE code_descriptor =");
38 print_byte_array(input->code_descriptor, input->code_descriptor_size);
39 LOG_DBGFMT(" - DICE config_type = %d\r\n", input->config_type);
40 LOG_DBGFMT(" - DICE config_value =");
41 print_byte_array(input->config_value, sizeof(input->config_value));
42 LOG_DBGFMT(" - DICE config_descriptor =");
43 print_byte_array(input->config_descriptor, input->config_descriptor_size);
44 LOG_DBGFMT(" - DICE authority_hash =");
45 print_byte_array(input->authority_hash, sizeof(input->authority_hash));
46 LOG_DBGFMT(" - DICE authority_descriptor =");
47 print_byte_array(input->authority_descriptor,
48 input->authority_descriptor_size);
49 LOG_DBGFMT(" - DICE mode = %d\r\n", input->mode);
50 LOG_DBGFMT(" - DICE hidden =");
51 print_byte_array(input->hidden, sizeof(input->hidden));
52}
53
Maulik Patelad2f3db2023-05-17 15:41:36 +010054void log_derive_rot_context(const DiceInputValues *dice_inputs)
55{
56 LOG_DBGFMT("DPE DeriveRoTContext:\r\n");
57 log_dice_inputs(dice_inputs);
58}
59
Jamie Foxe7f8b4e2023-05-30 18:03:20 +010060void log_derive_child(int context_handle,
61 bool retain_parent_context,
62 bool allow_child_to_derive,
63 bool create_certificate,
Maulik Patelad2f3db2023-05-17 15:41:36 +010064 const DiceInputValues *dice_inputs,
65 int32_t client_id)
Jamie Foxe7f8b4e2023-05-30 18:03:20 +010066{
67 LOG_DBGFMT("DPE DeriveChild:\r\n");
Maulik Patelad2f3db2023-05-17 15:41:36 +010068 LOG_DBGFMT(" - context_handle index = %d\r\n", GET_IDX(context_handle));
69 LOG_DBGFMT(" - context_handle nonce = %d\r\n", GET_NONCE(context_handle));
Jamie Foxe7f8b4e2023-05-30 18:03:20 +010070 LOG_DBGFMT(" - retain_parent_context = %d\r\n", retain_parent_context);
71 LOG_DBGFMT(" - allow_child_to_derive = %d\r\n", allow_child_to_derive);
72 LOG_DBGFMT(" - create_certificate = %d\r\n", create_certificate);
73 log_dice_inputs(dice_inputs);
Maulik Patelad2f3db2023-05-17 15:41:36 +010074 LOG_DBGFMT(" - client_id = %d\r\n", client_id);
Jamie Foxe7f8b4e2023-05-30 18:03:20 +010075}
76
77void log_certify_key(int context_handle,
78 bool retain_context,
79 const uint8_t *public_key,
80 size_t public_key_size,
81 const uint8_t *label,
82 size_t label_size)
83{
84 LOG_DBGFMT("DPE CertifyKey:\r\n");
Maulik Patelad2f3db2023-05-17 15:41:36 +010085 LOG_DBGFMT(" - context_handle index = %d\r\n", GET_IDX(context_handle));
86 LOG_DBGFMT(" - context_handle nonce = %d\r\n", GET_NONCE(context_handle));
Jamie Foxe7f8b4e2023-05-30 18:03:20 +010087 LOG_DBGFMT(" - retain_context = %d\r\n", retain_context);
88 LOG_DBGFMT(" - public_key =");
89 print_byte_array(public_key, public_key_size);
90 LOG_DBGFMT(" - label =");
91 print_byte_array(label, label_size);
92}
93
94#endif /* TFM_PARTITION_LOG_LEVEL */