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 } AuthIdentityType; 41 42 typedef struct { 43 int32_t (*getCredInfosByPeerIdentity)(const CJson *in, IdentityInfoVec *vec); 44 int32_t (*getCredInfoByPeerUrl)(const CJson *in, const Uint8Buff *presharedUrl, IdentityInfo **returnInfo); 45 int32_t (*getSharedSecretByUrl)( 46 const CJson *in, const Uint8Buff *presharedUrl, ProtocolAlgType protocolType, Uint8Buff *sharedSecret); 47 int32_t (*getCredInfoByPeerCert)(const CJson *in, const CertInfo *certInfo, IdentityInfo **returnInfo); 48 int32_t (*getSharedSecretByPeerCert)( 49 const CJson *in, const CertInfo *peerCertInfo, ProtocolAlgType protocolType, Uint8Buff *sharedSecret); 50 } AuthIdentity; 51 52 typedef struct { 53 int32_t (*queryCredential)(const char *reqJsonStr, char **returnData); 54 int32_t (*genarateCredential)(const char *reqJsonStr, char **returnData); 55 int32_t (*importCredential)(const char *reqJsonStr, char **returnData); 56 int32_t (*deleteCredential)(const char *reqJsonStr, char **returnData); 57 } CredentialOperator; 58 59 typedef struct { 60 const AuthIdentity *(*getAuthIdentityByType)(AuthIdentityType type); 61 const CredentialOperator *(*getCredentialOperator)(void); 62 } AuthIdentityManager; 63 64 const AuthIdentity *GetGroupAuthIdentity(void); 65 const AuthIdentity *GetPinAuthIdentity(void); 66 const AuthIdentity *GetP2pAuthIdentity(void); 67 const AuthIdentity *GetAuthIdentityByType(AuthIdentityType type); 68 const CredentialOperator *GetCredentialOperator(void); 69 const AuthIdentityManager *GetAuthIdentityManager(void); 70 71 uint8_t *GetKeyTypePair(KeyAliasType keyAliasType); 72 73 #ifdef __cplusplus 74 } 75 #endif 76 77 #endif // AUTH_IDENTITY_MANAGER_H