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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/*
* 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
*/
/**
* @file sa_svp.h
*
* This file contains the function declarations for the "svp" module of the SecAPI. "svp"
* module contains functions for performing cryptographic operations in Secure Video Pipeline
* protected memory region.
*/
extern "C" ENABLE_SVP
/**
* Allocate an SVP memory block.
*
* @param[out] svp_memory pointer to the SVP memory region.
* @param[in] size Size of the restricted SVP memory region in bytes.
* @return Operation status. Possible values are:
* + SA_STATUS_OK - Operation succeeded.
* + SA_STATUS_NULL_PARAMETER - svp_memory 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 ;
/**
* Allocate an SVP buffer handle. This is a convenience function that calls sa_svp_memory_alloc to allocate an SVP
* memory region and then calls sa_svp_buffer_create to create a handle to an SVP buffer.
*
* @param[out] svp_buffer SVP buffer handle.
* @param[in] size Size of the restricted SVP region buffer in bytes.
* @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 ;
/**
* Create an SVP buffer handle. An SVP buffer is a TA data structure that points to an SVP memory region and holds the
* size of the buffer. The SVP memory is allocated before calling this function and then is passed in via the svp_memory
* parameter. The size of the SVP memory region is passed in via the size parameter. SVP memory passed in must be
* validated to be wholly contained within the restricted SVP memory region.
*
* @param[out] svp_buffer SVP buffer handle.
* @param[in] svp_memory Restricted SVP memory region.
* @param[in] size Size of the restricted SVP memory region in bytes.
* @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 ;
/**
* Free an SVP memory block.
*
* @param[in] svp_memory pointer to the SVP memory region.
* @return Operation status. Possible values are:
* + SA_STATUS_OK - Operation succeeded.
* + SA_STATUS_NULL_PARAMETER - svp_memory 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 ;
/**
* Free the SVP buffer handle. This is a convenience functions that calls sa_svp_buffer_release followed by
* sa_svp_memory_free.
*
* @param[in] svp_buffer SVP buffer handle.
* @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 ;
/**
* Releases the SVP buffer handle. This call does not free the SVP memory region buffer associated with it. The SVP
* memory region and its length are returned to the caller and the caller must free the SVP memory region.
*
* @param[out] svp_memory A reference to the SVP memory region.
* @param[out] size The size of the SVP memory region.
* @param[in] svp_buffer SVP buffer handle.
* @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] offsets_length Number of offset blocks to copy.
* @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] offsets_length Number of offset blocks to copy.
* @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 ;
/**
* 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] bytes_to_process The number of bytes to process. Has to be equal to 16.
* @param[in] expected Expected result.
* @param[in] expected_length Expected result length in bytes. Has to be equal to 16.
* @return Operation status. Possible values are:
* + SA_STATUS_OK - Operation succeeded. Key check passed.
* + SA_STATUS_NULL_PARAMETER - in or expected is NULL.
* + SA_STATUS_INVALID_PARAMETER - in.context.clear/svp.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. This function can only be called from another TA. Calls from the REE will return
* SA_STATUS_OPERATION_NOT_SUPPORTED.
*
* @param[in] svp_buffer Buffer to hash.
* @param[in] offset Offset at which to begin the hash.
* @param[in] length Length of the data to hash.
* @param[in] digest_algorithm Digest algorithm to use.
* @param[in] hash Hash to compare against.
* @param[in] hash_length Length of the hash.
* @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
}
/* SA_SVP_H */