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 /* Tag of templateId data in TLV */ 34094332d3Sopenharmony_ci ATTR_TEMPLATE_ID = 100006, 35094332d3Sopenharmony_ci /* Expected attribute, tag of remain count in TLV */ 36094332d3Sopenharmony_ci ATTR_REMAIN_ATTEMPTS = 100009, 37094332d3Sopenharmony_ci /* Remain time */ 38094332d3Sopenharmony_ci ATTR_LOCKOUT_DURATION = 100010, 39094332d3Sopenharmony_ci /* Session id, required when decode in C */ 40094332d3Sopenharmony_ci ATTR_SCHEDULE_ID = 100014, 41094332d3Sopenharmony_ci /* Tag of data */ 42094332d3Sopenharmony_ci ATTR_DATA = 100020, 43094332d3Sopenharmony_ci /** Pin subtype, the value type is int32_t. */ 44094332d3Sopenharmony_ci ATTR_PIN_SUB_TYPE = 100021, 45094332d3Sopenharmony_ci /* capability level */ 46094332d3Sopenharmony_ci ATTR_ACL = 100029, 47094332d3Sopenharmony_ci /* time stamp */ 48094332d3Sopenharmony_ci ATTR_TIME_STAMP = 100031, 49094332d3Sopenharmony_ci /* root secret */ 50094332d3Sopenharmony_ci ATTR_ROOT_SECRET = 100032, 51094332d3Sopenharmony_ci ATTR_LOCAL_UDID = 100063, 52094332d3Sopenharmony_ci ATTR_PEER_UDID = 100064, 53094332d3Sopenharmony_ci ATTR_PUBLIC_KEY = 100065, 54094332d3Sopenharmony_ci ATTR_CHALLENGE = 100066, 55094332d3Sopenharmony_ci 56094332d3Sopenharmony_ci PIN_ATTR_MSG_ID = 200001, 57094332d3Sopenharmony_ci PIN_ATTR_ALGO_VERSION = 200004, 58094332d3Sopenharmony_ci PIN_ATTR_ALGO_PARAM = 200005, 59094332d3Sopenharmony_ci PIN_ATTR_KEK_SALT = 200100, 60094332d3Sopenharmony_ci PIN_ATTR_KEK_IV = 200101, 61094332d3Sopenharmony_ci PIN_ATTR_KEK_SECRET = 200102, 62094332d3Sopenharmony_ci PIN_ATTR_KEK_TAG = 200103, 63094332d3Sopenharmony_ci} AttributeKey; 64094332d3Sopenharmony_ci 65094332d3Sopenharmony_citypedef void Attribute; 66094332d3Sopenharmony_ci 67094332d3Sopenharmony_ciAttribute *CreateEmptyAttribute(void); 68094332d3Sopenharmony_ciAttribute *CreateAttributeFromSerializedMsg(const Uint8Array msg); 69094332d3Sopenharmony_civoid FreeAttribute(Attribute **attribute); 70094332d3Sopenharmony_ci 71094332d3Sopenharmony_ciResultCode GetAttributeSerializedMsg(const Attribute *attribute, Uint8Array *retMsg); 72094332d3Sopenharmony_ci 73094332d3Sopenharmony_ciResultCode GetAttributeLength(const Attribute *attribute, AttributeKey key, uint32_t *len); 74094332d3Sopenharmony_ciResultCode GetAttributeUint32(const Attribute *attribute, AttributeKey key, uint32_t *retValue); 75094332d3Sopenharmony_ciResultCode SetAttributeUint32(Attribute *attribute, AttributeKey key, const uint32_t value); 76094332d3Sopenharmony_ciResultCode GetAttributeInt32(const Attribute *attribute, AttributeKey key, int32_t *retValue); 77094332d3Sopenharmony_ciResultCode SetAttributeInt32(Attribute *attribute, AttributeKey key, const int32_t value); 78094332d3Sopenharmony_ciResultCode GetAttributeUint64(const Attribute *attribute, AttributeKey key, uint64_t *retValue); 79094332d3Sopenharmony_ciResultCode SetAttributeUint64(Attribute *attribute, AttributeKey key, const uint64_t value); 80094332d3Sopenharmony_ciResultCode GetAttributeUint8Array(const Attribute *attribute, AttributeKey key, Uint8Array *retData); 81094332d3Sopenharmony_ciResultCode SetAttributeUint8Array(Attribute *attribute, AttributeKey key, const Uint8Array data); 82094332d3Sopenharmony_ciResultCode GetAttributeUint64Array(const Attribute *attribute, AttributeKey key, Uint64Array *retData); 83094332d3Sopenharmony_ciResultCode SetAttributeUint64Array(Attribute *attribute, AttributeKey key, const Uint64Array data); 84094332d3Sopenharmony_ci 85094332d3Sopenharmony_ci#ifdef __cplusplus 86094332d3Sopenharmony_ci} 87094332d3Sopenharmony_ci#endif 88094332d3Sopenharmony_ci 89094332d3Sopenharmony_ci#endif // ATTRIBUTE_H