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 PAKE_V2_AUTH_TASK_COMMON_H 17 #define PAKE_V2_AUTH_TASK_COMMON_H 18 19 #include "json_utils.h" 20 #include "pake_defs.h" 21 #include "string_util.h" 22 #include "account_module_defines.h" 23 #include "account_task_main.h" 24 #include "account_version_util.h" 25 26 typedef struct { 27 PakeBaseParams pakeParams; 28 uint64_t versionNo; 29 int32_t authForm; 30 int32_t credentialType; 31 int32_t osAccountId; 32 int32_t authKeyAlgEncode; 33 Uint8Buff deviceIdSelf; 34 Uint8Buff deviceIdPeer; 35 Uint8Buff devIdSelf; 36 Uint8Buff devIdPeer; 37 uint8_t userIdSelf[DEV_AUTH_USER_ID_SIZE]; 38 uint8_t userIdPeer[DEV_AUTH_USER_ID_SIZE]; 39 uint8_t pkSelf[PK_SIZE]; 40 Uint8Buff pkInfoSelf; 41 Uint8Buff pkInfoSignSelf; 42 uint8_t pkPeer[PK_SIZE]; 43 Uint8Buff pkPeerBuff; 44 Uint8Buff pkInfoPeer; 45 Uint8Buff pkInfoSignPeer; 46 } PakeAuthParams; 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 bool IsPakeV2AuthTaskSupported(void); 52 53 TaskBase *CreatePakeV2AuthTask(const CJson *in, CJson *out, const AccountVersionInfo *verInfo); 54 55 int32_t VerifyPkSignPeer(const PakeAuthParams *params); 56 57 int32_t GenerateEcdhSharedKey(PakeAuthParams *params); 58 59 int32_t GetPkInfoPeer(PakeAuthParams *params, const CJson *in); 60 61 int32_t InitPakeAuthParams(const CJson *in, PakeAuthParams *params, const AccountVersionInfo *verInfo); 62 63 void DestroyPakeAuthParams(PakeAuthParams *params); 64 65 int32_t ExtractPakePeerId(PakeAuthParams *params, const CJson *in); 66 67 int32_t ExtractPakeSelfId(PakeAuthParams *params); 68 69 int32_t ExtractPeerDeviceId(PakeAuthParams *params, const CJson *in); 70 71 int32_t ExtractPeerDevId(PakeAuthParams *params, const CJson *in); 72 73 #ifdef __cplusplus 74 } 75 #endif 76 77 #endif 78