blob: 18b97166d9802b7870684452bac4eb7981d4b132 [file] [log] [blame]
Pascal Brandc639ac82015-07-02 08:53:34 +02001/*
2 * Copyright (c) 2014, STMicroelectronics International N.V.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef TA_CRYPT_H
29#define TA_CRYPT_H
30
31/* This UUID is generated with the ITU-T UUID generator at
32 http://www.itu.int/ITU-T/asn1/uuid.html */
33#define TA_CRYPT_UUID { 0xcb3e5ba0, 0xadf1, 0x11e0, \
34 { 0x99, 0x8b, 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }
35
36#define TA_CRYPT_CMD_SHA224 1
37#define TA_CRYPT_CMD_SHA256 2
38#define TA_CRYPT_CMD_AES256ECB_ENC 3
39#define TA_CRYPT_CMD_AES256ECB_DEC 4
40
41/*
42 * TEE_Result TEE_AllocateOperation(TEE_OperationHandle *operation,
43 * uint32_t algorithm, uint32_t mode, uint32_t maxKeySize);
44 * in/out params[0].value.a = operation
45 * in/out params[0].value.b = algorithm
46 * in params[1].value.a = mode
47 * in params[2].value.b = maxKeySize
48 */
49#define TA_CRYPT_CMD_ALLOCATE_OPERATION 5
50
51/*
52 * void TEE_FreeOperation(TEE_OperationHandle operation);
53 * in params[0].value.a = operation
54 */
55#define TA_CRYPT_CMD_FREE_OPERATION 6
56
57/*
58 * void TEE_GetOperationInfo(TEE_OperationHandle operation,
59 * TEE_OperationInfo* operationInfo);
60 * in params[0].value.a = operation
61 * out params[1].memref = operationInfo
62 */
63#define TA_CRYPT_CMD_GET_OPERATION_INFO 7
64
65/*
66 * void TEE_ResetOperation(TEE_OperationHandle operation);
67 * in params[0].value.a = operation
68 */
69#define TA_CRYPT_CMD_RESET_OPERATION 8
70
71/*
72 * TEE_Result TEE_SetOperationKey(TEE_OperationHandle operation,
73 * TEE_ObjectHandle key);
74 * in params[0].value.a = operation
75 * in params[0].value.b = key
76 */
77#define TA_CRYPT_CMD_SET_OPERATION_KEY 9
78
79/*
80 * TEE_Result TEE_SetOperationKey2(TEE_OperationHandle operation,
81 * TEE_ObjectHandle key1, TEE_ObjectHandle key2);
82 * in params[0].value.a = operation
83 * in params[0].value.b = key1
84 * in params[0].value.a = key2
85 */
86#define TA_CRYPT_CMD_SET_OPERATION_KEY2 10
87
88/*
89 * void TEE_CopyOperation(TEE_OperationHandle dstOperation,
90 * TEE_OperationHandle srcOperation);
91 * in params[0].value.a = dstOperation
92 * in params[0].value.b = srcOperation
93 */
94#define TA_CRYPT_CMD_COPY_OPERATION 11
95
96/*
97 * void TEE_DigestUpdate(TEE_OperationHandle operation,
98 * void *chunk, size_t chunkSize);
99 * in params[0].value.a = operation
100 * in params[1].memref = chunk
101 */
102#define TA_CRYPT_CMD_DIGEST_UPDATE 12
103
104/*
105 * TEE_Result TEE_DigestDoFinal(TEE_OperationHandle operation,
106 * const void *chunk, size_t chunkLen,
107 * void *hash, size_t *hashLen);
108 * in params[0].value.a = operation
109 * in params[1].memref = chunk
110 * out params[2].memref = hash
111 */
112#define TA_CRYPT_CMD_DIGEST_DO_FINAL 13
113
114/*
115 * void TEE_CipherInit(TEE_OperationHandle operation, const void *IV,
116 * size_t IVLen);
117 * in params[0].value.a = operation
118 * in params[1].memref = IV
119 */
120#define TA_CRYPT_CMD_CIPHER_INIT 14
121
122/*
123 * TEE_Result TEE_CipherUpdate(TEE_OperationHandle operation,
124 * const void *srcData, size_t srcLen,
125 * void *destData, size_t *destLen);
126 * in params[0].value.a = operation
127 * in params[1].memref = srcData
128 * out params[2].memref = dstData
129 */
130#define TA_CRYPT_CMD_CIPHER_UPDATE 15
131
132/*
133 * TEE_Result TEE_CipherDoFinal(TEE_OperationHandle operation,
134 * const void *srcData, size_t srcLen,
135 * void *destData, size_t *destLen);
136 * in params[0].value.a = operation
137 * in params[1].memref = srcData
138 * out params[2].memref = destData
139 */
140#define TA_CRYPT_CMD_CIPHER_DO_FINAL 16
141
142/*
143 * void TEE_MACInit(TEE_OperationHandle operation,
144 * const void *IV, size_t IVLen);
145 * in params[0].value.a = operation
146 * in params[1].memref = IV
147 */
148#define TA_CRYPT_CMD_MAC_INIT 17
149
150/*
151 * void TEE_MACUpdate(TEE_OperationHandle operation,
152 * const void *chunk, size_t chunkSize);
153 * in params[0].value.a = operation
154 * in params[1].memref = chunk
155 */
156#define TA_CRYPT_CMD_MAC_UPDATE 18
157
158/*
159 * TEE_Result TEE_MACFinalCompute(TEE_OperationHandle operation,
160 * const void *message, size_t messageLen,
161 * void *mac, size_t *macLen);
162 * in params[0].value.a = operation
163 * in params[1].memref = message
164 * out params[2].memref = mac
165 */
166#define TA_CRYPT_CMD_MAC_FINAL_COMPUTE 19
167
168/*
169 * TEE_Result TEE_MACFinalCompare(TEE_OperationHandle operation,
170 * const void *message, size_t messageLen,
171 * const void *mac, size_t *macLen);
172 * in params[0].value.a = operation
173 * in params[1].memref = message
174 * in params[2].memref = mac
175 */
176#define TA_CRYPT_CMD_MAC_FINAL_COMPARE 20
177
178/*
179 * TEE_Result TEE_AllocateTransientObject(TEE_ObjectType objectType,
180 * uint32_t maxObjectSize, TEE_ObjectHandle* object);
181 * in params[0].value.a = objectType
182 * in params[0].value.b = maxObjectSize
183 * out params[1].value.a = object;
184 */
185#define TA_CRYPT_CMD_ALLOCATE_TRANSIENT_OBJECT 21
186
187/*
188 * void TEE_FreeTransientObject(TEE_ObjectHandle object);
189 * in params[0].value.a = object
190 */
191#define TA_CRYPT_CMD_FREE_TRANSIENT_OBJECT 22
192
193/*
194 * void TEE_ResetTransientObject(TEE_ObjectHandle object);
195 * in params[0].value.a = object
196 */
197#define TA_CRYPT_CMD_RESET_TRANSIENT_OBJECT 23
198
199/*
200 * TEE_Result TEE_PopulateTransientObject(TEE_ObjectHandle object,
201 * TEE_Attribute *attrs, uint32_t attrCount);
202 * in params[0].value.a = object
203 * in params[1].memref = attrs
204 */
205#define TA_CRYPT_CMD_POPULATE_TRANSIENT_OBJECT 24
206
207/*
208 * void TEE_CopyObjectAttributes(TEE_ObjectHandle destObject,
209 * TEE_ObjectHandle srcObject);
210 * in params[0].value.a = destObject
211 * in params[0].value.b = srcObject
212 */
213#define TA_CRYPT_CMD_COPY_OBJECT_ATTRIBUTES 25
214
215/*
216 * TEE_Result TEE_GenerateKey(TEE_ObjectHandle object, uint32_t keySize,
217 * TEE_Attribute *params, uint32_t paramCount);
218 * in params[0].value.a = object
219 * in params[0].value.b = keySize
220 * in params[1].memref = params
221 */
222#define TA_CRYPT_CMD_GENERATE_KEY 26
223
224/*
225 * TEE_Result TEE_AsymmetricEncrypt(TEE_OperationHandle operation,
226 * const TEE_Attribute *params, uint32_t paramCount,
227 * const void *srcData, size_t srcLen, void *destData,
228 * size_t *destLen);
229 * in params[0].value.a = operation
230 * in params[1].memref = params
231 * in params[2].memref = srcData
232 * out params[3].memref = destData
233 */
234#define TA_CRYPT_CMD_ASYMMETRIC_ENCRYPT 27
235
236/*
237 * TEE_Result TEE_AsymmetricDecrypt(TEE_OperationHandle operation,
238 * const TEE_Attribute *params, uint32_t paramCount,
239 * const void *srcData, size_t srcLen, void *destData,
240 * size_t *destLen)
241 * in params[0].value.a = operation
242 * in params[1].memref = params
243 * in params[2].memref = srcData
244 * out params[3].memref = destData
245 */
246#define TA_CRYPT_CMD_ASYMMETRIC_DECRYPT 28
247
248/*
249 * TEE_Result TEE_AsymmetricSignDigest(TEE_OperationHandle operation,
250 * const TEE_Attribute *params, uint32_t paramCount,
251 * const void *digest, size_t digestLen, void *signature,
252 * size_t *signatureLen)
253 * in params[0].value.a = operation
254 * in params[1].memref = params
255 * in params[2].memref = digest
256 * out params[3].memref = signature
257 */
258#define TA_CRYPT_CMD_ASYMMETRIC_SIGN_DIGEST 29
259
260/*
261 * TEE_Result TEE_AsymmetricVerifyDigest(TEE_OperationHandle operation,
262 * const TEE_Attribute *params, uint32_t paramCount,
263 * const void *digest, size_t digestLen, const void *signature,
264 * size_t signatureLen)
265 * in params[0].value.a = operation
266 * in params[1].memref = params
267 * in params[2].memref = digest
268 * in params[3].memref = signature
269 */
270#define TA_CRYPT_CMD_ASYMMETRIC_VERIFY_DIGEST 30
271
272/*
273 * void TEE_DeriveKey(TEE_OperationHandle operation,
274 * const TEE_Attribute *params, uint32_t paramCount,
275 * TEE_ObjectHandle derivedKey)
276 * in params[0].value.a = operation
277 * in params[1].memref = params
278 * in params[0].value.b = derivedKey
279 */
280#define TA_CRYPT_CMD_DERIVE_KEY 31
281
282/*
283 * void TEE_RandomNumberGenerate(void *randomBuffer, size_t randomBufferLen);
284 * out params[0].memref = randomBuffer
285 */
286#define TA_CRYPT_CMD_RANDOM_NUMBER_GENEREATE 32
287
288/*
289 * TEE_Result TEE_AEInit(TEE_OperationHandle operation,
290 * const void* nonce, size_t nonceLen,
291 * uint32_t tagLen, uint32_t AADLen, uint32_t payloadLen);
292 * in params[0].value.a = operation
293 * in params[1].memref = nonce
294 * in params[0].value.b = tagLen
295 * in params[2].value.a = AADLen
296 * in params[2].value.b = payloadLen
297 */
298#define TA_CRYPT_CMD_AE_INIT 33
299
300/*
301 * void TEE_AEUpdateAAD(TEE_OperationHandle operation,
302 * void* AADdata, size_t AADdataLen);
303 * in params[0].value.a = operation
304 * in params[1].memref = AADdata
305 */
306#define TA_CRYPT_CMD_AE_UPDATE_AAD 34
307
308/*
309 * TEE_Result TEE_AEUpdate(TEE_OperationHandle operation,
310 * const void* srcData, size_t srcLen,
311 * void* destData, size_t *destLen);
312 * in params[0].value.a = operation
313 * in params[1].memref = srcData
314 * out params[2].memref = destData
315 */
316#define TA_CRYPT_CMD_AE_UPDATE 35
317
318/*
319 * TEE_Result TEE_AEEncryptFinal(TEE_OperationHandle operation,
320 * const void* srcData, size_t srcLen,
321 * void* destData, size_t* destLen,
322 * void* tag, size_t* tagLen);
323 * in params[0].value[0].a = operation
324 * in params[1].memref = srcData
325 * out params[2].memref = destData
326 * out params[3].memref = tag
327 */
328#define TA_CRYPT_CMD_AE_ENCRYPT_FINAL 36
329
330/*
331 * TEE_Result TEE_AEDecryptFinal(TEE_OperationHandle operation,
332 * const void* srcData, size_t srcLen,
333 * void* destData, size_t *destLen,
334 * const void* tag, size_t tagLen);
335 * in params[0].value.a = operation
336 * in params[1].memref = srcData
337 * out params[2].memref = destData
338 * in params[3].memref = tag
339 */
340#define TA_CRYPT_CMD_AE_DECRYPT_FINAL 37
341
342/*
343 * TEE_Result TEE_GetObjectBufferAttribute(TEE_ObjectHandle object,
344 * uint32_t attributeID, void* buffer, size_t* size);
345 * in params[0].value.a = object
346 * in params[0].value.b = attributeID
347 * out params[1].memrefs = buffer
348 */
349#define TA_CRYPT_CMD_GET_OBJECT_BUFFER_ATTRIBUTE 38
350
351/*
352 * TEE_Result TEE_GetObjectValueAttribute(TEE_ObjectHandle object,
353 * uint32_t attributeID, void* buffer, size_t* size);
354 * in params[0].value.a = object
355 * in params[0].value.b = attributeID
356 * out params[1].value.a = value a
357 * out params[1].value.b = value b
358 */
359#define TA_CRYPT_CMD_GET_OBJECT_VALUE_ATTRIBUTE 39
360
361/* To set or get a global value */
362#define TA_CRYPT_CMD_SETGLOBAL 40
363#define TA_CRYPT_CMD_GETGLOBAL 41
364
365#endif /*TA_CRYPT_H */