1 /* 2 * Copyright (C) 2023-2024 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 ATTR_ROOT = 100000, 29 /* Result code */ 30 ATTR_RESULT_CODE = 100001, 31 /* Tag of signature data in TLV */ 32 ATTR_SIGNATURE = 100004, 33 /* Tag of templateId data in TLV */ 34 ATTR_TEMPLATE_ID = 100006, 35 /* Expected attribute, tag of remain count in TLV */ 36 ATTR_REMAIN_ATTEMPTS = 100009, 37 /* Remain time */ 38 ATTR_LOCKOUT_DURATION = 100010, 39 /* Session id, required when decode in C */ 40 ATTR_SCHEDULE_ID = 100014, 41 /* Tag of data */ 42 ATTR_DATA = 100020, 43 /** Pin subtype, the value type is int32_t. */ 44 ATTR_PIN_SUB_TYPE = 100021, 45 /* capability level */ 46 ATTR_ACL = 100029, 47 /* time stamp */ 48 ATTR_TIME_STAMP = 100031, 49 /* root secret */ 50 ATTR_ROOT_SECRET = 100032, 51 ATTR_LOCAL_UDID = 100063, 52 ATTR_PEER_UDID = 100064, 53 ATTR_PUBLIC_KEY = 100065, 54 ATTR_CHALLENGE = 100066, 55 56 PIN_ATTR_MSG_ID = 200001, 57 PIN_ATTR_ALGO_VERSION = 200004, 58 PIN_ATTR_ALGO_PARAM = 200005, 59 PIN_ATTR_KEK_SALT = 200100, 60 PIN_ATTR_KEK_IV = 200101, 61 PIN_ATTR_KEK_SECRET = 200102, 62 PIN_ATTR_KEK_TAG = 200103, 63 } AttributeKey; 64 65 typedef void Attribute; 66 67 Attribute *CreateEmptyAttribute(void); 68 Attribute *CreateAttributeFromSerializedMsg(const Uint8Array msg); 69 void FreeAttribute(Attribute **attribute); 70 71 ResultCode GetAttributeSerializedMsg(const Attribute *attribute, Uint8Array *retMsg); 72 73 ResultCode GetAttributeLength(const Attribute *attribute, AttributeKey key, uint32_t *len); 74 ResultCode GetAttributeUint32(const Attribute *attribute, AttributeKey key, uint32_t *retValue); 75 ResultCode SetAttributeUint32(Attribute *attribute, AttributeKey key, const uint32_t value); 76 ResultCode GetAttributeInt32(const Attribute *attribute, AttributeKey key, int32_t *retValue); 77 ResultCode SetAttributeInt32(Attribute *attribute, AttributeKey key, const int32_t value); 78 ResultCode GetAttributeUint64(const Attribute *attribute, AttributeKey key, uint64_t *retValue); 79 ResultCode SetAttributeUint64(Attribute *attribute, AttributeKey key, const uint64_t value); 80 ResultCode GetAttributeUint8Array(const Attribute *attribute, AttributeKey key, Uint8Array *retData); 81 ResultCode SetAttributeUint8Array(Attribute *attribute, AttributeKey key, const Uint8Array data); 82 ResultCode GetAttributeUint64Array(const Attribute *attribute, AttributeKey key, Uint64Array *retData); 83 ResultCode SetAttributeUint64Array(Attribute *attribute, AttributeKey key, const Uint64Array data); 84 85 #ifdef __cplusplus 86 } 87 #endif 88 89 #endif // ATTRIBUTE_H