1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*
* Copyright 2020-2025 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
/** @section Description
* @file ta_sa_svp.h
*
* This file contains the TA implementation of "svp" module functions. Please refer to
* sa_svp.h file for method and parameter documentation.
*/
extern "C" ENABLE_SVP
/**
* Create an SVP buffer handle. Buffer passed in is validated to be wholly contained within the
* restricted SVP memory region. SecAPI does not provide functionality for allocating and
* deallocating the secure region buffers.
*
* @param[out] svp_buffer SVP buffer handle.
* @param[in] buffer Restricted SVP region buffer.
* @param[in] size Size of the restricted SVP region buffer in bytes.
* @param[in] client the client slot ID.
* @param[in] caller_uuid the UUID of the caller.
* @return Operation status. Possible values are:
* + SA_STATUS_OK - Operation succeeded.
* + SA_STATUS_NO_AVAILABLE_RESOURCE_SLOT - No available SVP slots.
* + SA_STATUS_NULL_PARAMETER - SVP_buffer or buffer is NULL.
* + SA_STATUS_INVALID_SVP_BUFFER - SVP buffer is not fully contained withing SVP memory region.
* + SA_STATUS_OPERATION_NOT_SUPPORTED - Implementation does not support the specified operation.
* + SA_STATUS_SELF_TEST - Implementation self-test has failed.
* + SA_STATUS_INTERNAL_ERROR - An unexpected error has occurred.
*/
sa_status ;
/**
* Release the SVP buffer handle. This call does not delete the SVP memory region buffer associated with it.
*
* @param[out] out a reference to the SVP memory region.
* @param[out] out_length the length of the SVP memory region.
* @param[in] svp_buffer SVP buffer handle.
* @param[in] client_slot the client slot ID.
* @param[in] caller_uuid the UUID of the caller.
* @return Operation status. Possible values are:
* + SA_STATUS_OK - Operation succeeded.
* + SA_STATUS_NULL_PARAMETER - svp_buffer is NULL.
* + SA_STATUS_OPERATION_NOT_SUPPORTED - Implementation does not support the specified operation.
* + SA_STATUS_SELF_TEST - Implementation self-test has failed.
* + SA_STATUS_INTERNAL_ERROR - An unexpected error has occurred.
*/
sa_status ;
/**
* Write a block of data into an SVP buffer.
*
* @param[in] out Destination SVP buffer.
* @param[in] in Source data to write.
* @param[in] in_length The length of the source data.
* @param[in] offsets a list of offsets into the source and destination of the block to copy and the length of the
* block.
* @param[in] offset_length Number of offset blocks to copy.
* @param[in] client_slot the client slot ID.
* @param[in] caller_uuid the UUID of the caller.
* @return Operation status. Possible values are:
* + SA_STATUS_OK - Operation succeeded.
* + SA_STATUS_NULL_PARAMETER - out, out_offset, or in is NULL.
* + SA_STATUS_INVALID_PARAMETER - Writing past the end of the SVP buffer detected.
* + SA_STATUS_INVALID_SVP_BUFFER - SVP buffer is not fully contained withing SVP memory region.
* + SA_STATUS_OPERATION_NOT_SUPPORTED - Implementation does not support the specified operation.
* + SA_STATUS_SELF_TEST - Implementation self-test has failed.
* + SA_STATUS_INTERNAL_ERROR - An unexpected error has occurred.
*/
sa_status ;
/**
* Copy a block of data from one secure buffer to another. Destination buffer is validated to be wholly contained within
* the restricted SVP memory region. Destination range is validated to be wholly contained within the destination SVP
* buffer. Input range is validated to be wholly contained within the input SVP buffer.
*
* @param[in] out Destination SVP buffer.
* @param[in] in Source data to write.
* @param[in] offsets a list of offsets into the source and destination of the block to copy and the length of the
* block.
* @param[in] offset_length Number of offset blocks to copy.
* @param[in] client_slot the client slot ID.
* @param[in] caller_uuid the UUID of the caller.
* @return Operation status. Possible values are:
* + SA_STATUS_OK - Operation succeeded.
* + SA_STATUS_NULL_PARAMETER - out, out_offset or in is NULL.
* + SA_STATUS_INVALID_PARAMETER - Reading or writing past the end of the SVP buffer detected.
* + SA_STATUS_INVALID_SVP_BUFFER - SVP buffer is not fully contained withing SVP memory region.
* + SA_STATUS_OPERATION_NOT_SUPPORTED - Implementation does not support the specified operation.
* + SA_STATUS_SELF_TEST - Implementation self-test has failed.
* + SA_STATUS_INTERNAL_ERROR - An unexpected error has occurred.
*/
sa_status ;
// ENABLE_SVP
/**
* Perform a key check by decrypting input data with an AES ECB into restricted memory and comparing with reference
* value. This operation allows validation of keys that cannot decrypt into non-SVP buffers.
*
* @param[in] key Cipher key.
* @param[in] in Input data.
* @param[in] in_buffer_type the type of the in buffer.
* @param[in] expected Expected result.
* @param[in] expected_length Expected result length in bytes. Has to be equal to 16.
* @param[in] client_slot the client slot ID.
* @param[in] caller_uuid the UUID of the caller.
* @return Operation status. Possible values are:
* + SA_STATUS_OK - Operation succeeded. Key check passed.
* + SA_STATUS_NULL_PARAMETER - key, in, or expected is NULL.
* + SA_STATUS_INVALID_PARAMETER - in_length or expected length are not 16.
* + SA_STATUS_OPERATION_NOT_ALLOWED - Key usage requirements are not met for the specified
* operation.
* + SA_STATUS_OPERATION_NOT_SUPPORTED - Implementation does not support the specified operation.
* + SA_STATUS_SELF_TEST - Implementation self-test has failed.
* + SA_STATUS_VERIFICATION_FAILED - Computed value does not match the expected one.
* + SA_STATUS_INTERNAL_ERROR - An unexpected error has occurred.
*/
sa_status ;
/**
* Perform a buffer check by digesting the data in the buffer at the offset and length and comparing it with the input
* hash.
*
* @param[in] svp_buffer the buffer to hash.
* @param[in] offset the offset at which to begin the hash.
* @param[in] length the length of the data to hash.
* @param[in] digest_algorithm the digest algorithm to use.
* @param[in] hash the hash to compare against.
* @param[in] hash_length the length of the hash.
* @param[in] client_slot the client slot ID.
* @param[in] caller_uuid the UUID of the caller.
* @return Operation status. Possible values are:
* + SA_STATUS_OK - Operation succeeded. Key check passed.
* + SA_STATUS_NULL_PARAMETER - hash is NULL.
* + SA_STATUS_INVALID_PARAMETER - offset or length is outside the buffer range.
* + SA_STATUS_OPERATION_NOT_SUPPORTED - Implementation does not support the specified operation.
* + SA_STATUS_INVALID_SVP_BUFFER - invalid SVP buffer.
* + SA_STATUS_SELF_TEST - Implementation self-test has failed.
* + SA_STATUS_VERIFICATION_FAILED - Computed value does not match the expected one.
* + SA_STATUS_INTERNAL_ERROR - An unexpected error has occurred.
*/
sa_status ;
// ENABLE_SVP
}
// TA_SA_SVP_H