1 /* 2 * Copyright (C) 2022 Huawei Technologies Co., Ltd. 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 #ifndef TEST_TRUSTED_STORAGE_DEFINES_H 13 #define TEST_TRUSTED_STORAGE_DEFINES_H 14 #include "stddef.h" 15 #include "tee_trusted_storage_api.h" 16 #include "tee_object_api.h" 17 #include "tee_log.h" 18 19 struct _IntermediateReprestation; 20 typedef int (*ActionEntryType)(struct _IntermediateReprestation *ir); 21 22 #define MAX_STRING_NAME_LEN 100 23 #define MAX_ACTIONS_SIZE 100 24 25 #define MAX_DATA_LEN 1024 26 #define MAX_ACTION_LOOP_SIZE 10 27 28 // test vector 29 typedef struct { 30 // start of declaration of user defined test data factors 31 uint32_t storageID; 32 33 void *createObjectID; 34 size_t createObjectLen; 35 uint32_t createFlags; 36 uint32_t createNum; 37 void* initialData; 38 size_t initialDataLen; 39 TEE_ObjectHandle attributes; 40 41 void *openObjectID; 42 size_t openObjectLen; 43 uint32_t openFlags; 44 45 int32_t seekOffset; 46 TEE_Whence whence; 47 void* writeBuffer; 48 size_t writeBufferLen; 49 size_t readBufferLen; 50 51 void *newObjectID; 52 size_t newObjectLen; 53 size_t resetSize; 54 55 uint32_t objectUsage[MAX_ACTION_LOOP_SIZE]; 56 uint32_t objectType[MAX_ACTION_LOOP_SIZE]; 57 uint32_t maxObjectSize[MAX_ACTION_LOOP_SIZE]; 58 uint32_t transientObjectNum; 59 bool isTransientObject; 60 61 uint32_t attributeID[MAX_ACTION_LOOP_SIZE]; 62 void *attrInitBuffer[MAX_ACTION_LOOP_SIZE]; 63 size_t attrInitLength[MAX_ACTION_LOOP_SIZE]; 64 uint32_t attrInitA[MAX_ACTION_LOOP_SIZE]; 65 uint32_t attrInitB[MAX_ACTION_LOOP_SIZE]; 66 uint32_t getAttributeID[MAX_ACTION_LOOP_SIZE]; 67 68 uint32_t generateKeySize; 69 uint32_t attrCount; 70 71 // end of declaration of user defined test data factors 72 // start of declaration of factors of the test framework 73 ActionEntryType actions[MAX_ACTIONS_SIZE]; 74 uint32_t expRet; 75 } TestVector; 76 77 // expect result 78 enum { 79 ER_OK = 0, 80 ER_JF = 1, 81 }; 82 83 // inverse actions map info manage 84 enum { 85 GROUP_BALANCED = 0, 86 GROUP_NOT_BALANCED = 1, 87 }; 88 typedef struct { 89 char *elementName; 90 ActionEntryType element; 91 char *inverseElementName; 92 ActionEntryType inverseElement; 93 uint32_t isBalanced; 94 } MonadReversibilityProperty; 95 96 // intermediate represtation of test context 97 #define MONAD_REVERSE_PROP_LIST_SIZE 100 98 typedef struct _IntermediateReprestation { 99 // start of declaration of user defined test data factors 100 TEE_ObjectHandle object; 101 TEE_ObjectInfo objectInfo; 102 103 char readBuffer[MAX_DATA_LEN]; 104 uint32_t readCount; 105 106 TEE_ObjectEnumHandle objectEnumerator; 107 char enumObjectID[MAX_DATA_LEN]; 108 size_t enumObjectIDLen; 109 110 TEE_ObjectHandle transientObject[MAX_ACTION_LOOP_SIZE]; 111 TEE_Attribute attr[MAX_ACTION_LOOP_SIZE]; 112 uint32_t initAttrNum; 113 114 void *attrGetBuffer[MAX_ACTION_LOOP_SIZE][MAX_DATA_LEN]; 115 size_t attrGetBufferLen[MAX_ACTION_LOOP_SIZE]; 116 uint32_t attrGetA[MAX_ACTION_LOOP_SIZE]; 117 uint32_t attrGetB[MAX_ACTION_LOOP_SIZE]; 118 119 /* function invoke count */ 120 uint32_t getAttrNum; 121 uint32_t getRefCount; 122 uint32_t getValueCount; 123 uint32_t restrictUsageCount; 124 uint32_t checkUsageCount; 125 uint32_t initRefAddrCount; 126 uint32_t initValueAddrCount; 127 uint32_t pos; 128 uint32_t len; 129 // end of declaration of user defined test data factors 130 131 // start of declaration factors of the test framework 132 TestVector *tv; 133 MonadReversibilityProperty mrpl[MONAD_REVERSE_PROP_LIST_SIZE]; 134 uint32_t mrplSize; 135 } IntermediateReprestation; 136 #endif // end TEST_DEFINES_H