Raef Coles | 734aaac | 2022-06-15 14:37:22 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef __RSS_COMMS_PROTOCOL_EMBED_H__ |
| 9 | #define __RSS_COMMS_PROTOCOL_EMBED_H__ |
| 10 | |
| 11 | #include <cdefs.h> |
| 12 | |
| 13 | #include <initial_attestation.h> |
| 14 | #include <psa/client.h> |
| 15 | |
| 16 | #include <platform_def.h> |
| 17 | |
| 18 | /* |
| 19 | * In the current implementation the RoT Service request that requires the |
| 20 | * biggest message buffer is the RSS_ATTEST_GET_TOKEN. The maximum required |
| 21 | * buffer size is calculated based on the platform-specific needs of |
| 22 | * this request. |
| 23 | */ |
| 24 | #ifndef RSS_COMMS_PAYLOAD_MAX_SIZE |
| 25 | #define RSS_COMMS_PAYLOAD_MAX_SIZE (PSA_INITIAL_ATTEST_CHALLENGE_SIZE_64 \ |
| 26 | + PLAT_ATTEST_TOKEN_MAX_SIZE) |
| 27 | #endif |
| 28 | |
| 29 | struct __packed rss_embed_msg_t { |
| 30 | psa_handle_t handle; |
| 31 | uint32_t ctrl_param; /* type, in_len, out_len */ |
| 32 | uint16_t io_size[PSA_MAX_IOVEC]; |
| 33 | uint8_t trailer[RSS_COMMS_PAYLOAD_MAX_SIZE]; |
| 34 | }; |
| 35 | |
| 36 | struct __packed rss_embed_reply_t { |
| 37 | int32_t return_val; |
| 38 | uint16_t out_size[PSA_MAX_IOVEC]; |
| 39 | uint8_t trailer[RSS_COMMS_PAYLOAD_MAX_SIZE]; |
| 40 | }; |
| 41 | |
| 42 | psa_status_t rss_protocol_embed_serialize_msg(psa_handle_t handle, |
| 43 | int16_t type, |
| 44 | const psa_invec *in_vec, |
| 45 | uint8_t in_len, |
| 46 | const psa_outvec *out_vec, |
| 47 | uint8_t out_len, |
| 48 | struct rss_embed_msg_t *msg, |
| 49 | size_t *msg_len); |
| 50 | |
| 51 | psa_status_t rss_protocol_embed_deserialize_reply(psa_outvec *out_vec, |
| 52 | uint8_t out_len, |
| 53 | psa_status_t *return_val, |
| 54 | const struct rss_embed_reply_t *reply, |
| 55 | size_t reply_size); |
| 56 | |
| 57 | #endif /* __RSS_COMMS_PROTOCOL_EMBED_H__ */ |