1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (C) 2023-2024 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci 16094332d3Sopenharmony_ci#ifndef ATTRIBUTE_H 17094332d3Sopenharmony_ci#define ATTRIBUTE_H 18094332d3Sopenharmony_ci 19094332d3Sopenharmony_ci#include "c_array.h" 20094332d3Sopenharmony_ci#include "defines.h" 21094332d3Sopenharmony_ci 22094332d3Sopenharmony_ci#ifdef __cplusplus 23094332d3Sopenharmony_ciextern "C" { 24094332d3Sopenharmony_ci#endif 25094332d3Sopenharmony_ci 26094332d3Sopenharmony_citypedef enum { 27094332d3Sopenharmony_ci /* Root tag */ 28094332d3Sopenharmony_ci ATTR_ROOT = 100000, 29094332d3Sopenharmony_ci /* Result code */ 30094332d3Sopenharmony_ci ATTR_RESULT_CODE = 100001, 31094332d3Sopenharmony_ci /* Tag of signature data in TLV */ 32094332d3Sopenharmony_ci ATTR_SIGNATURE = 100004, 33094332d3Sopenharmony_ci /* Identify mode */ 34094332d3Sopenharmony_ci ATTR_IDENTIFY_MODE = 100005, 35094332d3Sopenharmony_ci /* Tag of templateId data in TLV */ 36094332d3Sopenharmony_ci ATTR_TEMPLATE_ID = 100006, 37094332d3Sopenharmony_ci /* Tag of templateId list data in TLV */ 38094332d3Sopenharmony_ci ATTR_TEMPLATE_ID_LIST = 100007, 39094332d3Sopenharmony_ci /* Expected attribute, tag of remain count in TLV */ 40094332d3Sopenharmony_ci ATTR_REMAIN_ATTEMPTS = 100009, 41094332d3Sopenharmony_ci /* Remain time */ 42094332d3Sopenharmony_ci ATTR_LOCKOUT_DURATION = 100010, 43094332d3Sopenharmony_ci /* Session id, required when decode in C */ 44094332d3Sopenharmony_ci ATTR_SCHEDULE_ID = 100014, 45094332d3Sopenharmony_ci /* Tag of data */ 46094332d3Sopenharmony_ci ATTR_DATA = 100020, 47094332d3Sopenharmony_ci /* Tag of auth subType */ 48094332d3Sopenharmony_ci ATTR_PIN_SUB_TYPE = 100021, 49094332d3Sopenharmony_ci /* Tag of auth schedule mode */ 50094332d3Sopenharmony_ci ATTR_SCHEDULE_MODE = 100022, 51094332d3Sopenharmony_ci /* Tag of property */ 52094332d3Sopenharmony_ci ATTR_PROPERTY_MODE = 100023, 53094332d3Sopenharmony_ci /* Tag of auth type */ 54094332d3Sopenharmony_ci ATTR_TYPE = 100024, 55094332d3Sopenharmony_ci /* Tag of cred id */ 56094332d3Sopenharmony_ci ATTR_CREDENTIAL_ID = 100025, 57094332d3Sopenharmony_ci /* Controller */ 58094332d3Sopenharmony_ci ATTR_CONTROLLER = 100026, 59094332d3Sopenharmony_ci /* calleruid */ 60094332d3Sopenharmony_ci ATTR_CALLER_UID = 100027, 61094332d3Sopenharmony_ci /* result */ 62094332d3Sopenharmony_ci ATTR_RESULT = 100028, 63094332d3Sopenharmony_ci /* capability level */ 64094332d3Sopenharmony_ci ATTR_CAPABILITY_LEVEL = 100029, 65094332d3Sopenharmony_ci /* algorithm setinfo */ 66094332d3Sopenharmony_ci ATTR_ALGORITHM_INFO = 100030, 67094332d3Sopenharmony_ci /* time stamp */ 68094332d3Sopenharmony_ci ATTR_TIME_STAMP = 100031, 69094332d3Sopenharmony_ci /* root secret */ 70094332d3Sopenharmony_ci ATTR_ROOT_SECRET = 100032, 71094332d3Sopenharmony_ci /* attrs */ 72094332d3Sopenharmony_ci ATTR_ATTRS = 100033, 73094332d3Sopenharmony_ci /* pin expired sys time */ 74094332d3Sopenharmony_ci ATTR_EXPIRED_SYS_TIME = 100034, 75094332d3Sopenharmony_ci /* executor matcher */ 76094332d3Sopenharmony_ci ATTR_EXECUTOR_MATCHER = 100036, 77094332d3Sopenharmony_ci /* user id */ 78094332d3Sopenharmony_ci ATTR_USER_ID = 100041, 79094332d3Sopenharmony_ci /* token */ 80094332d3Sopenharmony_ci ATTR_TOKEN = 100042, 81094332d3Sopenharmony_ci /* executor role */ 82094332d3Sopenharmony_ci ATTR_EXECUTOR_ROLE = 100043, 83094332d3Sopenharmony_ci /* esl */ 84094332d3Sopenharmony_ci ATTR_ESL = 100044, 85094332d3Sopenharmony_ci /* VERIFIER udid */ 86094332d3Sopenharmony_ci ATTR_VERIFIER_UDID = 100045, 87094332d3Sopenharmony_ci /* COLLECTOR udid */ 88094332d3Sopenharmony_ci ATTR_COLLECTOR_UDID = 100046, 89094332d3Sopenharmony_ci /* local udid */ 90094332d3Sopenharmony_ci ATTR_LOCAL_UDID = 100063, 91094332d3Sopenharmony_ci /* peer udid */ 92094332d3Sopenharmony_ci ATTR_PEER_UDID = 100064, 93094332d3Sopenharmony_ci /* public key */ 94094332d3Sopenharmony_ci ATTR_PUBLIC_KEY = 100065, 95094332d3Sopenharmony_ci /* Challenge */ 96094332d3Sopenharmony_ci ATTR_CHALLENGE = 100066, 97094332d3Sopenharmony_ci /* executor index */ 98094332d3Sopenharmony_ci ATTR_EXECUTOR_INDEX = 100067, 99094332d3Sopenharmony_ci} AttributeKey; 100094332d3Sopenharmony_ci 101094332d3Sopenharmony_ci#define MAX_SUB_MSG_NUM 10 102094332d3Sopenharmony_ci 103094332d3Sopenharmony_citypedef void Attribute; 104094332d3Sopenharmony_ci 105094332d3Sopenharmony_ci#define MAX_EXECUTOR_MSG_LEN 2048 106094332d3Sopenharmony_ci 107094332d3Sopenharmony_ciAttribute *CreateEmptyAttribute(void); 108094332d3Sopenharmony_ciAttribute *CreateAttributeFromSerializedMsg(const Uint8Array msg); 109094332d3Sopenharmony_civoid FreeAttribute(Attribute **attribute); 110094332d3Sopenharmony_ci 111094332d3Sopenharmony_ciResultCode GetAttributeSerializedMsg(const Attribute *attribute, Uint8Array *retMsg); 112094332d3Sopenharmony_ci 113094332d3Sopenharmony_ciResultCode GetAttributeUint32(const Attribute *attribute, AttributeKey key, uint32_t *retValue); 114094332d3Sopenharmony_ciResultCode SetAttributeUint32(Attribute *attribute, AttributeKey key, const uint32_t value); 115094332d3Sopenharmony_ciResultCode GetAttributeInt32(const Attribute *attribute, AttributeKey key, int32_t *retValue); 116094332d3Sopenharmony_ciResultCode SetAttributeInt32(Attribute *attribute, AttributeKey key, const int32_t value); 117094332d3Sopenharmony_ciResultCode GetAttributeUint64(const Attribute *attribute, AttributeKey key, uint64_t *retValue); 118094332d3Sopenharmony_ciResultCode SetAttributeUint64(Attribute *attribute, AttributeKey key, const uint64_t value); 119094332d3Sopenharmony_ciResultCode GetAttributeUint8Array(const Attribute *attribute, AttributeKey key, Uint8Array *retData); 120094332d3Sopenharmony_ciResultCode SetAttributeUint8Array(Attribute *attribute, AttributeKey key, const Uint8Array data); 121094332d3Sopenharmony_ciResultCode GetAttributeUint64Array(const Attribute *attribute, AttributeKey key, Uint64Array *retData); 122094332d3Sopenharmony_ciResultCode SetAttributeUint64Array(Attribute *attribute, AttributeKey key, const Uint64Array data); 123094332d3Sopenharmony_ci 124094332d3Sopenharmony_ciResultCode ParseMultiDataSerializedMsg(const Uint8Array msg, Uint8Array *subMsgData, int *subMsgSize); 125094332d3Sopenharmony_ciResultCode GetMultiDataSerializedMsg(Uint8Array *sourceArrayMsg, uint32_t size, Uint8Array *retMsg); 126094332d3Sopenharmony_ci 127094332d3Sopenharmony_ci#ifdef __cplusplus 128094332d3Sopenharmony_ci} 129094332d3Sopenharmony_ci#endif 130094332d3Sopenharmony_ci 131094332d3Sopenharmony_ci#endif // ATTRIBUTE_H