summaryrefslogtreecommitdiff
path: root/lib/trusty/ql-tipc/keymaster.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/trusty/ql-tipc/keymaster.c')
-rw-r--r--lib/trusty/ql-tipc/keymaster.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/trusty/ql-tipc/keymaster.c b/lib/trusty/ql-tipc/keymaster.c
index d3957b853b..282cb53cdb 100644
--- a/lib/trusty/ql-tipc/keymaster.c
+++ b/lib/trusty/ql-tipc/keymaster.c
@@ -247,7 +247,7 @@ static int km_get_version(int32_t *version)
rc = km_send_request(KM_GET_VERSION, NULL, 0);
if (rc < 0) {
- trusty_error("failed to send km version request", rc);
+ trusty_error("failed (%d) to send km version request", rc);
return rc;
}
@@ -524,7 +524,7 @@ int trusty_get_mppubk(uint8_t *mppubk, uint32_t *size)
rc = km_send_request(KM_GET_MPPUBK, NULL, 0);
if (rc < 0) {
- trusty_error("failed to send km mppubk request\n", rc);
+ trusty_error("%s: failed (%d) to send km mppubk request\n", __func__, rc);
return rc;
}
@@ -586,6 +586,7 @@ int trusty_set_attestation_id(void)
{
uint8_t *req = NULL, *tmp = NULL;
uint32_t req_size = 0;
+ char *serial = NULL;
int rc;
req = trusty_calloc(1024, 1); // 1024 bytes buffer should be enough.
@@ -620,10 +621,14 @@ int trusty_set_attestation_id(void)
}
/* serial number, bail out when fail because it's a MUST. */
- char *serial = get_serial();
- if (serial)
- km_attestation_id_data_serialize((uint8_t *)serial, 16, &tmp, &req_size);
- else {
+ serial = get_serial();
+ if (serial != NULL) {
+ rc = km_attestation_id_data_serialize((uint8_t *)serial, 16, &tmp, &req_size);
+ if (rc < 0) {
+ trusty_error("%s: failed (%d) to set id serial.\n", __func__, rc);
+ goto end;
+ }
+ } else {
trusty_error("%s: failed to get serial number.\n", __func__);
goto end;
}
@@ -685,6 +690,11 @@ int trusty_set_boot_patch_level(uint32_t boot_patch_level)
int rc;
req = trusty_calloc(4, 1); // 4 bytes should be enough.
+ if (!req) {
+ trusty_error("trusty_calloc memory failed!\n");
+ return -1;
+ }
+
memcpy(req, &boot_patch_level, sizeof(uint32_t));
req_size = sizeof(uint32_t);