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 | |
| 47 | /* |
| 48 | * Helpers for commands towards the crypt TA |
| 49 | */ |
| 50 | TEEC_Result ta_crypt_cmd_allocate_operation(ADBG_Case_t *c, |
| 51 | TEEC_Session *s, |
| 52 | TEE_OperationHandle *oph, |
| 53 | uint32_t algo, |
| 54 | uint32_t mode, |
| 55 | uint32_t max_key_size); |
| 56 | |
| 57 | TEEC_Result ta_crypt_cmd_allocate_transient_object(ADBG_Case_t *c, |
| 58 | TEEC_Session *s, |
| 59 | TEE_ObjectType obj_type, uint32_t max_obj_size, |
| 60 | TEE_ObjectHandle *o); |
| 61 | |
| 62 | TEEC_Result ta_crypt_cmd_populate_transient_object(ADBG_Case_t *c, |
| 63 | TEEC_Session *s, |
| 64 | TEE_ObjectHandle o, |
| 65 | const TEE_Attribute *attrs, |
| 66 | uint32_t attr_count); |
| 67 | |
| 68 | TEE_Result ta_crypt_cmd_set_operation_key(ADBG_Case_t *c, |
| 69 | TEEC_Session *s, |
| 70 | TEE_OperationHandle oph, |
| 71 | TEE_ObjectHandle key); |
| 72 | |
| 73 | TEEC_Result ta_crypt_cmd_free_transient_object(ADBG_Case_t *c, |
| 74 | TEEC_Session *s, |
| 75 | TEE_ObjectHandle o); |
| 76 | |
| 77 | TEEC_Result ta_crypt_cmd_derive_key(ADBG_Case_t *c, |
| 78 | TEEC_Session *s, |
| 79 | TEE_OperationHandle oph, |
| 80 | TEE_ObjectHandle o, |
| 81 | const TEE_Attribute *params, |
| 82 | uint32_t paramCount); |
| 83 | |
| 84 | TEEC_Result ta_crypt_cmd_get_object_buffer_attribute(ADBG_Case_t *c, |
| 85 | TEEC_Session *s, |
| 86 | TEE_ObjectHandle o, |
| 87 | uint32_t attr_id, |
| 88 | void *buf, |
| 89 | size_t *blen); |
| 90 | |
| 91 | TEEC_Result ta_crypt_cmd_free_operation(ADBG_Case_t *c, |
| 92 | TEEC_Session *s, |
| 93 | TEE_OperationHandle oph); |
| 94 | |
| 95 | void xtest_add_attr(size_t *attr_count, TEE_Attribute *attrs, |
| 96 | uint32_t attr_id, const void *buf, size_t len); |
Pascal Brand | e61133f | 2015-07-08 15:38:37 +0200 | [diff] [blame] | 97 | void xtest_add_attr_value(size_t *attr_count, TEE_Attribute *attrs, |
| 98 | uint32_t attr_id, uint32_t value_a, uint32_t value_b); |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 99 | |
| 100 | TEE_Result pack_attrs(const TEE_Attribute *attrs, uint32_t attr_count, |
| 101 | uint8_t **buf, size_t *blen); |
| 102 | |
| 103 | #endif /*XTEST_HELPERS_H*/ |