blob: a2908918dfb2641add4069993f7b6f668c917e63 [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"
9
10#if (TFM_PARTITION_LOG_LEVEL >= TFM_PARTITION_LOG_LEVEL_DEBUG)
11
12static void print_byte_array(const uint8_t *array, size_t len)
13{
14 size_t i;
15
16 if (array != NULL) {
17 for (i = 0; i < len; ++i) {
18 if ((i & 0xF) == 0) {
19 LOG_DBGFMT("\r\n ");
20 }
21 if (array[i] < 0x10) {
22 LOG_DBGFMT(" 0%x", array[i]);
23 } else {
24 LOG_DBGFMT(" %x", array[i]);
25 }
26 }
27 }
28
29 LOG_DBGFMT("\r\n");
30}
31
32static void log_dice_inputs(const DiceInputValues *input)
33{
34 LOG_DBGFMT(" - DICE code_hash =");
35 print_byte_array(input->code_hash, sizeof(input->code_hash));
36 LOG_DBGFMT(" - DICE code_descriptor =");
37 print_byte_array(input->code_descriptor, input->code_descriptor_size);
38 LOG_DBGFMT(" - DICE config_type = %d\r\n", input->config_type);
39 LOG_DBGFMT(" - DICE config_value =");
40 print_byte_array(input->config_value, sizeof(input->config_value));
41 LOG_DBGFMT(" - DICE config_descriptor =");
42 print_byte_array(input->config_descriptor, input->config_descriptor_size);
43 LOG_DBGFMT(" - DICE authority_hash =");
44 print_byte_array(input->authority_hash, sizeof(input->authority_hash));
45 LOG_DBGFMT(" - DICE authority_descriptor =");
46 print_byte_array(input->authority_descriptor,
47 input->authority_descriptor_size);
48 LOG_DBGFMT(" - DICE mode = %d\r\n", input->mode);
49 LOG_DBGFMT(" - DICE hidden =");
50 print_byte_array(input->hidden, sizeof(input->hidden));
51}
52
53void log_derive_child(int context_handle,
54 bool retain_parent_context,
55 bool allow_child_to_derive,
56 bool create_certificate,
57 const DiceInputValues *dice_inputs)
58{
59 LOG_DBGFMT("DPE DeriveChild:\r\n");
60 LOG_DBGFMT(" - context_handle = %d\r\n", context_handle);
61 LOG_DBGFMT(" - retain_parent_context = %d\r\n", retain_parent_context);
62 LOG_DBGFMT(" - allow_child_to_derive = %d\r\n", allow_child_to_derive);
63 LOG_DBGFMT(" - create_certificate = %d\r\n", create_certificate);
64 log_dice_inputs(dice_inputs);
65}
66
67void log_certify_key(int context_handle,
68 bool retain_context,
69 const uint8_t *public_key,
70 size_t public_key_size,
71 const uint8_t *label,
72 size_t label_size)
73{
74 LOG_DBGFMT("DPE CertifyKey:\r\n");
75 LOG_DBGFMT(" - context_handle = %d\r\n", context_handle);
76 LOG_DBGFMT(" - retain_context = %d\r\n", retain_context);
77 LOG_DBGFMT(" - public_key =");
78 print_byte_array(public_key, public_key_size);
79 LOG_DBGFMT(" - label =");
80 print_byte_array(label, label_size);
81}
82
83#endif /* TFM_PARTITION_LOG_LEVEL */