Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014, STMicroelectronics International N.V. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License Version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | #ifndef XTEST_HELPERS_H |
| 15 | #define XTEST_HELPERS_H |
| 16 | |
| 17 | #include <tee_client_api.h> |
| 18 | #include <tee_api_types.h> |
| 19 | #include <adbg.h> |
| 20 | |
Cedric Chaumont | c3b6c28 | 2015-09-25 03:05:18 +0200 | [diff] [blame] | 21 | extern unsigned int level; |
| 22 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 23 | /* Global context to use if any context is needed as input to a function */ |
| 24 | extern TEEC_Context xtest_teec_ctx; |
| 25 | |
| 26 | /* |
| 27 | * Initializes the context above, should be called before the ADBG test |
| 28 | * cases are run. |
| 29 | */ |
| 30 | TEEC_Result xtest_teec_ctx_init(void); |
| 31 | void xtest_teec_ctx_deinit(void); |
| 32 | |
| 33 | /* Opens a session */ |
| 34 | TEEC_Result xtest_teec_open_session(TEEC_Session *session, |
| 35 | const TEEC_UUID *uuid, TEEC_Operation *op, |
| 36 | uint32_t *ret_orig); |
| 37 | |
| 38 | TEEC_Result xtest_teec_open_static_session(TEEC_Session *session, |
| 39 | TEEC_Operation *op, |
| 40 | uint32_t *ret_orig); |
| 41 | |
Aijun Sun | 9dbed27 | 2015-10-15 15:44:19 +0800 | [diff] [blame] | 42 | #define TEEC_OPERATION_INITIALIZER { 0 } |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 43 | |
| 44 | /* IO access macro */ |
| 45 | #define IO(addr) (*((volatile unsigned long *)(addr))) |
| 46 | |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 47 | #define UNUSED(x) (void)(x) |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 48 | /* |
| 49 | * Helpers for commands towards the crypt TA |
| 50 | */ |
| 51 | TEEC_Result ta_crypt_cmd_allocate_operation(ADBG_Case_t *c, |
| 52 | TEEC_Session *s, |
| 53 | TEE_OperationHandle *oph, |
| 54 | uint32_t algo, |
| 55 | uint32_t mode, |
| 56 | uint32_t max_key_size); |
| 57 | |
| 58 | TEEC_Result ta_crypt_cmd_allocate_transient_object(ADBG_Case_t *c, |
| 59 | TEEC_Session *s, |
| 60 | TEE_ObjectType obj_type, uint32_t max_obj_size, |
| 61 | TEE_ObjectHandle *o); |
| 62 | |
| 63 | TEEC_Result ta_crypt_cmd_populate_transient_object(ADBG_Case_t *c, |
| 64 | TEEC_Session *s, |
| 65 | TEE_ObjectHandle o, |
| 66 | const TEE_Attribute *attrs, |
| 67 | uint32_t attr_count); |
| 68 | |
| 69 | TEE_Result ta_crypt_cmd_set_operation_key(ADBG_Case_t *c, |
| 70 | TEEC_Session *s, |
| 71 | TEE_OperationHandle oph, |
| 72 | TEE_ObjectHandle key); |
| 73 | |
| 74 | TEEC_Result ta_crypt_cmd_free_transient_object(ADBG_Case_t *c, |
| 75 | TEEC_Session *s, |
| 76 | TEE_ObjectHandle o); |
| 77 | |
| 78 | TEEC_Result ta_crypt_cmd_derive_key(ADBG_Case_t *c, |
| 79 | TEEC_Session *s, |
| 80 | TEE_OperationHandle oph, |
| 81 | TEE_ObjectHandle o, |
| 82 | const TEE_Attribute *params, |
| 83 | uint32_t paramCount); |
| 84 | |
| 85 | TEEC_Result ta_crypt_cmd_get_object_buffer_attribute(ADBG_Case_t *c, |
| 86 | TEEC_Session *s, |
| 87 | TEE_ObjectHandle o, |
| 88 | uint32_t attr_id, |
| 89 | void *buf, |
| 90 | size_t *blen); |
| 91 | |
| 92 | TEEC_Result ta_crypt_cmd_free_operation(ADBG_Case_t *c, |
| 93 | TEEC_Session *s, |
| 94 | TEE_OperationHandle oph); |
| 95 | |
| 96 | void xtest_add_attr(size_t *attr_count, TEE_Attribute *attrs, |
| 97 | uint32_t attr_id, const void *buf, size_t len); |
Pascal Brand | e61133f | 2015-07-08 15:38:37 +0200 | [diff] [blame] | 98 | void xtest_add_attr_value(size_t *attr_count, TEE_Attribute *attrs, |
| 99 | uint32_t attr_id, uint32_t value_a, uint32_t value_b); |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 100 | |
| 101 | TEE_Result pack_attrs(const TEE_Attribute *attrs, uint32_t attr_count, |
| 102 | uint8_t **buf, size_t *blen); |
| 103 | |
Jerome Forissier | e385416 | 2016-08-12 12:40:12 +0200 | [diff] [blame] | 104 | int ree_fs_get_ta_dirname(TEEC_UUID *p_uuid, char *buffer, uint32_t len); |
| 105 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 106 | #endif /*XTEST_HELPERS_H*/ |