blob: 805a94163c711d4e4539a4fe4260ec6cc86aa8dd [file] [log] [blame]
Tamas Ban3ae52c62022-08-31 14:50:27 +02001/*
Manish V Badarkhe37f9ac22023-03-12 21:34:44 +00002 * Copyright (c) 2022-2023, Arm Limited. All rights reserved.
Tamas Ban3ae52c62022-08-31 14:50:27 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Tamas Ban3ae52c62022-08-31 14:50:27 +02008#include <delegated_attestation.h>
9#include <psa/client.h>
10#include <psa_manifest/sid.h>
11
Tamas Ban3ae52c62022-08-31 14:50:27 +020012psa_status_t
Tamas Bandc2a2862024-02-22 11:41:25 +010013rse_delegated_attest_get_delegated_key(uint8_t ecc_curve,
Tamas Ban3ae52c62022-08-31 14:50:27 +020014 uint32_t key_bits,
15 uint8_t *key_buf,
16 size_t key_buf_size,
17 size_t *key_size,
18 uint32_t hash_algo)
19{
20 psa_status_t status;
21 psa_invec in_vec[] = {
22 {&ecc_curve, sizeof(ecc_curve)},
23 {&key_bits, sizeof(key_bits)},
24 {&hash_algo, sizeof(hash_algo)}
25 };
26 psa_outvec out_vec[] = {
27 {key_buf, key_buf_size}
28 };
29
30 if (key_size == NULL) {
31 return PSA_ERROR_INVALID_ARGUMENT;
32 }
33
Tamas Bandc2a2862024-02-22 11:41:25 +010034 status = psa_call(RSE_DELEGATED_SERVICE_HANDLE,
35 RSE_DELEGATED_ATTEST_GET_DELEGATED_KEY,
Tamas Ban3ae52c62022-08-31 14:50:27 +020036 in_vec, IOVEC_LEN(in_vec),
37 out_vec, IOVEC_LEN(out_vec));
38 if (status == PSA_SUCCESS) {
39 *key_size = out_vec[0].len;
40 }
41
42 return status;
43}
44
45psa_status_t
Tamas Bandc2a2862024-02-22 11:41:25 +010046rse_delegated_attest_get_token(const uint8_t *dak_pub_hash,
Tamas Ban3ae52c62022-08-31 14:50:27 +020047 size_t dak_pub_hash_size,
48 uint8_t *token_buf,
49 size_t token_buf_size,
50 size_t *token_size)
51{
52 psa_status_t status;
53 psa_invec in_vec[] = {
54 {dak_pub_hash, dak_pub_hash_size}
55 };
56 psa_outvec out_vec[] = {
57 {token_buf, token_buf_size}
58 };
59
60 if (token_size == NULL) {
61 return PSA_ERROR_INVALID_ARGUMENT;
62 }
63
Tamas Bandc2a2862024-02-22 11:41:25 +010064 status = psa_call(RSE_DELEGATED_SERVICE_HANDLE,
65 RSE_DELEGATED_ATTEST_GET_PLATFORM_TOKEN,
Tamas Ban3ae52c62022-08-31 14:50:27 +020066 in_vec, IOVEC_LEN(in_vec),
67 out_vec, IOVEC_LEN(out_vec));
68 if (status == PSA_SUCCESS) {
69 *token_size = out_vec[0].len;
70 }
71
72 return status;
73}