• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 pkInfoPeer;
44     Uint8Buff pkInfoSignPeer;
45 } PakeAuthParams;
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 bool IsPakeV2AuthTaskSupported(void);
51 
52 TaskBase *CreatePakeV2AuthTask(const CJson *in, CJson *out, const AccountVersionInfo *verInfo);
53 
54 int32_t VerifyPkSignPeer(const PakeAuthParams *params);
55 
56 int32_t GenerateEcdhSharedKey(PakeAuthParams *params);
57 
58 int32_t GetPkInfoPeer(PakeAuthParams *params, const CJson *in);
59 
60 int32_t InitPakeAuthParams(const CJson *in, PakeAuthParams *params, const AccountVersionInfo *verInfo);
61 
62 void DestroyPakeAuthParams(PakeAuthParams *params);
63 
64 int32_t ExtractPakePeerId(PakeAuthParams *params, const CJson *in);
65 
66 int32_t ExtractPakeSelfId(PakeAuthParams *params);
67 
68 int32_t ExtractPeerDeviceId(PakeAuthParams *params, const CJson *in);
69 
70 int32_t ExtractPeerDevId(PakeAuthParams *params, const CJson *in);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif
77