diff options
Diffstat (limited to 'lib/trusty/ql-tipc/keymaster.c')
-rw-r--r-- | lib/trusty/ql-tipc/keymaster.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/trusty/ql-tipc/keymaster.c b/lib/trusty/ql-tipc/keymaster.c index b4fa8cac7f..90a34e5d2c 100644 --- a/lib/trusty/ql-tipc/keymaster.c +++ b/lib/trusty/ql-tipc/keymaster.c @@ -398,6 +398,10 @@ end: int trusty_set_attestation_key(const uint8_t *key, uint32_t key_size, keymaster_algorithm_t algorithm) { + if (!initialized) { + trusty_error("Keymaster TIPC client not initialized!\n"); + return -1; + } return trusty_send_attestation_data(KM_SET_ATTESTATION_KEY, key, key_size, algorithm); } @@ -406,6 +410,10 @@ int trusty_append_attestation_cert_chain(const uint8_t *cert, uint32_t cert_size, keymaster_algorithm_t algorithm) { + if (!initialized) { + trusty_error("Keymaster TIPC client not initialized!\n"); + return -1; + } return trusty_send_attestation_data(KM_APPEND_ATTESTATION_CERT_CHAIN, cert, cert_size, algorithm); } @@ -413,6 +421,10 @@ int trusty_append_attestation_cert_chain(const uint8_t *cert, int trusty_set_attestation_key_enc(const uint8_t *key, uint32_t key_size, keymaster_algorithm_t algorithm) { + if (!initialized) { + trusty_error("Keymaster TIPC client not initialized!\n"); + return -1; + } return trusty_send_attestation_data(KM_SET_ATTESTATION_KEY_ENC, key, key_size, algorithm); } @@ -421,6 +433,10 @@ int trusty_append_attestation_cert_chain_enc(const uint8_t *cert, uint32_t cert_size, keymaster_algorithm_t algorithm) { + if (!initialized) { + trusty_error("Keymaster TIPC client not initialized!\n"); + return -1; + } return trusty_send_attestation_data(KM_APPEND_ATTESTATION_CERT_CHAIN_ENC, cert, cert_size, algorithm); } @@ -501,6 +517,11 @@ int trusty_get_mppubk(uint8_t *mppubk, uint32_t *size) int rc = TRUSTY_ERR_GENERIC; struct km_get_mppubk_resp resp; + if (!initialized) { + trusty_error("Keymaster TIPC client not initialized!\n"); + return -1; + } + rc = km_send_request(KM_GET_MPPUBK, NULL, 0); if (rc < 0) { trusty_error("%s: failed (%d) to send km mppubk request\n", __func__, rc); @@ -532,6 +553,11 @@ int trusty_verify_secure_unlock(uint8_t *unlock_credential, uint8_t *req = NULL; uint32_t req_size = 0; + if (!initialized) { + trusty_error("Keymaster TIPC client not initialized!\n"); + return -1; + } + struct km_secure_unlock_data secure_unlock_data = { .serial_size = serial_size, .serial_data = serial, @@ -554,3 +580,26 @@ end: } return rc; } + +int trusty_append_attestation_id(const char *data, uint32_t data_size) +{ + struct km_attestation_id_data attestation_id_data = { + .data_size = data_size, + .data = (uint8_t *)data, + }; + uint8_t *req = NULL; + uint32_t req_size = 0; + int rc = km_attestation_id_data_serialize(&attestation_id_data, &req, &req_size); + + if (rc < 0) { + trusty_error("failed (%d) to serialize request\n", rc); + goto end; + } + rc = km_do_tipc(KM_APPEND_ATTESTATION_ID, req, req_size, NULL, NULL); + +end: + if (req) { + trusty_free(req); + } + return rc; +} |