1 /* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ATTRIBUTE_H 17 #define ATTRIBUTE_H 18 19 #include "c_array.h" 20 #include "defines.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 typedef enum { 27 /* Root tag */ 28 AUTH_ROOT = 100000, 29 /* Result code */ 30 AUTH_RESULT_CODE = 100001, 31 /* Tag of signature data in TLV */ 32 AUTH_SIGNATURE = 100004, 33 /* Identify mode */ 34 AUTH_IDENTIFY_MODE = 100005, 35 /* Tag of templateId data in TLV */ 36 AUTH_TEMPLATE_ID = 100006, 37 /* Tag of templateId list data in TLV */ 38 AUTH_TEMPLATE_ID_LIST = 100007, 39 /* Expected attribute, tag of remain count in TLV */ 40 AUTH_REMAIN_COUNT = 100009, 41 /* Remain time */ 42 AUTH_REMAIN_TIME = 100010, 43 /* Session id, required when decode in C */ 44 AUTH_SCHEDULE_ID = 100014, 45 /* Package name */ 46 AUTH_CALLER_NAME = 100015, 47 /* Schedule version */ 48 AUTH_SCHEDULE_VERSION = 100016, 49 /* Tag of lock out template in TLV */ 50 AUTH_LOCK_OUT_TEMPLATE = 100018, 51 /* Tag of unlock template in TLV */ 52 AUTH_UNLOCK_TEMPLATE = 100019, 53 /* Tag of data */ 54 AUTH_DATA = 100020, 55 /* Tag of auth subType */ 56 AUTH_SUB_TYPE = 100021, 57 /* Tag of auth schedule mode */ 58 AUTH_SCHEDULE_MODE = 100022, 59 /* Tag of property */ 60 AUTH_PROPERTY_MODE = 100023, 61 /* Tag of auth type */ 62 AUTH_TYPE = 100024, 63 /* Tag of cred id */ 64 AUTH_CREDENTIAL_ID = 100025, 65 /* Controller */ 66 AUTH_CONTROLLER = 100026, 67 /* calleruid */ 68 AUTH_CALLER_UID = 100027, 69 /* result */ 70 AUTH_RESULT = 100028, 71 /* capability level */ 72 AUTH_CAPABILITY_LEVEL = 100029, 73 /* algorithm setinfo */ 74 AUTH_ALGORITHM_INFO = 100030, 75 /* time stamp */ 76 AUTH_TIME_STAMP = 100031, 77 /* root secret */ 78 AUTH_ROOT_SECRET = 100032, 79 } AttributeKey; 80 81 typedef void Attribute; 82 83 #define MAX_EXECUTOR_MSG_LEN 2048 84 85 Attribute *CreateEmptyAttribute(void); 86 Attribute *CreateAttributeFromSerializedMsg(const Uint8Array msg); 87 void FreeAttribute(Attribute **attribute); 88 89 ResultCode GetAttributeSerializedMsg(const Attribute *attribute, Uint8Array *retMsg); 90 91 ResultCode GetAttributeUint32(const Attribute *attribute, AttributeKey key, uint32_t *retValue); 92 ResultCode SetAttributeUint32(Attribute *attribute, AttributeKey key, const uint32_t value); 93 ResultCode GetAttributeInt32(const Attribute *attribute, AttributeKey key, int32_t *retValue); 94 ResultCode SetAttributeInt32(Attribute *attribute, AttributeKey key, const int32_t value); 95 ResultCode GetAttributeUint64(const Attribute *attribute, AttributeKey key, uint64_t *retValue); 96 ResultCode SetAttributeUint64(Attribute *attribute, AttributeKey key, const uint64_t value); 97 ResultCode GetAttributeUint8Array(const Attribute *attribute, AttributeKey key, Uint8Array *retData); 98 ResultCode SetAttributeUint8Array(Attribute *attribute, AttributeKey key, const Uint8Array data); 99 ResultCode GetAttributeUint64Array(const Attribute *attribute, AttributeKey key, Uint64Array *retData); 100 ResultCode SetAttributeUint64Array(Attribute *attribute, AttributeKey key, const Uint64Array data); 101 102 #ifdef __cplusplus 103 } 104 #endif 105 106 #endif // ATTRIBUTE_H