• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 AUTH_IDENTITY_MANAGER_H
17 #define AUTH_IDENTITY_MANAGER_H
18 
19 #include "alg_defs.h"
20 #include "alg_loader.h"
21 #include "common_defs.h"
22 #include "das_task_common.h"
23 #include "device_auth_defines.h"
24 #include "hc_log.h"
25 #include "hc_types.h"
26 #include "identity_common.h"
27 #include "identity_defines.h"
28 #include "json_utils.h"
29 #include "securec.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 typedef enum {
36     AUTH_IDENTITY_TYPE_INVALID = -1,
37     AUTH_IDENTITY_TYPE_GROUP,
38     AUTH_IDENTITY_TYPE_PIN,
39     AUTH_IDENTITY_TYPE_P2P,
40     AUTH_IDENTITY_TYPE_CRED,
41 } AuthIdentityType;
42 
43 typedef struct {
44     int32_t (*getCredInfosByPeerIdentity)(const CJson *in, IdentityInfoVec *vec);
45     int32_t (*getCredInfoByPeerUrl)(const CJson *in, const Uint8Buff *presharedUrl, IdentityInfo **returnInfo);
46     int32_t (*getSharedSecretByUrl)(
47         const CJson *in, const Uint8Buff *presharedUrl, ProtocolAlgType protocolType, Uint8Buff *sharedSecret);
48     int32_t (*getCredInfoByPeerCert)(const CJson *in, const CertInfo *certInfo, IdentityInfo **returnInfo);
49     int32_t (*getSharedSecretByPeerCert)(
50         const CJson *in, const CertInfo *peerCertInfo, ProtocolAlgType protocolType, Uint8Buff *sharedSecret);
51 } AuthIdentity;
52 
53 typedef struct {
54     int32_t (*queryCredential)(const char *reqJsonStr, char **returnData);
55     int32_t (*genarateCredential)(const char *reqJsonStr, char **returnData);
56     int32_t (*importCredential)(const char *reqJsonStr, char **returnData);
57     int32_t (*deleteCredential)(const char *reqJsonStr, char **returnData);
58 } CredentialOperator;
59 
60 typedef struct {
61     const AuthIdentity *(*getAuthIdentityByType)(AuthIdentityType type);
62     const CredentialOperator *(*getCredentialOperator)(void);
63 } AuthIdentityManager;
64 
65 const AuthIdentity *GetGroupAuthIdentity(void);
66 const AuthIdentity *GetPinAuthIdentity(void);
67 const AuthIdentity *GetP2pAuthIdentity(void);
68 const AuthIdentity *GetCredAuthIdentity(void);
69 const AuthIdentity *GetAuthIdentityByType(AuthIdentityType type);
70 const CredentialOperator *GetCredentialOperator(void);
71 const AuthIdentityManager *GetAuthIdentityManager(void);
72 
73 uint8_t *GetKeyTypePair(KeyAliasType keyAliasType);
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif // AUTH_IDENTITY_MANAGER_H