1 /* 2 * Copyright (C) 2022 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 ACCOUNT_VERSION_UTIL_H 17 #define ACCOUNT_VERSION_UTIL_H 18 19 #include "alg_defs.h" 20 #include "json_utils.h" 21 #include "pake_defs.h" 22 #include "protocol_common.h" 23 #include "account_task_main.h" 24 25 typedef enum { 26 BIND_VERSION_NO_NONE = 0, 27 BIND_PAKE_V2_DL = 0x0001, 28 BIND_PAKE_V2_EC_P256 = 0x0002, 29 BIND_PAKE_V2_EC_P256_WITH_PROOF = 0x0004, 30 BIND_PAKE_V2_EC_X25519 = 0x0008, 31 BIND_PAKE_V1_DL = 0x0010, 32 } BindVersionNo; 33 34 typedef enum { 35 AUTH_VERSION_NO_NONE = 0, 36 AUTH_PAKE_V2_EC_P256 = 0x0001, 37 AUTH_ISO = 0x0002, 38 } AuthVersionNo; 39 40 typedef enum { 41 VERSION_INITIAL = 0, 42 VERSION_NEGOTIATION = 1, 43 VERSION_CONFIRMED = 2, 44 } AccountVersionStatus; 45 46 typedef struct AccountVersionInfoT { 47 uint64_t versionNo; 48 ProtocolType protocolType; 49 PakeAlgType pakeAlgType; 50 CurveType curveType; 51 bool withExtraOperation; 52 bool (*isTaskSupported)(void); 53 TaskBase *(*createTask)(const CJson *, CJson *, const struct AccountVersionInfoT *); 54 } AccountVersionInfo; 55 56 #ifdef __cplusplus 57 extern "C" { 58 #endif 59 60 void InitVersionInfos(void); 61 void DestroyVersionInfos(void); 62 uint64_t GetSupportedVersionNo(int32_t operationCode); 63 const AccountVersionInfo *GetNegotiatedVersionInfo(int32_t operationCode, int32_t credentialType); 64 65 #ifdef __cplusplus 66 } 67 #endif 68 69 #endif 70